# HG changeset patch # User Sebastian Kruse # Date 1354813539 -3600 # Node ID 20eb7596d4668a179f0a6518e0ace1fa753a0d69 # Parent ba7d401c2750a06c1e0e460ded0ec351a932fd13 Preparation for a switch to a CellTable. This is work in progress. diff -r ba7d401c2750 -r 20eb7596d466 src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java --- a/src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java Thu Dec 06 18:05:16 2012 +0100 +++ b/src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java Thu Dec 06 18:05:39 2012 +0100 @@ -1,7 +1,11 @@ package econnect.wp3_3.client.widgets.table; import java.util.ArrayList; +import java.util.List; +import com.google.gwt.user.cellview.client.CellTable; +import com.google.gwt.user.cellview.client.SimplePager; +import com.google.gwt.user.cellview.client.TextColumn; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Button; @@ -13,6 +17,7 @@ import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasHorizontalAlignment; import com.google.gwt.user.client.ui.TextBox; +import com.google.gwt.view.client.ListDataProvider; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickEvent; @@ -36,11 +41,6 @@ public class DynamicStiTable extends Grid { /** - * The maximum number of columns of the table - */ - private int maxCols = 4; - - /** * The maximum number of rows of the table */ private int maxRows = 10; @@ -61,24 +61,15 @@ private int index; /** + * ArrayList that holds all elements that can be shown + * (smaller than "dataSet" if showSelected) + */ + private ArrayList actualObjectSet; + + /** * The dataobjects, which are presented at the actual page */ - private DataObject[][] displayedObjects; - - /** - * The visual representations of the actual displayed objects - */ - private Grid elements; - - /** - * The number of chunks (pages) for the table - */ - private int chunkCount; - - /** - * The actual selected chunk (page) - */ - private int selectedChunk = 0; + //private DataObject[][] displayedObjects; /** * The grid for the page links @@ -116,11 +107,6 @@ private int viewAll = 1; /** - * ArrayList that holds all elements that can be shown - */ - private ArrayList actualObjectSet; - - /** * Anchor that holds the URL for the KML download */ private Anchor aDownloadKML; @@ -131,6 +117,11 @@ private ExportWriterInterfaceAsync exportWriter; /** + * CellTable which will replace the elements-Grid + */ + private CellTable elementsTable; + + /** * Constructor for initialization of the dynamic table * * @param core object to allow interaction with all javascript components @@ -142,10 +133,9 @@ final StiConstants textConstants = (StiConstants) GWT.create(StiConstants.class); this.resize(2,1); - this.elements = new Grid(); this.addStyleName("dataTable"); this.addStyleName("center"); - + this.index = id; this.core = stiCore; this.dataSet = core.getDataSets().get(index); @@ -161,7 +151,6 @@ previous.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { - selectedChunk--; organizePages(); checkHide(); fillTable(); @@ -170,15 +159,11 @@ previous.setVisible(false); next.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { - selectedChunk++; organizePages(); checkHide(); fillTable(); } }); - if( chunkCount == 1 ){ - next.setVisible(false); - } showAll = new Image("images/viewAll"+(core.getColorId(index))+".png"); showAll.setTitle(textConstants.showAll()); @@ -262,7 +247,7 @@ core.reset(); //TODO: das gibt es nun mehrfach im Code, sollte also in eine Funktion - //Ÿberfuhrt werden + //�berfuhrt werden showSelected.removeStyleName("selectedView"); showAll.addStyleName("selectedView"); viewAll = 1; @@ -281,12 +266,14 @@ Label page = new Label(textConstants.page()+":"); page.setStyleName("pageLabel"); - Grid footer = new Grid(1,4); + 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 @@ -340,9 +327,29 @@ 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.addDataDisplay(this.elementsTable); - fillTable(); + TextColumn nameColumn = new TextColumn() { + @Override + public String getValue(DataObject object) { + return object.getName(); + } + + }; + this.elementsTable.addColumn(nameColumn); + + SimplePager pager = new SimplePager(); + pager.setDisplay(this.elementsTable); + footer.setWidget(0, 0, pager); + + dataProvider.setList(this.actualObjectSet); + + this.setWidget(1, 0, this.elementsTable); } /** @@ -361,7 +368,7 @@ } if( objects.size() > 0 ){ //TODO: Wenn die derzeitige Auswahl _keine_ Elemente - //enthŠlt, werden _alle_ angezeigt. Ist das sinnvoll? + //enth�lt, werden _alle_ angezeigt. Ist das sinnvoll? actualObjectSet = objects; } else { @@ -374,10 +381,7 @@ actualObjectSet.add(this.dataSet.getObjects().get(i)); } } - this.chunkCount = actualObjectSet.size() / ( maxCols * maxRows ); - if( actualObjectSet.size() % ( maxCols * maxRows ) != 0 ){ - this.chunkCount++; - } + return true; } @@ -385,6 +389,7 @@ * Organizes the visible links in the pages grid */ private void organizePages(){ + /* ArrayList