[PATCH] issue1259: in WQAdaptedInputPanel (vollmer w/q-input) allow
Wald Commits
scm-commit at wald.intevation.org
Fri Jul 26 08:50:31 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1374821995 -7200
# Node ID 3c4c0ea52bbb55d805920088fe29757d8c2eec36
# Parent b7945db8a43b12b24a67d5552a8b718fe533043a
issue1259: in WQAdaptedInputPanel (vollmer w/q-input) allow
click selection of W values, analogously to Q values.
diff -r b7945db8a43b -r 3c4c0ea52bbb gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WQAdaptedInputPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WQAdaptedInputPanel.java Thu Jul 25 15:08:13 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WQAdaptedInputPanel.java Fri Jul 26 08:59:55 2013 +0200
@@ -140,6 +140,7 @@
}
+ /** Create labels, canvasses, layouts. */
@Override
public Canvas create(DataList data) {
readGaugeRanges(data);
@@ -196,7 +197,7 @@
qdTables.add(qdTable);
qdTable.showSelect();
- //wTable.showSelect();
+ wTable.showSelect();
wTab.setPane(wTable);
qTab.setPane(qdTable);
@@ -267,6 +268,57 @@
qdTable.addCellClickHandler(handler);
i++;
}
+
+ i = 0;
+ for (WTable wTable: wTables) {
+ // Register listener such that values are filled in on click.
+ final WTable table = wTable;
+ final int fi = i;
+ CellClickHandler handler = new CellClickHandler() {
+ @Override
+ public void onCellClick(CellClickEvent e) {
+ if (!isWMode() /*|| table.isLocked()*/) {
+ return;
+ }
+
+ Record r = e.getRecord();
+ double val = r.getAttributeAsDouble("value");
+
+ doubleArrayPanels.get(fi).setValues(new double[]{val});
+ // If a named value for first gauge is chosen, try to find and set
+ // the values to the other panels too.
+ if (fi == 0) {
+ String valueName = r.getAttribute("name");
+ int oi = 0;
+ // TODO instead of oi use random access.
+ for (WTable otherWTable: wTables) {
+ if (oi == 0) {
+ oi++;
+ continue;
+ }
+ Double value = otherWTable.findRecordValue(valueName);
+ if (value == null) {
+ // TODO: afterwards it freaks out
+ SC.warn(MSG.noMainValueAtGauge());
+ }
+ else {
+ doubleArrayPanels.get(oi).setValues(new double[]{value});
+ }
+ oi++;
+ }
+ }
+ else {
+ // Focus next.
+ if (fi != doubleArrayPanels.size()-1) {
+ doubleArrayPanels.get(fi+1).focusInItem(1);
+ }
+ }
+ }
+ };
+
+ wTable.addCellClickHandler(handler);
+ i++;
+ }
}
diff -r b7945db8a43b -r 3c4c0ea52bbb gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/QDTable.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/QDTable.java Thu Jul 25 15:08:13 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/QDTable.java Fri Jul 26 08:59:55 2013 +0200
@@ -22,7 +22,12 @@
/**
- * Table showing Q and D main values, allowing for selection.
+ * Table showing Q and D main values, allowing for selection, if
+ * showSelect is called. In that case, a CellClickHandler should
+ * be registered.
+ *
+ * TODO becomes very similiar to WTable. Probably mergeable.
+ *
* @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
*/
public class QDTable extends ListGrid {
@@ -119,6 +124,7 @@
hideField("min");
}
+ /** Whether or not can be clicked on. */
public boolean isLocked() {
return lockClick;
}
diff -r b7945db8a43b -r 3c4c0ea52bbb gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WTable.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WTable.java Thu Jul 25 15:08:13 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WTable.java Fri Jul 26 08:59:55 2013 +0200
@@ -21,6 +21,8 @@
import org.dive4elements.river.client.client.FLYSConstants;
/**
+ * Table showing W main values.
+ * TODO becomes very similiar to QDTable. Probably mergeable.
* @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
*/
public class WTable extends ListGrid {
@@ -30,6 +32,8 @@
public WTable() {
+ String baseUrl = GWT.getHostPageBaseURL();
+
setWidth100();
setHeight100();
setSelectionType(SelectionStyle.NONE);
@@ -68,7 +72,31 @@
}
});
- setFields(name, type, value);
+ ListGridField select = new ListGridField("select", MESSAGE.selection());
+ select.setType(ListGridFieldType.ICON);
+ select.setWidth(70);
+ select.setCellIcon(baseUrl + MESSAGE.markerGreen());
+
+ setFields(select, name, type, value);
+ hideField("select");
+ }
+
+ public void showSelect() {
+ showField("select");
+ }
+
+
+ /**
+ * Search all records for one with attribute name equals to given name.
+ * @return null if none found.
+ * */
+ public Double findRecordValue(String name) {
+ for (ListGridRecord record : getRecords()) {
+ if (record.getAttribute("name").equals(name)) {
+ return record.getAttributeAsDouble("value");
+ }
+ }
+ return null;
}
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4elements-commits
mailing list