Mercurial > dive4elements > river
changeset 787:4e0b73b7113b
Added new UI providers.
flys-client/trunk@2284 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/flys-client/ChangeLog Tue Jul 05 16:13:08 2011 +0000 +++ b/flys-client/ChangeLog Tue Jul 05 17:28:04 2011 +0000 @@ -1,3 +1,26 @@ +2011-07-05 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java, + src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java: + Modified these classes with the intent to override them easier. + + * src/main/java/de/intevation/flys/client/client/ui/BooleanPanel.java, + src/main/java/de/intevation/flys/client/client/ui/DatacagePanel.java, + src/main/java/de/intevation/flys/client/client/ui/TextProvider.java, + src/main/java/de/intevation/flys/client/client/ui/AutoIntegerPanel.java, + src/main/java/de/intevation/flys/client/client/ui/WaterlevelGroundPanel.java, + src/main/java/de/intevation/flys/client/client/ui/DatacageButton.java: + New panels for data input. The work on these classes is not finished + yet! + + * src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java: + Support more UI providers that return the new panels above. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java: New + strings used in the WaterlevelGroundPanel. + 2011-07-05 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/client/event/AdvanceHandler.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Tue Jul 05 16:13:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Tue Jul 05 17:28:04 2011 +0000 @@ -106,11 +106,11 @@ public void onModuleLoad() { openProjects = new ArrayList<String>(); - GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { - public void onUncaughtException(Throwable e) { - showWarning(e); - } - }); + //GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { + // public void onUncaughtException(Throwable e) { + // showWarning(e); + // } + //}); VLayout vertical = new VLayout(); vertical.setLayoutMargin(1);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Tue Jul 05 16:13:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Tue Jul 05 17:28:04 2011 +0000 @@ -120,6 +120,12 @@ String unitWidth(); + String unitFromInM(); + + String unitToInM(); + + String unitDiffInM(); + String unitLocation(); String wrongFormat();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Tue Jul 05 16:13:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Tue Jul 05 17:28:04 2011 +0000 @@ -43,6 +43,9 @@ unitFrom = km unitTo = km a unitWidth = m +unitFromInM = From [m]: +unitToInM = To [m]: +unitDiffInM = Diff [m]: unitLocation = km wrongFormat = Wrong format description = Description
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Tue Jul 05 16:13:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Tue Jul 05 17:28:04 2011 +0000 @@ -43,6 +43,9 @@ unitFrom = km - unitTo = km a unitWidth = m +unitFromInM = Von [m]: +unitToInM = Bis [m]: +unitDiffInM = Diff [m]: unitLocation = km wrongFormat = Falsches Format description = Beschreibung
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/AutoIntegerPanel.java Tue Jul 05 17:28:04 2011 +0000 @@ -0,0 +1,69 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +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.DefaultData; +import de.intevation.flys.client.shared.model.DefaultDataItem; +import de.intevation.flys.client.shared.model.DataList; + +import de.intevation.flys.client.client.FLYSConstants; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class AutoIntegerPanel extends TextProvider { + + protected static FLYSConstants MSG = GWT.create(FLYSConstants.class); + + protected String dataName; + + + @Override + public Canvas create(DataList dataList) { + Data data = dataList.get(0); + this.dataName = data.getLabel(); + + Canvas label = new Label(data.getDescription()); + Canvas form = createForm(MSG.uesk_profile_distance()); + Canvas submit = getNextButton(); + + VLayout layout = new VLayout(); + layout.setHeight(35); + label.setHeight(35); + + layout.addMember(label); + layout.addMember(form); + layout.addMember(submit); + layout.setMembersMargin(10); + + return layout; + } + + + @Override + public Canvas createOld(DataList dataList) { + Canvas c = new Canvas(); + c.setHeight(1); + c.setWidth(1); + + return c; + } + + + @Override + protected Data[] getData() { + GWT.log("+++ RETURN DATA FOR STATE: " + dataName + " +++"); + String value = "TODO:FIND VALUE"; + DataItem item = new DefaultDataItem(dataName, dataName, value); + return new Data[] { new DefaultData( + dataName, null, null, new DataItem[] { item }) }; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/BooleanPanel.java Tue Jul 05 17:28:04 2011 +0000 @@ -0,0 +1,111 @@ +package de.intevation.flys.client.client.ui; + +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.CheckboxItem; +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; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class BooleanPanel extends AbstractUIProvider { + + public static final String FIELD_NAME = "boolean_field"; + + protected DynamicForm form; + + protected String dataName; + + + @Override + public Canvas create(DataList dataList) { + Data data = dataList.get(0); + DataItem[] items = data.getItems(); + + this.dataName = data.getLabel(); + + VLayout layout = new VLayout(); + Label label = new Label(data.getDescription()); + + layout.setMembersMargin(10); + layout.setHeight(35); + label.setHeight(35); + + layout.addMember(label); + layout.addMember(createForm(items[0].getLabel())); + layout.addMember(getNextButton()); + + return layout; + } + + + protected Canvas createForm() { + return createForm(null); + } + + + protected Canvas createForm(String title) { + HLayout layout = new HLayout(); + layout.setMembersMargin(10); + + if (title != null && title.length() > 0) { + Label label = new Label(title); + label.setHeight(25); + layout.addMember(label); + } + + form = new DynamicForm(); + layout.addMember(form); + + CheckboxItem item = new CheckboxItem(FIELD_NAME); + item.setShowTitle(false); + item.setShowLabel(false); + + form.setFields(item); + + return layout; + } + + + @Override + public Canvas createOld(DataList dataList) { + Data data = dataList.get(0); + DataItem[] items = data.getItems(); + + HLayout layout = new HLayout(); + Label label = new Label(dataList.getLabel()); + Label value = new Label(items[0].getLabel()); + + layout.setHeight(35); + layout.setWidth(400); + label.setWidth(200); + + layout.addMember(label); + layout.addMember(value); + layout.addMember(getBackButton(dataList.getState())); + + return layout; + } + + + @Override + protected Data[] getData() { + GWT.log("+++ RETURN DATA FOR STATE: " + dataName + " +++"); + String value = "TODO:FIND VALUE"; + DataItem item = new DefaultDataItem(dataName, dataName, value); + return new Data[] { new DefaultData( + dataName, null, null, new DataItem[] { item }) }; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageButton.java Tue Jul 05 17:28:04 2011 +0000 @@ -0,0 +1,36 @@ +package de.intevation.flys.client.client.ui; + +import com.smartgwt.client.widgets.Button; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.events.CloseClickHandler; +import com.smartgwt.client.widgets.events.CloseClientEvent; + +import de.intevation.flys.client.shared.model.Artifact; + + +public class DatacageButton extends Button implements ClickHandler { + + protected Artifact artifact; + + + public DatacageButton(String title, Artifact artifact) { + super(title); + + this.artifact = artifact; + + addClickHandler(this); + } + + + public void onClick(ClickEvent event) { + final DatacageWindow dc = new DatacageWindow(artifact); + dc.addCloseClickHandler(new CloseClickHandler() { + public void onCloseClick(CloseClientEvent event) { + dc.destroy(); + } + }); + dc.show(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePanel.java Tue Jul 05 17:28:04 2011 +0000 @@ -0,0 +1,69 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +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.DefaultData; +import de.intevation.flys.client.shared.model.DefaultDataItem; +import de.intevation.flys.client.shared.model.DataList; + +import de.intevation.flys.client.client.FLYSConstants; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class DatacagePanel extends TextProvider { + + protected static FLYSConstants MSG = GWT.create(FLYSConstants.class); + + protected String dataName; + + + @Override + public Canvas create(DataList dataList) { + Data data = dataList.get(0); + this.dataName = data.getLabel(); + + Canvas label = new Label(data.getDescription()); + Canvas widget = createWidget(); + Canvas submit = getNextButton(); + + VLayout layout = new VLayout(); + label.setHeight(25); + + layout.addMember(label); + layout.addMember(widget); + layout.addMember(submit); + layout.setMembersMargin(10); + + return layout; + } + + + public Canvas createWidget() { + HLayout layout = new HLayout(); + layout.setMembersMargin(10); + + layout.addMember(createForm()); + layout.addMember(new DatacageButton(MSG.databasket(), artifact)); + + return layout; + } + + + @Override + protected Data[] getData() { + String value = "TODO:FIND VALUE"; + DataItem item = new DefaultDataItem(dataName, dataName, value); + return new Data[] { new DefaultData( + dataName, null, null, new DataItem[] { item }) }; + } +} +// 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/DistancePanel.java Tue Jul 05 16:13:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java Tue Jul 05 17:28:04 2011 +0000 @@ -37,6 +37,10 @@ public static final int DEFAULT_STEP_WIDTH = 100; + public static final String FIELD_LOWER = "ld_from"; + public static final String FIELD_UPPER = "ld_to"; + public static final String FIELD_STEP = "ld_step"; + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -52,20 +56,27 @@ public DistancePanel() { + this("right"); + } + + + public DistancePanel(String labelOrientation) { distancesTable = new RangeTable(); locationsTable = new LocationsTable(); distancePanel = new DoubleRangePanel( - MSG.unitFrom(), MSG.unitTo(), MSG.unitWidth(), - 0d, 0d, 0d, 250, this); + getLabelFrom(), getLabelTo(), getLabelStep(), + 0d, 0d, 0d, 250, this, labelOrientation); } @Override public Canvas create(DataList data) { + Data d = data.get(0); + VLayout layout = new VLayout(); layout.setMembersMargin(10); - Label label = new Label(MSG.distance_state()); + Label label = new Label(d.getDescription()); Canvas submit = getNextButton(); @@ -109,9 +120,9 @@ protected String getOldSelectionString(DataList dataList) { List<Data> items = dataList.getAll(); - Data dFrom = getData(items, "ld_from"); - Data dTo = getData(items, "ld_to"); - Data dStep = getData(items, "ld_step"); + Data dFrom = getData(items, getLowerField()); + Data dTo = getData(items, getUpperField()); + Data dStep = getData(items, getStepField()); DataItem[] from = dFrom.getItems(); DataItem[] to = dTo.getItems(); @@ -119,16 +130,46 @@ StringBuilder sb = new StringBuilder(); sb.append(from[0].getLabel()); - sb.append(" " + MSG.unitFrom() + " "); + sb.append(" " + getLabelFrom() + " "); sb.append(to[0].getLabel()); - sb.append(" " + MSG.unitTo() + " "); + sb.append(" " + getLabelTo() + " "); sb.append(step[0].getLabel()); - sb.append(" " + MSG.unitWidth()); + sb.append(" " + getLabelStep()); return sb.toString(); } + protected String getLabelFrom() { + return MSG.unitFrom(); + } + + + protected String getLabelTo() { + return MSG.unitTo(); + } + + + protected String getLabelStep() { + return MSG.unitWidth(); + } + + + protected String getLowerField() { + return FIELD_LOWER; + } + + + protected String getUpperField() { + return FIELD_UPPER; + } + + + protected String getStepField() { + return FIELD_STEP; + } + + @Override public List<String> validate() { List<String> errors = new ArrayList<String>(); @@ -191,26 +232,32 @@ protected Data getDataFrom() { - String value = String.valueOf(distancePanel.getFrom()); - DataItem item = new DefaultDataItem("ld_from", "ld_from", value); + String value = String.valueOf(distancePanel.getFrom()); + String field = getLowerField(); + + DataItem item = new DefaultDataItem(field, field, value); return new DefaultData( - "ld_from", null, null, new DataItem[] { item }); + field, null, null, new DataItem[] { item }); } protected Data getDataTo() { - String value = String.valueOf(distancePanel.getTo()); - DataItem item = new DefaultDataItem("ld_to", "ld_to", value); + String value = String.valueOf(distancePanel.getTo()); + String field = getUpperField(); + + DataItem item = new DefaultDataItem(field, field, value); return new DefaultData( - "ld_to", null, null, new DataItem[] { item }); + field, null, null, new DataItem[] { item }); } protected Data getDataStep() { - String value = String.valueOf(distancePanel.getStep()); - DataItem item = new DefaultDataItem("ld_step","ld_step", value); + String value = String.valueOf(distancePanel.getStep()); + String field = getStepField(); + + DataItem item = new DefaultDataItem(field, field, value); return new DefaultData( - "ld_step", null, null, new DataItem[] { item }); + field, null, null, new DataItem[] { item }); } @@ -221,8 +268,8 @@ protected void initMinMaxValues(DataList data) { - Data f = getData(data.getAll(), "ld_from"); - Data t = getData(data.getAll(), "ld_to"); + Data f = getData(data.getAll(), getLowerField()); + Data t = getData(data.getAll(), getUpperField()); DataItem[] fItems = f.getItems(); DataItem[] tItems = t.getItems(); @@ -246,9 +293,9 @@ protected void initDefaultFrom(DataList data) { - Data f = getData(data.getAll(), "ld_from"); + Data f = getData(data.getAll(), getLowerField()); - double from = min; + double from = getDefaultFrom(); try { from = getDefaultValue(f); @@ -261,10 +308,15 @@ } + protected double getDefaultFrom() { + return min; + } + + protected void initDefaultTo(DataList data) { - Data t = getData(data.getAll(), "ld_to"); + Data t = getData(data.getAll(), getUpperField()); - double to = max; + double to = getDefaultTo(); try { to = getDefaultValue(t); @@ -277,10 +329,15 @@ } + protected double getDefaultTo() { + return max; + } + + protected void initDefaultStep(DataList data) { - Data s = getData(data.getAll(), "ld_step"); + Data s = getData(data.getAll(), getStepField()); - double step = (double) DEFAULT_STEP_WIDTH; + double step = getDefaultStep(); try { step = getDefaultValue(s); @@ -293,6 +350,11 @@ } + protected double getDefaultStep() { + return (double) DEFAULT_STEP_WIDTH; + } + + protected double getDefaultValue(Data data) throws NumberFormatException {
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java Tue Jul 05 16:13:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java Tue Jul 05 17:28:04 2011 +0000 @@ -59,6 +59,22 @@ int width, BlurHandler handler) { + this( + titleFrom, titleTo, titleStep, + from, to, step, + width, + handler, + "right"); + } + + + public DoubleRangePanel( + String titleFrom, String titleTo, String titleStep, + double from, double to, double step, + int width, + BlurHandler handler, + String labelOrientation) + { fromItem = new FloatItem(FIELD_FROM); toItem = new FloatItem(FIELD_TO); stepItem = new FloatItem(FIELD_WIDTH); @@ -96,7 +112,13 @@ stepItem.setWidth(itemWidth); stepText.setWidth(itemWidth); - setFields(fromItem, fromText, toItem, toText, stepItem, stepText); + if (labelOrientation.equals("right")) { + setFields(fromItem, fromText, toItem, toText, stepItem, stepText); + } + else { + setFields(fromText, fromItem, toText, toItem, stepText, stepItem); + } + setFixedColWidths(false); setNumCols(6); setWidth(width);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TextProvider.java Tue Jul 05 17:28:04 2011 +0000 @@ -0,0 +1,86 @@ +package de.intevation.flys.client.client.ui; + +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.layout.HLayout; + +import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataItem; +import de.intevation.flys.client.shared.model.DataList; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class TextProvider extends AbstractUIProvider { + + public static final String FIELD_NAME = "textprovider_inputfield"; + + protected DynamicForm form; + + + @Override + public Canvas create(DataList dataList) { + GWT.log("CREATE NEW TEXTPROVIDER PANEL"); + + return createForm(); + } + + + protected Canvas createForm() { + return createForm(null); + } + + + protected Canvas createForm(String title) { + HLayout layout = new HLayout(); + + if (title != null && title.length() > 0) { + Label label = new Label(title); + label.setHeight(25); + layout.addMember(label); + } + + form = new DynamicForm(); + layout.addMember(form); + + TextItem item = new TextItem(FIELD_NAME); + item.setShowTitle(false); + + form.setFields(item); + + return layout; + } + + + @Override + public Canvas createOld(DataList dataList) { + Data data = dataList.get(0); + DataItem[] items = data.getItems(); + + HLayout layout = new HLayout(); + Label label = new Label(dataList.getLabel()); + Label value = new Label(items[0].getLabel()); + + layout.setHeight(35); + layout.setWidth(400); + label.setWidth(200); + + layout.addMember(label); + layout.addMember(value); + layout.addMember(getBackButton(dataList.getState())); + + return layout; + } + + + @Override + protected Data[] getData() { + return new Data[0]; + } +} +// 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/UIProviderFactory.java Tue Jul 05 16:13:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Tue Jul 05 17:28:04 2011 +0000 @@ -22,6 +22,9 @@ else if (uiProvider.equals("distance_panel")) { return new DistancePanel(); } + else if (uiProvider.equals("waterlevel_ground_panel")) { + return new WaterlevelGroundPanel(); + } else if (uiProvider.equals("wq_panel")) { return new WQInputPanel(); } @@ -34,6 +37,15 @@ else if (uiProvider.equals("continue")) { return new ContinuePanel(); } + else if (uiProvider.equals("datacage_panel")) { + return new DatacagePanel(); + } + else if (uiProvider.equals("auto_integer")) { + return new AutoIntegerPanel(); + } + else if (uiProvider.equals("boolean_panel")) { + return new BooleanPanel(); + } else { 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/WaterlevelGroundPanel.java Tue Jul 05 17:28:04 2011 +0000 @@ -0,0 +1,68 @@ +package de.intevation.flys.client.client.ui; + +public class WaterlevelGroundPanel extends DistancePanel { + + public static final String FIELD_LOWER = "diff_from"; + public static final String FIELD_UPPER = "diff_to"; + public static final String FIELD_STEP = "diff_diff"; + + + public WaterlevelGroundPanel() { + super("left"); + } + + + @Override + protected String getLowerField() { + return FIELD_LOWER; + } + + + @Override + protected String getUpperField() { + return FIELD_UPPER; + } + + + @Override + protected String getStepField() { + return FIELD_STEP; + } + + + @Override + protected String getLabelFrom() { + return MSG.unitFromInM(); + } + + + @Override + protected String getLabelTo() { + return MSG.unitToInM(); + } + + + @Override + protected String getLabelStep() { + return MSG.unitDiffInM(); + } + + + @Override + protected double getDefaultFrom() { + return 0; + } + + + @Override + protected double getDefaultTo() { + return 0; + } + + + @Override + protected double getDefaultStep() { + return 0; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :