Mercurial > dive4elements > river
changeset 282:e92f7ef455d6
Show rivers as links instead of a combobox.
flys-client/trunk@1911 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 12 May 2011 14:59:18 +0000 |
parents | c271012a97a3 |
children | 08eef8a047eb |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/LinkSelection.java flys-client/src/main/java/de/intevation/flys/client/client/ui/MapSelection.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java |
diffstat | 6 files changed, 212 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Thu May 12 09:59:29 2011 +0000 +++ b/flys-client/ChangeLog Thu May 12 14:59:18 2011 +0000 @@ -1,3 +1,14 @@ +2011-05-12 Raimund Renkert <rrenkert@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/LinkSelection.java: + New. Shows a list of rivers displayed as links. + + * src/main/java/de/intevation/flys/client/client/ui/ParameterList.java, + src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java, + src/main/java/de/intevation/flys/client/client/ui/MapSelection.java, + src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java: + Use the new Panel to show rivers as links. + 2011-05-12 Ingo Weinzierl <ingo@intevation.de> ISSUE-15
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LinkSelection.java Thu May 12 14:59:18 2011 +0000 @@ -0,0 +1,175 @@ +package de.intevation.flys.client.client.ui; + +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.LinkItem; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.form.fields.events.ClickHandler; +import com.smartgwt.client.widgets.form.fields.events.ClickEvent; + +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.event.StepForwardEvent; + +import de.intevation.flys.client.client.FLYSConstants; + + +/** + * This UIProvider displays the DataItems of the Data object in a list of links. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class LinkSelection +extends MapSelection +{ + /** The message class that provides i18n strings.*/ + protected FLYSConstants messages = GWT.create(FLYSConstants.class); + + /** The combobox.*/ + protected DynamicForm form; + + /** The selected river*/ + protected Data river; + + /** + * This method currently returns a + * {@link com.smartgwt.client.widgets.form.DynamicForm} that contains all + * data items in a list of links stored in <i>data</i>. + * + * @param data The {@link Data} object. + * + * @return a combobox. + */ + public Canvas create(DataList data) { + VLayout v = new VLayout(); + v.setMembersMargin(10); + v.setAlign(VerticalAlignment.TOP); + GWT.log("-------datastate: "+ data.getState()); + if (data.getState() == null) { + Canvas module = super.createWidget(data); + v.addMember(module); + } + Canvas content = createWidget(data); + v.addMember(content); + + return v; + } + + + public Canvas createOld(DataList dataList) { + HLayout layout = new HLayout(); + VLayout vLayout = new VLayout(); + layout.setWidth("400px"); + + Label label = new Label(dataList.getLabel()); + label.setWidth("200px"); + + int size = dataList.size(); + for (int i = 0; i < size; i++) { + Data data = dataList.get(i); + DataItem[] items = data.getItems(); + + for (DataItem item: items) { + HLayout hLayout = new HLayout(); + + hLayout.addMember(label); + hLayout.addMember(new Label(item.getLabel())); + + vLayout.addMember(hLayout); + vLayout.setWidth("130px"); + } + } + + Canvas back = getBackButton(dataList.getState()); + + layout.addMember(label); + layout.addMember(vLayout); + layout.addMember(back); + + return layout; + } + + + /** + * This method creates the content of the widget. + * + * @param data The {@link Data} object. + * + * @return a list of links + */ + protected Canvas createWidget(DataList data) { + GWT.log("LinkSelection - create()"); + + VLayout layout = new VLayout(); + layout.setAlign(VerticalAlignment.TOP); + layout.setHeight(25); + + + form = new DynamicForm(); + VLayout formLayout = new VLayout(); + + formLayout.setLayoutLeftMargin(60); + int size = data.size(); + + for (int i = 0; i < size; i++) { + Data d = data.get(i); + + Label label = new Label(d.getDescription()); + label.setValign(VerticalAlignment.TOP); + label.setHeight(20); + + for (DataItem item: d.getItems()) { + LinkItem link = new LinkItem("river"); + link.setLinkTitle(item.getLabel()); + link.setTarget(item.getStringValue()); + link.setShowTitle(false); + DynamicForm f = new DynamicForm(); + f.setItems(link); + formLayout.addMember(f); + link.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + DataItem item = new DefaultDataItem( + ((LinkItem)event.getItem()).getLinkTitle(), + null, + ((LinkItem)event.getItem()).getLinkTitle()); + + river = new DefaultData( + "river", + null, + null, + new DataItem [] {item}); + fireStepForwardEvent (new StepForwardEvent (getData())); + } + }); + + } + label.setWidth(50); + + layout.addMember(label); + layout.addMember(formLayout); + } + layout.setAlign(VerticalAlignment.TOP); + + return layout; + } + + + protected Data[] getData() { + Data[] module = super.getData(); + if (module != null) { + return new Data[] {module[0], river}; + } + else { + return new Data[] {river}; + } + } +} +// 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/MapSelection.java Thu May 12 09:59:29 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MapSelection.java Thu May 12 14:59:18 2011 +0000 @@ -10,6 +10,8 @@ import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.client.FLYSImages; +import de.intevation.flys.client.client.event.HasStepForwardHandlers; +import de.intevation.flys.client.shared.model.Data; /** @@ -24,6 +26,7 @@ /** The interface that provides the image resources. */ private FLYSImages IMAGES = GWT.create(FLYSImages.class); + protected ModuleSelection moduleSelection; public MapSelection() { } @@ -46,8 +49,10 @@ HLayout h = new HLayout(); h.setAlign(VerticalAlignment.TOP); + h.setHeight(100); + moduleSelection = new ModuleSelection(); - Canvas form = super.createWidget(data); + Canvas form = moduleSelection.create(data); form.setWidth(250); form.setLayoutAlign(VerticalAlignment.TOP); @@ -61,5 +66,14 @@ return h; } + + protected Data[] getData() { + if (moduleSelection != null) { + return moduleSelection.getData(); + } + else { + return null; + } + } } // 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/ModuleSelection.java Thu May 12 09:59:29 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java Thu May 12 14:59:18 2011 +0000 @@ -17,6 +17,7 @@ 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.event.HasStepForwardHandlers; import de.intevation.flys.client.client.FLYSConstants; @@ -75,19 +76,12 @@ public Canvas create(DataList data) { VLayout newLayout = new VLayout(); newLayout.setMembersMargin(10); - //newLayout.setAlign(VerticalAlignment.TOP); - + newLayout.setAlign(VerticalAlignment.TOP); Canvas moduleSelection = createWidget(); - Canvas riverSelection = super.createWidget(data); - Canvas go = getNextButton(); - //go.setLayoutAlign(VerticalAlignment.TOP); - riverSelection.setHeight(25); - moduleSelection.setHeight(25); - + moduleSelection.setHeight(100); + newLayout.setHeight(70); newLayout.addMember(moduleSelection); - newLayout.addMember(riverSelection); - newLayout.addMember(go); return newLayout; } @@ -107,6 +101,7 @@ radio = new RadioGroupItem("plugin"); label.setWidth(50); + label.setHeight(25); LinkedHashMap values = new LinkedHashMap(); values.put(FIELD_PLUGIN_WINFO, messages.winfo()); @@ -141,7 +136,6 @@ * @return the Data that was chosen in this widget. */ protected Data[] getData() { - Data[] river = super.getData(); String module = radio.getValueAsString(); @@ -150,7 +144,7 @@ Data data = new DefaultData("module", null, null, items); - return new Data[] {data, river[0]}; + return new Data[] {data}; } } // 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/ParameterList.java Thu May 12 09:59:29 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Thu May 12 14:59:18 2011 +0000 @@ -229,7 +229,7 @@ null, items); - ModuleSelection widget = new ModuleSelection(); + LinkSelection widget = new LinkSelection(); HasStepForwardHandlers handler = (HasStepForwardHandlers) widget; widget.setContainer(helperPanel);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Thu May 12 09:59:29 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Thu May 12 14:59:18 2011 +0000 @@ -6,6 +6,7 @@ } public static UIProvider getProvider(String uiProvider) { + System.out.println("Provider: " + uiProvider); if (uiProvider == null || uiProvider.equals("")) { return new SelectProvider(); } @@ -24,6 +25,9 @@ else if (uiProvider.equals("wq_panel_adapted")) { return new WQAdaptedInputPanel(); } + else if (uiProvider.equals("river_panel")) { + return new LinkSelection(); + } else { return new SelectProvider(); }