Mercurial > dive4elements > river
changeset 3854:3228d65b0db9
Improved fix for issue860 (parameter in helper pane).
flys-client/trunk@5595 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 25 Sep 2012 13:13:48 +0000 |
parents | 8ef59abc0fbf |
children | b6b2d9aad95d |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java |
diffstat | 3 files changed, 80 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Tue Sep 25 06:50:55 2012 +0000 +++ b/flys-client/ChangeLog Tue Sep 25 13:13:48 2012 +0000 @@ -1,3 +1,14 @@ +2012-09-25 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Improved fix for issue860 (minfo parameterization in helper pane). + + * src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java + (createWidget, createCheckBox): Renamed. + Use smartgwt stuff to profit from scrollbars (yay!). + + * src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java: + Place ParameterMatrix in helper pane if too long. + 2012-09-25 Felix Wolfsteller <felix.wolfsteller@intevation.de> Attempt at issue860 (minfo parameterization in helper pane).
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java Tue Sep 25 06:50:55 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java Tue Sep 25 13:13:48 2012 +0000 @@ -13,7 +13,9 @@ import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.ClickListener; +import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.tile.TileLayout; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.shared.model.DataItem; @@ -21,6 +23,14 @@ import de.intevation.flys.client.shared.model.StringOptionsData; +/** + * Some parameters take the form of on/off options that can also be seen + * as a matrix. + * + * This class helps to survive the underlying objects and create a visual + * representation of this matrix. Later can happen in two ways to overcome + * shortcomings of GWT/SmartGWT combination. + */ public class ParameterMatrix { public static class Column implements Serializable { @@ -117,8 +127,55 @@ } - public Widget create() { - Grid grid = new Grid(valueNames.size()+1, columnNames.size() + 1); + public Widget createTileLayout() { + TileLayout tileLayout = new TileLayout(); + tileLayout.setTilesPerLine (columnNames.size() + 1); + tileLayout.setAutoWrapLines(false); + tileLayout.setTileMargin(1); + + tileLayout.addTile(new Label("")); + for (int i = 0, n = columnNames.size(); i < n; i++) { + String columnName = columnNames.get(i); + Column col = columns.get(columnName); + + selected.put(columnName, new ArrayList<String>()); + + tileLayout.addTile(createLabel(MESSAGE.getString(columnName))); + } + + int nVals = valueNames.size(); + + for (int j = 0; j < nVals; j++) { + for (int i = 0, n = columnNames.size(); i < n; i++) { + String valueName = valueNames.get(j); + String columnName = columnNames.get(i); + Column col = columns.get(columnName); + String value = col.getValue(valueName); + + if (i == 0) { + tileLayout.addTile(createLabel(valueName)); + } + + if (value != null && value.length() > 0) { + tileLayout.addTile(createCheckBox(columnName, value)); + } + } + } + + return tileLayout; + } + + + /** + * Returns a widget with matrix of checkboxes and labels. + * @param tileLayouted if true, use a TileLayout (for inclusion in SmartGWT + * containers, avoiding scrollbar-issues. + */ + public Widget create(boolean tileLayouted) { + if (tileLayouted) { + return createTileLayout(); + } + Grid grid = new Grid(valueNames.size() + 1, columnNames.size() + 1); for (int i = 0, n = columnNames.size(); i < n; i++) { String columnName = columnNames.get(i); @@ -137,7 +194,7 @@ } if (value != null && value.length() > 0) { - grid.setWidget(j+1, i+1, createWidget(columnName, value)); + grid.setWidget(j+1, i+1, createCheckBox(columnName, value)); } } } @@ -146,6 +203,7 @@ } + /** Creates label with given text. */ protected Label createLabel(String text) { Label label = new Label(text); label.setHeight(CELL_HEIGHT); @@ -154,7 +212,8 @@ } - protected CheckBox createWidget(final String colName, final String value) { + /** Create Checkbox for column/value. */ + protected Canvas createCheckBox(final String colName, final String value) { CheckBox box = new CheckBox(); box.addClickListener(new ClickListener() { @Override @@ -172,7 +231,9 @@ } }); - return box; + Canvas c = new Canvas(); + c.addChild(box); + return c; }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java Tue Sep 25 06:50:55 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java Tue Sep 25 13:13:48 2012 +0000 @@ -142,11 +142,12 @@ } // If too many items are shown, show it in the helper Panel. + // TODO its not about the datalist, but about the "rows" in the data. if (dataList.getAll().size() > 5) { - v.addMember(matrix.create()); + v.addMember(matrix.create(false)); } else { - helperContainer.addMember(matrix.create()); + helperContainer.addMember(matrix.create(true)); } v.addMember(getNextButton());