# HG changeset patch # User gernotbelger # Date 1526400276 -7200 # Node ID 611a523fc42fdabcb45c51dd03d61c041197515b # Parent 1ffd3882617534b372e3d5b367bd6e370c07af5a VegetationZoneAccessHelper, VegetationTablePanels verbessert diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java Tue May 15 18:04:36 2018 +0200 @@ -8,25 +8,23 @@ package org.dive4elements.river.artifacts.access; -import gnu.trove.TDoubleArrayList; - +import org.apache.commons.lang.math.DoubleRange; import org.apache.log4j.Logger; - import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.WINFOArtifact; - +import org.dive4elements.river.utils.DoubleUtil; import org.dive4elements.river.utils.RiverUtils; -import org.dive4elements.river.utils.DoubleUtil; +import gnu.trove.TDoubleArrayList; /** For the moment, light-weight wrapper around RiverUtils. */ // TODO employ 'Caching' like other Accesses, remove usage of RiverUtils. -public class RangeAccess -extends RiverAccess -{ +public class RangeAccess extends RiverAccess { private static Logger log = Logger.getLogger(RangeAccess.class); - public static enum KM_MODE { RANGE, LOCATIONS, NONE }; + public static enum KM_MODE { + RANGE, LOCATIONS, NONE + }; /** The default step width between the start end end kilometer. */ public static final double DEFAULT_KM_STEPS = 0.1; @@ -44,32 +42,34 @@ public RangeAccess() { } - public RangeAccess(D4EArtifact artifact) { + public RangeAccess(final D4EArtifact artifact) { super(artifact); } - /** Evaluate the ld_mode data of artifact. */ public KM_MODE getKmRangeMode() { - if (mode != null) { - return mode; + if (this.mode != null) { + return this.mode; } - String modeData = getString("ld_mode"); + final String modeData = getString("ld_mode"); if (modeData == null || modeData.length() == 0) { - mode = KM_MODE.NONE; - } - else if (modeData.equals("distance")) { - mode = KM_MODE.RANGE; - } - else if (modeData.equals("locations")) { - mode = KM_MODE.LOCATIONS; - } - else { - mode = KM_MODE.NONE; + this.mode = KM_MODE.NONE; + } else if (modeData.equals("distance")) { + this.mode = KM_MODE.RANGE; + } else if (modeData.equals("locations")) { + this.mode = KM_MODE.LOCATIONS; + } else { + this.mode = KM_MODE.NONE; } - return mode; + return this.mode; + } + + public final DoubleRange getRange() { + final double from = getFrom(); + final double to = getTo(); + return new DoubleRange(from, to); } /** Check if the calculation mode is Range. */ @@ -82,39 +82,28 @@ * (from ld_locations data), null if not parameterized this way. */ public double[] getLocations() { - String locationStr = getString("ld_locations"); + final String locationStr = getString("ld_locations"); if (locationStr == null || locationStr.length() == 0) { if (getArtifact() instanceof WINFOArtifact) { - WINFOArtifact winfo = (WINFOArtifact) getArtifact(); - if (winfo.getReferenceStartKm() != null - && winfo.getReferenceEndKms() != null - ) { - return new double[] - { - winfo.getReferenceStartKm().doubleValue(), - winfo.getReferenceEndKms()[0] - }; - } - else if (winfo.getReferenceStartKm() != null) { - return new double[] - { - winfo.getReferenceStartKm().doubleValue(), - winfo.getReferenceStartKm().doubleValue() - }; + final WINFOArtifact winfo = (WINFOArtifact) getArtifact(); + if (winfo.getReferenceStartKm() != null && winfo.getReferenceEndKms() != null) { + return new double[] { winfo.getReferenceStartKm().doubleValue(), winfo.getReferenceEndKms()[0] }; + } else if (winfo.getReferenceStartKm() != null) { + return new double[] { winfo.getReferenceStartKm().doubleValue(), winfo.getReferenceStartKm().doubleValue() }; } } return null; } - String[] tmp = locationStr.split(" "); - TDoubleArrayList locations = new TDoubleArrayList(); + final String[] tmp = locationStr.split(" "); + final TDoubleArrayList locations = new TDoubleArrayList(); - for (String l: tmp) { + for (final String l : tmp) { try { locations.add(Double.parseDouble(l)); } - catch (NumberFormatException nfe) { + catch (final NumberFormatException nfe) { log.debug(nfe.getLocalizedMessage(), nfe); } } @@ -125,87 +114,89 @@ } public boolean hasFrom() { - return from != null || (from = getDouble("ld_from")) != null; + return this.from != null || (this.from = getDouble("ld_from")) != null; } public boolean hasTo() { - return to != null || (to = getDouble("ld_to")) != null; + return this.to != null || (this.to = getDouble("ld_to")) != null; } - /* If left_to_right is set to true this returns - * the smaller value of from and to. */ - public double getFrom(boolean left_to_right) { + /* + * If left_to_right is set to true this returns + * the smaller value of from and to. + */ + public double getFrom(final boolean left_to_right) { if (!left_to_right) { return getFrom(); } - double from = getFrom(); - double to = getTo(); + final double from = getFrom(); + final double to = getTo(); return from > to ? to : from; } /** Return ld_from data (in km). If not found, the min. */ public double getFrom() { - if (from == null) { - from = getDouble("ld_from"); + if (this.from == null) { + this.from = getDouble("ld_from"); } if (log.isDebugEnabled()) { - log.debug("from from data: '" + from + "'"); + log.debug("from from data: '" + this.from + "'"); } - if (from == null) { + if (this.from == null) { log.warn("No 'from' found. Assume min of river."); return getRiver().determineMinMaxDistance()[0]; } - return from.doubleValue(); + return this.from.doubleValue(); } - /* If left_to_right is set to true this returns - * the larger value of from and to. */ - public double getTo(boolean left_to_right) { + /* + * If left_to_right is set to true this returns + * the larger value of from and to. + */ + public double getTo(final boolean left_to_right) { if (!left_to_right) { return getTo(); } - double from = getFrom(); - double to = getTo(); + final double from = getFrom(); + final double to = getTo(); return from > to ? from : to; } /** Return ld_to data (in km), if not found, the max. */ public double getTo() { - if (to == null) { - to = getDouble("ld_to"); + if (this.to == null) { + this.to = getDouble("ld_to"); } if (log.isDebugEnabled()) { - log.debug("to from data: '" + to + "'"); + log.debug("to from data: '" + this.to + "'"); } - if (to == null) { + if (this.to == null) { log.warn("No 'to' found. Assume max of river."); return getRiver().determineMinMaxDistance()[1]; } - return to.doubleValue(); + return this.to.doubleValue(); } - /** Step width for calculation. */ public Double getStep() { - if (step == null) { - step = getDouble("ld_step"); + if (this.step == null) { + this.step = getDouble("ld_step"); } if (log.isDebugEnabled()) { - log.debug("step: '" + step + "'"); + log.debug("step: '" + this.step + "'"); } - return step; + return this.step; } - /** * Get min and max kilometer, independent of parametization * (ld_from/to vs ld_locations). @@ -213,37 +204,35 @@ public double[] getKmRange() { // TODO store kmRange in field. switch (getKmRangeMode()) { - case RANGE: { + case RANGE: { + return getKmFromTo(); + } + + case LOCATIONS: { + final double[] locs = getLocations(); + // if no locations, nPE. + if (locs == null) { + log.warn("no locations to get km range from."); + return new double[] { Double.NaN, Double.NaN }; + } + return new double[] { locs[0], locs[locs.length - 1] }; + } + + case NONE: { + final double[] locs = getLocations(); + if (locs != null) { + return new double[] { locs[0], locs[locs.length - 1] }; + } else { return getKmFromTo(); } - - case LOCATIONS: { - double[] locs = getLocations(); - // if no locations, nPE. - if (locs == null) { - log.warn("no locations to get km range from."); - return new double[] { Double.NaN, Double.NaN }; - } - return new double[] { locs[0], locs[locs.length-1] }; - } - - case NONE: { - double[] locs = getLocations(); - if (locs != null) { - return new double[] { locs[0], locs[locs.length-1] }; - } - else { - return getKmFromTo(); - } - } + } } return new double[] { Double.NaN, Double.NaN }; } - public double[] getKmFromTo() { - return RiverUtils.getKmFromTo(this.getArtifact()); + return RiverUtils.getKmFromTo(this.getArtifact()); } /** diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/common/AccessHelper.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/AccessHelper.java Tue May 15 12:00:26 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde - * Software engineering by - * Björnsen Beratende Ingenieure GmbH - * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ -package org.dive4elements.river.artifacts.common; - -import org.apache.log4j.Logger; -import org.dive4elements.artifacts.Artifact; -import org.dive4elements.river.artifacts.D4EArtifact; -import org.dive4elements.river.artifacts.access.Access; - -import gnu.trove.TIntArrayList; - -/** - * @author Domenico Nardi Tironi - * - */ -public class AccessHelper extends Access { - - private static Logger log = Logger.getLogger(AccessHelper.class); - - // private final Artifact artifact; - - public AccessHelper(final Artifact artifact) { - this.artifact = (D4EArtifact) artifact; - } - - public String getYearEpoch() { - - return getString("ye_select"); // ACHTUNG, Ergebniswerte wurden geändert in state.sinfo.epoch und state.sinfo.year - - } - - /** [year1, years2,..] if its about years. */ - public int[] getYears(final String yearSelectedValue, final String yearKey) { - int[] years = null; - // if (years != null) { - // return years; - // } - if (getYearEpoch().equals(yearSelectedValue)) { - final TIntArrayList ints = new TIntArrayList(); - final String yearsData = getString(yearKey); - if (yearsData == null || yearsData.isEmpty()) { - log.warn("No years provided"); - return null; - } - for (final String sValue : yearsData.split(" ")) { - try { - ints.add(Integer.parseInt(sValue)); - } - catch (final NumberFormatException e) { - /* Client should prevent this */ - log.warn("Invalid year value: " + sValue); - continue; - } - } - - if (!ints.isEmpty()) { - ints.sort(); - years = ints.toNativeArray(); - } - return years; - } - return null; - } - - public int[][] getEpochs(final String epochSelectedValue, final String epochKey) { - int epochs[][] = null; - // if (epochs != null) { - // return epochs; - // } - - if (!getYearEpoch().equals(epochSelectedValue)) { - return null; - } - - final String data = getString(epochKey); - - if (data == null) { - log.warn("No 'epochs' parameter specified!"); - return null; - } - - final String[] parts = data.split(";"); - - epochs = new int[parts.length][]; - - for (int i = 0; i < parts.length; i++) { - final String[] values = parts[i].split(","); - final TIntArrayList ints = new TIntArrayList(); - try { - ints.add(Integer.parseInt(values[0])); - ints.add(Integer.parseInt(values[1])); - epochs[i] = ints.toNativeArray(); - } - catch (final NumberFormatException nfe) { - log.warn("Cannot parse int from string: '" + values + "'"); - } - } - return epochs; - } - -} diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/common/EpochYearAccessHelper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/EpochYearAccessHelper.java Tue May 15 18:04:36 2018 +0200 @@ -0,0 +1,106 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ +package org.dive4elements.river.artifacts.common; + +import org.apache.log4j.Logger; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.Access; + +import gnu.trove.TIntArrayList; + +/** + * @author Domenico Nardi Tironi + * + */ +// TODO: rename? +public class EpochYearAccessHelper extends Access { + + private static Logger log = Logger.getLogger(EpochYearAccessHelper.class); + + // private final Artifact artifact; + + public EpochYearAccessHelper(final Artifact artifact) { + this.artifact = (D4EArtifact) artifact; + } + + public String getYearEpoch() { + return getString("ye_select"); // ACHTUNG, Ergebniswerte wurden geändert in state.sinfo.epoch und state.sinfo.year + } + + /** [year1, years2,..] if its about years. */ + public int[] getYears(final String yearSelectedValue, final String yearKey) { + int[] years = null; + // if (years != null) { + // return years; + // } + if (getYearEpoch().equals(yearSelectedValue)) { + final TIntArrayList ints = new TIntArrayList(); + final String yearsData = getString(yearKey); + if (yearsData == null || yearsData.isEmpty()) { + log.warn("No years provided"); + return null; + } + for (final String sValue : yearsData.split(" ")) { + try { + ints.add(Integer.parseInt(sValue)); + } + catch (final NumberFormatException e) { + /* Client should prevent this */ + log.warn("Invalid year value: " + sValue); + continue; + } + } + + if (!ints.isEmpty()) { + ints.sort(); + years = ints.toNativeArray(); + } + return years; + } + return null; + } + + public int[][] getEpochs(final String epochSelectedValue, final String epochKey) { + int epochs[][] = null; + // if (epochs != null) { + // return epochs; + // } + + if (!getYearEpoch().equals(epochSelectedValue)) { + return null; + } + + final String data = getString(epochKey); + + if (data == null) { + log.warn("No 'epochs' parameter specified!"); + return null; + } + + final String[] parts = data.split(";"); + + epochs = new int[parts.length][]; + + for (int i = 0; i < parts.length; i++) { + final String[] values = parts[i].split(","); + final TIntArrayList ints = new TIntArrayList(); + try { + ints.add(Integer.parseInt(values[0])); + ints.add(Integer.parseInt(values[1])); + epochs[i] = ints.toNativeArray(); + } + catch (final NumberFormatException nfe) { + log.warn("Cannot parse int from string: '" + values + "'"); + } + } + return epochs; + } +} \ No newline at end of file diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionAccess.java Tue May 15 18:04:36 2018 +0200 @@ -10,9 +10,8 @@ package org.dive4elements.river.artifacts.sinfo.collision; -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.access.RangeAccess; -import org.dive4elements.river.artifacts.common.AccessHelper; +import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; @@ -26,7 +25,7 @@ */ final class CollisionAccess extends RangeAccess { - private final AccessHelper helper; + private final EpochYearAccessHelper helper; /// Fields from state: @@ -41,16 +40,10 @@ /* assert calculation mode */ final SinfoCalcMode calculationMode = artifact.getCalculationMode(); - this.helper = new AccessHelper(artifact); + this.helper = new EpochYearAccessHelper(artifact); assert (calculationMode == SinfoCalcMode.sinfo_calc_flow_depth); } - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - public int[] getYears() { return this.helper.getYears("state.sinfo.year", "years"); } diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationAccess.java Tue May 15 18:04:36 2018 +0200 @@ -10,10 +10,9 @@ package org.dive4elements.river.artifacts.sinfo.flood_duration; -import org.apache.commons.lang.math.DoubleRange; import org.apache.log4j.Logger; import org.dive4elements.river.artifacts.access.RangeAccess; -import org.dive4elements.river.artifacts.common.AccessHelper; +import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; @@ -31,11 +30,7 @@ private static Logger log = Logger.getLogger(FloodDurationAccess.class); - private static final String FIELD_DIFFIDS = "diffids"; //$NON-NLS-1$ - - private static final String FIELD_USE_TKH = "use_transport_bodies"; //$NON-NLS-1$ - - private final AccessHelper helper; + private final EpochYearAccessHelper helper; /// Fields from state: @@ -56,16 +51,10 @@ /* assert calculation mode */ final SinfoCalcMode calculationMode = artifact.getCalculationMode(); - this.helper = new AccessHelper(artifact); + this.helper = new EpochYearAccessHelper(artifact); assert (calculationMode == SinfoCalcMode.sinfo_calc_flood_duration); } - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - @Override public Double getStep() { return super.getStep(); diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java Tue May 15 18:04:36 2018 +0200 @@ -49,6 +49,9 @@ final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name()); final String riverside = access.getRiverside(); + + // TODO: mis- ups.. re-use WINFO Artifact as in TkhState + final double step = access.getStep(); final boolean wspl = access.getWspl(); final Boolean wqisfree = access.getWqIsFree(); diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthAccess.java Tue May 15 18:04:36 2018 +0200 @@ -13,7 +13,6 @@ import java.util.Collection; import java.util.Collections; -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; @@ -40,12 +39,6 @@ assert (calculationMode == SinfoCalcMode.sinfo_calc_flow_depth); } - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - public boolean isUseTransportBodies() { final Boolean useTkh = this.artifact.getDataAsBoolean(FIELD_USE_TKH); return useTkh == null ? false : useTkh; diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentAccess.java Tue May 15 18:04:36 2018 +0200 @@ -12,7 +12,6 @@ import java.util.List; -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; @@ -39,12 +38,6 @@ assert (calculationMode == SinfoCalcMode.sinfo_calc_flow_depth_minmax); } - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - public WstSoundingIdPair getCurrentPair() { return getPair(FIELD_DIFFID_CURRENT); } diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxAccess.java Tue May 15 18:04:36 2018 +0200 @@ -12,7 +12,6 @@ import java.util.Collection; -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; @@ -38,12 +37,6 @@ assert (calculationMode == SinfoCalcMode.sinfo_calc_flow_depth_minmax); } - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - public Collection getMinMaxPairs() { final String diffids = getString(FIELD_DIFFIDS); return WstSoundingIdPair.parsePairs(diffids); diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefineddepthevol/PredefinedDepthEvolAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefineddepthevol/PredefinedDepthEvolAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefineddepthevol/PredefinedDepthEvolAccess.java Tue May 15 18:04:36 2018 +0200 @@ -10,7 +10,6 @@ package org.dive4elements.river.artifacts.sinfo.predefineddepthevol; -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RangeAccess; @@ -27,22 +26,14 @@ private String name; - /***** CONSTRUCTORS *****/ public PredefinedDepthEvolAccess(final D4EArtifact artifact) { super(artifact); } - /***** METHDOS *****/ - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - public Integer getId() { if (this.id == null) { this.id = getInteger("depthevol_id"); diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedflowdepth/PredefinedFlowDepthColumnAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedflowdepth/PredefinedFlowDepthColumnAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedflowdepth/PredefinedFlowDepthColumnAccess.java Tue May 15 18:04:36 2018 +0200 @@ -10,7 +10,6 @@ package org.dive4elements.river.artifacts.sinfo.predefinedflowdepth; -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RangeAccess; @@ -29,22 +28,14 @@ private String name; - /***** CONSTRUCTORS *****/ public PredefinedFlowDepthColumnAccess(final D4EArtifact artifact) { super(artifact); } - /***** METHDOS *****/ - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - public Integer getSeriesId() { if (this.seriesId == null) { this.seriesId = getInteger("flowdepth_id"); diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhColumnAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhColumnAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhColumnAccess.java Tue May 15 18:04:36 2018 +0200 @@ -10,7 +10,6 @@ package org.dive4elements.river.artifacts.sinfo.predefinedtkh; -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RangeAccess; @@ -29,22 +28,14 @@ private String name; - /***** CONSTRUCTORS *****/ public PredefinedTkhColumnAccess(final D4EArtifact artifact) { super(artifact); } - /***** METHDOS *****/ - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - public Integer getTkhId() { if (this.tkhId == null) { this.tkhId = getInteger("tkh_id"); diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhAccess.java Tue May 15 18:04:36 2018 +0200 @@ -10,7 +10,6 @@ package org.dive4elements.river.artifacts.sinfo.tkhstate; -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; @@ -32,9 +31,4 @@ assert (calculationMode == SinfoCalcMode.sinfo_calc_transport_bodies_heights); } - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } } \ No newline at end of file diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/states/DistanceOnlyPartSelect.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DistanceOnlyPartSelect.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DistanceOnlyPartSelect.java Tue May 15 18:04:36 2018 +0200 @@ -18,4 +18,5 @@ protected String getUIProvider() { return "distance_only_part_panel"; } + } diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java Tue May 15 18:04:36 2018 +0200 @@ -10,11 +10,8 @@ package org.dive4elements.river.artifacts.uinfo.inundationduration; -import java.util.ArrayList; - -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.access.RangeAccess; -import org.dive4elements.river.artifacts.common.AccessHelper; +import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; @@ -31,7 +28,8 @@ // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; - private final AccessHelper helper; + + private final EpochYearAccessHelper helper; // Fields from state: // @@ -47,19 +45,12 @@ public InundationDurationAccess(final UINFOArtifact uinfo) { super(uinfo); - /* assert calculation mode */ final UinfoCalcMode calculationMode = uinfo.getCalculationMode(); - this.helper = new AccessHelper(uinfo); + this.helper = new EpochYearAccessHelper(uinfo); assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration); } - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - public Double getSedimentHeight() { if (super.getBoolean("use_scenario")) { return super.getDouble("sedimentheight"); // TODO: INPUT Valdiation (nicht hier, sondern im Panel. Erinnerung) @@ -83,20 +74,9 @@ return null; } - public ArrayList getVegZones() { - // TODO: MIT VegetationzonesAccess zusammenlegen - final ArrayList results = new ArrayList<>(); - final String zonesRaw = super.getString("vegzones"); - if (zonesRaw.contains(TABLE_ROW_SEPARATOR)) { - final String[] rows = zonesRaw.split(TABLE_ROW_SEPARATOR); - for (final String row : rows) { - if (row.contains(TABLE_CELL_SEPARATOR)) { - final String[] result = row.split(TABLE_CELL_SEPARATOR); - results.add(result); - } - } - } - return results; + public String getVegZones() { + // MIT VegetationzonesAccess zusammenlegen (eine Zeile sparen...) + return super.getString("vegzones"); } } \ No newline at end of file diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationCalculation.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationCalculation.java Tue May 15 18:04:36 2018 +0200 @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.artifacts.CallContext; @@ -23,6 +24,7 @@ import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; +import org.dive4elements.river.artifacts.uinfo.vegetationzones.VegetationZoneAccessHelper; import org.dive4elements.river.model.River; /** @@ -44,15 +46,17 @@ final String user = CalculationUtils.findArtifactUser(this.context, uinfo); final RiverAccess access = new RiverAccess(uinfo); - final River river = access.getRiver(); - final DoubleRange calcRange = null; - final RiverInfo riverInfo = new RiverInfo(river); final InundationDurationAccess indurax = new InundationDurationAccess(uinfo); + final River river = indurax.getRiver(); + final RiverInfo riverInfo = new RiverInfo(river); + final DoubleRange calcRange = indurax.getRange(); final int[] totalEpoch = indurax.getTotalEpoch(); final Integer year = indurax.getYear(); // null bei year -> Integer.. evtl ungünstig.. evtl. anders lösen final DoubleRange range = indurax.getRange(); final Double sedimentHeight = indurax.getSedimentHeight(); + final String zonesRaw = indurax.getVegZones(); + final List zones = VegetationZoneAccessHelper.parse(zonesRaw); final InundationDurationCalculationResults results = new InundationDurationCalculationResults(calcModeLabel, user, riverInfo, calcRange); diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java Tue May 15 18:04:36 2018 +0200 @@ -10,7 +10,6 @@ package org.dive4elements.river.artifacts.uinfo.salix; -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; @@ -41,12 +40,6 @@ assert (calculationMode == UinfoCalcMode.uinfo_salix_line); } - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - public boolean getUseScenario() { return super.getBoolean("use_scenario"); } diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java Tue May 15 18:04:36 2018 +0200 @@ -14,7 +14,6 @@ import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.common.GeneralResultType; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.model.Calculation; @@ -44,12 +43,11 @@ final String calcModeLabel = Resources.getMsg(this.context.getMeta(), uinfo.getCalculationMode().name()); final String user = CalculationUtils.findArtifactUser(this.context, uinfo); - final RiverAccess access = new RiverAccess(uinfo); - final River river = access.getRiver(); - final DoubleRange calcRange = null; + final SalixLineAccess accessSalix = new SalixLineAccess(uinfo); + + final River river = accessSalix.getRiver(); final RiverInfo riverInfo = new RiverInfo(river); - final SalixLineAccess accessSalix = new SalixLineAccess(uinfo); final DoubleRange range = accessSalix.getRange(); final boolean useScenario = accessSalix.getUseScenario(); final String selectedScenario = accessSalix.getScenario(); @@ -61,7 +59,9 @@ // ld_from_part; ld_to_part // scenario_selection (mögliche Werte:"scenarioType.option1" "scenarioType.option2" "scenarioType.option3" - final SalixLineCalculationResults results = new SalixLineCalculationResults(calcModeLabel, user, riverInfo, calcRange); + // FIXME: real calculation + + final SalixLineCalculationResults results = new SalixLineCalculationResults(calcModeLabel, user, riverInfo, range); final Collection rows = new ArrayList<>(); diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java Tue May 15 18:04:36 2018 +0200 @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.artifacts.CallContext; @@ -43,22 +44,23 @@ final String calcModeLabel = Resources.getMsg(this.context.getMeta(), uinfo.getCalculationMode().name()); final String user = CalculationUtils.findArtifactUser(this.context, uinfo); + // FIXME: remove, check other states as well final RiverAccess access = new RiverAccess(uinfo); final River river = access.getRiver(); final DoubleRange calcRange = null; final RiverInfo riverInfo = new RiverInfo(river); final VegetationzonesAccess vAccess = new VegetationzonesAccess(uinfo); - final ArrayList zones = vAccess.getVegZones(); - + final String zonesRaw = vAccess.getVegZones(); + final List helpers = VegetationZoneAccessHelper.parse(zonesRaw); final VegetationZonesCalculationResults results = new VegetationZonesCalculationResults(calcModeLabel, user, riverInfo, calcRange); final Collection rows = new ArrayList<>(); - for (final String[] zone : zones) { + for (final VegetationZoneAccessHelper zone : helpers) { final ResultRow row2 = ResultRow.create().// - putValue(UInfoResultType.vegname, zone[0]).// - putValue(UInfoResultType.vegdauervon, zone[1]).// - putValue(UInfoResultType.vegdauerbis, zone[2]); + putValue(UInfoResultType.vegname, zone.getZoneName()).// + putValue(UInfoResultType.vegdauervon, zone.getMin_day_overflow()).// + putValue(UInfoResultType.vegdauerbis, zone.getMax_day_overflow()); rows.add(row2); } diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesState.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesState.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesState.java Tue May 15 18:04:36 2018 +0200 @@ -49,7 +49,6 @@ facets.add(new EmptyFacet()); return null; } - return compute((UINFOArtifact) artifact, context, hash, facets, old); } diff -r 1ffd38826175 -r 611a523fc42f artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationzonesAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationzonesAccess.java Tue May 15 12:00:26 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationzonesAccess.java Tue May 15 18:04:36 2018 +0200 @@ -10,11 +10,8 @@ package org.dive4elements.river.artifacts.uinfo.vegetationzones; -import java.util.ArrayList; - -import org.apache.commons.lang.math.DoubleRange; import org.dive4elements.river.artifacts.access.RangeAccess; -import org.dive4elements.river.artifacts.common.AccessHelper; +import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; @@ -28,10 +25,7 @@ */ final class VegetationzonesAccess extends RangeAccess { - // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR - public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; - public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; - private final AccessHelper helper; + private final EpochYearAccessHelper helper; // Fields from state: // calculation_mode (String) @@ -43,29 +37,12 @@ /* assert calculation mode */ final UinfoCalcMode calculationMode = uinfo.getCalculationMode(); - this.helper = new AccessHelper(uinfo); + this.helper = new EpochYearAccessHelper(uinfo); assert (calculationMode == UinfoCalcMode.uinfo_vegetation_zones); } - public DoubleRange getRange() { - final double from = getFrom(); - final double to = getTo(); - return new DoubleRange(from, to); - } - - public ArrayList getVegZones() { - final ArrayList results = new ArrayList<>(); - final String zonesRaw = super.getString("vegzones"); - if (zonesRaw.contains(TABLE_ROW_SEPARATOR)) { - final String[] rows = zonesRaw.split(TABLE_ROW_SEPARATOR); - for (final String row : rows) { - if (row.contains(TABLE_CELL_SEPARATOR)) { - final String[] result = row.split(TABLE_CELL_SEPARATOR); - results.add(result); - } - } - } - return results; + public String getVegZones() { + return super.getString("vegzones"); } } \ No newline at end of file diff -r 1ffd38826175 -r 611a523fc42f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java Tue May 15 18:04:36 2018 +0200 @@ -0,0 +1,278 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ +package org.dive4elements.river.client.client.ui.uinfo; + +import java.util.ArrayList; +import java.util.List; + +import org.dive4elements.river.client.client.ui.AbstractUIProvider; +import org.dive4elements.river.client.client.ui.PanelHelper; +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 com.smartgwt.client.data.Record; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +/** + * @author Domenico Nardi Tironi + * + */ +public abstract class AbstractVegZonesTablePanel extends AbstractUIProvider { + private static final long serialVersionUID = 1L; + public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; + public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; + + protected static final String datakey = "vegzones"; + + protected final ListGrid elements = new ListGrid(); + protected TextItem vegzone; + protected TextItem start; + protected TextItem end; + private ListGrid table; + + protected ListGridField vegzoneField;// = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label()); + protected ListGridField fromField;// = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from()); + protected ListGridField toField;// = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to()); + + final protected VLayout root = new VLayout(); + final protected HLayout input = new HLayout(); + final protected VLayout tableLayout = new VLayout(); + + protected final void createTable(final DataList data, final int width) { + data.add(VegetationzonesTablePanel.getDummyData()); // TODO: GET REAL DATA! + + final Label title = new Label(data.get(0).getDescription()); + title.setHeight("35px"); // orig:25 + + this.elements.setWidth(width); // 185 + this.elements.setHeight(300); // + this.elements.setShowHeaderContextMenu(false); + this.elements.setCanReorderFields(false); + this.elements.setCanSort(false); + this.elements.setCanEdit(false); + this.vegzoneField = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label()); + this.fromField = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from()); + this.toField = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to()); + this.vegzoneField.setWidth(245); + this.fromField.setWidth(80); + this.toField.setWidth(80); + this.fromField.setAlign(Alignment.RIGHT); + this.toField.setAlign(Alignment.RIGHT); + + addDataInit(data); + + this.root.addMember(title); + this.tableLayout.addMember(this.elements); + this.root.addMember(this.input); + this.root.addMember(this.tableLayout); + this.root.addMember(PanelHelper.getSpacer(10)); + + } + + protected final Canvas createHelper() { + this.table = new ListGrid(); + this.table.setShowHeaderContextMenu(false); + this.table.setWidth100(); + this.table.setShowRecordComponents(true); + this.table.setShowRecordComponentsByCell(true); + this.table.setHeight100(); + this.table.setEmptyMessage(this.MSG.empty_table()); + this.table.setCanReorderFields(false); + + /* Input support pins */ + // final String baseUrl = GWT.getHostPageBaseURL(); + // final ListGridField pinFrom = new ListGridField("fromIcon", this.MSG.uinfo_vegetation_zones_from()); + // pinFrom.setWidth(300); + // pinFrom.setType(ListGridFieldType.ICON); + // pinFrom.setCellIcon(baseUrl + this.MSG.markerGreen()); + // + // final ListGridField pinTo = new ListGridField("toIcon", this.MSG.uinfo_vegetation_zones_to()); + // pinTo.setType(ListGridFieldType.ICON); + // pinTo.setWidth(300); + // pinTo.setCellIcon(baseUrl + this.MSG.markerRed()); + // + // pinFrom.addRecordClickHandler(new RecordClickHandler() { + // @Override + // public void onRecordClick(final RecordClickEvent e) { + // final Record r = e.getRecord(); + // VegetationzonesTableEditPanel.this.vegzone.setValue(r.getAttribute("date")); // date?? + // } + // }); + // + // pinFrom.addRecordClickHandler(new RecordClickHandler() { + // @Override + // public void onRecordClick(final RecordClickEvent e) { + // final Record r = e.getRecord(); + // VegetationzonesTableEditPanel.this.start.setValue(r.getAttribute("date")); + // } + // }); + // + // pinTo.addRecordClickHandler(new RecordClickHandler() { + // @Override + // public void onRecordClick(final RecordClickEvent e) { + // final Record r = e.getRecord(); + // VegetationzonesTableEditPanel.this.end.setValue(r.getAttribute("date")); + // } + // }); + // + // final ListGridField date = new ListGridField("date", this.MSG.year()); + // date.setType(ListGridFieldType.TEXT); + // date.setWidth(100); + // + // final ListGridField descr = new ListGridField("description", this.MSG.description()); + // descr.setType(ListGridFieldType.TEXT); + // descr.setWidth("*"); + // + // this.table.setFields(pinFrom, pinTo, date, descr); + return this.table; + } + + public abstract Canvas createWidget(final DataList data); + + private final void addDataInit(final DataList data) { + for (final Data dataItemContainer : data.getAll()) { + if (dataItemContainer.getItems() != null) { + for (final DataItem dataItem : dataItemContainer.getItems()) { + if (dataItem.getStringValue() != null && dataItem.getStringValue().contains(TABLE_ROW_SEPARATOR)) { + + final String[] rows = dataItem.getStringValue().split(TABLE_ROW_SEPARATOR); + for (final String row : rows) { + this.elements.addData(createEntry(row)); + } + } + } + } + } + } + + @Override + public final Canvas create(final DataList data) { + final VLayout layout = new VLayout(); + final Canvas helper = createHelper(); + this.helperContainer.addMember(helper); + + final Canvas submit = getNextButton(); + final Canvas widget = createWidget(data); + + layout.addMember(widget); + layout.addMember(submit); // TODO: SUBMIT + + // fetchSedimentLoadData(); //TODO: feed from database... + + return layout; + } + + @Override + public Canvas createOld(final DataList dataList) { + final HLayout layout = new HLayout(); + layout.setWidth("400px"); + final VLayout vLayout = new VLayout(); + vLayout.setWidth(130); + final Label label = new Label(dataList.getLabel()); + label.setWidth("200px"); + label.setHeight(25); + + final List items = dataList.getAll(); + final Data str = getData(items, datakey); + final DataItem[] strItems = str.getItems(); + + final String[] entries = strItems[0].getLabel().split(VegetationzonesTablePanel.TABLE_ROW_SEPARATOR); + for (final String entry : entries) { + final String[] vals = entry.split(VegetationzonesTablePanel.TABLE_CELL_SEPARATOR); + final Label dateLabel = new Label(vals[0] + " (" + vals[1] + "-" + vals[2] + ")"); + dateLabel.setHeight(20); + vLayout.addMember(dateLabel); + } + final Canvas back = getBackButton(dataList.getState()); + layout.addMember(label); + layout.addMember(vLayout); + layout.addMember(back); + + return layout; + } + + protected static final Data[] getDummyData() { + final List data = new ArrayList(); + + // TODO: move to messages + final String d = "Zonaler Wald" + TABLE_CELL_SEPARATOR + "0" + TABLE_CELL_SEPARATOR + "5" + TABLE_ROW_SEPARATOR// + + "Hartholzaue, trocken" + TABLE_CELL_SEPARATOR + "5" + TABLE_CELL_SEPARATOR + "40" + TABLE_ROW_SEPARATOR// + + "Hartholzaue, feucht" + TABLE_CELL_SEPARATOR + "40" + TABLE_CELL_SEPARATOR + "80" + TABLE_ROW_SEPARATOR// + + "Silberweidenwald" + TABLE_CELL_SEPARATOR + "80" + TABLE_CELL_SEPARATOR + "140" + TABLE_ROW_SEPARATOR// + + "Weidengebüsch" + TABLE_CELL_SEPARATOR + "140" + TABLE_CELL_SEPARATOR + "200" + TABLE_ROW_SEPARATOR// + + "Uferröhricht" + TABLE_CELL_SEPARATOR + "200" + TABLE_CELL_SEPARATOR + "260" + TABLE_ROW_SEPARATOR// + + "Uferpioniere" + TABLE_CELL_SEPARATOR + "260" + TABLE_CELL_SEPARATOR + "320" + TABLE_ROW_SEPARATOR// + + "Vegetationslos" + TABLE_CELL_SEPARATOR + "320" + TABLE_CELL_SEPARATOR + "365" + TABLE_ROW_SEPARATOR// + + "Wasserfläche" + TABLE_CELL_SEPARATOR + "365" + TABLE_CELL_SEPARATOR + "365" + TABLE_ROW_SEPARATOR;// + + final DataItem item = new DefaultDataItem(datakey, "entryDescription", d); // DATA-key + data.add(new DefaultData(datakey, null, null, new DataItem[] { item })); + return data.toArray(new Data[data.size()]); + } + + @Override + protected final Data[] getData() { + final List data = new ArrayList(); + + final ListGridRecord[] lgr = this.elements.getRecords(); + if (lgr.length == 0) { + return getDummyData();// new Data[0]; // return getDummyData(); + } + String d = ""; + for (final ListGridRecord element : lgr) { + final Record r = element; + d += r.getAttribute("vegzone") + VegetationzonesTablePanel.TABLE_CELL_SEPARATOR + r.getAttribute("from") + + VegetationzonesTablePanel.TABLE_CELL_SEPARATOR + r.getAttribute("to"); + d += VegetationzonesTablePanel.TABLE_ROW_SEPARATOR; + } + + final DataItem item = new DefaultDataItem(datakey, null, d); // DATA-key + data.add(new DefaultData(datakey, null, null, new DataItem[] { item })); + return data.toArray(new Data[data.size()]); + } + + public final ListGridRecord createEntry(final String row) { + + if (row.contains(TABLE_CELL_SEPARATOR)) { + + final String[] vals = row.split(TABLE_CELL_SEPARATOR); + if (vals.length == 3) { + final String vegzone = vals[0]; + final String from = vals[1]; + final String to = vals[2]; + + if (vegzone == null || from == null || to == null) { + return null; + } + + final ListGridRecord r = new ListGridRecord(); + r.setAttribute("vegzone", vegzone); + r.setAttribute("from", from); + r.setAttribute("to", to); + return r; + + } + + } + return null; + } + +} diff -r 1ffd38826175 -r 611a523fc42f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SuperVegZonesTablePanel.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SuperVegZonesTablePanel.java Tue May 15 12:00:26 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,244 +0,0 @@ -/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde - * Software engineering by - * Björnsen Beratende Ingenieure GmbH - * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ -package org.dive4elements.river.client.client.ui.uinfo; - -import java.util.ArrayList; -import java.util.List; - -import org.dive4elements.river.client.client.ui.AbstractUIProvider; -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 com.smartgwt.client.data.Record; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.Label; -import com.smartgwt.client.widgets.form.fields.TextItem; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.widgets.layout.HLayout; -import com.smartgwt.client.widgets.layout.VLayout; - -/** - * @author Domenico Nardi Tironi - * - */ -public abstract class SuperVegZonesTablePanel extends AbstractUIProvider { - private static final long serialVersionUID = 1L; - public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; - public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; - - protected static final String datakey = "vegzones"; - - protected final ListGrid elements = new ListGrid(); - protected TextItem vegzone; - protected TextItem start; - protected TextItem end; - private ListGrid table; - - final protected VLayout root = new VLayout(); - final protected HLayout input = new HLayout(); - final protected VLayout tableLayout = new VLayout(); - - public SuperVegZonesTablePanel() { - - } - - protected final Canvas createHelper() { - this.table = new ListGrid(); - this.table.setShowHeaderContextMenu(false); - this.table.setWidth100(); - this.table.setShowRecordComponents(true); - this.table.setShowRecordComponentsByCell(true); - this.table.setHeight100(); - this.table.setEmptyMessage(this.MSG.empty_table()); - this.table.setCanReorderFields(false); - - /* Input support pins */ - // final String baseUrl = GWT.getHostPageBaseURL(); - // final ListGridField pinFrom = new ListGridField("fromIcon", this.MSG.uinfo_vegetation_zones_from()); - // pinFrom.setWidth(300); - // pinFrom.setType(ListGridFieldType.ICON); - // pinFrom.setCellIcon(baseUrl + this.MSG.markerGreen()); - // - // final ListGridField pinTo = new ListGridField("toIcon", this.MSG.uinfo_vegetation_zones_to()); - // pinTo.setType(ListGridFieldType.ICON); - // pinTo.setWidth(300); - // pinTo.setCellIcon(baseUrl + this.MSG.markerRed()); - // - // pinFrom.addRecordClickHandler(new RecordClickHandler() { - // @Override - // public void onRecordClick(final RecordClickEvent e) { - // final Record r = e.getRecord(); - // VegetationzonesTableEditPanel.this.vegzone.setValue(r.getAttribute("date")); // date?? - // } - // }); - // - // pinFrom.addRecordClickHandler(new RecordClickHandler() { - // @Override - // public void onRecordClick(final RecordClickEvent e) { - // final Record r = e.getRecord(); - // VegetationzonesTableEditPanel.this.start.setValue(r.getAttribute("date")); - // } - // }); - // - // pinTo.addRecordClickHandler(new RecordClickHandler() { - // @Override - // public void onRecordClick(final RecordClickEvent e) { - // final Record r = e.getRecord(); - // VegetationzonesTableEditPanel.this.end.setValue(r.getAttribute("date")); - // } - // }); - // - // final ListGridField date = new ListGridField("date", this.MSG.year()); - // date.setType(ListGridFieldType.TEXT); - // date.setWidth(100); - // - // final ListGridField descr = new ListGridField("description", this.MSG.description()); - // descr.setType(ListGridFieldType.TEXT); - // descr.setWidth("*"); - // - // this.table.setFields(pinFrom, pinTo, date, descr); - return this.table; - } - - public abstract Canvas createWidget(final DataList data); - - protected final void addDataInit(final DataList data) { - for (final Data dataItemContainer : data.getAll()) { - if (dataItemContainer.getItems() != null) { - for (final DataItem dataItem : dataItemContainer.getItems()) { - if (dataItem.getStringValue() != null && dataItem.getStringValue().contains(TABLE_ROW_SEPARATOR)) { - - final String[] rows = dataItem.getStringValue().split(TABLE_ROW_SEPARATOR); - for (final String row : rows) { - this.elements.addData(createEntry(row)); - } - } - } - } - } - } - - @Override - public final Canvas create(final DataList data) { - final VLayout layout = new VLayout(); - final Canvas helper = createHelper(); - this.helperContainer.addMember(helper); - - final Canvas submit = getNextButton(); - final Canvas widget = createWidget(data); - - layout.addMember(widget); - layout.addMember(submit); // TODO: SUBMIT - - // fetchSedimentLoadData(); //TODO: feed from database... - - return layout; - } - - @Override - public Canvas createOld(final DataList dataList) { - final HLayout layout = new HLayout(); - layout.setWidth("400px"); - final VLayout vLayout = new VLayout(); - vLayout.setWidth(130); - final Label label = new Label(dataList.getLabel()); - label.setWidth("200px"); - label.setHeight(25); - - final List items = dataList.getAll(); - final Data str = getData(items, datakey); - final DataItem[] strItems = str.getItems(); - - final String[] entries = strItems[0].getLabel().split(VegetationzonesTablePanel.TABLE_ROW_SEPARATOR); - for (final String entry : entries) { - final String[] vals = entry.split(VegetationzonesTablePanel.TABLE_CELL_SEPARATOR); - final Label dateLabel = new Label(vals[0] + " (" + vals[1] + "-" + vals[2] + ")"); - dateLabel.setHeight(20); - vLayout.addMember(dateLabel); - } - final Canvas back = getBackButton(dataList.getState()); - layout.addMember(label); - layout.addMember(vLayout); - layout.addMember(back); - - return layout; - } - - protected static final Data[] getDummyData() { - final List data = new ArrayList(); - String d = ""; - // TODO: move to messages - d = d + "Zonaler Wald" + TABLE_CELL_SEPARATOR + "0" + TABLE_CELL_SEPARATOR + "5" + TABLE_ROW_SEPARATOR; - d = d + "Hartholzaue, trocken" + TABLE_CELL_SEPARATOR + "5" + TABLE_CELL_SEPARATOR + "40" + TABLE_ROW_SEPARATOR; - d = d + "Hartholzaue, feucht" + TABLE_CELL_SEPARATOR + "40" + TABLE_CELL_SEPARATOR + "80" + TABLE_ROW_SEPARATOR; - d = d + "Silberweidenwald" + TABLE_CELL_SEPARATOR + "80" + TABLE_CELL_SEPARATOR + "140" + TABLE_ROW_SEPARATOR; - d = d + "Weidengebüsch" + TABLE_CELL_SEPARATOR + "140" + TABLE_CELL_SEPARATOR + "200" + TABLE_ROW_SEPARATOR; - d = d + "Uferröhricht" + TABLE_CELL_SEPARATOR + "200" + TABLE_CELL_SEPARATOR + "260" + TABLE_ROW_SEPARATOR; - d = d + "Uferpioniere" + TABLE_CELL_SEPARATOR + "260" + TABLE_CELL_SEPARATOR + "320" + TABLE_ROW_SEPARATOR; - d = d + "Vegetationslos" + TABLE_CELL_SEPARATOR + "320" + TABLE_CELL_SEPARATOR + "365" + TABLE_ROW_SEPARATOR; - d = d + "Wasserfläche" + TABLE_CELL_SEPARATOR + "365" + TABLE_CELL_SEPARATOR + "365" + TABLE_ROW_SEPARATOR; - - final DataItem item = new DefaultDataItem(datakey, "entryDescription", d); // DATA-key - data.add(new DefaultData(datakey, null, null, new DataItem[] { item })); - return data.toArray(new Data[data.size()]); - } - - @Override - protected final Data[] getData() { - final List data = new ArrayList(); - - final ListGridRecord[] lgr = this.elements.getRecords(); - if (lgr.length == 0) { - return getDummyData();// new Data[0]; // return getDummyData(); - } - String d = ""; - for (final ListGridRecord element : lgr) { - final Record r = element; - d += r.getAttribute("vegzone") + VegetationzonesTablePanel.TABLE_CELL_SEPARATOR + r.getAttribute("from") - + VegetationzonesTablePanel.TABLE_CELL_SEPARATOR + r.getAttribute("to"); - d += VegetationzonesTablePanel.TABLE_ROW_SEPARATOR; - } - - final DataItem item = new DefaultDataItem(datakey, null, d); // DATA-key - data.add(new DefaultData(datakey, null, null, new DataItem[] { item })); - return data.toArray(new Data[data.size()]); - } - - public final ListGridRecord createEntry(final String row) { - - if (row.contains(TABLE_CELL_SEPARATOR)) { - - final String[] vals = row.split(TABLE_CELL_SEPARATOR); - if (vals.length == 3) { - final String vegzone = vals[0]; - final String from = vals[1]; - final String to = vals[2]; - - if (vegzone == null || from == null || to == null) { - return null; - } - - final ListGridRecord r = new ListGridRecord(); - r.setAttribute("vegzone", vegzone); - r.setAttribute("from", from); - r.setAttribute("to", to); - return r; - - } - - } - return null; - } - -} diff -r 1ffd38826175 -r 611a523fc42f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java Tue May 15 12:00:26 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java Tue May 15 18:04:36 2018 +0200 @@ -15,7 +15,6 @@ import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; @@ -27,26 +26,20 @@ import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.HLayout; -public class VegetationzonesTableEditPanel extends SuperVegZonesTablePanel { +public class VegetationzonesTableEditPanel extends AbstractVegZonesTablePanel { private static final long serialVersionUID = 1L; @Override public Canvas createWidget(final DataList data) { - + super.createTable(data, 450); + this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), 200, new IsStringValidator()); + this.start = PanelHelper.createItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(), 40, new IsIntegerValidator()); + this.end = PanelHelper.createItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), 40, new IsIntegerValidator()); final HLayout fields = new HLayout(); final HLayout fields2 = new HLayout(); final Button add = new Button(this.MSG.add_date()); // TODO: make key more generic or change to more specific - data.add(VegetationzonesTablePanel.getDummyData()); - - final Label title = new Label(data.get(0).getDescription()); - title.setHeight("35px"); // orig:25 - - this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), 200, new IsStringValidator()); - this.start = PanelHelper.createItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(), 40, new IsIntegerValidator()); - this.end = PanelHelper.createItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), 40, new IsIntegerValidator()); - final DynamicForm form1 = new DynamicForm(); final DynamicForm form2 = new DynamicForm(); form2.setNumCols(5); @@ -81,23 +74,6 @@ } }); - final Label sel = new Label(this.MSG.select()); - sel.setHeight(25); - this.elements.setWidth(450); // 185 - this.elements.setHeight(300); // 120 - this.elements.setShowHeaderContextMenu(false); - this.elements.setCanReorderFields(false); - this.elements.setCanSort(false); - this.elements.setCanEdit(false); - final ListGridField vegzone = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label()); - final ListGridField from = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from()); - final ListGridField to = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to()); - vegzone.setWidth(285); - from.setWidth(70); - to.setWidth(70); - - addDataInit(data); - final ListGridField removeField = new ListGridField("_removeRecord", "Remove Record") { { setType(ListGridFieldType.ICON); @@ -122,16 +98,11 @@ } }); - this.elements.setFields(vegzone, from, to, removeField); + this.elements.setFields(super.vegzoneField, super.fromField, super.toField, removeField); fields.addMember(form1); fields2.addMember(form2); - this.tableLayout.addMember(this.elements); - this.root.addMember(title); - this.root.addMember(this.input); - this.root.addMember(this.tableLayout); - this.root.addMember(PanelHelper.getSpacer(10)); this.root.addMember(fields); this.root.addMember(fields2); this.root.addMember(PanelHelper.getSpacer(10)); diff -r 1ffd38826175 -r 611a523fc42f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java Tue May 15 12:00:26 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java Tue May 15 18:04:36 2018 +0200 @@ -8,57 +8,19 @@ package org.dive4elements.river.client.client.ui.uinfo; -import org.dive4elements.river.client.client.ui.PanelHelper; import org.dive4elements.river.client.shared.model.DataList; import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.Label; -import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; -import com.smartgwt.client.widgets.form.validator.IsStringValidator; -import com.smartgwt.client.widgets.grid.ListGridField; -public class VegetationzonesTablePanel extends SuperVegZonesTablePanel { +public class VegetationzonesTablePanel extends AbstractVegZonesTablePanel { private static final long serialVersionUID = 1L; @Override public Canvas createWidget(final DataList data) { - data.add(VegetationzonesTablePanel.getDummyData()); // TODO: GET REAL DATA! - - final Label title = new Label(data.get(0).getDescription()); - title.setHeight("35px"); // orig:25 - - this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), 200, new IsStringValidator()); - this.start = PanelHelper.createItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(), 40, new IsIntegerValidator()); - this.end = PanelHelper.createItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), 40, new IsIntegerValidator()); - - final Label sel = new Label(this.MSG.select()); - sel.setHeight(25); - this.elements.setWidth(420); // 185 - this.elements.setHeight(300); // - this.elements.setShowHeaderContextMenu(false); - this.elements.setCanReorderFields(false); - this.elements.setCanSort(false); - this.elements.setCanEdit(false); - final ListGridField vegzone = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label()); - final ListGridField from = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from()); - final ListGridField to = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to()); - vegzone.setWidth(265); - from.setWidth(70); - to.setWidth(70); - - addDataInit(data); - - this.elements.setFields(vegzone, from, to); - - this.tableLayout.addMember(this.elements); - this.root.addMember(title); - this.root.addMember(this.input); - this.root.addMember(this.tableLayout); - this.root.addMember(PanelHelper.getSpacer(10)); - + createTable(data, 420); + this.elements.setFields(this.vegzoneField, this.fromField, this.toField); return this.root; } - } diff -r 1ffd38826175 -r 611a523fc42f gwt-client/src/main/java/org/dive4elements/river/client/shared/model/Artifact.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/Artifact.java Tue May 15 12:00:26 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/Artifact.java Tue May 15 18:04:36 2018 +0200 @@ -11,7 +11,6 @@ import java.io.Serializable; import java.util.List; - /** * This class represents an artifact for the client. It contains the necessary * information for the client and the communication with the artifact server. @@ -27,7 +26,6 @@ */ public String getUuid(); - /** * Returns the hash of the artifact. * @@ -35,7 +33,6 @@ */ public String getHash(); - /** * Returns the name of the artifact. * This happens to be the factory name, too. @@ -51,7 +48,6 @@ */ public ArtifactDescription getArtifactDescription(); - /** * Returns true, if the Artifact is in Background mode. * @@ -59,7 +55,6 @@ */ public boolean isInBackground(); - /** * Return a list of background messages. * @@ -67,11 +62,11 @@ */ public List getBackgroundMessages(); - /** * Sets a new ArtifactDescription. * - * @param artifactDescription The new artifact description. + * @param artifactDescription + * The new artifact description. */ public void setArtifactDescription(ArtifactDescription artifactDescription); }