Mercurial > dive4elements > river
changeset 4273:edcd276a7234
Merged.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 26 Oct 2012 15:11:35 +0200 |
parents | 270f3ac8a82e (current diff) 6c776f102e03 (diff) |
children | f46caf95ab7f |
files | |
diffstat | 20 files changed, 777 insertions(+), 374 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HistoricalDischargeWQFacet.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HistoricalDischargeWQFacet.java Fri Oct 26 15:11:35 2012 +0200 @@ -3,6 +3,7 @@ import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; +import de.intevation.flys.artifacts.states.DefaultState.ComputeType; /** @@ -15,8 +16,11 @@ public HistoricalDischargeWQFacet() { } - public HistoricalDischargeWQFacet(String name, String desc, double value) { - super(name, desc); + public HistoricalDischargeWQFacet(int index, String name, + String description, ComputeType type, String hash, String stateId, + double value) { + + super(index, name, description, type, hash, stateId); this.value = value; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MeasurementStationInfoService.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MeasurementStationInfoService.java Fri Oct 26 15:11:35 2012 +0200 @@ -24,7 +24,7 @@ public class MeasurementStationInfoService extends RiverInfoService { private static final Logger logger = Logger.getLogger( - GaugeOverviewInfoService.class); + MeasurementStationInfoService.class); @Override public Document doProcess( @@ -50,6 +50,11 @@ ec.addAttr(eg, "name", name, true); } + Integer id = mstation.getId(); + if (id != null) { + ec.addAttr(eg, "id", Integer.toString(id), true); + } + String type = mstation.getMeasurementType(); if (type != null) { ec.addAttr(eg, "type", type, true); @@ -78,6 +83,11 @@ } } + String moperator = mstation.getOperator(); + if (moperator != null) { + ec.addAttr(eg, "operator", moperator, true); + } + egs.appendChild(eg); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java Fri Oct 26 15:11:35 2012 +0200 @@ -137,13 +137,15 @@ double[] qs = access.getQs(); for (int k = 0; k < ws.length; k++) { - facets.add(new HistoricalDischargeWQFacet( - HISTORICAL_DISCHARGE_WQ_W, "W=" + ws[k], ws[k])); + facets.add(new HistoricalDischargeWQFacet(k, + HISTORICAL_DISCHARGE_WQ_W, "W=" + ws[k], ComputeType.ADVANCE, + hash, getID(), ws[k])); } for (int k = 0; k < qs.length; k++) { - facets.add(new HistoricalDischargeWQFacet( - HISTORICAL_DISCHARGE_WQ_Q, "Q=" + qs[k], qs[k])); + facets.add(new HistoricalDischargeWQFacet(k, + HISTORICAL_DISCHARGE_WQ_Q, "Q=" + qs[k], ComputeType.ADVANCE, + hash, getID(), qs[k])); } int idx = 0;
--- a/flys-backend/src/main/java/de/intevation/flys/model/MeasurementStation.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/model/MeasurementStation.java Fri Oct 26 15:11:35 2012 +0200 @@ -32,6 +32,9 @@ private TimeInterval observationTimerange; + public MeasurementStation() { + } + public MeasurementStation(River river, String name, String measurementType, String riverside, Double station, Range range, Gauge gauge, TimeInterval observationTimerange, String operator, String comment) {
--- a/flys-backend/src/main/java/de/intevation/flys/model/River.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/model/River.java Fri Oct 26 15:11:35 2012 +0200 @@ -13,6 +13,7 @@ import javax.persistence.SequenceGenerator; import javax.persistence.OneToMany; import javax.persistence.OneToOne; +import javax.persistence.OrderBy; import javax.persistence.JoinColumn; import javax.persistence.GenerationType; @@ -124,6 +125,7 @@ @OneToMany + @OrderBy("station") @JoinColumn(name="river_id") public List<MeasurementStation> getMeasurementStations() { return measurementstations;
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Fri Oct 26 15:11:35 2012 +0200 @@ -236,6 +236,8 @@ String gaugePanelTitle(); + String measurementStationPanelTitle(); + String wqTitle(); String wqadaptedTitle(); @@ -1062,6 +1064,12 @@ String gauge_discharge_curve_at_export(); + // Measurement Station Info + + String measurement_station_type(); + + String measurement_station_operator(); + String discharge_timeranges(); String discharge_chart();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Fri Oct 26 15:11:35 2012 +0200 @@ -158,6 +158,7 @@ calcTableTitle = Calculated Output helperPanelTitle = Input Support gaugePanelTitle = Gauge Information +measurementStationPanelTitle = Measurement Station Information wqW = W at Gauge [cm] wqQ = Q [m\u00b3/s] wqWFree = W free position [m+NHN] @@ -553,4 +554,7 @@ gauge_river_url = https://flys-intern.intevation.de/GewaesserInfo/ gauge_curve_link = Dischargecurve discharge_timeranges = DC-Timeranges -discharge_chart = DC-Chart \ No newline at end of file +discharge_chart = DC-Chart + +measurement_station_type = Type of Measurement Station +measurement_station_operator = Operator
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Fri Oct 26 15:11:35 2012 +0200 @@ -144,6 +144,7 @@ calcTableTitle = Berechnungsausgabe helperPanelTitle = Eingabeunterst\u00fctzung gaugePanelTitle = Gew\u00e4sser/Pegel-Info +measurementStationPanelTitle = Gew\u00e4sser/Messstellen-Info wqW = W am Pegel [cm] wqQ = Q [m\u00b3/s] wqWFree = W auf freier Strecke [m+NHN] @@ -551,4 +552,7 @@ gauge_river_url = https://flys-intern.intevation.de/GewaesserInfo/ gauge_curve_link = Abflusskurve discharge_timeranges = AK-Zeitr\u00e4ume -discharge_chart = AK-Diagramm \ No newline at end of file +discharge_chart = AK-Diagramm + +measurement_station_type = Typ der Messstelle +measurement_station_operator = Operator
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Fri Oct 26 15:11:35 2012 +0200 @@ -158,6 +158,7 @@ calcTableTitle = Calculated Output helperPanelTitle = Input Support gaugePanelTitle = Gauge Information +measurementStationPanelTitle = Measurement Station Information wqW = W at Gauge [cm] wqQ = Q [m\u00b3/s] wqWFree = W at free position [m+NHN] @@ -552,4 +553,7 @@ gauge_river_url = https://flys-intern.intevation.de/GewaesserInfo/ gauge_curve_link = Dischargecurve discharge_timeranges = DC-Timeranges -discharge_chart = DC-Chart \ No newline at end of file +discharge_chart = DC-Chart + +measurement_station_type = Type of Measurement Station +measurement_station_operator = Operator
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeDischargeCurvePanel.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeDischargeCurvePanel.java Fri Oct 26 15:11:35 2012 +0200 @@ -1,25 +1,16 @@ package de.intevation.flys.client.client.ui; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; - import com.google.gwt.core.client.GWT; -import com.smartgwt.client.types.VerticalAlignment; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; -import de.intevation.flys.client.shared.model.DefaultData; -import de.intevation.flys.client.shared.model.DefaultDataItem; - import de.intevation.flys.client.client.FLYSConstants; @@ -45,7 +36,6 @@ @Override public Canvas createOld(DataList dataList) { - HLayout layout = new HLayout(); VLayout vLayout = new VLayout(); vLayout.setWidth("400px");
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java Fri Oct 26 15:11:35 2012 +0200 @@ -1,100 +1,30 @@ package de.intevation.flys.client.client.ui; import com.google.gwt.core.client.GWT; -import com.google.gwt.i18n.client.NumberFormat; import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Anchor; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Label; - -import com.smartgwt.client.types.Overflow; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.WidgetCanvas; -import com.smartgwt.client.widgets.events.ResizedEvent; -import com.smartgwt.client.widgets.events.ResizedHandler; -import com.smartgwt.client.widgets.layout.SectionStackSection; -import com.smartgwt.client.widgets.layout.VLayout; - import de.intevation.flys.client.client.FLYS; -import de.intevation.flys.client.client.FLYSConstants; -import de.intevation.flys.client.client.services.RiverInfoService; -import de.intevation.flys.client.client.services.RiverInfoServiceAsync; -import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.RiverInfo; /** * The GaugePanel is intended to be used within a SectionStackSection - * It extends the VLayout by two methods to show and hide the - * section stack section. * * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> */ -public class GaugePanel extends VLayout implements ResizedHandler { - - /** SectionStackSection where this GaugePanel belongs in*/ - private SectionStackSection section; - - /** Name of the river */ - private String river; - - /** The message class that provides i18n strings.*/ - protected FLYSConstants MSG = GWT.create(FLYSConstants.class); - - protected RiverInfoServiceAsync riverInfoService = - GWT.create(RiverInfoService.class); - - protected GaugeTree gaugetree; - protected Canvas gaugetreecanvas; - - protected RiverInfoPanel riverinfopanel; - - public final static String SECTION_ID = "GaugePanelSection"; - private final static String GAUGE_TREE_CANVAS_ID = - "GaugeTreeCanvas"; +public class GaugePanel extends InfoPanel { /** - * Creates a new VLayout with a SectionStackSection - * The GaugePanel's SectionStackSection is hidden by default. + * GaugePanel loads the GaugeInfo from the RiverInfoService and + * displays them in a tree underneath a RiverInfoPanel * * @param flys The FLYS object - * @param section The section stack section to place the VLayout in. */ public GaugePanel(FLYS flys) { - SectionStackSection section = new SectionStackSection(); - section.setExpanded(false); - section.setTitle(MSG.gaugePanelTitle()); - section.setName(SECTION_ID); - section.setID(SECTION_ID); - - gaugetree = new GaugeTree(flys); - gaugetreecanvas = new WidgetCanvas(gaugetree); - gaugetreecanvas.setID(GAUGE_TREE_CANVAS_ID); - - setOverflow(Overflow.HIDDEN); - setStyleName("gaugepanel"); - - section.setHidden(true); - section.setItems(this); - this.section = section; - - addResizedHandler(this); + super(new GaugeTree(flys)); } - /** - * Sets and loads the river data if river is not the current set river - */ - public void setRiver(String river) { - if (!river.equals(this.river)) { - this.river = river; - this.refresh(); - } - } - - /** - * Sets the data and closes not corresponding folds in the gauge tree - */ - public void setData(DataList[] data) { - gaugetree.setData(data); + @Override + public String getSectionTitle() { + return MSG.gaugePanelTitle(); } /** @@ -112,96 +42,10 @@ @Override public void onSuccess(RiverInfo riverinfo) { GWT.log("Loaded river info"); - renderGaugeOverviewInfo(riverinfo); + render(riverinfo); expand(); } }); } - public void renderGaugeOverviewInfo(RiverInfo riverinfo) { - gaugetree.setGauges(riverinfo); - - if (riverinfopanel == null) { - removeAllMembers(); - - riverinfopanel = new RiverInfoPanel(riverinfo); - - addMember(riverinfopanel); - addMember(gaugetreecanvas); - } - else { - riverinfopanel.setRiverInfo(riverinfo); - } - } - - @Override - public void onResized(ResizedEvent event) { - /* this height calculation is only an approximation and doesn't reflect - * the real height of the the gaugetree. */ - int height = getInnerContentHeight() - - RiverInfoPanel.getStaticHeight(); - int width = getInnerContentWidth(); - - if (height < 0) { - height = 0; - } - - GWT.log("GaugePanel - onResize " + height); - - gaugetree.setHeight("" + height + "px"); - gaugetree.setWidth("" + width + "px"); - } - - - /** - * Hide the section stack section. - */ - @Override - public void hide() { - GWT.log("GaugePanel - hide"); - this.section.setHidden(true); - } - - /** - * Show the section stack section. - */ - @Override - public void show() { - GWT.log("GaugePanel - show"); - this.section.setHidden(false); - } - - @Override - public void addMember(Canvas component) { - super.addMember(component); - expand(); - } - - @Override - public void removeMembers(Canvas[] components) { - super.removeMembers(components); - contract(); - } - - public SectionStackSection getSection() { - return this.section; - } - - private void removeAllMembers() { - removeMembers(getMembers()); - } - - /** - * Expands the gauge section - */ - public void expand() { - section.setExpanded(true); - } - - /** - * Contracts/shrinks the expanded gauge section - */ - public void contract() { - section.setExpanded(false); - } }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java Fri Oct 26 15:11:35 2012 +0200 @@ -8,14 +8,12 @@ import com.google.gwt.user.client.ui.DecoratorPanel; import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.Tree; import com.google.gwt.user.client.ui.TreeItem; import com.smartgwt.client.widgets.layout.HLayout; import de.intevation.flys.client.client.FLYS; -import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; @@ -26,15 +24,10 @@ import java.util.Iterator; import java.util.List; - -public class GaugeTree extends ScrollPanel { - - private FLYS flys; - private Tree tree; - private DataList[] data; - - /** The message class that provides i18n strings.*/ - protected FLYSConstants MSG = GWT.create(FLYSConstants.class); +/** + * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> + */ +public class GaugeTree extends InfoTree { public GaugeTree(FLYS flys) { this.flys = flys; @@ -46,7 +39,8 @@ * Resets the items of the tree. * If the list of gauges is empty or null the tree will be empty. */ - public void setGauges(RiverInfo riverinfo) { + @Override + public void setRiverInfo(RiverInfo riverinfo) { tree.clear(); List<GaugeInfo> gauges = riverinfo.getGauges(); @@ -90,114 +84,7 @@ tree.addItem(gaugeitem); } - public void openAll() { - GWT.log("GaugeTree - openAll"); - for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) { - TreeItem item = it.next(); - item.setState(true); - } - } - - public void setData(DataList[] data) { - this.data = data; - if (tree.getItemCount() > 0) { - open(); - } - } - - public void open() { - ArrayList<Double> locations = new ArrayList<Double>(); - - if (data != null && data.length > 0) { - for (int i = 0; i < data.length; i++) { - DataList dl = data[i]; - String state = dl.getState(); - GWT.log("GaugeTree - open " + state); - if (state.equals("state.winfo.location_distance")) { - Double ldfrom = null; - Double ldto = null; - - for (int j = dl.size()-1; j >= 0; --j) { - Data d = dl.get(j); - String label = d.getLabel(); - GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue()); - if (label.equals("ld_from")) { - ldfrom = getDoubleValue(d); - } - else if (label.equals("ld_to")) { - ldto = getDoubleValue(d); - } - else if (label.equals("ld_locations")) { - getLocationsFromData(locations, d); - openOnLocations(locations); - return; - } - } - if (ldfrom != null) { - openOnDistance(ldfrom, ldto); - return; - } - } - else if(state.equals("state.winfo.distance_only") || - state.equals("state.winfo.distance")) { - Double ldfrom = null; - Double ldto = null; - - for (int j = dl.size()-1; j >= 0; --j) { - Data d = dl.get(j); - String label = d.getLabel(); - GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue()); - if (label.equals("ld_from")) { - ldfrom = getDoubleValue(d); - } - else if (label.equals("ld_to")) { - ldto = getDoubleValue(d); - } - } - - if (ldfrom != null) { - openOnDistance(ldfrom, ldto); - return; - } - } - else if (state.equals("state.winfo.location")) { - getLocations("ld_locations", locations, dl); - openOnLocations(locations); - return; - } - else if (state.equals("state.winfo.reference.curve.input.start")) { - getLocations("reference_startpoint", locations, dl); - } - else if (state.equals("state.winfo.reference.curve.input.end")) { - getLocations("reference_endpoint", locations, dl); - } - else if (state.equals("state.winfo.historicalq.reference_gauge")) { - for (int j = dl.size()-1; j >= 0; --j) { - Data d = dl.get(j); - String label = d.getLabel(); - if (label.equals("reference_gauge")) { - String tmp = d.getStringValue(); - if (tmp != null) { - Long gaugereference = Long.valueOf(tmp); - if (gaugereference != null) { - openOnReference(gaugereference); - return; - } - } - } - } - } - } - } - if (!locations.isEmpty()) { - openOnLocations(locations); - } - else { - openAll(); - } - } - - private void getLocations(String labelname, List<Double> locations, DataList dl) { + void getLocations(String labelname, List<Double> locations, DataList dl) { for (int j = dl.size()-1; j >= 0; --j) { Data d = dl.get(j); String label = d.getLabel(); @@ -207,7 +94,7 @@ } } - private void getLocationsFromData(List<Double> locations, Data data) { + void getLocationsFromData(List<Double> locations, Data data) { DataItem[] items = data.getItems(); for (int k = 0; k < items.length; k++) { String tmp = items[k].getStringValue(); @@ -233,14 +120,6 @@ } } - private Double getDoubleValue(Data d) { - String tmp = d.getStringValue(); - if (tmp != null) { - return Double.valueOf(tmp); - } - return null; - } - public void openOnReference(Long number) { GWT.log("GaugeTree - openOnReference " + number); for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) { @@ -476,4 +355,95 @@ } } + public void open() { + ArrayList<Double> locations = new ArrayList<Double>(); + + if (data != null && data.length > 0) { + for (int i = 0; i < data.length; i++) { + DataList dl = data[i]; + String state = dl.getState(); + GWT.log("GaugeTree - open " + state); + if (state.equals("state.winfo.location_distance")) { + Double ldfrom = null; + Double ldto = null; + + for (int j = dl.size()-1; j >= 0; --j) { + Data d = dl.get(j); + String label = d.getLabel(); + GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue()); + if (label.equals("ld_from")) { + ldfrom = getDoubleValue(d); + } + else if (label.equals("ld_to")) { + ldto = getDoubleValue(d); + } + else if (label.equals("ld_locations")) { + getLocationsFromData(locations, d); + openOnLocations(locations); + return; + } + } + if (ldfrom != null) { + openOnDistance(ldfrom, ldto); + return; + } + } + else if(state.equals("state.winfo.distance_only") || + state.equals("state.winfo.distance")) { + Double ldfrom = null; + Double ldto = null; + + for (int j = dl.size()-1; j >= 0; --j) { + Data d = dl.get(j); + String label = d.getLabel(); + GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue()); + if (label.equals("ld_from")) { + ldfrom = getDoubleValue(d); + } + else if (label.equals("ld_to")) { + ldto = getDoubleValue(d); + } + } + + if (ldfrom != null) { + openOnDistance(ldfrom, ldto); + return; + } + } + else if (state.equals("state.winfo.location")) { + getLocations("ld_locations", locations, dl); + openOnLocations(locations); + return; + } + else if (state.equals("state.winfo.reference.curve.input.start")) { + getLocations("reference_startpoint", locations, dl); + } + else if (state.equals("state.winfo.reference.curve.input.end")) { + getLocations("reference_endpoint", locations, dl); + } + else if (state.equals("state.winfo.historicalq.reference_gauge")) { + for (int j = dl.size()-1; j >= 0; --j) { + Data d = dl.get(j); + String label = d.getLabel(); + if (label.equals("reference_gauge")) { + String tmp = d.getStringValue(); + if (tmp != null) { + Long gaugereference = Long.valueOf(tmp); + if (gaugereference != null) { + openOnReference(gaugereference); + return; + } + } + } + } + } + } + } + if (!locations.isEmpty()) { + openOnLocations(locations); + } + else { + openAll(); + } + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/InfoPanel.java Fri Oct 26 15:11:35 2012 +0200 @@ -0,0 +1,170 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.events.ResizedEvent; +import com.smartgwt.client.widgets.events.ResizedHandler; +import com.smartgwt.client.widgets.layout.SectionStackSection; +import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.WidgetCanvas; + +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.services.RiverInfoService; +import de.intevation.flys.client.client.services.RiverInfoServiceAsync; +import de.intevation.flys.client.shared.model.DataList; +import de.intevation.flys.client.shared.model.RiverInfo; + +/** + * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> + */ +public abstract class InfoPanel extends VLayout implements ResizedHandler { + + /** SectionStackSection where this InfoPanel belongs in*/ + protected SectionStackSection section; + + /** Name of the river */ + protected String river; + + /** The message class that provides i18n strings.*/ + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + + protected RiverInfoServiceAsync riverInfoService = GWT.create(RiverInfoService.class); + + /** Panel to show the info about the river */ + protected RiverInfoPanel riverinfopanel; + protected InfoTree tree; + + /** Wrapper arround the GWT Tree (InfoTree) object */ + protected Canvas treecanvas; + + protected final static String SECTION_ID = "InfoPanelSection"; + + public InfoPanel(InfoTree tree) { + SectionStackSection section = new SectionStackSection(); + section.setExpanded(false); + section.setTitle(getSectionTitle()); + section.setName(SECTION_ID); + section.setID(SECTION_ID); + + treecanvas = new WidgetCanvas(tree); + + setOverflow(Overflow.HIDDEN); + setStyleName("infopanel"); + + section.setHidden(true); + section.setItems(this); + this.section = section; + this.tree = tree; + + addResizedHandler(this); + } + + /** + * Sets and loads the river data if river is not the current set river + */ + public void setRiver(String river) { + if (!river.equals(this.river)) { + this.river = river; + this.refresh(); + } + } + + /** + * Sets the data and closes not corresponding folds in the gauge tree + */ + public void setData(DataList[] data) { + tree.setData(data); + } + + protected void render(RiverInfo riverinfo) { + tree.setRiverInfo(riverinfo); + + if (riverinfopanel == null) { + removeAllMembers(); + + riverinfopanel = new RiverInfoPanel(riverinfo); + + addMember(riverinfopanel); + addMember(treecanvas); + } + else { + riverinfopanel.setRiverInfo(riverinfo); + } + } + + @Override + public void onResized(ResizedEvent event) { + /* this height calculation is only an approximation and doesn't reflect + * the real height of the the gaugetree. */ + int height = getInnerContentHeight() - + RiverInfoPanel.getStaticHeight(); + int width = getInnerContentWidth(); + + if (height < 0) { + height = 0; + } + + GWT.log("InfoPanel - onResize " + height); + + tree.setHeight("" + height + "px"); + tree.setWidth("" + width + "px"); + } + + /** + * Hide the section stack section. + */ + @Override + public void hide() { + GWT.log("InfoPanel - hide"); + this.section.setHidden(true); + } + + /** + * Show the section stack section. + */ + @Override + public void show() { + GWT.log("InfoPanel - show"); + this.section.setHidden(false); + } + + @Override + public void addMember(Canvas component) { + super.addMember(component); + expand(); + } + + @Override + public void removeMembers(Canvas[] components) { + super.removeMembers(components); + contract(); + } + + public SectionStackSection getSection() { + return this.section; + } + + protected void removeAllMembers() { + removeMembers(getMembers()); + } + + /** + * Expands the gauge section + */ + public void expand() { + section.setExpanded(true); + } + + /** + * Contracts/shrinks the expanded gauge section + */ + public void contract() { + section.setExpanded(false); + } + + protected abstract void refresh(); + + protected abstract String getSectionTitle(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/InfoTree.java Fri Oct 26 15:11:35 2012 +0200 @@ -0,0 +1,55 @@ +package de.intevation.flys.client.client.ui; + +import java.util.Iterator; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.ui.ScrollPanel; +import com.google.gwt.user.client.ui.Tree; +import com.google.gwt.user.client.ui.TreeItem; + +import de.intevation.flys.client.client.FLYS; +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataList; +import de.intevation.flys.client.shared.model.RiverInfo; + +/** + * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> + */ +public abstract class InfoTree extends ScrollPanel { + + protected FLYS flys; + protected Tree tree; + protected DataList[] data; + + /** The message class that provides i18n strings.*/ + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + + public void openAll() { + for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) { + TreeItem item = it.next(); + item.setState(true); + } + } + + public void setData(DataList[] data) { + this.data = data; + if (tree.getItemCount() > 0) { + open(); + } + } + + protected Double getDoubleValue(Data d) { + String tmp = d.getStringValue(); + if (tmp != null) { + return Double.valueOf(tmp); + } + return null; + } + + public abstract void open() ; + + public abstract void setRiverInfo(RiverInfo riverinfo); + + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MeasurementStationPanel.java Fri Oct 26 15:11:35 2012 +0200 @@ -0,0 +1,55 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; +import de.intevation.flys.client.client.FLYS; +import de.intevation.flys.client.shared.model.RiverInfo; + +/** + * A Panel to show info about the MeasurementStations of a river + * + * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> + */ +public class MeasurementStationPanel extends InfoPanel { + + /** + * MeasurementStationPanel loads the MeasurementStations from the + * RiverInfoService and displays them in a tree underneath a RiverInfoPanel + * + * @param flys The FLYS object + */ + public MeasurementStationPanel(FLYS flys) { + super(new MeasurementStationTree(flys)); + } + + /** + * Returns the title which should be displayed in the section + */ + @Override + public String getSectionTitle() { + return MSG.measurementStationPanelTitle(); + } + + /** + * Loads the river info and renders it afterwards + */ + @Override + public void refresh() { + contract(); + + riverInfoService.getMeasurementStations(this.river, + new AsyncCallback<RiverInfo>() { + @Override + public void onFailure(Throwable e) { + GWT.log("Could not load the river info." + e); + } + + @Override + public void onSuccess(RiverInfo riverinfo) { + GWT.log("Loaded river info"); + render(riverinfo); + expand(); + } + }); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MeasurementStationTree.java Fri Oct 26 15:11:35 2012 +0200 @@ -0,0 +1,205 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.i18n.client.NumberFormat; +import com.google.gwt.user.client.ui.Anchor; +import com.google.gwt.user.client.ui.DecoratorPanel; +import com.google.gwt.user.client.ui.Grid; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.Tree; +import com.google.gwt.user.client.ui.TreeItem; + +import com.smartgwt.client.widgets.layout.HLayout; + +import de.intevation.flys.client.client.FLYS; +import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataItem; +import de.intevation.flys.client.shared.model.DataList; +import de.intevation.flys.client.shared.model.MeasurementStation; +import de.intevation.flys.client.shared.model.RiverInfo; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> + */ +public class MeasurementStationTree extends InfoTree { + + public MeasurementStationTree(FLYS flys) { + this.flys = flys; + tree = new Tree(); + setWidget(tree); + } + + /** + * Resets the items of the tree. + * If the list of gauges is empty or null the tree will be empty. + */ + @Override + public void setRiverInfo(RiverInfo riverinfo) { + tree.clear(); + + List<MeasurementStation> stations = riverinfo.getMeasurementStations(); + + if (stations != null && !stations.isEmpty()) { + + ArrayList<MeasurementStation> emptystations = + new ArrayList<MeasurementStation>(); + + if (!riverinfo.isKmUp()) { + for (MeasurementStation station : stations) { + addStation(station, emptystations); + } + } + else { + for (int i = stations.size()-1; i >= 0; i--) { + MeasurementStation station = stations.get(i); + addStation(station, emptystations); + } + } + + // put empty stations to the end + for (MeasurementStation station : emptystations) { + addStation(station); + } + } + } + + private void addStation(MeasurementStation station, + List<MeasurementStation> empty) { + if (station.getKmStart() != null && station.getKmEnd() != null) { + addStation(station); + } + else { + empty.add(station); + } + } + + private void addStation(MeasurementStation station) { + MeasurementStationItem sitem = + new MeasurementStationItem(flys, station); + tree.addItem(sitem); + } + + class MeasurementStationItem extends TreeItem { + + private MeasurementStation station; + + public MeasurementStationItem(FLYS flys, MeasurementStation station) { + MeasurementStationHead head = + new MeasurementStationHead(flys, station); + MeasurementStationDecoratorPanel + panel = new MeasurementStationDecoratorPanel(station); + setWidget(head); + addItem(panel); + this.station = station; + } + + public Double getStart() { + return station.getKmStart(); + } + + public Double getEnd() { + return station.getKmEnd(); + } + + public Integer getID() { + return station.getID(); + } + } + + class MeasurementStationHead extends HLayout { + + public MeasurementStationHead(FLYS flys, MeasurementStation station) { + setStyleName("infohead"); + setAutoHeight(); + setAutoWidth(); + + NumberFormat nf = NumberFormat.getDecimalFormat(); + + Label label = new Label(station.getName(), true); + addMember(label); + + Double start; + Double end; + + if (!station.isKmUp()) { + start = station.getKmStart(); + end = station.getKmEnd(); + } + else { + start = station.getKmEnd(); + end = station.getKmStart(); + } + + String kmtext = ""; + if (start != null) { + kmtext += nf.format(start); + kmtext += " - "; + } + if (end != null) { + kmtext += nf.format(end); + } + if (start != null || end != null) { + kmtext += " km"; + } + + label = new Label(kmtext); + + addMember(label); + + Double dstation = station.getStation(); + if (dstation != null) { + String stext = nf.format(dstation); + stext += " km"; + label = new Label(stext); + addMember(label); + } + + /* Long number = gauge.getOfficialNumber(); */ + /* String url = number != null ? */ + /* MSG.gauge_url() + number : */ + /* MSG.gauge_url(); */ + /* Anchor anchor = new Anchor(MSG.gauge_info_link(), url, "_blank"); */ + /* addMember(anchor); */ + } + } + + class MeasurementStationDecoratorPanel extends DecoratorPanel { + + public MeasurementStationDecoratorPanel(MeasurementStation station) { + setStyleName("infopanel"); + Grid grid = new Grid(4, 2); + + NumberFormat nf = NumberFormat.getDecimalFormat(); + + String riverside = station.getRiverSide(); + if (riverside != null) { + grid.setText(0, 0, MSG.riverside()); + grid.setText(0, 1, riverside); + } + + String type = station.getMeasurementType(); + if (type != null) { + grid.setText(1, 0, MSG.measurement_station_type()); + grid.setText(1, 1, type); + } + + String moperator = station.getOperator(); + if (moperator != null) { + grid.setText(2, 0, MSG.measurement_station_operator()); + grid.setText(2, 1, moperator); + } + + setWidget(grid); + } + } + + @Override + public void open() { + } +}
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Fri Oct 26 15:11:35 2012 +0200 @@ -52,6 +52,7 @@ import de.intevation.flys.client.shared.model.ReportMode; import de.intevation.flys.client.shared.model.River; import de.intevation.flys.client.shared.model.WINFOArtifact; +import de.intevation.flys.client.shared.model.MINFOArtifact; import java.util.ArrayList; import java.util.List; @@ -112,7 +113,7 @@ protected VLayout report; protected VLayout helperPanel; protected VLayout tablePanel; - protected GaugePanel gaugePanel; + protected InfoPanel infoPanel; protected Canvas reportPanel; private SectionStack stack; @@ -752,17 +753,15 @@ } } if (art instanceof WINFOArtifact) { - String river = desc.getRiver(); - - if (river != null) { - renderGaugeInfo(desc.getRiver(), desc.getOldData()); - } - else { - hideGaugePanel(); - } + createGaugePanel(); + renderInfo(desc.getRiver(), desc.getOldData()); + } + else if (art instanceof MINFOArtifact) { + createMeasurementStationPanel(); + renderInfo(desc.getRiver(), desc.getOldData()); } else { - removeGaugePanel(); + removeInfoPanel(); } addOldDatas( @@ -944,49 +943,60 @@ private void createGaugePanel() { GWT.log("ParameterList - createGaugePanel"); - if (gaugePanel == null) { - gaugePanel = new GaugePanel(flys); - gaugePanel.setWidth100(); - gaugePanel.setHeight100(); + if (infoPanel == null) { + infoPanel = new GaugePanel(flys); + infoPanel.setWidth100(); + infoPanel.setHeight100(); } } - private void addGaugePanel() { - GWT.log("ParameterList - addGaugePanel"); - createGaugePanel(); - stack.addSection(gaugePanel.getSection(), 0); - } - - private void showGaugePanel() { - GWT.log("ParameterList - showGaugePanel"); - - /* Don't add GaugePanel twice */ - SectionStackSection exists = stack.getSection(GaugePanel.SECTION_ID); - if (exists == null) { - addGaugePanel(); - } - - gaugePanel.show(); - } - - private void hideGaugePanel() { - GWT.log("ParameterList - hideGaugePanel"); - - if (gaugePanel != null) { - gaugePanel.hide(); + private void createMeasurementStationPanel() { + GWT.log("ParameterList - createMeasurementStationPanel"); + if (infoPanel == null) { + infoPanel = new MeasurementStationPanel(flys); + infoPanel.setWidth100(); + infoPanel.setHeight100(); } } - private void removeGaugePanel() { - GWT.log("ParameterList - removeGaugePanel"); - stack.removeSection(GaugePanel.SECTION_ID); + private void showInfoPanel() { + GWT.log("ParameterList - showInfoPanel"); + + /* Don't add InfoPanel twice */ + SectionStackSection exists = stack.getSection(InfoPanel.SECTION_ID); + if (exists == null) { + stack.addSection(infoPanel.getSection(), 0); + } + + infoPanel.show(); + } + + private void hideInfoPanel() { + GWT.log("ParameterList - hideInfoPanel"); + + if (infoPanel != null) { + infoPanel.hide(); + } + } + + private void removeInfoPanel() { + GWT.log("ParameterList - removeInfoPanel"); + stack.removeSection(InfoPanel.SECTION_ID); } - private void renderGaugeInfo(String river, DataList[] data) { - showGaugePanel(); - gaugePanel.setRiver(river); - gaugePanel.setData(data); + private void renderInfo(String river, DataList[] data) { + GWT.log("ParameterList - renderInfo"); + + if (river != null) { + showInfoPanel(); + infoPanel.setRiver(river); + infoPanel.setData(data); + } + else { + GWT.log("ParameterList - renderInfo no river"); + hideInfoPanel(); + } } }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java Fri Oct 26 15:11:35 2012 +0200 @@ -112,7 +112,7 @@ DefaultRiverInfo riverinfo = getRiverInfo(result); List<MeasurementStation> mstations = createMeasurementStations( - result, riverinfo.getName()); + result, riverinfo.getName(), riverinfo.isKmUp()); riverinfo.setMeasurementStations(mstations); @@ -157,8 +157,22 @@ } } + private Integer parseInteger(String value) { + if (value == null || value.isEmpty()) { + return null; + } + try { + return Integer.valueOf(value); + } + catch(NumberFormatException e) { + logger.error(e, e); + return null; + } + } + private List<MeasurementStation> createMeasurementStations( - Document result, String rivername) { + Document result, String rivername, boolean kmup) { + NodeList stationnodes = (NodeList) XMLUtils.xpath( result, XPATH_STATIONS, @@ -190,17 +204,24 @@ ArtifactNamespaceContext.NAMESPACE_URI, "type"); String riverside = stationele.getAttributeNS( ArtifactNamespaceContext.NAMESPACE_URI, "riverside"); + String mid = stationele.getAttributeNS( + ArtifactNamespaceContext.NAMESPACE_URI, "id"); + String moperator = stationele.getAttributeNS( + ArtifactNamespaceContext.NAMESPACE_URI, "operator"); logger.debug("Found measurement station with name " + mname); MeasurementStation station = new DefaultMeasurementStation( rivername, mname, + parseInteger(mid), parseDouble(mstation), parseDouble(mstart), parseDouble(mend), + kmup, riverside, - mtype + mtype, + moperator ); mstations.add(station);
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultMeasurementStation.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultMeasurementStation.java Fri Oct 26 15:11:35 2012 +0200 @@ -5,25 +5,31 @@ */ public class DefaultMeasurementStation implements MeasurementStation { - private String name; - private Double start; - private Double end; - private Double station; - private String rivername; - private String measurementtype; - private String riverside; + private String name; + private Double start; + private Double end; + private Double station; + private String rivername; + private String measurementtype; + private String riverside; + private Integer id; + private boolean kmup; + private String moperator; public DefaultMeasurementStation() { } public DefaultMeasurementStation( - String rivername, - String name, - Double station, - Double start, - Double end, - String riverside, - String measurementtype) + String rivername, + String name, + Integer id, + Double station, + Double start, + Double end, + boolean kmup, + String riverside, + String measurementtype, + String moperator) { this.rivername = rivername; this.name = name; @@ -32,6 +38,9 @@ this.end = end; this.riverside = riverside; this.measurementtype = measurementtype; + this.id = id; + this.kmup = kmup; + this.moperator = moperator; } /** @@ -90,4 +99,25 @@ public String getRiverSide() { return this.riverside; } + + /** + * Returns the ID of the measurement station + */ + @Override + public Integer getID() { + return this.id; + } + + @Override + public boolean isKmUp() { + return this.kmup; + } + + /** + * Returns the operator of the measurement station + */ + @Override + public String getOperator() { + return this.moperator; + } }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/MeasurementStation.java Fri Oct 26 15:09:48 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/MeasurementStation.java Fri Oct 26 15:11:35 2012 +0200 @@ -22,6 +22,8 @@ */ Double getKmEnd(); + boolean isKmUp(); + /** * Returns the station km of the measurement station or null if not * available @@ -42,4 +44,14 @@ * Returns the type of the measurement station */ String getMeasurementType(); + + /** + * Returns the ID of the measurement station + */ + Integer getID(); + + /** + * Returns the operator of the measurement station + */ + String getOperator(); }