# HG changeset patch # User Sebastian Kruse # Date 1354892667 -3600 # Node ID fad6fb60a2dbe79e4178754c3ffe4752996c64cb # Parent fe6778a2fada4fb314759e2181ebb2d085219fec refining of data in CellTable diff -r fe6778a2fada -r fad6fb60a2db src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java --- a/src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java Fri Dec 07 16:01:51 2012 +0100 +++ b/src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java Fri Dec 07 16:04:27 2012 +0100 @@ -51,45 +51,40 @@ private StiCore core; /** + * The index of the dataset + */ + private int index; + + /** * The dataset of this dynamic table */ private DataSet dataSet; /** - * The index of the dataset - */ - private int index; - - /** * ArrayList that holds all elements that can be shown * (smaller than "dataSet" if showSelected) */ private ArrayList actualObjectSet; /** + * Provider that hands the data to the table + */ + private ListDataProvider dataProvider; + + /** + * CellTable which displays the data + */ + private CellTable elementsTable; + + /** * The dataobjects, which are presented at the actual page */ //private DataObject[][] displayedObjects; /** - * The grid for the page links - */ - private Grid pages; - - /** * The number-of-results label */ private Label results; - - /** - * The image for the previous page - */ - private Image previous; - - /** - * The image for the next page - */ - private Image next; /** * The image for show selected elements @@ -115,11 +110,6 @@ * RPC Interface for writing the KML file */ private ExportWriterInterfaceAsync exportWriter; - - /** - * CellTable which will replace the elements-Grid - */ - private CellTable elementsTable; /** * Constructor for initialization of the dynamic table @@ -139,32 +129,9 @@ this.index = id; this.core = stiCore; this.dataSet = core.getDataSets().get(index); + this.actualObjectSet = new ArrayList(); setActualObjectSet(); - previous = new Image( "images/prev.png" ); - previous.setStyleName("arrow"); - next = new Image( "images/next.png" ); - next.setStyleName("arrow"); - - pages = new Grid(0,0); - organizePages(); - - previous.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { - organizePages(); - checkHide(); - fillTable(); - } - }); - previous.setVisible(false); - next.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { - organizePages(); - checkHide(); - fillTable(); - } - }); - showAll = new Image("images/viewAll"+(core.getColorId(index))+".png"); showAll.setTitle(textConstants.showAll()); showSelected = new Image("images/viewSelected"+(core.getColorId(index))+".png"); @@ -179,9 +146,6 @@ showAll.addStyleName("selectedView"); viewAll = 1; setActualObjectSet(); - organizePages(); - checkHide(); - fillTable(); } } }); @@ -192,9 +156,6 @@ if( setActualObjectSet() ){ showAll.removeStyleName("selectedView"); showSelected.addStyleName("selectedView"); - organizePages(); - checkHide(); - fillTable(); } else { viewAll = 1; @@ -252,9 +213,6 @@ showAll.addStyleName("selectedView"); viewAll = 1; setActualObjectSet(); - organizePages(); - checkHide(); - fillTable(); refine.setWidget(0, 1, search); } @@ -266,16 +224,6 @@ Label page = new Label(textConstants.page()+":"); page.setStyleName("pageLabel"); - Grid footer = new Grid(1,1); - /* - footer.setWidget(0, 0, page ); - footer.setWidget(0, 1, pages ); - footer.setWidget(0, 2, previous); - footer.setWidget(0, 3, next); - footer.addStyleName("center"); - */ - - //This anchor will hold the URL of the export-file //for download from the ExportServlet aDownloadKML = new Anchor("download KML"); @@ -312,25 +260,9 @@ func.setWidget(0, 2, delete); func.addStyleName("center"); - Grid tableControls = new Grid(1,5); - tableControls.setWidget(0,0,showOptions); - tableControls.setWidget(0,1,refine); - tableControls.setWidget(0,2,this.results); - tableControls.setWidget(0,3,footer); - tableControls.setWidget(0,4,func); - tableControls.setStyleName("tableControls"); - - this.setWidget(0, 0, tableControls); - - tableControls.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); - - this.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); - this.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); - this.getCellFormatter().setWidth(1, 0, "100%"); - this.elementsTable = new CellTable(); - ListDataProvider dataProvider = new ListDataProvider(); + dataProvider = new ListDataProvider(); dataProvider.addDataDisplay(this.elementsTable); TextColumn nameColumn = new TextColumn() { @@ -345,11 +277,26 @@ SimplePager pager = new SimplePager(); pager.setDisplay(this.elementsTable); - footer.setWidget(0, 0, pager); dataProvider.setList(this.actualObjectSet); - this.setWidget(1, 0, this.elementsTable); + this.setWidget(1, 0, this.elementsTable); + + Grid tableControls = new Grid(1,5); + tableControls.setWidget(0,0,showOptions); + tableControls.setWidget(0,1,refine); + tableControls.setWidget(0,2,this.results); + tableControls.setWidget(0,3,pager); + tableControls.setWidget(0,4,func); + tableControls.setStyleName("tableControls"); + + this.setWidget(0, 0, tableControls); + + tableControls.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); + + this.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); + this.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); + this.getCellFormatter().setWidth(1, 0, "100%"); } /** @@ -358,168 +305,45 @@ * @return boolean value, if there are selected objects */ private boolean setActualObjectSet(){ + + boolean dataSetWasEmpty = false; + if( viewAll == -1 ){ - ArrayList objects = new ArrayList(); + + this.actualObjectSet.clear(); + for( int i=0; i 0 ){ + if( this.actualObjectSet.size() == 0 ){ //TODO: Wenn die derzeitige Auswahl _keine_ Elemente //enth�lt, werden _alle_ angezeigt. Ist das sinnvoll? - actualObjectSet = objects; - } - else { - return false; - } - } - else if( viewAll == 1 ){ - actualObjectSet = new ArrayList(); - for( int i=0; i pageLabels = new ArrayList