# HG changeset patch
# User gernotbelger
# Date 1529942291 -7200
# Node ID 34dc0163ad2d3d1829a38be51cd6c6f506081576
# Parent 06bb3e94a927275f9401e7a16674d49d1a0fc2a8
DistancePanel Berechnungsstrecke->Darstellungsbereich Refactoring
diff -r 06bb3e94a927 -r 34dc0163ad2d artifacts/doc/conf/artifacts/uinfo.xml
--- a/artifacts/doc/conf/artifacts/uinfo.xml Mon Jun 25 16:07:41 2018 +0200
+++ b/artifacts/doc/conf/artifacts/uinfo.xml Mon Jun 25 17:58:11 2018 +0200
@@ -19,6 +19,12 @@
+
+
+
+
+
+
@@ -113,12 +119,12 @@
-
+
-
+
@@ -145,7 +151,7 @@
-
+
diff -r 06bb3e94a927 -r 34dc0163ad2d artifacts/src/main/java/org/dive4elements/river/artifacts/states/ComputationRangeState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/ComputationRangeState.java Mon Jun 25 16:07:41 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/ComputationRangeState.java Mon Jun 25 17:58:11 2018 +0200
@@ -40,7 +40,9 @@
final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
- label.setTextContent(Resources.getMsg(context.getMeta(), getID(), getID()));
+ final String msg = getTitle(context);
+
+ label.setTextContent(msg);
// VORHER: data.getName(), data.getName())) (entsprach "ld_from", "ld_to" - unterschied zu jetzt: description wird
// anders gesetzt ("Wahl der Berechnungsstrecke")
// label bleibt "ld_from", "ld_to"; unklar, wo das gesetzt wird. unklar, warum das Element "label" die Description
@@ -54,6 +56,16 @@
return select;
}
+ // REMARK: allows to overwrite the titel which is shown on the client side.
+ // TODO: instead of a fixed string, we should translate the 'id', but in that case we need to change all old workflows
+ // (reason is, that we have different texts for the title and the 'old' title, which in turn is the translation of
+ // 'description').
+
+ protected String getTitle(final CallContext context) {
+ // REMARK: that is how it should be: return Resources.getMsg(context.getMeta(), getID());
+ return Resources.getMsg(context.getMeta(), "state.title.distance_state");
+ }
+
@Override
protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
final double[] minmax = getMinMax(artifact);
diff -r 06bb3e94a927 -r 34dc0163ad2d artifacts/src/main/java/org/dive4elements/river/artifacts/states/DistanceOnlyPartSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DistanceOnlyPartSelect.java Mon Jun 25 16:07:41 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DistanceOnlyPartSelect.java Mon Jun 25 17:58:11 2018 +0200
@@ -9,6 +9,8 @@
package org.dive4elements.river.artifacts.states;
import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.resources.Resources;
public class DistanceOnlyPartSelect extends DistanceOnlySelect {
@@ -19,4 +21,10 @@
return "distance_only_part_panel";
}
+ @Override
+ protected String getTitle(final CallContext context) {
+ // REMARK: that is how it should be: return Resources.getMsg(context.getMeta(), getID());
+ return Resources.getMsg(context.getMeta(), "state.title.distance_part_state");
+ }
+
}
diff -r 06bb3e94a927 -r 34dc0163ad2d artifacts/src/main/java/org/dive4elements/river/artifacts/states/LocationDistanceSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/LocationDistanceSelect.java Mon Jun 25 16:07:41 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/LocationDistanceSelect.java Mon Jun 25 17:58:11 2018 +0200
@@ -9,23 +9,18 @@
package org.dive4elements.river.artifacts.states;
import org.apache.log4j.Logger;
-
+import org.dive4elements.artifactdatabase.data.StateData;
import org.dive4elements.artifacts.Artifact;
-
-import org.dive4elements.artifactdatabase.data.StateData;
-
+import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.D4EArtifact;
import org.dive4elements.river.artifacts.WINFOArtifact;
-
import org.dive4elements.river.artifacts.access.RangeAccess;
-
+import org.dive4elements.river.artifacts.resources.Resources;
/**
* @author Ingo Weinzierl
*/
-public class LocationDistanceSelect
-extends ComputationRangeState
-{
+public class LocationDistanceSelect extends ComputationRangeState {
/** The log used in this class. */
private static Logger log = Logger.getLogger(LocationDistanceSelect.class);
@@ -36,55 +31,46 @@
/** The name of the 'locations' field. */
public static final String LOCATIONS = "ld_locations";
-
/**
* The default constructor that initializes an empty State object.
*/
public LocationDistanceSelect() {
}
-
@Override
protected String getUIProvider() {
return "location_distance_panel";
}
-
/** Validates the range (or location). */
@Override
- public boolean validate(Artifact artifact)
- throws IllegalArgumentException
- {
+ public boolean validate(final Artifact artifact) throws IllegalArgumentException {
log.debug("LocationDistanceSelect.validate");
- D4EArtifact flys = (D4EArtifact)artifact;
- StateData mode = getData(flys, MODE);
- String mValue = mode != null ? (String)mode.getValue() : null;
+ final D4EArtifact flys = (D4EArtifact) artifact;
+ final StateData mode = getData(flys, MODE);
+ final String mValue = mode != null ? (String) mode.getValue() : null;
if (mValue != null) {
if (mValue.equals("distance")) {
return super.validate(flys);
- }
- else {
+ } else {
return validateLocations(flys);
}
}
return false;
}
-
/** Validate selected locations. */
- protected boolean validateLocations(D4EArtifact flys)
- throws IllegalArgumentException
- {
- StateData dValues = getData(flys, LOCATIONS);
- String values = dValues != null ? (String)dValues.getValue() : null;
+ protected boolean validateLocations(final D4EArtifact flys) throws IllegalArgumentException {
+ final StateData dValues = getData(flys, LOCATIONS);
+ final String values = dValues != null ? (String) dValues.getValue() : null;
if (values == null || values.length() == 0) {
throw new IllegalArgumentException("error_empty_state");
}
- double[] absMinMax = getMinMax(flys);
- double[] relMinMax = getMinMaxFromString(values);
+ final double[] absMinMax = getMinMax(flys);
+ final double[] relMinMax = getMinMaxFromString(values);
if (relMinMax[0] < absMinMax[0] || relMinMax[0] > absMinMax[1]) {
throw new IllegalArgumentException("error_feed_from_out_of_range");
@@ -97,45 +83,46 @@
return true;
}
-
/**
* Extracts the min/max values from String s. An
* IllegalArgumentException is thrown if there is a value that throws a
* NumberFormatException.
*
- * @param s String that contains whitespace separated double values.
+ * @param s
+ * String that contains whitespace separated double values.
*
* @return a 2dmin array [min,max].
*/
- public static double[] getMinMaxFromString(String s)
- throws IllegalArgumentException
- {
- String[] values = s.split(" ");
+ public static double[] getMinMaxFromString(final String s) throws IllegalArgumentException {
+ final String[] values = s.split(" ");
- double[] minmax = new double[] {
- Double.MAX_VALUE,
- -Double.MAX_VALUE };
+ final double[] minmax = new double[] { Double.MAX_VALUE, -Double.MAX_VALUE };
- for (String v: values) {
+ for (final String v : values) {
try {
- double value = Double.valueOf(v);
+ final double value = Double.valueOf(v);
minmax[0] = minmax[0] < value ? minmax[0] : value;
minmax[1] = minmax[1] > value ? minmax[1] : value;
}
- catch (NumberFormatException nfe) {
- throw new IllegalArgumentException(
- "error_invalid_double_value");
+ catch (final NumberFormatException nfe) {
+ throw new IllegalArgumentException("error_invalid_double_value");
}
}
return minmax;
}
-
- public static double[] getLocations(WINFOArtifact flys) {
- RangeAccess ra = new RangeAccess(flys);
+ public static double[] getLocations(final WINFOArtifact flys) {
+ final RangeAccess ra = new RangeAccess(flys);
return ra.getLocations();
}
+
+ @Override
+ protected String getTitle(final CallContext context) {
+ // REMARK: that is how it should be: return Resources.getMsg(context.getMeta(), getID());
+ return Resources.getMsg(context.getMeta(), "state.title.location_distance_state");
+ }
+
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 06bb3e94a927 -r 34dc0163ad2d artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDistanceSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDistanceSelect.java Mon Jun 25 16:07:41 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDistanceSelect.java Mon Jun 25 17:58:11 2018 +0200
@@ -10,12 +10,12 @@
import org.dive4elements.river.artifacts.states.DistanceOnlySelect;
-
-public class SedimentLoadDistanceSelect
-extends DistanceOnlySelect
-{
+public class SedimentLoadDistanceSelect extends DistanceOnlySelect {
@Override
protected String getUIProvider() {
return "minfo.sedimentload_distance_select";
}
+
+ // title müsste distance_state sein; schon in CompuatationRange
+
}
diff -r 06bb3e94a927 -r 34dc0163ad2d artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties Mon Jun 25 16:07:41 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties Mon Jun 25 17:58:11 2018 +0200
@@ -1067,7 +1067,8 @@
state.uinfo.distance_only_part = Teilabschnitt
help.state.uinfo.distance_only_part = ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only_part
-state.uinfo.distance_only = Wahl des Darstellungsbereichs
+state.uinfo.distance_only = Choose calculation range [km]
+state.uinfo.inundationduration.distance_only = Wahl des Darstellungsbereichs
help.state.uinfo.distance_only = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.distance_only
uinfo_salix_line = Salix-Linie
uinfo_inundation_duration = \u00dcberflutungsdauern Aue
@@ -1165,4 +1166,9 @@
common.client.ui.from = from
common.client.ui.to = to
-chart.subtitle.metadata = FLYS-Version: {0} - Bearbeiter: {1} - Datum der Erstellung: {2}
\ No newline at end of file
+chart.subtitle.metadata = FLYS-Version: {0} - Bearbeiter: {1} - Datum der Erstellung: {2}
+
+state.title.distance_state = Choose calculation range [km]
+state.title.location_distance_state = Choose calculation location(s) / range [km]
+state.title.distance_part_state = Choose calculation subregion [km]
+state.title.distance_only_inundationduration_state = Darstellungsbereich w\u00e4hlen [km]
\ No newline at end of file
diff -r 06bb3e94a927 -r 34dc0163ad2d artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties Mon Jun 25 16:07:41 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties Mon Jun 25 17:58:11 2018 +0200
@@ -1067,7 +1067,8 @@
state.uinfo.distance_only_part = Teilabschnitt
help.state.uinfo.distance_only_part = ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only_part
-state.uinfo.distance_only = Wahl des Darstellungsbereichs
+state.uinfo.distance_only = Wahl der Berechnungsstrecke
+state.uinfo.inundationduration.distance_only = Wahl des Darstellungsbereichs
help.state.uinfo.distance_only = ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only
uinfo_salix_line = Salix-Linie
uinfo_inundation_duration = \u00dcberflutungsdauern Aue
@@ -1165,4 +1166,9 @@
common.client.ui.from = von
common.client.ui.to = bis
-chart.subtitle.metadata = FLYS-Version: {0} - Bearbeiter: {1} - Datum der Erstellung: {2}
\ No newline at end of file
+chart.subtitle.metadata = FLYS-Version: {0} - Bearbeiter: {1} - Datum der Erstellung: {2}
+
+state.title.distance_state = Berechnungsstrecke w\u00e4hlen [km]
+state.title.location_distance_state = Berechnungsort(e) / strecke w\u00e4hlen [km]
+state.title.distance_part_state = Teilstrecke w\u00e4hlen [km]
+state.title.distance_only_inundationduration_state = Darstellungsbereich w\u00e4hlen [km]
\ No newline at end of file
diff -r 06bb3e94a927 -r 34dc0163ad2d gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Jun 25 16:07:41 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Jun 25 17:58:11 2018 +0200
@@ -175,14 +175,6 @@
String uesk_profile_distance();
- String location_distance_state();
-
- String distance_state();
-
- String distance_part_state();
-
- String waterlevel_ground_state();
-
String location();
String locations();
@@ -1542,4 +1534,6 @@
String sinfo_floodduration_report();
String export_csv_title();
+
+ String waterlevel_ground_state();
}
\ No newline at end of file
diff -r 06bb3e94a927 -r 34dc0163ad2d gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Jun 25 16:07:41 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Jun 25 17:58:11 2018 +0200
@@ -59,11 +59,7 @@
databasket_loading = Loading Databasket content
fix = Fixing
fixanalysis = Fixing Analysis
-next = Next
-location_distance_state = Choose calculation location(s) / range [km]
-distance_state = Choose calculation range [km]
-distance_part_state = Choose calculation subregion [km]
-waterlevel_ground_state = Choose differences betweeen waterlevel and ground [m]
+next = Next
location = Location(s)
locations = Locations
single_location = Location
@@ -403,6 +399,8 @@
warning_cannot_parse_date = Invalid date!
warning_select_two_values = Please select two values!
+waterlevel_ground_state = Choose differences betweeen waterlevel and ground [m]
+
## map related strings
digitize = images/digitize.png
pipe1 = Pipe1
diff -r 06bb3e94a927 -r 34dc0163ad2d gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Jun 25 16:07:41 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Jun 25 17:58:11 2018 +0200
@@ -59,11 +59,7 @@
databasket_loading=Lade Datenkorb Inhalt
fix = Fixierungsanalyse
fixanalysis = Fixierungsanalyse
-next = Weiter
-location_distance_state = Berechnungsort(e) / strecke w\u00e4hlen [km]
-distance_state = Berechnungsstrecke w\u00e4hlen [km]
-distance_part_state = Teilstrecke w\u00e4hlen [km]
-waterlevel_ground_state = Differenzen zwischen Wasserspiegel und Gel\u00e4nde [m]
+next = Weiter
location = Ort(e)
locations = Orte
single_location = Ort
@@ -403,6 +399,8 @@
warning_cannot_parse_date = Datum ist ung\u00fcltig!
warning_select_two_values = Bitte zwei Werte w\u00e4hlen!
+waterlevel_ground_state = Differenzen zwischen Wasserspiegel und Gel\u00e4nde [m]
+
## map related strings
digitize = images/digitize.png
pipe1 = Rohr1
diff -r 06bb3e94a927 -r 34dc0163ad2d gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistanceOnlyPartPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistanceOnlyPartPanel.java Mon Jun 25 16:07:41 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistanceOnlyPartPanel.java Mon Jun 25 17:58:11 2018 +0200
@@ -13,6 +13,8 @@
import org.dive4elements.river.client.shared.model.DataItem;
import org.dive4elements.river.client.shared.model.DataList;
+import com.smartgwt.client.widgets.Label;
+
public class DistanceOnlyPartPanel extends DistanceOnlyPanel {
private static final long serialVersionUID = -5794138573892656947L;
@@ -22,8 +24,11 @@
}
@Override
- protected String getLabel() {
- return this.MSG.distance_part_state();
+ protected Label getLabel(final DataList data) {
+ final Data item = data.get(0);
+ return new Label(item.getDescription());//
+ // TODO: migrate distance_part_state to server
+ // item.getDescription()); // holt das Label vom Server (funktoniert schon sehr oft so!)
}
@Override
diff -r 06bb3e94a927 -r 34dc0163ad2d gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java Mon Jun 25 16:07:41 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java Mon Jun 25 17:58:11 2018 +0200
@@ -115,12 +115,9 @@
return layout;
}
- private Label getLabel(final DataList data) {
+ protected Label getLabel(final DataList data) {
final Data item = data.get(0);
- if (data.getState().contains("uinfo")) { // "Wahl der Berechnungsstrecke/des Darstellungsbereichs" (server) vs. "Berechnungsstrecke wählen" (client)
- return new Label(item.getDescription()); // holt das Label vom Server (funktoniert schon sehr oft so!)
- }
- return new Label(getLabel()); // holt das Label aus den Flys-Constants..
+ return new Label(item.getDescription()); // holt das Label vom Server (funktoniert schon sehr oft so!)
}
@Override
@@ -166,9 +163,9 @@
return sb.toString();
}
- protected String getLabel() {
- return this.MSG.distance_state();
- }
+ // protected String getLabel() {
+ // return this.MSG.distance_state();
+ // }
protected String labelFrom() {
return getLabelFrom() + " [" + getUnitFrom() + "]";
diff -r 06bb3e94a927 -r 34dc0163ad2d gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LocationDistancePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LocationDistancePanel.java Mon Jun 25 16:07:41 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LocationDistancePanel.java Mon Jun 25 17:58:11 2018 +0200
@@ -8,9 +8,28 @@
package org.dive4elements.river.client.client.ui;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import org.dive4elements.river.client.client.Config;
+import org.dive4elements.river.client.client.FLYSConstants;
+import org.dive4elements.river.client.client.event.FilterHandler;
+import org.dive4elements.river.client.client.event.RangeFilterEvent;
+import org.dive4elements.river.client.client.event.StringFilterEvent;
+import org.dive4elements.river.client.client.services.DistanceInfoService;
+import org.dive4elements.river.client.client.services.DistanceInfoServiceAsync;
+import org.dive4elements.river.client.client.ui.range.DistanceInfoDataSource;
+import org.dive4elements.river.client.shared.model.ArtifactDescription;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.DefaultData;
+import org.dive4elements.river.client.shared.model.DefaultDataItem;
+import org.dive4elements.river.client.shared.model.DistanceInfoObject;
+
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.NumberFormat;
-
import com.smartgwt.client.data.AdvancedCriteria;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.Criterion;
@@ -44,88 +63,64 @@
import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
-import org.dive4elements.river.client.client.Config;
-import org.dive4elements.river.client.client.FLYSConstants;
-import org.dive4elements.river.client.client.event.FilterHandler;
-import org.dive4elements.river.client.client.event.RangeFilterEvent;
-import org.dive4elements.river.client.client.event.StringFilterEvent;
-import org.dive4elements.river.client.client.services.DistanceInfoService;
-import org.dive4elements.river.client.client.services.DistanceInfoServiceAsync;
-import org.dive4elements.river.client.client.ui.range.DistanceInfoDataSource;
-import org.dive4elements.river.client.shared.model.ArtifactDescription;
-import org.dive4elements.river.client.shared.model.Data;
-import org.dive4elements.river.client.shared.model.DataItem;
-import org.dive4elements.river.client.shared.model.DataList;
-import org.dive4elements.river.client.shared.model.DefaultData;
-import org.dive4elements.river.client.shared.model.DefaultDataItem;
-import org.dive4elements.river.client.shared.model.DistanceInfoObject;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-
/**
* This UIProvider creates a widget to enter locations or a distance.
*
* @author Ingo Weinzierl
*/
-public class LocationDistancePanel
-extends AbstractUIProvider
-implements ChangeHandler, BlurHandler, FilterHandler
-{
+public class LocationDistancePanel extends AbstractUIProvider implements ChangeHandler, BlurHandler, FilterHandler {
private static final long serialVersionUID = -10820092176039372L;
/** The message class that provides i18n strings. */
protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
/** The DistanceInfoService used to retrieve locations about rivers. */
- protected DistanceInfoServiceAsync distanceInfoService =
- GWT.create(DistanceInfoService.class);
+ protected DistanceInfoServiceAsync distanceInfoService = GWT.create(DistanceInfoService.class);
public static final String FIELD_MODE = "mode";
- /** The constant name of the input field to enter the start of a distance.*/
+ /** The constant name of the input field to enter the start of a distance. */
public static final String FIELD_FROM = "from";
- /** The constant name of the input field to enter the end of a distance.*/
+ /** The constant name of the input field to enter the end of a distance. */
public static final String FIELD_TO = "to";
- /** The constant name of the input field to enter locations.*/
+ /** The constant name of the input field to enter locations. */
public static final String FIELD_VALUE_LOCATION = "location";
- /** The constant name of the input field to enter distance.*/
+ /** The constant name of the input field to enter distance. */
public static final String FIELD_VALUE_DISTANCE = "distance";
- /** The constant name of the input field to enter the step width of a
- * distance.*/
+ /**
+ * The constant name of the input field to enter the step width of a
+ * distance.
+ */
public static final String FIELD_WIDTH = "width";
public static final int WIDTH = 250;
-
- /** The radio group for input mode selection.*/
+ /** The radio group for input mode selection. */
protected DynamicForm mode;
- /** A container that will contain the location or the distance panel.*/
+ /** A container that will contain the location or the distance panel. */
protected HLayout container;
- /** The min value for a distance.*/
+ /** The min value for a distance. */
protected double min;
- /** The max value for a distance.*/
+ /** The max value for a distance. */
protected double max;
- /** The 'from' value entered in the distance mode.*/
+ /** The 'from' value entered in the distance mode. */
protected double from;
- /** The 'to' value entered in the distance mode.*/
+ /** The 'to' value entered in the distance mode. */
protected double to;
- /** The 'step' value entered in the distance mode.*/
+ /** The 'step' value entered in the distance mode. */
protected double step;
- /** The values entered in the location mode.*/
+ /** The values entered in the location mode. */
protected double[] values;
/** The input panel for locations. */
@@ -146,7 +141,7 @@
/** The table data. */
protected DistanceInfoObject[] tableData;
- /** The table filter.*/
+ /** The table filter. */
protected TableFilter filterDescription;
protected RangeTableFilter filterRange;
@@ -159,34 +154,34 @@
* Creates a new LocationDistancePanel instance.
*/
public LocationDistancePanel() {
- distanceTable = new ListGrid();
- distanceTable.setAutoFetchData(true);
+ this.distanceTable = new ListGrid();
+ this.distanceTable.setAutoFetchData(true);
- locationsTable = new ListGrid();
- locationsTable.setAutoFetchData(true);
+ this.locationsTable = new ListGrid();
+ this.locationsTable.setAutoFetchData(true);
- distanceTable.setShowHeaderContextMenu(false);
- locationsTable.setShowHeaderContextMenu(false);
+ this.distanceTable.setShowHeaderContextMenu(false);
+ this.locationsTable.setShowHeaderContextMenu(false);
}
-
/**
* This method creates a widget that contains a label, a panel with
* checkboxes to switch the input mode between location and distance input,
* and a the mode specific panel.
*
- * @param data The data that might be inserted.
+ * @param data
+ * The data that might be inserted.
*
* @return a panel.
*/
@Override
- public Canvas create(DataList data) {
- VLayout layout = new VLayout();
+ public Canvas create(final DataList data) {
+ final VLayout layout = new VLayout();
layout.setMembersMargin(10);
- Label label = new Label(MESSAGES.location_distance_state());
- Canvas widget = createWidget(data);
- Canvas submit = getNextButton();
+ final Label label = getLabel(data);// new Label(MESSAGES.location_distance_state());
+ final Canvas widget = createWidget(data);
+ final Canvas submit = getNextButton();
createDistanceInputPanel();
initDefaults(data);
@@ -201,6 +196,12 @@
return layout;
}
+ protected Label getLabel(final DataList data) {
+ final Data item = data.get(0);
+ return new Label(item.getDescription());//
+ // TODO: migrate distance_part_state to server
+ // item.getDescription()); // holt das Label vom Server (funktoniert schon sehr oft so!)
+ }
/**
* Setup a table for a DistanceInfoDataSource.
@@ -210,68 +211,67 @@
* Depending on the value of isDistance the table will
* have a to and a from column or a single location column.
*
- * @param table the ListGrid to set up.
- * @param doublePins wether or not to have.
- * @param isDistance wether or not to and from should be included.
+ * @param table
+ * the ListGrid to set up.
+ * @param doublePins
+ * wether or not to have.
+ * @param isDistance
+ * wether or not to and from should be included.
*/
- protected void setupDistanceInfoTable(ListGrid table,
- boolean doublePins,
- boolean isDistance) {
+ protected void setupDistanceInfoTable(final ListGrid table, final boolean doublePins, final boolean isDistance) {
- String baseUrl = GWT.getHostPageBaseURL();
+ final String baseUrl = GWT.getHostPageBaseURL();
table.setWidth100();
table.setShowRecordComponents(true);
table.setShowRecordComponentsByCell(true);
table.setHeight100();
- table.setEmptyMessage(MESSAGES.empty_filter());
+ table.setEmptyMessage(this.MESSAGES.empty_filter());
table.setCanReorderFields(false);
- CellFormatter cf = new CellFormatter() {
+ final CellFormatter cf = new CellFormatter() {
@Override
- public String format(
- Object value,
- ListGridRecord record,
- int rowNum, int colNum) {
- if (value == null) return null;
- try {
- NumberFormat nf;
- double v = Double.parseDouble((String)value);
- nf = NumberFormat.getFormat("###0.00##");
- return nf.format(v);
- }
- catch (Exception e) {
- return value.toString();
- }
+ public String format(final Object value, final ListGridRecord record, final int rowNum, final int colNum) {
+ if (value == null)
+ return null;
+ try {
+ NumberFormat nf;
+ final double v = Double.parseDouble((String) value);
+ nf = NumberFormat.getFormat("###0.00##");
+ return nf.format(v);
+ }
+ catch (final Exception e) {
+ return value.toString();
+ }
}
};
ListGridField pin1 = null;
ListGridField pin2 = null;
if (doublePins) {
- pin1 = new ListGridField ("fromIcon", MESSAGES.from());
- pin1.setWidth (30);
+ pin1 = new ListGridField("fromIcon", this.MESSAGES.from());
+ pin1.setWidth(30);
} else {
- pin1 = new ListGridField ("fromIcon", MESSAGES.selection());
- pin1.setWidth (60);
+ pin1 = new ListGridField("fromIcon", this.MESSAGES.selection());
+ pin1.setWidth(60);
}
- pin1.setType (ListGridFieldType.ICON);
- pin1.setCellIcon(baseUrl + MESSAGES.markerGreen());
+ pin1.setType(ListGridFieldType.ICON);
+ pin1.setCellIcon(baseUrl + this.MESSAGES.markerGreen());
if (doublePins) {
- pin2 = new ListGridField ("toIcon", MESSAGES.to());
- pin2.setType (ListGridFieldType.ICON);
- pin2.setWidth (30);
- pin2.setCellIcon(baseUrl + MESSAGES.markerRed());
+ pin2 = new ListGridField("toIcon", this.MESSAGES.to());
+ pin2.setType(ListGridFieldType.ICON);
+ pin2.setWidth(30);
+ pin2.setCellIcon(baseUrl + this.MESSAGES.markerRed());
}
if (isDistance) {
/* We have from / to fields */
- pin1.addRecordClickHandler (new RecordClickHandler () {
+ pin1.addRecordClickHandler(new RecordClickHandler() {
@Override
- public void onRecordClick (RecordClickEvent e) {
- Record r = e.getRecord();
- if (!isLocationMode ()) {
+ public void onRecordClick(final RecordClickEvent e) {
+ final Record r = e.getRecord();
+ if (!isLocationMode()) {
/* distance panel and distance mode */
setFrom(r.getAttribute("from"));
setTo(r.getAttribute("to"));
@@ -283,15 +283,17 @@
}
});
if (doublePins) {
- pin2.addRecordClickHandler (new RecordClickHandler () {
+ pin2.addRecordClickHandler(new RecordClickHandler() {
@Override
- public void onRecordClick (RecordClickEvent e) {
- Record r = e.getRecord();
- if (isLocationMode ()) {
+ public void onRecordClick(final RecordClickEvent e) {
+ final Record r = e.getRecord();
+ if (isLocationMode()) {
appendLocation(r.getAttribute("to"));
} else {
- /* Distance and double pin behavior is only
- * defined for location mode. */
+ /*
+ * Distance and double pin behavior is only
+ * defined for location mode.
+ */
GWT.log("Unhandled input state.");
}
}
@@ -299,11 +301,11 @@
}
} else {
/* We only have the from field */
- pin1.addRecordClickHandler (new RecordClickHandler () {
+ pin1.addRecordClickHandler(new RecordClickHandler() {
@Override
- public void onRecordClick (RecordClickEvent e) {
- Record r = e.getRecord();
- if (!isLocationMode ()) {
+ public void onRecordClick(final RecordClickEvent e) {
+ final Record r = e.getRecord();
+ if (!isLocationMode()) {
/* Location panel and distance mode */
setFrom(r.getAttribute("from"));
} else {
@@ -313,15 +315,17 @@
}
});
if (doublePins) {
- pin2.addRecordClickHandler (new RecordClickHandler () {
+ pin2.addRecordClickHandler(new RecordClickHandler() {
@Override
- public void onRecordClick (RecordClickEvent e) {
- Record r = e.getRecord();
- if (!isLocationMode ()) {
+ public void onRecordClick(final RecordClickEvent e) {
+ final Record r = e.getRecord();
+ if (!isLocationMode()) {
setTo(r.getAttribute("from"));
} else {
- /* Distance and double pin behavior is only
- * defined for location mode. */
+ /*
+ * Distance and double pin behavior is only
+ * defined for location mode.
+ */
GWT.log("Unhandled input state.");
}
}
@@ -329,8 +333,7 @@
}
}
- ListGridField ddescr = new ListGridField("description",
- MESSAGES.description());
+ final ListGridField ddescr = new ListGridField("description", this.MESSAGES.description());
ddescr.setType(ListGridFieldType.TEXT);
ddescr.setWidth("*");
@@ -338,32 +341,29 @@
ListGridField to = null;
if (isDistance) {
- from = new ListGridField("from", MESSAGES.from());
- to = new ListGridField("to", MESSAGES.to());
+ from = new ListGridField("from", this.MESSAGES.from());
+ to = new ListGridField("to", this.MESSAGES.to());
to.setType(ListGridFieldType.FLOAT);
to.setCellFormatter(cf);
to.setWidth("12%");
to.setAlign(Alignment.LEFT);
} else {
- from = new ListGridField("from", MESSAGES.locations());
+ from = new ListGridField("from", this.MESSAGES.locations());
}
from.setCellFormatter(cf);
from.setWidth("12%");
- ListGridField dside = new ListGridField("riverside",
- MESSAGES.riverside());
+ final ListGridField dside = new ListGridField("riverside", this.MESSAGES.riverside());
dside.setType(ListGridFieldType.TEXT);
dside.setWidth("12%");
- ListGridField bottom =
- new ListGridField("bottom", MESSAGES.bottom_edge());
+ final ListGridField bottom = new ListGridField("bottom", this.MESSAGES.bottom_edge());
bottom.setType(ListGridFieldType.TEXT);
bottom.setWidth("10%");
bottom.setCellFormatter(cf);
- ListGridField top =
- new ListGridField("top", MESSAGES.top_edge());
+ final ListGridField top = new ListGridField("top", this.MESSAGES.top_edge());
top.setType(ListGridFieldType.TEXT);
top.setWidth("10%");
top.setCellFormatter(cf);
@@ -380,31 +380,30 @@
}
@Override
- public Canvas createOld(DataList dataList) {
- List items = dataList.getAll();
+ public Canvas createOld(final DataList dataList) {
+ final List items = dataList.getAll();
- Data dMode = getData(items, "ld_mode");
- DataItem[] dItems = dMode.getItems();
+ final Data dMode = getData(items, "ld_mode");
+ final DataItem[] dItems = dMode.getItems();
boolean rangeMode = true;
if (dItems != null && dItems[0] != null) {
rangeMode = FIELD_VALUE_DISTANCE.equals(dItems[0].getStringValue());
}
- HLayout layout = new HLayout();
+ final HLayout layout = new HLayout();
layout.setWidth("400px");
- Label label = new Label(dataList.getLabel());
+ final Label label = new Label(dataList.getLabel());
label.setWidth("200px");
- Canvas back = getBackButton(dataList.getState());
+ final Canvas back = getBackButton(dataList.getState());
layout.addMember(label);
if (rangeMode) {
layout.addMember(getOldRangeSelection(dataList));
- }
- else {
+ } else {
layout.addMember(getOldLocationSelection(dataList));
}
@@ -413,124 +412,116 @@
return layout;
}
-
/**
* Creates a label for the selected range.
*
- * @param dataList The DataList containing all values for this state.
+ * @param dataList
+ * The DataList containing all values for this state.
*
* @return A label displaying the selected values.
*/
- protected Label getOldRangeSelection(DataList dataList) {
- List items = dataList.getAll();
-
- Data dFrom = getData(items, "ld_from");
- Data dTo = getData(items, "ld_to");
- Data dStep = getData(items, "ld_step");
+ protected Label getOldRangeSelection(final DataList dataList) {
+ final List items = dataList.getAll();
- DataItem[] from = dFrom.getItems();
- DataItem[] to = dTo.getItems();
- DataItem[] step = dStep.getItems();
+ final Data dFrom = getData(items, "ld_from");
+ final Data dTo = getData(items, "ld_to");
+ final Data dStep = getData(items, "ld_step");
- StringBuilder sb = new StringBuilder();
+ final DataItem[] from = dFrom.getItems();
+ final DataItem[] to = dTo.getItems();
+ final DataItem[] step = dStep.getItems();
+
+ final StringBuilder sb = new StringBuilder();
sb.append(from[0].getLabel());
- sb.append(" " + MESSAGES.unitFrom() + " ");
+ sb.append(" " + this.MESSAGES.unitFrom() + " ");
sb.append(to[0].getLabel());
- sb.append(" " + MESSAGES.unitTo() + " ");
+ sb.append(" " + this.MESSAGES.unitTo() + " ");
sb.append(step[0].getLabel());
- sb.append(" " + MESSAGES.unitWidth());
+ sb.append(" " + this.MESSAGES.unitWidth());
- Label selected = new Label(sb.toString());
+ final Label selected = new Label(sb.toString());
selected.setWidth("130px");
return selected;
}
-
/**
* Creates a label for the selected locations.
*
- * @param dataList The DataList containing all values for this state.
+ * @param dataList
+ * The DataList containing all values for this state.
*
* @return A label displaying the selected values.
*/
- protected Label getOldLocationSelection(DataList dataList) {
- List items = dataList.getAll();
-
- Data dLocations = getData(items, "ld_locations");
- DataItem[] lItems = dLocations.getItems();
+ protected Label getOldLocationSelection(final DataList dataList) {
+ final List items = dataList.getAll();
- String[] splitted = lItems[0].getStringValue().split(" ");
+ final Data dLocations = getData(items, "ld_locations");
+ final DataItem[] lItems = dLocations.getItems();
+
+ final String[] splitted = lItems[0].getStringValue().split(" ");
String value = "";
- for (int i = 0; i < splitted.length; i++) {
+ for (final String element : splitted) {
try {
- NumberFormat nf = NumberFormat.getDecimalFormat();
- double dv = Double.parseDouble(splitted[i]);
+ final NumberFormat nf = NumberFormat.getDecimalFormat();
+ final double dv = Double.parseDouble(element);
value += nf.format(dv) + " ";
}
- catch(NumberFormatException nfe) {
- value += splitted[i] + " ";
+ catch (final NumberFormatException nfe) {
+ value += element + " ";
}
}
- Label selected = new Label(value);
+ final Label selected = new Label(value);
selected.setWidth(130);
return selected;
}
-
/**
* This method reads the default values defined in the DataItems of the Data
* objects in list.
*
- * @param list The DataList container that stores the Data objects.
+ * @param list
+ * The DataList container that stores the Data objects.
*/
- protected void initDefaults(DataList list) {
- Data m = getData(list.getAll(), "ld_mode");
- Data l = getData(list.getAll(), "ld_locations");
- Data f = getData(list.getAll(), "ld_from");
- Data t = getData(list.getAll(), "ld_to");
- Data s = getData(list.getAll(), "ld_step");
-
- DataItem[] fItems = f.getItems();
- DataItem[] tItems = t.getItems();
- DataItem[] sItems = s.getItems();
-
- min = Double.valueOf(fItems[0].getStringValue());
- max = Double.valueOf(tItems[0].getStringValue());
- step = Double.valueOf(sItems[0].getStringValue());
+ protected void initDefaults(final DataList list) {
+ final Data m = getData(list.getAll(), "ld_mode");
+ final Data l = getData(list.getAll(), "ld_locations");
+ final Data f = getData(list.getAll(), "ld_from");
+ final Data t = getData(list.getAll(), "ld_to");
+ final Data s = getData(list.getAll(), "ld_step");
- DataItem mDef = m.getDefault();
- DataItem lDef = l.getDefault();
- DataItem fDef = f.getDefault();
- DataItem tDef = t.getDefault();
- DataItem sDef = s.getDefault();
-
- String mDefValue = mDef != null ? mDef.getStringValue() : null;
- String theMode = mDefValue != null && mDefValue.length() > 0
- ? mDef.getStringValue()
- : FIELD_VALUE_DISTANCE;
-
- mode.setValue(FIELD_MODE, theMode);
+ final DataItem[] fItems = f.getItems();
+ final DataItem[] tItems = t.getItems();
+ final DataItem[] sItems = s.getItems();
- String fDefValue = fDef != null ? fDef.getStringValue() : null;
- setFrom(fDefValue != null && fDefValue.length() > 0
- ? Double.valueOf(fDef.getStringValue())
- : min);
+ this.min = Double.valueOf(fItems[0].getStringValue());
+ this.max = Double.valueOf(tItems[0].getStringValue());
+ this.step = Double.valueOf(sItems[0].getStringValue());
- String tDefValue = tDef != null ? tDef.getStringValue() : null;
- setTo(tDefValue != null && tDefValue.length() > 0
- ? Double.valueOf(tDef.getStringValue())
- : max);
+ final DataItem mDef = m.getDefault();
+ final DataItem lDef = l.getDefault();
+ final DataItem fDef = f.getDefault();
+ final DataItem tDef = t.getDefault();
+ final DataItem sDef = s.getDefault();
- String sDefValue = sDef != null ? sDef.getStringValue() : null;
- setStep(sDefValue != null && sDefValue.length() > 0
- ? Double.valueOf(sDef.getStringValue())
- : step);
+ final String mDefValue = mDef != null ? mDef.getStringValue() : null;
+ final String theMode = mDefValue != null && mDefValue.length() > 0 ? mDef.getStringValue() : FIELD_VALUE_DISTANCE;
+
+ this.mode.setValue(FIELD_MODE, theMode);
+
+ final String fDefValue = fDef != null ? fDef.getStringValue() : null;
+ setFrom(fDefValue != null && fDefValue.length() > 0 ? Double.valueOf(fDef.getStringValue()) : this.min);
+
+ final String tDefValue = tDef != null ? tDef.getStringValue() : null;
+ setTo(tDefValue != null && tDefValue.length() > 0 ? Double.valueOf(tDef.getStringValue()) : this.max);
+
+ final String sDefValue = sDef != null ? sDef.getStringValue() : null;
+ setStep(sDefValue != null && sDefValue.length() > 0 ? Double.valueOf(sDef.getStringValue()) : this.step);
if (lDef != null) {
- String lDefValue = lDef != null ? lDef.getStringValue() : null;
+ final String lDefValue = lDef != null ? lDef.getStringValue() : null;
if (lDefValue != null && lDefValue.length() > 0) {
setLocationValues(lDef.getStringValue());
@@ -539,309 +530,277 @@
if (theMode.equals(FIELD_VALUE_DISTANCE)) {
enableDistanceMode();
- inputTables.selectTab(1);
+ this.inputTables.selectTab(1);
} else {
enableLocationMode();
}
- currentFiltered = (ListGrid)inputTables.getSelectedTab().getPane();
+ this.currentFiltered = (ListGrid) this.inputTables.getSelectedTab().getPane();
- distancePanel.setValues(getFrom(), getTo(), getStep());
+ this.distancePanel.setValues(getFrom(), getTo(), getStep());
}
-
- protected Canvas createWidget(DataList data) {
- VLayout layout = new VLayout();
- container = new HLayout();
- Canvas checkboxPanel = createRadioButtonPanel();
+ protected Canvas createWidget(final DataList data) {
+ final VLayout layout = new VLayout();
+ this.container = new HLayout();
+ final Canvas checkboxPanel = createRadioButtonPanel();
- locationPanel = new DoubleArrayPanel(
- MESSAGES.unitLocation(),
- getLocationValues(),
- this);
+ this.locationPanel = new DoubleArrayPanel(this.MESSAGES.unitLocation(), getLocationValues(), this);
- distancePanel = new DoubleRangePanel(
- MESSAGES.unitFrom(), MESSAGES.unitTo(), MESSAGES.unitWidth(),
- 0, 0, 0, /* initDefaults set the default values for this. */
- 400,
- this);
+ this.distancePanel = new DoubleRangePanel(this.MESSAGES.unitFrom(), this.MESSAGES.unitTo(), this.MESSAGES.unitWidth(), 0, 0, 0, /*
+ * initDefaults set the
+ * default values for
+ * this.
+ */
+ 400, this);
- container.addMember(locationPanel);
- container.addMember(distancePanel);
- container.hideMember(locationPanel);
+ this.container.addMember(this.locationPanel);
+ this.container.addMember(this.distancePanel);
+ this.container.hideMember(this.locationPanel);
layout.addMember(checkboxPanel);
- layout.addMember(container);
-
- container.setMembersMargin(30);
+ layout.addMember(this.container);
- inputTables = new TabSet();
- inputTables.addTabSelectedHandler(new TabSelectedHandler() {
+ this.container.setMembersMargin(30);
+
+ this.inputTables = new TabSet();
+ this.inputTables.addTabSelectedHandler(new TabSelectedHandler() {
@Override
- public void onTabSelected(TabSelectedEvent evt) {
- filterDescription.clear();
- filterRange.clear();
- filterResultCount.setValue("");
+ public void onTabSelected(final TabSelectedEvent evt) {
+ LocationDistancePanel.this.filterDescription.clear();
+ LocationDistancePanel.this.filterRange.clear();
+ LocationDistancePanel.this.filterResultCount.setValue("");
// The assumption is that location is tab 0 and distance tab 1
- Canvas c = evt.getTabPane();
- if(c instanceof ListGrid) {
- currentFiltered = (ListGrid)c;
+ final Canvas c = evt.getTabPane();
+ if (c instanceof ListGrid) {
+ LocationDistancePanel.this.currentFiltered = (ListGrid) c;
}
}
});
- Tab locations = new Tab(MESSAGES.locations());
- Tab distances = new Tab(MESSAGES.distance());
-
- inputTables.setWidth100();
- inputTables.setHeight100();
-
- locations.setPane(locationsTable);
- distances.setPane(distanceTable);
-
- inputTables.addTab(locations);
- inputTables.addTab(distances);
-
- filterResultCount = new StaticTextItem(MESSAGES.resultCount());
- filterResultCount.setTitleAlign(Alignment.LEFT);
- filterResultCount.setTitleStyle("color: #000");
-
- filterDescription = new TableFilter();
- filterDescription.setHeight("30px");
- filterDescription.addFilterHandler(this);
+ final Tab locations = new Tab(this.MESSAGES.locations());
+ final Tab distances = new Tab(this.MESSAGES.distance());
- filterRange = new RangeTableFilter();
- filterRange.setHeight("30px");
- filterRange.addFilterHandler(this);
- filterRange.setVisible(false);
+ this.inputTables.setWidth100();
+ this.inputTables.setHeight100();
- filterCriteria = new SelectItem();
- filterCriteria.setShowTitle(false);
- filterCriteria.setWidth(100);
- filterCriteria.addChangedHandler(new ChangedHandler() {
+ locations.setPane(this.locationsTable);
+ distances.setPane(this.distanceTable);
+
+ this.inputTables.addTab(locations);
+ this.inputTables.addTab(distances);
+
+ this.filterResultCount = new StaticTextItem(this.MESSAGES.resultCount());
+ this.filterResultCount.setTitleAlign(Alignment.LEFT);
+ this.filterResultCount.setTitleStyle("color: #000");
+
+ this.filterDescription = new TableFilter();
+ this.filterDescription.setHeight("30px");
+ this.filterDescription.addFilterHandler(this);
+
+ this.filterRange = new RangeTableFilter();
+ this.filterRange.setHeight("30px");
+ this.filterRange.addFilterHandler(this);
+ this.filterRange.setVisible(false);
+
+ this.filterCriteria = new SelectItem();
+ this.filterCriteria.setShowTitle(false);
+ this.filterCriteria.setWidth(100);
+ this.filterCriteria.addChangedHandler(new ChangedHandler() {
@Override
- public void onChanged(ChangedEvent e) {
- if(e.getValue().toString().equals("range")) {
- filterRange.setVisible(true);
- filterDescription.setVisible(false);
- filterDescription.clear();
- filterResultCount.setValue("");
- }
- else {
- filterRange.setVisible(false);
- filterRange.clear();
- filterDescription.setVisible(true);
- filterResultCount.setValue("");
+ public void onChanged(final ChangedEvent e) {
+ if (e.getValue().toString().equals("range")) {
+ LocationDistancePanel.this.filterRange.setVisible(true);
+ LocationDistancePanel.this.filterDescription.setVisible(false);
+ LocationDistancePanel.this.filterDescription.clear();
+ LocationDistancePanel.this.filterResultCount.setValue("");
+ } else {
+ LocationDistancePanel.this.filterRange.setVisible(false);
+ LocationDistancePanel.this.filterRange.clear();
+ LocationDistancePanel.this.filterDescription.setVisible(true);
+ LocationDistancePanel.this.filterResultCount.setValue("");
}
}
});
- LinkedHashMap filterMap =
- new LinkedHashMap();
- filterMap.put("description", MESSAGES.description());
- filterMap.put("range", MESSAGES.range());
- filterCriteria.setValueMap(filterMap);
- filterCriteria.setValue("description");
+ final LinkedHashMap filterMap = new LinkedHashMap();
+ filterMap.put("description", this.MESSAGES.description());
+ filterMap.put("range", this.MESSAGES.range());
+ this.filterCriteria.setValueMap(filterMap);
+ this.filterCriteria.setValue("description");
- DynamicForm form = new DynamicForm();
- form.setFields(filterCriteria);
- inputTables.setHeight("*");
- DynamicForm form2 = new DynamicForm();
- form2.setFields(filterResultCount);
+ final DynamicForm form = new DynamicForm();
+ form.setFields(this.filterCriteria);
+ this.inputTables.setHeight("*");
+ final DynamicForm form2 = new DynamicForm();
+ form2.setFields(this.filterResultCount);
- VLayout helper = new VLayout();
- HLayout filterLayout = new HLayout();
+ final VLayout helper = new VLayout();
+ final HLayout filterLayout = new HLayout();
filterLayout.addMember(form);
- filterLayout.addMember(filterDescription);
- filterLayout.addMember(filterRange);
+ filterLayout.addMember(this.filterDescription);
+ filterLayout.addMember(this.filterRange);
filterLayout.setHeight("30px");
- helper.addMember(inputTables);
+ helper.addMember(this.inputTables);
helper.addMember(filterLayout);
helper.addMember(form2);
helper.setHeight100();
helper.setWidth100();
- helperContainer.addMember(helper);
+ this.helperContainer.addMember(helper);
filterLayout.setWidth("200");
return layout;
}
-
@Override
- public void onFilterCriteriaChanged(StringFilterEvent event) {
- String search = event.getFilter();
+ public void onFilterCriteriaChanged(final StringFilterEvent event) {
+ final String search = event.getFilter();
if (search != null && search.length() > 0) {
- Criteria c = new Criteria("description", search);
+ final Criteria c = new Criteria("description", search);
- locationsTable.filterData(c);
- distanceTable.filterData(c);
- filterResultCount.setValue(currentFiltered.getRecords().length);
- }
- else {
- locationsTable.clearCriteria();
- distanceTable.clearCriteria();
- filterResultCount.setValue("");
+ this.locationsTable.filterData(c);
+ this.distanceTable.filterData(c);
+ this.filterResultCount.setValue(this.currentFiltered.getRecords().length);
+ } else {
+ this.locationsTable.clearCriteria();
+ this.distanceTable.clearCriteria();
+ this.filterResultCount.setValue("");
}
}
-
@Override
- public void onFilterCriteriaChanged(RangeFilterEvent event) {
- Float from = event.getFrom() - 0.001f;
- Float to = event.getTo() + 0.001f;
+ public void onFilterCriteriaChanged(final RangeFilterEvent event) {
+ final Float from = event.getFrom() - 0.001f;
+ final Float to = event.getTo() + 0.001f;
GWT.log("filtering range: " + from + " to " + to);
-
Criterion combinedFilter = null;
Criterion locationFilter = null;
if (from.equals(Float.NaN) && to.equals(Float.NaN)) {
- locationsTable.clearCriteria();
- distanceTable.clearCriteria();
- filterResultCount.setValue("");
+ this.locationsTable.clearCriteria();
+ this.distanceTable.clearCriteria();
+ this.filterResultCount.setValue("");
return;
- }
- else if (from.equals(Float.NaN)) {
+ } else if (from.equals(Float.NaN)) {
combinedFilter = new Criterion("to", OperatorId.LESS_OR_EQUAL, to);
- locationFilter =
- new Criterion("from", OperatorId.LESS_OR_EQUAL, to);
- locationsTable.filterData(locationFilter);
- distanceTable.filterData(combinedFilter);
- filterResultCount.setValue(currentFiltered.getRecords().length);
+ locationFilter = new Criterion("from", OperatorId.LESS_OR_EQUAL, to);
+ this.locationsTable.filterData(locationFilter);
+ this.distanceTable.filterData(combinedFilter);
+ this.filterResultCount.setValue(this.currentFiltered.getRecords().length);
return;
- }
- else if (to.equals(Float.NaN)) {
- combinedFilter =
- new Criterion("from", OperatorId.GREATER_OR_EQUAL, from);
- locationsTable.filterData(combinedFilter);
- distanceTable.filterData(combinedFilter);
+ } else if (to.equals(Float.NaN)) {
+ combinedFilter = new Criterion("from", OperatorId.GREATER_OR_EQUAL, from);
+ this.locationsTable.filterData(combinedFilter);
+ this.distanceTable.filterData(combinedFilter);
+ } else {
+ final AdvancedCriteria c1 = new AdvancedCriteria(OperatorId.AND,
+ new Criterion[] { new Criterion("from", OperatorId.GREATER_OR_EQUAL, from), new Criterion("from", OperatorId.LESS_OR_EQUAL, to) });
+
+ final AdvancedCriteria c2 = new AdvancedCriteria(OperatorId.AND,
+ new Criterion[] { new Criterion("to", OperatorId.GREATER_OR_EQUAL, from), new Criterion("to", OperatorId.LESS_OR_EQUAL, to) });
+
+ final AdvancedCriteria c3 = new AdvancedCriteria(OperatorId.AND,
+ new Criterion[] { new Criterion("from", OperatorId.LESS_OR_EQUAL, to), new Criterion("to", OperatorId.GREATER_OR_EQUAL, from) });
+
+ combinedFilter = new AdvancedCriteria(OperatorId.OR, new Criterion[] { c1, c2, c3 });
}
- else {
- AdvancedCriteria c1 =
- new AdvancedCriteria(OperatorId.AND, new Criterion[] {
- new Criterion("from", OperatorId.GREATER_OR_EQUAL, from),
- new Criterion("from", OperatorId.LESS_OR_EQUAL, to)
- });
-
- AdvancedCriteria c2 =
- new AdvancedCriteria(OperatorId.AND, new Criterion[] {
- new Criterion("to", OperatorId.GREATER_OR_EQUAL, from),
- new Criterion("to", OperatorId.LESS_OR_EQUAL, to)
- });
-
- AdvancedCriteria c3 =
- new AdvancedCriteria(OperatorId.AND, new Criterion[] {
- new Criterion("from", OperatorId.LESS_OR_EQUAL, to),
- new Criterion("to", OperatorId.GREATER_OR_EQUAL, from)
- });
-
- combinedFilter =
- new AdvancedCriteria(OperatorId.OR, new Criterion[] {
- c1, c2, c3
- });
- }
- locationsTable.filterData(combinedFilter);
- distanceTable.filterData(combinedFilter);
- filterResultCount.setValue(currentFiltered.getRecords().length);
+ this.locationsTable.filterData(combinedFilter);
+ this.distanceTable.filterData(combinedFilter);
+ this.filterResultCount.setValue(this.currentFiltered.getRecords().length);
}
-
@Override
public List validate() {
if (isLocationMode()) {
return validateLocations();
- }
- else {
+ } else {
return validateRange();
}
}
-
protected List validateLocations() {
- List errors = new ArrayList();
- NumberFormat nf = NumberFormat.getDecimalFormat();
+ final List errors = new ArrayList();
+ final NumberFormat nf = NumberFormat.getDecimalFormat();
try {
- saveLocationValues(locationPanel);
+ saveLocationValues(this.locationPanel);
}
- catch (Exception e) {
- errors.add(MESSAGES.wrongFormat());
+ catch (final Exception e) {
+ errors.add(this.MESSAGES.wrongFormat());
}
- double[] values = getLocationValues();
- double[] good = new double[values.length];
- int idx = 0;
+ final double[] values = getLocationValues();
+ final double[] good = new double[values.length];
+ int idx = 0;
- for (double value: values) {
- if (value < min || value > max) {
- String tmp = MESSAGES.error_validate_range();
+ for (final double value : values) {
+ if (value < this.min || value > this.max) {
+ String tmp = this.MESSAGES.error_validate_range();
tmp = tmp.replace("$1", nf.format(value));
- tmp = tmp.replace("$2", nf.format(min));
- tmp = tmp.replace("$3", nf.format(max));
+ tmp = tmp.replace("$2", nf.format(this.min));
+ tmp = tmp.replace("$3", nf.format(this.max));
errors.add(tmp);
- }
- else {
+ } else {
good[idx++] = value;
}
}
- double[] justGood = new double[idx];
+ final double[] justGood = new double[idx];
for (int i = 0; i < justGood.length; i++) {
justGood[i] = good[i];
}
if (!errors.isEmpty()) {
- locationPanel.setValues(justGood);
+ this.locationPanel.setValues(justGood);
}
return errors;
}
-
protected List validateRange() {
- List errors = new ArrayList();
- NumberFormat nf = NumberFormat.getDecimalFormat();
+ final List errors = new ArrayList();
+ final NumberFormat nf = NumberFormat.getDecimalFormat();
try {
- saveDistanceValues(distancePanel);
+ saveDistanceValues(this.distancePanel);
}
- catch (Exception e) {
- errors.add(MESSAGES.wrongFormat());
+ catch (final Exception e) {
+ errors.add(this.MESSAGES.wrongFormat());
}
double from = getFrom();
- double to = getTo();
- double step = getStep();
+ double to = getTo();
+ final double step = getStep();
- if (from < min || from > max) {
- String tmp = MESSAGES.error_validate_range();
+ if (from < this.min || from > this.max) {
+ String tmp = this.MESSAGES.error_validate_range();
tmp = tmp.replace("$1", nf.format(from));
- tmp = tmp.replace("$2", nf.format(min));
- tmp = tmp.replace("$3", nf.format(max));
+ tmp = tmp.replace("$2", nf.format(this.min));
+ tmp = tmp.replace("$3", nf.format(this.max));
errors.add(tmp);
- from = min;
+ from = this.min;
}
- if (to < min || to > max) {
- String tmp = MESSAGES.error_validate_range();
+ if (to < this.min || to > this.max) {
+ String tmp = this.MESSAGES.error_validate_range();
tmp = tmp.replace("$1", nf.format(to));
- tmp = tmp.replace("$2", nf.format(min));
- tmp = tmp.replace("$3", nf.format(max));
+ tmp = tmp.replace("$2", nf.format(this.min));
+ tmp = tmp.replace("$3", nf.format(this.max));
errors.add(tmp);
- to = max;
+ to = this.max;
}
if (!errors.isEmpty()) {
- distancePanel.setValues(from, to, step);
+ this.distancePanel.setValues(from, to, step);
}
return errors;
}
-
/**
* This method returns the selected data.
*
@@ -849,52 +808,46 @@
*/
@Override
public Data[] getData() {
- List data = new ArrayList();
+ final List data = new ArrayList();
// If we have entered a value and click right afterwards on the
// 'next' button, the BlurEvent is not fired, and the values are not
// saved. So, we gonna save those values explicitly.
if (isLocationMode()) {
- Canvas member = container.getMember(0);
+ final Canvas member = this.container.getMember(0);
if (member instanceof DoubleArrayPanel) {
- DoubleArrayPanel form = (DoubleArrayPanel) member;
+ final DoubleArrayPanel form = (DoubleArrayPanel) member;
saveLocationValues(form);
}
- Data dLocations = getDataLocations();
- DataItem dFrom = new DefaultDataItem("ld_from", "ld_from", "");
- DataItem dTo = new DefaultDataItem("ld_to", "ld_to", "");
- DataItem dStep = new DefaultDataItem("ld_step", "ld_step", "");
+ final Data dLocations = getDataLocations();
+ final DataItem dFrom = new DefaultDataItem("ld_from", "ld_from", "");
+ final DataItem dTo = new DefaultDataItem("ld_to", "ld_to", "");
+ final DataItem dStep = new DefaultDataItem("ld_step", "ld_step", "");
data.add(dLocations);
- data.add(new DefaultData(
- "ld_from", null, null, new DataItem[] { dFrom } ));
- data.add(new DefaultData(
- "ld_to", null, null, new DataItem[] { dTo } ));
- data.add(new DefaultData(
- "ld_step", null, null, new DataItem[] { dStep } ));
- }
- else {
- Canvas member = container.getMember(0);
+ data.add(new DefaultData("ld_from", null, null, new DataItem[] { dFrom }));
+ data.add(new DefaultData("ld_to", null, null, new DataItem[] { dTo }));
+ data.add(new DefaultData("ld_step", null, null, new DataItem[] { dStep }));
+ } else {
+ final Canvas member = this.container.getMember(0);
if (member instanceof DoubleRangePanel) {
- DoubleRangePanel form = (DoubleRangePanel) member;
+ final DoubleRangePanel form = (DoubleRangePanel) member;
saveDistanceValues(form);
}
- Data dFrom = getDataFrom();
- Data dTo = getDataTo();
- Data dStep = getDataStep();
- DataItem loc = new DefaultDataItem(
- "ld_locations", "ld_locations","");
+ final Data dFrom = getDataFrom();
+ final Data dTo = getDataTo();
+ final Data dStep = getDataStep();
+ final DataItem loc = new DefaultDataItem("ld_locations", "ld_locations", "");
data.add(dFrom);
data.add(dTo);
data.add(dStep);
- data.add(new DefaultData(
- "ld_locations", null, null, new DataItem[] { loc } ));
+ data.add(new DefaultData("ld_locations", null, null, new DataItem[] { loc }));
}
- Data dMode = getDataMode();
+ final Data dMode = getDataMode();
if (dMode != null) {
data.add(dMode);
}
@@ -902,30 +855,28 @@
return data.toArray(new Data[data.size()]);
}
-
/**
* Returns the Data object for the 'mode' attribute.
*
* @return the Data object for the 'mode' attribute.
*/
protected Data getDataMode() {
- String value = mode.getValueAsString(FIELD_MODE);
- DataItem item = new DefaultDataItem("ld_mode", "ld_mode", value);
+ final String value = this.mode.getValueAsString(FIELD_MODE);
+ final DataItem item = new DefaultDataItem("ld_mode", "ld_mode", value);
return new DefaultData("ld_mode", null, null, new DataItem[] { item });
}
-
protected Data getDataLocations() {
- double[] locations = getLocationValues();
- boolean first = true;
+ final double[] locations = getLocationValues();
+ boolean first = true;
if (locations == null) {
return null;
}
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
- for (double l: locations) {
+ for (final double l : locations) {
if (!first) {
sb.append(" ");
}
@@ -935,210 +886,193 @@
first = false;
}
- DataItem item = new DefaultDataItem(
- "ld_locations",
- "ld_locations",
- sb.toString());
+ final DataItem item = new DefaultDataItem("ld_locations", "ld_locations", sb.toString());
- return new DefaultData(
- "ld_locations",
- null,
- null,
- new DataItem[] { item });
+ return new DefaultData("ld_locations", null, null, new DataItem[] { item });
}
-
/**
* Returns the Data object for the 'from' attribute.
*
* @return the Data object for the 'from' attribute.
*/
protected Data getDataFrom() {
- String value = Double.valueOf(getFrom()).toString();
- DataItem item = new DefaultDataItem("ld_from", "ld_from", value);
- return new DefaultData(
- "ld_from", null, null, new DataItem[] { item });
+ final String value = Double.valueOf(getFrom()).toString();
+ final DataItem item = new DefaultDataItem("ld_from", "ld_from", value);
+ return new DefaultData("ld_from", null, null, new DataItem[] { item });
}
-
/**
* Returns the Data object for the 'to' attribute.
*
* @return the Data object for the 'to' attribute.
*/
protected Data getDataTo() {
- String value = Double.valueOf(getTo()).toString();
- DataItem item = new DefaultDataItem("ld_to", "ld_to", value);
- return new DefaultData(
- "ld_to", null, null, new DataItem[] { item });
+ final String value = Double.valueOf(getTo()).toString();
+ final DataItem item = new DefaultDataItem("ld_to", "ld_to", value);
+ return new DefaultData("ld_to", null, null, new DataItem[] { item });
}
-
/**
* Returns the Data object for the 'step' attribute.
*
* @return the Data object for the 'step' attribute.
*/
protected Data getDataStep() {
- String value = Double.valueOf(getStep()).toString();
- DataItem item = new DefaultDataItem("ld_step","ld_step", value);
- return new DefaultData(
- "ld_step", null, null, new DataItem[] { item });
+ final String value = Double.valueOf(getStep()).toString();
+ final DataItem item = new DefaultDataItem("ld_step", "ld_step", value);
+ return new DefaultData("ld_step", null, null, new DataItem[] { item });
}
-
/**
* Determines the current input mode.
*
* @return true, if 'location' is the current input mode, otherwise false.
*/
public boolean isLocationMode() {
- String inputMode = mode.getValueAsString(FIELD_MODE);
+ final String inputMode = this.mode.getValueAsString(FIELD_MODE);
return inputMode.equals(FIELD_VALUE_LOCATION) ? true : false;
}
-
/**
* Activates the location panel.
*/
protected void enableLocationMode() {
- mode.setValue(FIELD_MODE, FIELD_VALUE_LOCATION);
- container.hideMember(distancePanel);
- container.showMember(locationPanel);
- setupDistanceInfoTable(locationsTable, false, false);
- setupDistanceInfoTable(distanceTable, true, true);
- inputTables.updateTab(0, locationsTable);
- inputTables.updateTab(1, distanceTable);
+ this.mode.setValue(FIELD_MODE, FIELD_VALUE_LOCATION);
+ this.container.hideMember(this.distancePanel);
+ this.container.showMember(this.locationPanel);
+ setupDistanceInfoTable(this.locationsTable, false, false);
+ setupDistanceInfoTable(this.distanceTable, true, true);
+ this.inputTables.updateTab(0, this.locationsTable);
+ this.inputTables.updateTab(1, this.distanceTable);
}
-
/**
* Activates the distance panel.
*/
protected void enableDistanceMode() {
- mode.setValue(FIELD_MODE, FIELD_VALUE_DISTANCE);
- container.hideMember(locationPanel);
- container.showMember(distancePanel);
- setupDistanceInfoTable(locationsTable, true, false);
- setupDistanceInfoTable(distanceTable, false, true);
- inputTables.updateTab(0, locationsTable);
- inputTables.updateTab(1, distanceTable);
+ this.mode.setValue(FIELD_MODE, FIELD_VALUE_DISTANCE);
+ this.container.hideMember(this.locationPanel);
+ this.container.showMember(this.distancePanel);
+ setupDistanceInfoTable(this.locationsTable, true, false);
+ setupDistanceInfoTable(this.distanceTable, false, true);
+ this.inputTables.updateTab(0, this.locationsTable);
+ this.inputTables.updateTab(1, this.distanceTable);
}
-
/**
* This method switches the input mode between location and distance input.
*
- * @param event The click event fired by a RadioButtonGroupItem.
+ * @param event
+ * The click event fired by a RadioButtonGroupItem.
*/
@Override
- public void onChange(ChangeEvent event) {
- String value = (String) event.getValue();
+ public void onChange(final ChangeEvent event) {
+ final String value = (String) event.getValue();
if (value == null) {
return;
}
if (value.equals(FIELD_VALUE_LOCATION)) {
enableLocationMode();
- filterDescription.clear();
- filterRange.clear();
- filterResultCount.setValue("");
+ this.filterDescription.clear();
+ this.filterRange.clear();
+ this.filterResultCount.setValue("");
// Bring this tab to front.
- inputTables.selectTab(0);
- }
- else {
+ this.inputTables.selectTab(0);
+ } else {
enableDistanceMode();
- filterDescription.clear();
- filterRange.clear();
- filterResultCount.setValue("");
+ this.filterDescription.clear();
+ this.filterRange.clear();
+ this.filterResultCount.setValue("");
// Bring the distanceTable tab to front.
- inputTables.selectTab(1);
+ this.inputTables.selectTab(1);
}
}
-
/**
* This method is used to validate the inserted data in the form fields.
*
- * @param event The BlurEvent that gives information about the FormItem that
- * has been modified and its value.
+ * @param event
+ * The BlurEvent that gives information about the FormItem that
+ * has been modified and its value.
*/
@Override
- public void onBlur(BlurEvent event) {
- FormItem item = event.getItem();
- String field = item.getFieldName();
+ public void onBlur(final BlurEvent event) {
+ final FormItem item = event.getItem();
+ final String field = item.getFieldName();
if (field == null) {
return;
}
if (field.equals(DoubleArrayPanel.FIELD_NAME)) {
- DoubleArrayPanel p = (DoubleArrayPanel) event.getForm();
+ final DoubleArrayPanel p = (DoubleArrayPanel) event.getForm();
saveLocationValue(p, item);
- }
- else {
- DoubleRangePanel p = (DoubleRangePanel) event.getForm();
+ } else {
+ final DoubleRangePanel p = (DoubleRangePanel) event.getForm();
saveDistanceValue(p, item);
}
}
-
-
/**
* Validates and stores all values entered in the location mode.
*
- * @param p The DoubleArrayPanel.
+ * @param p
+ * The DoubleArrayPanel.
*/
- protected void saveLocationValues(DoubleArrayPanel p) {
- FormItem[] formItems = p.getFields();
+ protected void saveLocationValues(final DoubleArrayPanel p) {
+ final FormItem[] formItems = p.getFields();
- for (FormItem item: formItems) {
+ for (final FormItem item : formItems) {
if (item.getFieldName().equals(DoubleArrayPanel.FIELD_NAME)) {
saveLocationValue(p, item);
}
}
}
-
/**
* Validates and stores all values entered in the distance mode.
*
- * @param p The DoubleRangePanel.
+ * @param p
+ * The DoubleRangePanel.
*/
- protected void saveDistanceValues(DoubleRangePanel p) {
- FormItem[] formItems = p.getFields();
+ protected void saveDistanceValues(final DoubleRangePanel p) {
+ final FormItem[] formItems = p.getFields();
- for (FormItem item: formItems) {
+ for (final FormItem item : formItems) {
saveDistanceValue(p, item);
}
}
-
/**
* Validates and stores a value entered in the location mode.
*
- * @param p The DoubleArrayPanel.
- * @param item The item that needs to be validated.
+ * @param p
+ * The DoubleArrayPanel.
+ * @param item
+ * The item that needs to be validated.
*/
- protected void saveLocationValue(DoubleArrayPanel p, FormItem item) {
+ protected void saveLocationValue(final DoubleArrayPanel p, final FormItem item) {
if (p.validateForm(item)) {
setLocationValues(p.getInputValues(item));
}
}
-
/**
* Validates and stores value entered in the distance mode.
*
- * @param p The DoubleRangePanel.
- * @param item The item that needs to be validated.
+ * @param p
+ * The DoubleRangePanel.
+ * @param item
+ * The item that needs to be validated.
*/
- protected void saveDistanceValue(DoubleRangePanel p, FormItem item) {
+ protected void saveDistanceValue(final DoubleRangePanel p, final FormItem item) {
if (p.validateForm(item)) {
setFrom(p.getFrom());
setTo(p.getTo());
@@ -1146,7 +1080,6 @@
}
}
-
/**
* This method creates the panel that contains the checkboxes to switch
* between the input mode 'location' and 'distance'.
@@ -1154,161 +1087,148 @@
* @return the checkbox panel.
*/
protected Canvas createRadioButtonPanel() {
- mode = new DynamicForm();
+ this.mode = new DynamicForm();
- RadioGroupItem radio = new RadioGroupItem(FIELD_MODE);
+ final RadioGroupItem radio = new RadioGroupItem(FIELD_MODE);
radio.setShowTitle(false);
radio.setVertical(false);
radio.setWrap(false);
- LinkedHashMap values =
- new LinkedHashMap();
- values.put(FIELD_VALUE_LOCATION, MESSAGES.location());
- values.put(FIELD_VALUE_DISTANCE, MESSAGES.distance());
+ final LinkedHashMap values = new LinkedHashMap();
+ values.put(FIELD_VALUE_LOCATION, this.MESSAGES.location());
+ values.put(FIELD_VALUE_DISTANCE, this.MESSAGES.distance());
- LinkedHashMap initial =
- new LinkedHashMap();
+ final LinkedHashMap initial = new LinkedHashMap();
initial.put(FIELD_MODE, FIELD_VALUE_DISTANCE);
radio.setValueMap(values);
radio.addChangeHandler(this);
- mode.setFields(radio);
- mode.setValues(initial);
+ this.mode.setFields(radio);
+ this.mode.setValues(initial);
- return mode;
+ return this.mode;
}
-
protected void createDistanceInputPanel() {
- Config config = Config.getInstance();
- String url = config.getServerUrl();
- String river = "";
+ final Config config = Config.getInstance();
+ final String url = config.getServerUrl();
+ String river = "";
- ArtifactDescription adescr = artifact.getArtifactDescription();
- DataList[] data = adescr.getOldData();
+ final ArtifactDescription adescr = this.artifact.getArtifactDescription();
+ final DataList[] data = adescr.getOldData();
if (data != null && data.length > 0) {
- for (int i = 0; i < data.length; i++) {
- DataList dl = data[i];
+ for (final DataList dl : data) {
if (dl.getState().endsWith("river")) {
for (int j = 0; j < dl.size(); j++) {
- Data d = dl.get(j);
- DataItem[] di = d.getItems();
+ final Data d = dl.get(j);
+ final DataItem[] di = d.getItems();
if (di != null && di.length == 1) {
- river = d.getItems()[0].getStringValue();
+ river = d.getItems()[0].getStringValue();
}
}
}
}
}
- distanceTable.setDataSource(new DistanceInfoDataSource(
- url, river, "distances"));
- locationsTable.setDataSource(new DistanceInfoDataSource(
- url, river, "locations"));
+ this.distanceTable.setDataSource(new DistanceInfoDataSource(url, river, "distances"));
+ this.locationsTable.setDataSource(new DistanceInfoDataSource(url, river, "locations"));
}
protected double getFrom() {
- return from;
+ return this.from;
}
- protected void setTo(String to) {
- try {
- double toValue = Double.parseDouble(to);
+ protected void setTo(final String to) {
+ try {
+ final double toValue = Double.parseDouble(to);
setTo(toValue);
}
- catch(NumberFormatException nfe) {
- // Is there anything to do?
- }
- }
-
- protected void setFrom(String from) {
- try {
- double fromValue = Double.parseDouble(from);
- setFrom(fromValue);
- }
- catch(NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
// Is there anything to do?
}
}
- protected void setFrom(double from) {
- this.from = from;
- /* The doubling should be removed and this.from abolished */
- distancePanel.setFrom(from);
- }
-
-
- protected double getTo() {
- return to;
+ protected void setFrom(final String from) {
+ try {
+ final double fromValue = Double.parseDouble(from);
+ setFrom(fromValue);
+ }
+ catch (final NumberFormatException nfe) {
+ // Is there anything to do?
+ }
}
-
- protected void setTo(double to) {
- this.to = to;
- /* The doubling should be removed and this.to abolished */
- distancePanel.setTo(to);
+ protected void setFrom(final double from) {
+ this.from = from;
+ /* The doubling should be removed and this.from abolished */
+ this.distancePanel.setFrom(from);
}
+ protected double getTo() {
+ return this.to;
+ }
+
+ protected void setTo(final double to) {
+ this.to = to;
+ /* The doubling should be removed and this.to abolished */
+ this.distancePanel.setTo(to);
+ }
protected double getStep() {
- return step;
+ return this.step;
}
-
- protected void setStep(double step) {
+ protected void setStep(final double step) {
this.step = step;
}
-
protected double[] getLocationValues() {
- return values;
+ return this.values;
}
- protected void appendLocation(String loc) {
+ protected void appendLocation(final String loc) {
double[] selected;
if (getLocationValues() != null) {
- double[] val = getLocationValues();
+ final double[] val = getLocationValues();
selected = new double[val.length + 1];
- for(int i = 0; i < val.length; i++){
+ for (int i = 0; i < val.length; i++) {
selected[i] = val[i];
}
try {
selected[val.length] = Double.parseDouble(loc);
}
- catch(NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
// Is there anything to do here?
}
- }
- else {
+ } else {
selected = new double[1];
selected[0] = Double.parseDouble(loc);
}
setLocationValues(selected);
}
- protected void setLocationValues(double[] values) {
+ protected void setLocationValues(final double[] values) {
this.values = values;
- locationPanel.setValues(values);
+ this.locationPanel.setValues(values);
}
-
- protected void setLocationValues(String values) {
- String[] vs = values.split(" ");
+ protected void setLocationValues(final String values) {
+ final String[] vs = values.split(" ");
if (vs == null) {
return;
}
- double[] ds = new double[vs.length];
- int idx = 0;
+ final double[] ds = new double[vs.length];
+ int idx = 0;
- for (String s: vs) {
+ for (final String s : vs) {
try {
ds[idx++] = Double.valueOf(s);
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
// do nothing
}
}
@@ -1316,11 +1236,10 @@
setLocationValues(ds);
}
-
- protected void setDistanceValues (double from, double to) {
+ protected void setDistanceValues(final double from, final double to) {
setFrom(from);
setTo(to);
- distancePanel.setValues(from, to, getStep());
+ this.distancePanel.setValues(from, to, getStep());
}
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 06bb3e94a927 -r 34dc0163ad2d gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java Mon Jun 25 16:07:41 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java Mon Jun 25 17:58:11 2018 +0200
@@ -8,6 +8,10 @@
package org.dive4elements.river.client.client.ui;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataList;
+
+import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.validator.FloatRangeValidator;
public class WaterlevelGroundPanel extends DistancePanel {
@@ -16,116 +20,106 @@
public static final String FIELD_LOWER = "diff_from";
public static final String FIELD_UPPER = "diff_to";
- public static final String FIELD_STEP = "diff_diff";
-
+ public static final String FIELD_STEP = "diff_diff";
public WaterlevelGroundPanel() {
super("left");
- FloatRangeValidator frv = new FloatRangeValidator();
+ final FloatRangeValidator frv = new FloatRangeValidator();
frv.setMin(0f);
frv.setMax(Float.MAX_VALUE);
frv.setValidateOnChange(true);
- distancePanel.getToItem().setValidators(frv);
+ this.distancePanel.getToItem().setValidators(frv);
}
-
@Override
protected String getLowerField() {
return FIELD_LOWER;
}
-
@Override
protected String getUpperField() {
return FIELD_UPPER;
}
-
@Override
protected String getStepField() {
return FIELD_STEP;
}
-
@Override
- protected String getLabel() {
- return MSG.waterlevel_ground_state();
+ protected Label getLabel(final DataList data) {
+ final Data item = data.get(0);
+ return new Label(item.getDescription());//
+
+ // item.getDescription()); // holt das Label vom Server (funktoniert schon sehr oft so!)
}
+ // @Override
+ // protected String getLabel() {
+ // return MSG.waterlevel_ground_state();
+ // }
@Override
protected String labelFrom() {
return getLabelFrom() + " [" + getUnitFrom() + "]";
}
-
@Override
protected String getLabelFrom() {
- return MSG.wgLabelFrom();
+ return this.MSG.wgLabelFrom();
}
-
@Override
protected String getUnitFrom() {
- return MSG.wgUnitFrom();
+ return this.MSG.wgUnitFrom();
}
-
@Override
protected String labelTo() {
return getLabelTo() + " [" + getUnitTo() + "]";
}
-
@Override
protected String getLabelTo() {
- return MSG.wgLabelTo();
+ return this.MSG.wgLabelTo();
}
-
@Override
protected String getUnitTo() {
- return MSG.wgUnitTo();
+ return this.MSG.wgUnitTo();
}
-
@Override
protected String labelStep() {
return getLabelStep() + " [" + getUnitStep() + "]";
}
-
@Override
protected String getLabelStep() {
- return MSG.wgLabelStep();
+ return this.MSG.wgLabelStep();
}
-
@Override
protected String getUnitStep() {
- return MSG.wgUnitStep();
+ return this.MSG.wgUnitStep();
}
-
@Override
protected double getDefaultFrom() {
return 0;
}
-
@Override
protected double getDefaultTo() {
return 2;
}
-
@Override
protected double getDefaultStep() {
return 0.5;
}
-
@Override
protected void initHelperPanel() {
// We don't need a helper panel here. But we have to override this
diff -r 06bb3e94a927 -r 34dc0163ad2d gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadDistancePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadDistancePanel.java Mon Jun 25 16:07:41 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadDistancePanel.java Mon Jun 25 17:58:11 2018 +0200
@@ -10,17 +10,6 @@
import java.util.List;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
-import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
-import com.smartgwt.client.widgets.grid.events.CellClickEvent;
-import com.smartgwt.client.widgets.grid.events.CellClickHandler;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VLayout;
-
import org.dive4elements.river.client.client.Config;
import org.dive4elements.river.client.client.ui.AbstractUIProvider;
import org.dive4elements.river.client.client.ui.DoubleRangeOnlyPanel;
@@ -34,11 +23,18 @@
import org.dive4elements.river.client.shared.model.DefaultData;
import org.dive4elements.river.client.shared.model.DefaultDataItem;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
+import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
+import com.smartgwt.client.widgets.grid.events.CellClickEvent;
+import com.smartgwt.client.widgets.grid.events.CellClickHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
-public class SedLoadDistancePanel
-extends AbstractUIProvider
-implements BlurHandler, CellClickHandler
-{
+public class SedLoadDistancePanel extends AbstractUIProvider implements BlurHandler, CellClickHandler {
public static final String FIELD_LOWER = "ld_from";
public static final String FIELD_UPPER = "ld_to";
@@ -48,14 +44,14 @@
protected LocationPicker picker;
@Override
- public Canvas createOld(DataList dataList) {
- String s = getOldSelectionString(dataList);
- String l = dataList.getLabel();
+ public Canvas createOld(final DataList dataList) {
+ final String s = getOldSelectionString(dataList);
+ final String l = dataList.getLabel();
- Label label = new Label(l);
- Label selected = new Label(s);
+ final Label label = new Label(l);
+ final Label selected = new Label(s);
- HLayout layout = new HLayout();
+ final HLayout layout = new HLayout();
layout.setWidth(400);
label.setWidth(200);
@@ -68,174 +64,171 @@
return layout;
}
- protected String getOldSelectionString(DataList dataList) {
- List items = dataList.getAll();
-
- Data dFrom = getData(items, FIELD_LOWER);
- Data dTo = getData(items, FIELD_UPPER);
+ protected String getOldSelectionString(final DataList dataList) {
+ final List items = dataList.getAll();
- DataItem[] from = dFrom.getItems();
- DataItem[] to = dTo.getItems();
+ final Data dFrom = getData(items, FIELD_LOWER);
+ final Data dTo = getData(items, FIELD_UPPER);
- StringBuilder sb = new StringBuilder();
+ final DataItem[] from = dFrom.getItems();
+ final DataItem[] to = dTo.getItems();
+
+ final StringBuilder sb = new StringBuilder();
sb.append(from[0].getLabel());
- sb.append(" " + MSG.dpUnitFrom() + " - ");
+ sb.append(" " + this.MSG.dpUnitFrom() + " - ");
sb.append(to[0].getLabel());
- sb.append(" " + MSG.dpUnitTo());
+ sb.append(" " + this.MSG.dpUnitTo());
return sb.toString();
}
@Override
- public Canvas create(DataList data) {
- picker = new LocationPicker(this);
- distancePanel = new DoubleRangeOnlyPanel(
- MSG.dpUnitFrom() + " - ",
- MSG.dpUnitTo(), 0d, 0d, 250, this, "right");
- VLayout layout = new VLayout();
+ public Canvas create(final DataList data) {
+ this.picker = new LocationPicker(this);
+ this.distancePanel = new DoubleRangeOnlyPanel(this.MSG.dpUnitFrom() + " - ", this.MSG.dpUnitTo(), 0d, 0d, 250, this, "right");
+ final VLayout layout = new VLayout();
layout.setMembersMargin(10);
- Label label = new Label(MSG.distance_state());
+ final Label label = getLabel(data);
- Canvas submit = getNextButton();
+ final Canvas submit = getNextButton();
label.setHeight(25);
- distancePanel.setHeight(50);
+ this.distancePanel.setHeight(50);
layout.addMember(label);
- layout.addMember(distancePanel);
+ layout.addMember(this.distancePanel);
layout.addMember(submit);
initMinMaxValues(data);
initDefaultValues(data);
+ this.picker.setIsDistance(true);
+ this.picker.getLocationTable().setAutoFetchData(true);
+ this.picker.prepareFilter();
- picker.setIsDistance(true);
- picker.getLocationTable().setAutoFetchData(true);
- picker.prepareFilter();
-
- helperContainer.addMember(picker.getLocationTable());
- helperContainer.addMember(picker.getFilterLayout());
- helperContainer.addMember(picker.getResultCountForm());
+ this.helperContainer.addMember(this.picker.getLocationTable());
+ this.helperContainer.addMember(this.picker.getFilterLayout());
+ this.helperContainer.addMember(this.picker.getResultCountForm());
setPickerDataSource();
- picker.createLocationTable();
+ this.picker.createLocationTable();
return layout;
}
- protected void initMinMaxValues(DataList data) {
- Data f = getData(data.getAll(), FIELD_LOWER);
- Data t = getData(data.getAll(), FIELD_UPPER);
+ protected void initMinMaxValues(final DataList data) {
+ final Data f = getData(data.getAll(), FIELD_LOWER);
+ final Data t = getData(data.getAll(), FIELD_UPPER);
- DataItem[] fItems = f.getItems();
- DataItem[] tItems = t.getItems();
+ final DataItem[] fItems = f.getItems();
+ final DataItem[] tItems = t.getItems();
try {
- min = Double.valueOf(fItems[0].getStringValue());
- max = Double.valueOf(tItems[0].getStringValue());
+ this.min = Double.valueOf(fItems[0].getStringValue());
+ this.max = Double.valueOf(tItems[0].getStringValue());
}
- catch (NumberFormatException nfe) {
- min = -Double.MAX_VALUE;
- max = Double.MAX_VALUE;
+ catch (final NumberFormatException nfe) {
+ this.min = -Double.MAX_VALUE;
+ this.max = Double.MAX_VALUE;
}
}
- protected void initDefaultValues(DataList data) {
+ protected void initDefaultValues(final DataList data) {
initDefaultFrom(data);
initDefaultTo(data);
}
- protected void initDefaultFrom(DataList data) {
- Data f = getData(data.getAll(), FIELD_LOWER);
+ private Label getLabel(final DataList data) {
+ final Data item = data.get(0);
+ // if (data.getState().contains("uinfo")) { // "Wahl der Berechnungsstrecke/des Darstellungsbereichs" (server) vs.
+ // "Berechnungsstrecke wählen" (client)
+ return new Label(item.getDescription()); // holt das Label vom Server (funktoniert schon sehr oft so!)
+ // }
+ // return new Label(getLabel()); // holt das Label aus den Flys-Constants..
+ }
+
+ protected void initDefaultFrom(final DataList data) {
+ final Data f = getData(data.getAll(), FIELD_LOWER);
double from = getDefaultFrom();
try {
from = getDefaultValue(f);
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
// do nothing
}
- distancePanel.setFrom(from);
+ this.distancePanel.setFrom(from);
}
-
protected double getDefaultFrom() {
- return min;
+ return this.min;
}
-
- protected void initDefaultTo(DataList data) {
- Data t = getData(data.getAll(), FIELD_UPPER);
+ protected void initDefaultTo(final DataList data) {
+ final Data t = getData(data.getAll(), FIELD_UPPER);
double to = getDefaultTo();
try {
to = getDefaultValue(t);
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
// do nothing
}
- distancePanel.setTo(to);
+ this.distancePanel.setTo(to);
}
-
protected double getDefaultTo() {
- return max;
+ return this.max;
}
- protected double getDefaultValue(Data data)
- throws NumberFormatException
- {
- DataItem def = data.getDefault();
- String defValue = def != null ? def.getStringValue() : null;
+ protected double getDefaultValue(final Data data) throws NumberFormatException {
+ final DataItem def = data.getDefault();
+ final String defValue = def != null ? def.getStringValue() : null;
return Double.valueOf(defValue);
}
/** Hook service to the listgrid with possible input values. */
protected void setPickerDataSource() {
- Config config = Config.getInstance();
- String url = config.getServerUrl();
- String river = "";
+ final Config config = Config.getInstance();
+ final String url = config.getServerUrl();
+ String river = "";
- ArtifactDescription adescr = artifact.getArtifactDescription();
- DataList[] data = adescr.getOldData();
+ final ArtifactDescription adescr = this.artifact.getArtifactDescription();
+ final DataList[] data = adescr.getOldData();
// Try to find a "river" data item to set the source for the
// list grid.
String dataFilter = "locations";
if (data != null && data.length > 0) {
- for (int i = 0; i < data.length; i++) {
- DataList dl = data[i];
+ for (final DataList dl : data) {
if (dl.getState().equals("state.minfo.river")) {
dataFilter = "measuringpoint";
}
- if (dl.getState().equals("state.winfo.river") ||
- dl.getState().equals("state.chart.river") ||
- dl.getState().equals("state.minfo.river")) {
+ if (dl.getState().equals("state.winfo.river") || dl.getState().equals("state.chart.river") || dl.getState().equals("state.minfo.river")) {
for (int j = 0; j < dl.size(); j++) {
- Data d = dl.get(j);
- DataItem[] di = d.getItems();
+ final Data d = dl.get(j);
+ final DataItem[] di = d.getItems();
if (di != null && di.length == 1) {
- river = d.getItems()[0].getStringValue();
- break;
+ river = d.getItems()[0].getStringValue();
+ break;
}
}
}
}
}
- picker.getLocationTable().setDataSource(new DistanceInfoDataSource(
- url, river, dataFilter));
+ this.picker.getLocationTable().setDataSource(new DistanceInfoDataSource(url, river, dataFilter));
}
@Override
protected Data[] getData() {
- Data[] data = new Data[2];
+ final Data[] data = new Data[2];
data[0] = getDataFrom();
data[1] = getDataTo();
@@ -244,42 +237,45 @@
}
protected Data getDataFrom() {
- String value = String.valueOf(distancePanel.getFrom());
- String field = FIELD_LOWER;
+ final String value = String.valueOf(this.distancePanel.getFrom());
+ final String field = FIELD_LOWER;
- DataItem item = new DefaultDataItem(field, field, value);
- return new DefaultData(
- field, null, null, new DataItem[] { item });
+ final DataItem item = new DefaultDataItem(field, field, value);
+ return new DefaultData(field, null, null, new DataItem[] { item });
}
protected Data getDataTo() {
- String value = String.valueOf(distancePanel.getTo());
- String field = FIELD_UPPER;
+ final String value = String.valueOf(this.distancePanel.getTo());
+ final String field = FIELD_UPPER;
- DataItem item = new DefaultDataItem(field, field, value);
- return new DefaultData(
- field, null, null, new DataItem[] { item });
+ final DataItem item = new DefaultDataItem(field, field, value);
+ return new DefaultData(field, null, null, new DataItem[] { item });
}
@Override
- public void onBlur(BlurEvent event) {
- distancePanel.validateForm();
+ public void onBlur(final BlurEvent event) {
+ this.distancePanel.validateForm();
}
@Override
- public void onCellClick(CellClickEvent e) {
- Record record = e.getRecord();
- int ndx = e.getColNum();
- String from = record.getAttribute("from");
+ public void onCellClick(final CellClickEvent e) {
+ final Record record = e.getRecord();
+ final int ndx = e.getColNum();
+ final String from = record.getAttribute("from");
try {
- double value = Double.valueOf(from);
+ final double value = Double.valueOf(from);
switch (ndx) {
- case 0: distancePanel.setFrom(value); break;
- case 1: distancePanel.setTo(value); break;
+ case 0:
+ this.distancePanel.setFrom(value);
+ break;
+ case 1:
+ this.distancePanel.setTo(value);
+ break;
}
}
- catch(NumberFormatException nfe) {
- SC.warn(MSG.wrongFormat());
+ catch (final NumberFormatException nfe) {
+ SC.warn(this.MSG.wrongFormat());
}
}
+
}