# HG changeset patch # User Felix Wolfsteller # Date 1348578828 0 # Node ID 3228d65b0db95748bb15372e6938889883279a38 # Parent 8ef59abc0fbf106bc90aef40d0856d7f9ee435f8 Improved fix for issue860 (parameter in helper pane). flys-client/trunk@5595 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 8ef59abc0fbf -r 3228d65b0db9 flys-client/ChangeLog --- 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 + + 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 Attempt at issue860 (minfo parameterization in helper pane). diff -r 8ef59abc0fbf -r 3228d65b0db9 flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java --- 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()); + + 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; } diff -r 8ef59abc0fbf -r 3228d65b0db9 flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java --- 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());