Mercurial > dive4elements > river
changeset 9391:2da486c7c05f
salix historical sounding workflow changed
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/bundu.xml Thu Aug 09 15:22:31 2018 +0200 +++ b/artifacts/doc/conf/artifacts/bundu.xml Thu Aug 09 17:25:13 2018 +0200 @@ -491,7 +491,7 @@ <condition data="calculation_mode" value="bundu_bezugswst" operator="equal" /> </transition> - <state id="state.bundu.wst.soundings" description="state.bundu.wst.soundings" state="org.dive4elements.river.artifacts.states.SoundingsSelect" helpText="help.state.bundu.wst.soundings"> + <state id="state.bundu.wst.soundings" description="state.bundu.wst.soundings" state="org.dive4elements.river.artifacts.states.SoundingsSelectMultiple" helpText="help.state.bundu.wst.soundings"> <data name="soundings" type="multiattribute" /> </state>
--- a/artifacts/doc/conf/artifacts/minfo.xml Thu Aug 09 15:22:31 2018 +0200 +++ b/artifacts/doc/conf/artifacts/minfo.xml Thu Aug 09 17:25:13 2018 +0200 @@ -94,7 +94,7 @@ <data name="main_channel" type="intoptions"/> </state> - <state id="state.minfo.soundings" description="state.minfo.soundingsstate" state="org.dive4elements.river.artifacts.states.SoundingsSelect" helpText="help.state.minfo.soundings"> + <state id="state.minfo.soundings" description="state.minfo.soundingsstate" state="org.dive4elements.river.artifacts.states.SoundingsSelectMultiple" helpText="help.state.minfo.soundings"> <data name="soundings" type="multiattribute"/> </state>
--- a/artifacts/doc/conf/artifacts/uinfo.xml Thu Aug 09 15:22:31 2018 +0200 +++ b/artifacts/doc/conf/artifacts/uinfo.xml Thu Aug 09 17:25:13 2018 +0200 @@ -20,7 +20,7 @@ <data name="ld_to" type="Double" /> </state> - <state id="state.uinfo.salix.distance_only" description="state.uinfo.salix.distance_only" state="org.dive4elements.river.artifacts.states.DistanceOnlySelect" helpText="help.state.uinfo.salix.distance_only"> + <state id="state.uinfo.salix.distance_only" description="state.uinfo.salix.distance_only" state="org.dive4elements.river.artifacts.states.DistanceOnlySelect" helpText="help.state.uinfo.salix.distance_only"> <data name="ld_from" type="Double" /> <data name="ld_to" type="Double" /> </state> @@ -29,7 +29,7 @@ <data name="ld_to" type="Double" /> </state> - + <!-- Calculation Mode: Salix Linie --> @@ -85,47 +85,23 @@ <to state="state.uinfo.salix_line" /> <condition data="calculation_mode" value="uinfo_salix_line" operator="equal" /> </transition> - + <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> <from state="state.uinfo.salix.scenario_type" /> - <to state="state.uinfo.salix.year_epoch" /> + <to state="state.uinfo.salix.historical.soundings" /> <condition data="scenario_selection" value="scenarioType.option3" operator="equal" /> </transition> + + <state id="state.uinfo.salix.historical.soundings" description="state.uinfo.salix.historical.soundings" state="org.dive4elements.river.artifacts.states.SoundingsSelectSingle" helpText="help.state.uinfo.salix.historical.soundings"> + <data name="soundings" type="multiattribute" /> + </state> - <state id="state.uinfo.salix.year_epoch" description="state.uinfo.salix.year_epoch" state="org.dive4elements.river.artifacts.uinfo.salix.YearChoice" helpText="help.state.uinfo.salix.historical.year_choice"> - <data name="ye_select" type="String" /> - </state> <state id="state.uinfo.salix.supraregional" description="state.uinfo.salix.supraregional" state="org.dive4elements.river.artifacts.uinfo.salix.SupraRegionalTableState" helpText="help.state.uinfo.salix.supraregional"> <data name="supraregional_table" type="String" /> </state> <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> - <from state="state.uinfo.salix.year_epoch" /> - <to state="state.uinfo.load.year_with_soundings" /> - <condition data="ye_select" value="state.uinfo.year" operator="equal" /> - </transition> - - <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> - <from state="state.uinfo.salix.year_epoch" /> - <to state="state.uinfo.load.epoch" /> - <condition data="ye_select" value="state.uinfo.epoch" operator="equal" /> - </transition> - - <state id="state.uinfo.load.year_with_soundings" description="state.uinfo.load.year_with_soundings" state="org.dive4elements.river.artifacts.uinfo.salix.LoadSingleYearSelectState" helpText="help.state.uinfo.salix.historical.year"> - <data name="singleyear" type="String" /> - </state> - - <state id="state.uinfo.load.epoch" description="state.uinfo.load.epoch" state="org.dive4elements.river.artifacts.uinfo.salix.LoadSingleEpochSelectState" helpText="help.state.uinfo.salix.historical.epoch"> - <data name="singleepoch" type="Integer" /> - </state> - - <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> - <from state="state.uinfo.load.epoch" /> - <to state="state.uinfo.distance_only_part.historical" /> - <condition data="calculation_mode" value="uinfo_salix_line" operator="equal" /> - </transition> - <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> - <from state="state.uinfo.load.year_with_soundings" /> + <from state="state.uinfo.salix.historical.soundings" /> <to state="state.uinfo.distance_only_part.historical" /> <condition data="calculation_mode" value="uinfo_salix_line" operator="equal" /> </transition> @@ -133,7 +109,7 @@ <state id="state.uinfo.distance_only_part.historical" description="state.uinfo.distance_only_part.historical" state="org.dive4elements.river.artifacts.uinfo.salix.DistanceOnlyPartHistoricalSelect" helpText="help.state.uinfo.salix.historical.distance_only_part"> <data name="ld_from_part" type="Double" /> <data name="ld_to_part" type="Double" /> - <data name="bedheights_for_part" type="Double" /> + <data name="bedheights_for_part" type="Double" /> </state> <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> @@ -170,11 +146,11 @@ <outputmode name="uinfo_salix_line" description="output.uinfo_salix_line" mime-type="image/png" type="chart"> <facets> <facet name="uinfo_facet_salix_line.filtered" description="salix line, filtered by current zoom state" /> - <facet name="uinfo_facet_salix_line" description="salix line"/> + <facet name="uinfo_facet_salix_line" description="salix line" /> <facet name="uinfo_facet_salix_mnwmw.filtered" description="nmw-mw differences, filtered by current zoom state" /> - <facet name="uinfo_facet_salix_mnwmw" description="mnw-mw differences"/> + <facet name="uinfo_facet_salix_mnwmw" description="mnw-mw differences" /> <facet name="uinfo_facet_salix_scenario.filtered" description="scenario salix line, filtered by current zoom state" /> - <facet name="uinfo_facet_salix_scenario" description="scenario salix line"/> + <facet name="uinfo_facet_salix_scenario" description="scenario salix line" /> <facet name="uinfo_facet_salix_rank" description="salix ranks" /> </facets> </outputmode> @@ -367,7 +343,7 @@ <to state="state.uinfo.vegetation_zones.table" /> <condition data="calculation_mode" value="uinfo_vegetation_zones" operator="equal" /> </transition> - + <state id="state.uinfo.vegetation_zones.table" description="state.uinfo.vegetation_zones.table" state="org.dive4elements.river.artifacts.uinfo.vegetationzones.VegetationZonesTableEditState" helpText="help.state.uinfo.vegetation_zones">
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java Thu Aug 09 15:22:31 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java Thu Aug 09 17:25:13 2018 +0200 @@ -26,9 +26,9 @@ import org.dive4elements.river.utils.RiverUtils; import org.w3c.dom.Element; -public class SoundingsSelect extends DefaultState { +public abstract class SoundingsSelect extends DefaultState { - public static final String SOUNDINGS = "soundings"; + private static final String SOUNDINGS = "soundings"; public static final String PREFIX_SINGLE = "single-"; @@ -36,12 +36,8 @@ private static final Logger log = Logger.getLogger(SoundingsSelect.class); @Override - public String getUIProvider() { - return "parameter-matrix-sounding"; - } - - @Override - protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { + protected final void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, + final Element select) { try { creator.addAttr(select, "type", "multiattribute", true); @@ -73,7 +69,7 @@ } - protected KVP<String, String>[] getOptions(final Artifact artifact, final String parameterName, final CallContext context, final ElementCreator creator, + private KVP<String, String>[] getOptions(final Artifact artifact, final String parameterName, final CallContext context, final ElementCreator creator, final Element select) throws IllegalArgumentException { log.debug("Get options for parameter: '" + parameterName + "'"); @@ -94,7 +90,7 @@ return kvp.toArray(new KVP[kvp.size()]); } - protected void appendSingles(final River river, final double kmLo, final double kmHi, final ElementCreator creator, final Element select, + private void appendSingles(final River river, final double kmLo, final double kmHi, final ElementCreator creator, final Element select, final CallContext context) { final List<BedHeight> singles = BedHeight.getBedHeights(river, kmLo, kmHi); @@ -127,7 +123,7 @@ } @Override - protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value, + protected final Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value, final String type) { final Element data = creator.create("data"); creator.addAttr(data, "name", name, true); @@ -147,7 +143,7 @@ return data; } - protected String getLabelFor(final CallContext cc, final String parameterName, final String value) throws IllegalArgumentException { + private String getLabelFor(final CallContext cc, final String parameterName, final String value) throws IllegalArgumentException { if (!testParameterName(parameterName)) { throw new IllegalArgumentException("Invalid parameter for state: '" + parameterName + "'"); } @@ -158,7 +154,7 @@ return value; } - protected String getLabelForSingle(final CallContext cc, final String value) { + private String getLabelForSingle(final CallContext cc, final String value) { final String id = value.replace(PREFIX_SINGLE, ""); try { final BedHeight s = BedHeight.getBedHeightById(Integer.parseInt(id)); @@ -186,7 +182,7 @@ * @return true, if parameterName is one of <i>MAIN_CHANNEL</i> or * <i>TOTAL_CHANNEL</i>. Otherwise false. */ - protected boolean testParameterName(final String parameterName) { + private boolean testParameterName(final String parameterName) { if (parameterName == null || parameterName.length() == 0) { return false; } else if (parameterName.equals(SOUNDINGS)) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelectMultiple.java Thu Aug 09 17:25:13 2018 +0200 @@ -0,0 +1,24 @@ +/** 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.states; + +/** + * @author Domenico Nardi Tironi + * + */ +public class SoundingsSelectMultiple extends SoundingsSelect { + private static final long serialVersionUID = 1L; + + @Override + public String getUIProvider() { + return "parameter-matrix-sounding-multiple"; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelectSingle.java Thu Aug 09 17:25:13 2018 +0200 @@ -0,0 +1,24 @@ +/** 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.states; + +/** + * @author Domenico Nardi Tironi + * + */ +public class SoundingsSelectSingle extends SoundingsSelect { + private static final long serialVersionUID = 1L; + + @Override + public String getUIProvider() { + return "parameter-matrix-sounding-single"; + } + +}
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/DistanceOnlyPartHistoricalSelect.java Thu Aug 09 15:22:31 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/DistanceOnlyPartHistoricalSelect.java Thu Aug 09 17:25:13 2018 +0200 @@ -8,6 +8,7 @@ package org.dive4elements.river.artifacts.uinfo.salix; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -30,12 +31,12 @@ private static final long serialVersionUID = 1L; - private List<BedHeight> bhs = null; - private Integer epoch = null; - private Integer year = null; - private Double lowerKm = null; - private Double upperKm = null; - private River river = null; + private final List<BedHeight> bhs = null; + private final Integer epoch = null; + private final Integer year = null; + private final Double lowerKm = null; + private final Double upperKm = null; + private final River river = null; @Override protected String getUIProvider() { @@ -93,26 +94,9 @@ } private List<BedHeight> getBedheights(final Artifact artifact) { - - final SalixLineAccess access = new SalixLineAccess((UINFOArtifact) artifact); // improved lazy-loading - final Integer year = access.getYear(); - final Integer epoch = access.getEpoch(); - final River river = access.getRiver(); // comparable? workflow does not allow return and change anyway... - final Double lower = access.getLowerKm(); - final Double upper = access.getUpperKm(); - if (!(this.year == year && this.epoch == epoch && this.river == river && this.lowerKm == lower && this.upperKm == upper)) { - this.bhs = null; - } - if (this.bhs == null) { - final boolean isEpoch = epoch == null ? false : true; - this.bhs = BedHeight.getBedHeightYearEpoch(isEpoch, isEpoch ? epoch : year, river, lower, upper); - this.year = year; - this.epoch = epoch; - this.river = river; - this.lowerKm = lower; - this.upperKm = upper; - } - return this.bhs; + final List<BedHeight> list = new ArrayList<>(); + list.add(new SalixLineAccess((UINFOArtifact) artifact).getBedHeight()); + return list; } @@ -132,8 +116,6 @@ helper.addColumn(2, "description", "500", "uinfo.salix.sounding", "STRING", "LEFT", null); final TreeMap<String, String> bedHeightSorted = new TreeMap<>(); - final double min = Double.MAX_VALUE; - final double max = -Double.MAX_VALUE; final java.text.NumberFormat formatter = Formatter.getCalculationKm(context.getMeta()); for (final BedHeight bh : bedheights) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java Thu Aug 09 15:22:31 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java Thu Aug 09 17:25:13 2018 +0200 @@ -10,9 +10,11 @@ package org.dive4elements.river.artifacts.uinfo.salix; +import org.dive4elements.river.artifacts.access.BedHeightAccess; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; +import org.dive4elements.river.model.BedHeight; /** * Access to the flow depth calculation type specific SInfo artifact data. @@ -97,17 +99,21 @@ return super.getString("supraregional_table"); } - public Integer getYear() { - if (getString("ye_select").equals("state.uinfo.year")) { - return super.getInteger("singleyear"); + public BedHeight getBedHeight() { // TODO: make lazy? Aber achtung, falls der user zurückgeht und ne andere Peilung auswählt... + final BedHeightAccess access = new BedHeightAccess(this.artifact); + final int[] ids = access.getBedHeightIDs(); + if (ids != null && ids.length > 0) { + return BedHeight.getBedHeightById(ids[0]); // es nur eine bedheight ausgewählt werden; ist aber noch nicht implementiert... } return null; } - public Integer getEpoch() { - if (getString("ye_select").equals("state.uinfo.epoch")) { - return super.getInteger("singleepoch"); + public Integer getYearEpoch() { // TODO: make lazy? + final BedHeight bh = this.getBedHeight(); + if (bh != null) { + return bh.getYear(); } return null; } + } \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java Thu Aug 09 15:22:31 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java Thu Aug 09 17:25:13 2018 +0200 @@ -134,8 +134,7 @@ for (int i = 0; i <= deltaws.length - 1; i++) if (deltaws[i] != 0) labels.add(Integer.toString(deltaws[i]) + " cm"); - } - else if (access.getScenario() == ScenarioType.SUPRAREGIONAL) + } else if (access.getScenario() == ScenarioType.SUPRAREGIONAL) labels.add(Resources.getMsg(this.context.getMeta(), "uinfo_salix_scenario_supraregional")); else if (access.getScenario() == ScenarioType.HISTORICAL) labels.add(Resources.getMsg(this.context.getMeta(), "uinfo_salix_scenario_historical")); @@ -180,10 +179,7 @@ return deltas; } if (access.getScenario() == ScenarioType.HISTORICAL) { - if (access.getYear() != null) - return access.getYear().toString(); - else - return access.getEpoch().toString(); + return String.valueOf(access.getYearEpoch()); } if (access.getScenario() == ScenarioType.SUPRAREGIONAL) { String deltas = "";
--- a/artifacts/src/main/resources/messages.properties Thu Aug 09 15:22:31 2018 +0200 +++ b/artifacts/src/main/resources/messages.properties Thu Aug 09 17:25:13 2018 +0200 @@ -62,6 +62,7 @@ state.minfo.bed.error.no_data = No data found for selected range. state.minfo.bed.error.no_data_for_period = No data found for period: {0} - {1}. state.minfo.soundings = Choose Soundings +state.uinfo.salix.historical.soundings=Wahl des historischen Zustands anhand einer Peilung state.bundu.wst.soundings = Choose Soundings state.minfo.sediment.load.location = Range state.minfo.sediment.load.year_epoch = Year/Epoch @@ -1099,9 +1100,7 @@ help.state.uinfo.salix.supraregional = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.supraregional help.state.uinfo.salix.regional = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.regional help.state.uinfo.salix.historical = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical -help.state.uinfo.salix.historical.year_choice = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.year_choice -help.state.uinfo.salix.historical.year = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.year -help.state.uinfo.salix.historical.epoch = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.epoch +help.state.uinfo.salix.historical.soundings = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.soundings help.state.uinfo.salix.historical.distance_only_part = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.distance_only_part help.state.uinfo.inundation_duration = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.inundation_duration help.state.uinfo.inundation_duration.location = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.inundation_duration.location @@ -1123,7 +1122,6 @@ help.state.uinfo.distance_only = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.distance_only help.state.uinfo.inundation.year_totalepoch = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.inundation.year_totalepoch - uinfo_salix_line = Iota (Fluss/Aue-Konnektivit\u00e4t) uinfo_inundation_duration = \u00dcberflutungsdauern Aue uinfo_vegetation_zones = Vegetationszonen
--- a/artifacts/src/main/resources/messages_de.properties Thu Aug 09 15:22:31 2018 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Thu Aug 09 17:25:13 2018 +0200 @@ -62,6 +62,7 @@ state.minfo.bed.error.no_data = F\u00fcr die gew\u00e4hlte Strecke liegen keine Daten vor. state.minfo.bed.error.no_data_for_period = F\u00fcr den Zeitraum {0} - {1} liegen keine Daten vor. state.minfo.soundings = Wahl der Peilungen +state.uinfo.salix.historical.soundings=Wahl des historischen Zustands anhand einer Peilung state.bundu.wst.soundings = Wahl der Peilungen state.minfo.sediment.load.location = Berechnungsstrecke state.minfo.sediment.load.year_epoch = Jahr/Zeitraum @@ -1098,10 +1099,8 @@ help.state.uinfo.salix.scenario_type = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.scenario_type help.state.uinfo.salix.supraregional = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.supraregional help.state.uinfo.salix.regional = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.regional -help.state.uinfo.salix.historical = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical -help.state.uinfo.salix.historical.year_choice = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.year_choice -help.state.uinfo.salix.historical.year = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.year -help.state.uinfo.salix.historical.epoch = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.epoch +help.state.uinfo.salix.historical = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical +help.state.uinfo.salix.historical.soundings = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.soundings help.state.uinfo.salix.historical.distance_only_part = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.salix.historical.distance_only_part help.state.uinfo.inundation_duration = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.inundation_duration help.state.uinfo.inundation_duration.location = ${help.url}/OnlineHilfe/UINFO#help.state.uinfo.inundation_duration.location
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java Thu Aug 09 15:22:31 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java Thu Aug 09 17:25:13 2018 +0200 @@ -15,6 +15,7 @@ import java.util.Map; import org.dive4elements.river.client.client.FLYSConstants; +import org.dive4elements.river.client.client.ui.ParameterMatrix.Column.SelectionMode; import org.dive4elements.river.client.shared.model.DataItem; import org.dive4elements.river.client.shared.model.IntegerOptionsData; import org.dive4elements.river.client.shared.model.MultiAttributeData; @@ -33,6 +34,7 @@ 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.grid.events.ChangedHandler; /** * Some parameters take the form of on/off options that can also be seen @@ -44,12 +46,16 @@ */ public class ParameterMatrix { - protected ListGrid listGrid = null; + protected static ListGrid listGrid = null; public static class Column implements Serializable { private static final long serialVersionUID = -3493426383086860118L; + public static enum SelectionMode { + single, multi + } + protected String name; protected Map<String, String> values; @@ -84,9 +90,11 @@ /** Maps column names to list of rows' first fields. */ private final Map<String, List<String>> selected; private final String itemname; + private final SelectionMode mode; - public ParameterMatrix(final String itemnameColTitle) { + public ParameterMatrix(final String itemnameColTitle, final SelectionMode mode) { super(); + this.mode = mode; this.itemname = itemnameColTitle; this.columns = new HashMap<String, Column>(); this.columnNames = new ArrayList<String>(); @@ -215,6 +223,27 @@ final ListGridField field = new ListGridField(this.columnNames.get(i), this.MESSAGE.getString(this.columnNames.get(i))); field.setType(ListGridFieldType.BOOLEAN); field.setCanEdit(true); + if (this.mode == SelectionMode.single) { + field.addChangedHandler(new ChangedHandler() { + @Override + public void onChanged(final com.smartgwt.client.widgets.grid.events.ChangedEvent event) { + final int rowNumber = event.getRowNum(); + final Boolean value = (Boolean) event.getValue(); + final int colNr = event.getColNum(); + final String attr = ParameterMatrix.listGrid.getFieldName(colNr); + if (value) { + final ListGridRecord[] records = ParameterMatrix.listGrid.getRecords(); + for (int i = 0; i < records.length; i++) { + final ListGridRecord r = records[i]; + if (i != rowNumber) { + if (r.getAttributeAsBoolean(attr)) + r.setAttribute(attr, false); + } + } + } + } + }); + } fields.add(field); this.selected.put(this.columnNames.get(i), new ArrayList<String>()); }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java Thu Aug 09 15:22:31 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java Thu Aug 09 17:25:13 2018 +0200 @@ -14,6 +14,7 @@ import java.util.Set; import org.dive4elements.river.client.client.FLYSConstants; +import org.dive4elements.river.client.client.ui.ParameterMatrix.Column.SelectionMode; import org.dive4elements.river.client.shared.model.Data; import org.dive4elements.river.client.shared.model.DataItem; import org.dive4elements.river.client.shared.model.DataList; @@ -42,9 +43,11 @@ private ParameterMatrix matrix; private final String itemnameColTitle; + private final SelectionMode mode; - public ParameterMatrixPanel(final String itemNameColTitle) { + public ParameterMatrixPanel(final String itemNameColTitle, final SelectionMode mode) { this.itemnameColTitle = itemNameColTitle; + this.mode = mode; } @Override @@ -156,7 +159,7 @@ final VLayout v = new VLayout(); v.addMember(createTitle(dataList)); - this.matrix = new ParameterMatrix(this.itemnameColTitle); + this.matrix = new ParameterMatrix(this.itemnameColTitle, this.mode); for (final Data data : dataList.getAll()) { if (data instanceof IntegerOptionsData) {
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java Thu Aug 09 15:22:31 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java Thu Aug 09 17:25:13 2018 +0200 @@ -162,14 +162,21 @@ return new DoubleInputPanel(); } else if (uiProvider.equals("percent_input")) { return new DoubleInputPanel("percent"); - } else if (uiProvider.equals("parameter-matrix-sounding")) { - return new ParameterMatrixPanel(getMSG().getString("name_of_sounding")); - } else if (uiProvider.equals("parameter-matrix-flowvelocity")) { - return new ParameterMatrixPanel(" "); // TODO minfo.fließgeschwindigkeiten auflusszustand und gerinne title erste spalte ausdenken (nur - // wenn jemand + } else if (uiProvider.equals("parameter-matrix-sounding-multiple")) { + return new ParameterMatrixPanel(getMSG().getString("name_of_sounding"), ParameterMatrix.Column.SelectionMode.multi); + } else if (uiProvider.equals("parameter-matrix-sounding-single")) { + return new ParameterMatrixPanel(getMSG().getString("name_of_sounding"), ParameterMatrix.Column.SelectionMode.single); + } + + else if (uiProvider.equals("parameter-matrix-flowvelocity")) { + return new ParameterMatrixPanel(" ", ParameterMatrix.Column.SelectionMode.multi); // TODO minfo.fließgeschwindigkeiten auflusszustand und gerinne + // title + // erste spalte ausdenken (nur + // wenn jemand // danach fragt, ansonsten ist es old stuff) } else if (uiProvider.equals("parameter-matrix-char-diameter")) { - return new ParameterMatrixPanel(" "); // TODO minfo.sohlbeschaffenheit ? title erste spalte ausdenken (nur wenn jemand + return new ParameterMatrixPanel(" ", ParameterMatrix.Column.SelectionMode.multi); // TODO minfo.sohlbeschaffenheit ? title erste spalte ausdenken + // (nur wenn jemand // danach fragt, ansonsten ist es old stuff) }