Mercurial > dive4elements > river
changeset 4225:f4cee1a74605
Merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 23 Oct 2012 13:29:13 +0200 |
parents | 8b5133444bcc (diff) b7535b66490e (current diff) |
children | cb9f22c3553f |
files | |
diffstat | 17 files changed, 971 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/artifacts/minfo.xml Tue Oct 23 12:24:23 2012 +0200 +++ b/flys-artifacts/doc/conf/artifacts/minfo.xml Tue Oct 23 13:29:13 2012 +0200 @@ -45,6 +45,7 @@ <condition data="calculation_mode" value="calc.bed.quality" operator="equal"/> </transition> + <state id="state.minfo.distance_only" description="state.minfo.distance_only" state="de.intevation.flys.artifacts.states.DistanceOnlySelect" helpText="help.minfo.distance"> <data name="ld_from" type="Double" /> <data name="ld_to" type="Double" /> @@ -313,6 +314,92 @@ </outputmode> </outputmodes> </state> + + <!-- sediment load config--> + <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition"> + <from state="state.minfo.calculation_mode"/> + <to state="state.minfo.sediment.load.year_epoch"/> + <condition data="calculation_mode" value="calc.sediment.load" operator="equal"/> + </transition> + + <state id="state.minfo.sediment.load.year_epoch" description="state.minfo.sediment.load.year_epoch" state="de.intevation.flys.artifacts.states.minfo.YearEpochSelect" helpText="help.minfo.year_epoch"> + <data name="ye_select" type="String"/> + </state> + + <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition"> + <from state="state.minfo.sediment.load.year_epoch"/> + <to state="state.minfo.sediment.load.location"/> + </transition> + + <state id="state.minfo.sediment.load.location" description="state.minfo.distance_only" state="de.intevation.flys.artifacts.states.minfo.SedimentLoadDistanceSelect" helpText="help.minfo.distance"> + <data name="ld_from" type="Double" /> + <data name="ld_to" type="Double" /> + </state> + + <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition"> + <from state="state.minfo.sediment.load.location"/> + <to state="state.minfo.sediment.load.off_epochs"/> + <condition data="ye_select" value="off_epoch" operator="equal"/> + </transition> + + <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition"> + <from state="state.minfo.sediment.load.location"/> + <to state="state.minfo.sediment.load.period"/> + <condition data="ye_select" value="year" operator="equal"/> + </transition> + + <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition"> + <from state="state.minfo.sediment.load.location"/> + <to state="state.minfo.sediment.load.epochs"/> + <condition data="ye_select" value="epoch" operator="equal"/> + </transition> + + <state id="state.minfo.sediment.load.period" description="state.minfo.bed.period" state="de.intevation.flys.artifacts.states.minfo.SedimentLoadYearSelect"> + <data name="start" type="Long"/> + <data name="end" type="Long"/> + </state> + + <state id="state.minfo.sediment.load.epochs" description="state.minfo.bed.epochs" state="de.intevation.flys.artifacts.states.minfo.SedimentLoadEpochSelect"> + <data name="epochs" type="String"/> + </state> + + <state id="state.minfo.sediment.load.off_epochs" description="state.minfo.bed.off_epochs" state="de.intevation.flys.artifacts.states.minfo.SedimentLoadOffEpochSelect"> + <data name="off_epochs" type="String"/> + </state> + + <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition"> + <from state="state.minfo.sediment.load.period"/> + <to state="state.minfo.sediment.load.unit"/> + </transition> + + <state id="state.minfo.sediment.load.unit" description="state.minfo.sediment.load.unit" state="de.intevation.flys.artifacts.states.minfo.SedimentLoadUnit"> + <data name="unit" type="String"/> + </state> + + <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition"> + <from state="state.minfo.sediment.load.unit"/> + <to state="state.minfo.sediment.load.calculate"/> + </transition> + + <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition"> + <from state="state.minfo.sediment.load.epochs"/> + <to state="state.minfo.sediment.load.calculate"/> + </transition> + + <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition"> + <from state="state.minfo.sediment.load.off_epochs"/> + <to state="state.minfo.sediment.load.calculate"/> + </transition> + + <state id="state.minfo.sediment.load.calculate" description="state.minfo.sediment.load.calculate" state="de.intevation.flys.artifacts.states.minfo.SedimentLoadCalculate"> + <outputmodes> + <outputmode name="dummy" description="output.dummy" mime-type="image/png" type="chart"> + <facets> + </facets> + </outputmode> + </outputmodes> + </state> + </states> </artifact>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadCalculate.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,12 @@ +package de.intevation.flys.artifacts.states.minfo; + +import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.states.DefaultState; + + +public class SedimentLoadCalculate +extends DefaultState +implements FacetTypes +{ + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadDistanceSelect.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,13 @@ +package de.intevation.flys.artifacts.states.minfo; + +import de.intevation.flys.artifacts.states.DistanceOnlySelect; + + +public class SedimentLoadDistanceSelect +extends DistanceOnlySelect +{ + @Override + protected String getUIProvider() { + return "minfo.sedimentload_distance_select"; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadEpochSelect.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,25 @@ +package de.intevation.flys.artifacts.states.minfo; + +import org.apache.log4j.Logger; + +import de.intevation.flys.artifacts.states.DefaultState; + + +public class SedimentLoadEpochSelect +extends DefaultState +{ + /** The logger used in this class. */ + private static Logger logger = Logger.getLogger(SedimentLoadEpochSelect.class); + + + /** + * The default constructor that initializes an empty State object. + */ + public SedimentLoadEpochSelect() { + } + + @Override + protected String getUIProvider() { + return "minfo.sedimentload_epoch_select"; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadOffEpochSelect.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,25 @@ +package de.intevation.flys.artifacts.states.minfo; + +import org.apache.log4j.Logger; + +import de.intevation.flys.artifacts.states.DefaultState; + + +public class SedimentLoadOffEpochSelect +extends DefaultState +{ + /** The logger used in this class. */ + private static Logger logger = Logger.getLogger(SedimentLoadOffEpochSelect.class); + + + /** + * The default constructor that initializes an empty State object. + */ + public SedimentLoadOffEpochSelect() { + } + + @Override + protected String getUIProvider() { + return "minfo.sedimentload_offepoch_select"; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadUnit.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,60 @@ +package de.intevation.flys.artifacts.states.minfo; + +import org.apache.log4j.Logger; +import org.w3c.dom.Element; + +import de.intevation.artifacts.Artifact; +import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.CallMeta; +import de.intevation.artifacts.common.utils.XMLUtils; +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.resources.Resources; +import de.intevation.flys.artifacts.states.DefaultState; + + +public class SedimentLoadUnit +extends DefaultState +{ + /** The logger used in this class. */ + private static Logger logger = Logger.getLogger(SedimentLoadUnit.class); + + + /** + * The default constructor that initializes an empty State object. + */ + public SedimentLoadUnit() { + } + + @Override + protected String getUIProvider() { + return "minfo.sedimentload_unit_select"; + } + + @Override + protected Element[] createItems( + XMLUtils.ElementCreator ec, + Artifact artifact, + String name, + CallContext context) + { + CallMeta meta = context.getMeta(); + Element[] elements = new Element[2]; + elements[0] = createItem( + ec, + new String[] { + Resources.getMsg(meta, + "state.minfo.t_per_a", + "state.minfo.t_per_a"), + "t_per_a"}); + + elements[1] = createItem( + ec, + new String[] { + Resources.getMsg(meta, + "state.minfo.m3_per_a", + "state.minfo.m3_per_a"), + "m3_per_a"}); + + return elements; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadYearSelect.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,26 @@ +package de.intevation.flys.artifacts.states.minfo; + +import org.apache.log4j.Logger; + +import de.intevation.flys.artifacts.states.DefaultState; + + +public class SedimentLoadYearSelect +extends DefaultState +{ + /** The logger used in this class. */ + private static Logger logger = Logger.getLogger(SedimentLoadYearSelect.class); + + + /** + * The default constructor that initializes an empty State object. + */ + public SedimentLoadYearSelect() { + } + + @Override + protected String getUIProvider() { + return "minfo.sedimentload_year_select"; + } + +}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/YearEpochSelect.java Tue Oct 23 12:24:23 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/YearEpochSelect.java Tue Oct 23 13:29:13 2012 +0200 @@ -6,6 +6,7 @@ import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; import de.intevation.artifacts.common.utils.XMLUtils; +import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.resources.Resources; import de.intevation.flys.artifacts.states.DefaultState; @@ -33,7 +34,22 @@ CallContext context) { CallMeta meta = context.getMeta(); - Element[] elements = new Element[2]; + Element[] elements; + if (((FLYSArtifact)artifact).getCurrentStateId() + .equals("state.minfo.sediment.load.year_epoch") + ) { + elements = new Element[3]; + elements[2] = createItem( + ec, + new String[] { + Resources.getMsg(meta, + "state.minfo.off_epoch", + "state.minfo.off_epoch"), + "off_epoch"}); + } + else { + elements = new Element[2]; + } elements[0] = createItem( ec, new String[] { @@ -50,7 +66,7 @@ "state.minfo.epoch"), "epoch"}); - return elements; + return elements; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationPicker.java Tue Oct 23 12:24:23 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationPicker.java Tue Oct 23 13:29:13 2012 +0200 @@ -4,32 +4,28 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; - +import com.smartgwt.client.data.AdvancedCriteria; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.Criterion; -import com.smartgwt.client.data.AdvancedCriteria; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.OperatorId; - import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; -import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; - import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; -import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; +import com.smartgwt.client.widgets.grid.CellFormatter; 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.CellFormatter; -import com.smartgwt.client.widgets.grid.events.RecordClickHandler; - -import com.smartgwt.client.types.ListGridFieldType; -import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.widgets.grid.events.CellClickHandler; +import com.smartgwt.client.widgets.layout.HLayout; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.event.FilterHandler; +import de.intevation.flys.client.client.event.RangeFilterEvent; import de.intevation.flys.client.client.event.StringFilterEvent; -import de.intevation.flys.client.client.event.RangeFilterEvent; /** * Bundle widgets and handler for a lacation input helper. @@ -50,13 +46,15 @@ DynamicForm resultCountForm; - RecordClickHandler handler; + CellClickHandler handler; + + boolean isDistance = false; /** Text to show number of matched items when filtered. */ protected StaticTextItem filterResultCount; - public LocationPicker(RecordClickHandler handler) { + public LocationPicker(CellClickHandler handler) { locationTable = new ListGrid(); locationTable.setShowHeaderContextMenu(false); this.handler = handler; @@ -138,7 +136,7 @@ /** * This method creates a table that contains the location values. */ - protected void createLocationTable(/*RecordClickHandler handler*/) { + public void createLocationTable(/*RecordClickHandler handler*/) { GWT.log("Create Location Table in LocationPicker"); String baseUrl = GWT.getHostPageBaseURL(); @@ -153,10 +151,12 @@ ListGridField addLocation = new ListGridField ("", ""); addLocation.setType (ListGridFieldType.ICON); addLocation.setWidth (20); - addLocation.addRecordClickHandler (handler); addLocation.setCellIcon (baseUrl + MSG.markerGreen()); - GWT.log ("i18n: ..... " + MSG.description()); - + ListGridField addTo = new ListGridField ("", ""); + addTo.setType (ListGridFieldType.ICON); + addTo.setWidth (20); + addTo.setCellIcon (baseUrl + MSG.markerRed()); + ListGridField ldescr = new ListGridField("description", MSG.description()); ldescr.setType(ListGridFieldType.TEXT); @@ -198,10 +198,15 @@ new ListGridField("top", MSG.top_edge()); top.setType(ListGridFieldType.TEXT); top.setWidth("10%"); - - - locationTable.setFields( - addLocation, ldescr, loc, lside, bottom, top); + locationTable.addCellClickHandler(handler); + if (isDistance) { + locationTable.setFields( + addLocation, addTo, ldescr, loc, lside, bottom, top); + } + else { + locationTable.setFields( + addLocation, ldescr, loc, lside, bottom, top); + } } @@ -250,5 +255,13 @@ locationTable.filterData(combinedFilter); filterResultCount.setValue(locationTable.getRecords().length); } + + public void setIsDistance(boolean value) { + this.isDistance = value; + } + + public boolean isDistance() { + return this.isDistance; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java Tue Oct 23 12:24:23 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java Tue Oct 23 13:29:13 2012 +0200 @@ -9,8 +9,8 @@ import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; -import com.smartgwt.client.widgets.grid.events.RecordClickEvent; -import com.smartgwt.client.widgets.grid.events.RecordClickHandler; +import com.smartgwt.client.widgets.grid.events.CellClickEvent; +import com.smartgwt.client.widgets.grid.events.CellClickHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; @@ -37,7 +37,7 @@ */ public class MultipleLocationPanel extends LocationPanel -implements RecordClickHandler +implements CellClickHandler { private static final long serialVersionUID = -3359966826794082718L; @@ -317,7 +317,7 @@ * @param e event passed. */ @Override - public void onRecordClick (RecordClickEvent e) { + public void onCellClick (CellClickEvent e) { Record record = e.getRecord(); double[] old = getLocationValues(); double[] selected = DoubleUtils.copyOf(old, old.length + 1);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/RadioPanel.java Tue Oct 23 12:24:23 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RadioPanel.java Tue Oct 23 13:29:13 2012 +0200 @@ -83,9 +83,9 @@ @Override protected Data[] getData() { String value = form.getValueAsString("selection"); - DataItem item = new DefaultDataItem("ye_select", "ye_select", value); + DataItem item = new DefaultDataItem(this.dataName, this.dataName, value); return new Data[] { new DefaultData( - "ye_select", null, null, new DataItem[]{item})}; + this.dataName, null, null, new DataItem[]{item})}; } protected String getTitle(DataItem item) {
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Tue Oct 23 12:24:23 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Tue Oct 23 13:29:13 2012 +0200 @@ -3,7 +3,8 @@ import com.google.gwt.i18n.client.NumberFormat; import com.smartgwt.client.data.Record; -import com.smartgwt.client.widgets.grid.events.RecordClickEvent; + +import com.smartgwt.client.widgets.grid.events.CellClickEvent; import de.intevation.flys.client.shared.model.Data; @@ -105,7 +106,7 @@ * @param e event passed. */ @Override - public void onRecordClick (RecordClickEvent e) { + public void onCellClick (CellClickEvent e) { Record record = e.getRecord(); double[] selected = new double[1]; try {
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Tue Oct 23 12:24:23 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Tue Oct 23 13:29:13 2012 +0200 @@ -7,10 +7,14 @@ import de.intevation.flys.client.client.ui.fixation.FixMultiPeriodPanel; import de.intevation.flys.client.client.ui.fixation.FixPeriodPanel; import de.intevation.flys.client.client.ui.fixation.FixQSelectPanel; -import de.intevation.flys.client.client.ui.sq.SQPeriodPanel; import de.intevation.flys.client.client.ui.minfo.BedHeightsDatacagePanel; import de.intevation.flys.client.client.ui.minfo.BedMultiPeriodPanel; import de.intevation.flys.client.client.ui.minfo.CheckboxPanel; +import de.intevation.flys.client.client.ui.minfo.SedLoadDistancePanel; +import de.intevation.flys.client.client.ui.minfo.SedLoadEpochPanel; +import de.intevation.flys.client.client.ui.minfo.SedLoadOffEpochPanel; +import de.intevation.flys.client.client.ui.minfo.SedLoadPeriodPanel; +import de.intevation.flys.client.client.ui.sq.SQPeriodPanel; import de.intevation.flys.client.shared.model.User; /** @@ -152,9 +156,24 @@ else if (uiProvider.equals("minfo.bed.char_diameter")) { return new CheckboxPanel(); } + else if (uiProvider.equals("minfo.sedimentload_unit_select")) { + return new RadioPanel(); + } else if (uiProvider.equals("gauge_discharge_curve")) { return new GaugeDischargeCurvePanel(); } + else if (uiProvider.equals("minfo.sedimentload_distance_select")) { + return new SedLoadDistancePanel(); + } + else if (uiProvider.equals("minfo.sedimentload_year_select")) { + return new SedLoadPeriodPanel(); + } + else if (uiProvider.equals("minfo.sedimentload_epoch_select")) { + return new SedLoadEpochPanel(); + } + else if (uiProvider.equals("minfo.sedimentload_epoch_select")) { + return new SedLoadOffEpochPanel(); + } else { //GWT.log("Picked default provider."); return new SelectProvider();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadDistancePanel.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,280 @@ +package de.intevation.flys.client.client.ui.minfo; + +import java.util.List; + +import com.google.gwt.core.client.GWT; +import com.smartgwt.client.data.Record; +import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.form.fields.events.BlurEvent; +import com.smartgwt.client.widgets.form.fields.events.BlurHandler; +import com.smartgwt.client.widgets.grid.events.CellClickEvent; +import com.smartgwt.client.widgets.grid.events.CellClickHandler; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.event.FilterHandler; +import de.intevation.flys.client.client.event.RangeFilterEvent; +import de.intevation.flys.client.client.event.StringFilterEvent; +import de.intevation.flys.client.client.ui.AbstractUIProvider; +import de.intevation.flys.client.client.ui.DoubleRangeOnlyPanel; +import de.intevation.flys.client.client.ui.DoubleRangePanel; +import de.intevation.flys.client.client.ui.LocationPicker; +import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource; +import de.intevation.flys.client.shared.model.ArtifactDescription; +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; + + +public class SedLoadDistancePanel +extends AbstractUIProvider +implements BlurHandler, CellClickHandler +{ + public static final String FIELD_LOWER = "ld_from"; + public static final String FIELD_UPPER = "ld_to"; + + protected DoubleRangePanel distancePanel; + protected double min; + protected double max; + protected LocationPicker picker; + + @Override + public Canvas createOld(DataList dataList) { + String s = getOldSelectionString(dataList); + String l = dataList.getLabel(); + + Label label = new Label(l); + Label selected = new Label(s); + + HLayout layout = new HLayout(); + + layout.setWidth(400); + label.setWidth(200); + selected.setWidth(130); + + layout.addMember(label); + layout.addMember(selected); + layout.addMember(getBackButton(dataList.getState())); + + return layout; + } + + protected String getOldSelectionString(DataList dataList) { + List<Data> items = dataList.getAll(); + + Data dFrom = getData(items, FIELD_LOWER); + Data dTo = getData(items, FIELD_UPPER); + + DataItem[] from = dFrom.getItems(); + DataItem[] to = dTo.getItems(); + + StringBuilder sb = new StringBuilder(); + sb.append(from[0].getLabel()); + sb.append(" " + MSG.dpUnitFrom() + " - "); + sb.append(to[0].getLabel()); + sb.append(" " + MSG.dpUnitTo()); + + return sb.toString(); + } + + @Override + public Canvas create(DataList data) { + picker = new LocationPicker(this); + distancePanel = new DoubleRangeOnlyPanel( + MSG.dpUnitFrom() + " - ", MSG.dpUnitTo(), 0d, 0d, 250, this, "right"); + VLayout layout = new VLayout(); + layout.setMembersMargin(10); + + Label label = new Label(MSG.distance_state()); + + Canvas submit = getNextButton(); + + label.setHeight(25); + distancePanel.setHeight(50); + + layout.addMember(label); + layout.addMember(distancePanel); + layout.addMember(submit); + + initMinMaxValues(data); + initDefaultValues(data); + + + picker.setIsDistance(true); + picker.getLocationTable().setAutoFetchData(true); + picker.prepareFilter(); + + helperContainer.addMember(picker.getLocationTable()); + helperContainer.addMember(picker.getFilterLayout()); + helperContainer.addMember(picker.getResultCountForm()); + + setPickerDataSource(); + picker.createLocationTable(); + + return layout; + } + + protected void initMinMaxValues(DataList data) { + Data f = getData(data.getAll(), FIELD_LOWER); + Data t = getData(data.getAll(), FIELD_UPPER); + + DataItem[] fItems = f.getItems(); + DataItem[] tItems = t.getItems(); + + try { + min = Double.valueOf(fItems[0].getStringValue()); + max = Double.valueOf(tItems[0].getStringValue()); + } + catch (NumberFormatException nfe) { + min = -Double.MAX_VALUE; + max = Double.MAX_VALUE; + } + } + + protected void initDefaultValues(DataList data) { + initDefaultFrom(data); + initDefaultTo(data); + } + + protected void initDefaultFrom(DataList data) { + Data f = getData(data.getAll(), FIELD_LOWER); + + double from = getDefaultFrom(); + + try { + from = getDefaultValue(f); + } + catch (NumberFormatException nfe) { + // do nothing + } + + distancePanel.setFrom(from); + } + + + protected double getDefaultFrom() { + return min; + } + + + protected void initDefaultTo(DataList data) { + Data t = getData(data.getAll(), FIELD_UPPER); + + double to = getDefaultTo(); + + try { + to = getDefaultValue(t); + } + catch (NumberFormatException nfe) { + // do nothing + } + + distancePanel.setTo(to); + } + + + protected double getDefaultTo() { + return max; + } + + protected double getDefaultValue(Data data) + throws NumberFormatException + { + DataItem def = data.getDefault(); + String defValue = def != null ? def.getStringValue() : null; + + return Double.valueOf(defValue); + } + + /** Hook service to the listgrid with possible input values. */ + protected void setPickerDataSource() { + Config config = Config.getInstance(); + String url = config.getServerUrl(); + String river = ""; + + ArtifactDescription adescr = artifact.getArtifactDescription(); + DataList[] data = adescr.getOldData(); + + // Try to find a "river" data item to set the source for the + // list grid. + String dataFilter = "locations"; + if (data != null && data.length > 0) { + for (int i = 0; i < data.length; i++) { + DataList dl = data[i]; + if (dl.getState().equals("state.minfo.river")) { + dataFilter = "measuringpoint"; + } + if (dl.getState().equals("state.winfo.river") || + dl.getState().equals("state.chart.river") || + dl.getState().equals("state.minfo.river")) { + for (int j = 0; j < dl.size(); j++) { + Data d = dl.get(j); + DataItem[] di = d.getItems(); + if (di != null && di.length == 1) { + river = d.getItems()[0].getStringValue(); + break; + } + } + } + } + } + + picker.getLocationTable().setDataSource(new DistanceInfoDataSource( + url, river, dataFilter)); + } + + @Override + protected Data[] getData() { + Data[] data = new Data[2]; + + data[0] = getDataFrom(); + data[1] = getDataTo(); + + return data; + } + + protected Data getDataFrom() { + String value = String.valueOf(distancePanel.getFrom()); + String field = FIELD_LOWER; + + DataItem item = new DefaultDataItem(field, field, value); + return new DefaultData( + field, null, null, new DataItem[] { item }); + } + + protected Data getDataTo() { + String value = String.valueOf(distancePanel.getTo()); + String field = FIELD_UPPER; + + DataItem item = new DefaultDataItem(field, field, value); + return new DefaultData( + field, null, null, new DataItem[] { item }); + } + + @Override + public void onBlur(BlurEvent event) { + distancePanel.validateForm(); + } + + @Override + public void onCellClick(CellClickEvent e) { + Record record = e.getRecord(); + int ndx = e.getColNum(); + String from = record.getAttribute("from"); + try { + double value = Double.valueOf(from); + switch (ndx) { + case 0: distancePanel.setFrom(value); break; + case 1: distancePanel.setTo(value); break; + } + } + catch(NumberFormatException nfe) { + SC.warn(MSG.wrongFormat()); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadEpochPanel.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,197 @@ +package de.intevation.flys.client.client.ui.minfo; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.core.client.GWT; +import com.smartgwt.client.data.Record; +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; +import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; +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.RecordClickEvent; +import com.smartgwt.client.widgets.grid.events.RecordClickHandler; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.flys.client.client.ui.AbstractUIProvider; +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; + + +public class SedLoadEpochPanel +extends AbstractUIProvider +{ + protected ListGrid elements; + private TextItem start; + private TextItem end; + + public Canvas createWidget(DataList data) { + HLayout input = new HLayout(); + VLayout root = new VLayout(); + VLayout grid = new VLayout(); + VLayout intFields = new VLayout(); + Button add = new Button(MSG.add_date()); + elements = new ListGrid(); + + Label title = new Label(data.get(0).getDescription()); + title.setHeight("25px"); + + DynamicForm form = new DynamicForm(); + form.setNumCols(4); + start = new TextItem(MSG.from()); + start.setWidth(60); + start.setValidators(new IsIntegerValidator()); + end = new TextItem(MSG.to()); + end.setWidth(60); + end.setValidators(new IsIntegerValidator()); + form.setFields(start, end); + add.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent ce) { + String v1 = start.getValueAsString(); + String v2 = end.getValueAsString(); + //TODO: better validation. + if (v1 == null || v2 == null) { + return; + } + try { + int v1i = Integer.parseInt(v1); + int v2i = Integer.parseInt(v2); + } + catch(NumberFormatException nfe) { + return; + } + Record r = new Record(); + r.setAttribute("from", v1); + r.setAttribute("to", v2); + elements.addData(r); + } + }); + + Label sel = new Label(MSG.select()); + sel.setHeight(25); + elements.setWidth(185); + elements.setHeight(120); + elements.setShowHeaderContextMenu(false); + elements.setCanReorderFields(false); + elements.setCanSort(false); + elements.setCanEdit(false); + ListGridField from = new ListGridField("from", MSG.from()); + ListGridField to = new ListGridField("to", MSG.to()); + from.setWidth(70); + to.setWidth(70); + + final ListGridField removeField = + new ListGridField("_removeRecord", "Remove Record"){{ + setType(ListGridFieldType.ICON); + setIcon(GWT.getHostPageBaseURL() + MSG.removeFeature()); + setCanEdit(false); + setCanFilter(false); + setCanSort(false); + setCanGroupBy(false); + setCanFreeze(false); + setWidth(25); + }}; + + elements.addRecordClickHandler(new RecordClickHandler() { + @Override + public void onRecordClick(final RecordClickEvent event) { + // Just handle remove-clicks + if(!event.getField().getName().equals(removeField.getName())) { + return; + } + event.getViewer().removeData(event.getRecord()); + } + }); + + elements.setFields(from, to, removeField); + + intFields.addMember(form); + intFields.addMember(add); + grid.addMember(sel); + grid.addMember(elements); + input.addMember(intFields); + input.addMember(grid); + root.addMember(title); + root.addMember(input); + + return root; + } + @Override + public Canvas createOld(DataList dataList) { + GWT.log("old............................"); + HLayout layout = new HLayout(); + layout.setWidth("400px"); + VLayout vLayout = new VLayout(); + vLayout.setWidth(130); + Label label = new Label(dataList.getLabel()); + label.setWidth("200px"); + label.setHeight(25); + + List<Data> items = dataList.getAll(); + Data str = getData(items, "epochs"); + DataItem[] strItems = str.getItems(); + + String[] pairs = strItems[0].getLabel().split(";"); + for (int i = 0; i < pairs.length; i++) { + String[] vals = pairs[i].split(","); + Label dateLabel = new Label(vals[0] + " - " + vals[1]); + dateLabel.setHeight(20); + vLayout.addMember(dateLabel); + } + Canvas back = getBackButton(dataList.getState()); + layout.addMember(label); + layout.addMember(vLayout); + layout.addMember(back); + + return layout; + } + + @Override + public Canvas create(DataList data) { + VLayout layout = new VLayout(); + Canvas submit = getNextButton(); + Canvas widget = createWidget(data); + + layout.addMember(widget); + layout.addMember(submit); + return layout; + } + + @Override + protected Data[] getData() { + List<Data> data = new ArrayList<Data>(); + + ListGridRecord[] lgr = elements.getRecords(); + if (lgr.length == 0) { + return new Data[0]; + } + String d = ""; + for (int i = 0; i < lgr.length; i++) { + Record r = (Record) lgr[i]; + d += r.getAttribute("from") + "," + r.getAttribute("to"); + d += ";"; + } + + DataItem item = new DefaultDataItem("epochs", null, d); + data.add(new DefaultData( + "epochs", + null, + null, + new DataItem[] { item })); + return data.toArray(new Data[data.size()]); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadOffEpochPanel.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,10 @@ +package de.intevation.flys.client.client.ui.minfo; + +import de.intevation.flys.client.client.ui.PeriodPanel; + + +public class SedLoadOffEpochPanel +extends PeriodPanel +{ + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadPeriodPanel.java Tue Oct 23 13:29:13 2012 +0200 @@ -0,0 +1,153 @@ +package de.intevation.flys.client.client.ui.minfo; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.core.client.GWT; +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.TextItem; +import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.flys.client.client.ui.AbstractUIProvider; +import de.intevation.flys.client.client.ui.IntegerRangePanel; +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; + + +public class SedLoadPeriodPanel +extends AbstractUIProvider +//extends SedLoadPanel +{ + + private TextItem start; + private TextItem end; + + public SedLoadPeriodPanel () { + } + + @Override + public Canvas createOld(DataList dataList) { + List<Data> items = dataList.getAll(); + Data start = getData(items, "start"); + Data end = getData(items, "end"); + DataItem[] startItem = start.getItems(); + DataItem[] endItem = end.getItems(); + + String v1 = startItem[0].getStringValue(); + String v2 = endItem[0].getStringValue(); + + int v1i = 0; + int v2i = 0; + try { + v1i = Integer.parseInt(v1); + v2i = Integer.parseInt(v2); + } + catch (NumberFormatException nfe) { + GWT.log(nfe.toString()); + } + Label old = new Label(v1i + " - " + v2i); + HLayout layout = new HLayout(); + layout.setWidth("400px"); + + Label label = new Label(dataList.getLabel()); + label.setWidth("200px"); + + Canvas back = getBackButton(dataList.getState()); + + layout.addMember(label); + layout.addMember(old); + layout.addMember(back); + + return layout; + } + + @Override + public Canvas create(DataList data) { + VLayout layout = new VLayout(); + +// Canvas helper = createHelper(); +// this.helperContainer.addMember(helper); + + Canvas submit = getNextButton(); + Canvas widget = createWidget(data); + + layout.addMember(widget); + layout.addMember(submit); + return layout; + } + + public Canvas createWidget(DataList data) { + VLayout layout = new VLayout(); + + Label title = new Label(data.get(0).getDescription()); + title.setHeight("25px"); + + DynamicForm form = new DynamicForm(); + form.setNumCols(4); + start = new TextItem(MSG.from()); + start.setValidators(new IsIntegerValidator()); + end = new TextItem(MSG.to()); + end.setValidators(new IsIntegerValidator()); + form.setFields(start, end); +// inputPanel.setToTitle(MSG.to()); +// inputPanel.setFromTitle(MSG.from()); +// inputPanel.setShowTitle(false); + + layout.addMember(title); + layout.addMember(form); + + return layout; + } + + @Override + protected Data[] getData() { + int v1; + int v2; + try { + v1 = Integer.parseInt(start.getValueAsString()); + v2 = Integer.parseInt(end.getValueAsString()); + } + catch(NumberFormatException nfe) { + // warn the user... + return new Data[0]; + } + if (validateRange(v1, v2)) { + List<Data> data = new ArrayList<Data>(); + + DataItem startItem = new DefaultDataItem("start", "start", start.getValueAsString()); + DataItem endItem = new DefaultDataItem("end", "end", end.getValueAsString()); + data.add(new DefaultData( + "start", + null, + null, + new DataItem[] { startItem })); + data.add(new DefaultData( + "end", + null, + null, + new DataItem[] { endItem })); + + return data.toArray(new Data[data.size()]); + } + return new Data[0]; + } + + protected boolean validateRange(int v1, int v2) { + // TODO: Set useful years for validation. Current range is between start + // of gregorian calendar and a year in the future... + if ((v1 > 1582 && v1 < 2100) + && (v2 > 1582 && v2 < 2100)) { + return true; + } + return false; + } + + +}