Mercurial > dive4elements > river
changeset 785:3ae0facd4cab
Added a panel that lets users step to a next state without feeding the current artifact with new data.
flys-client/trunk@2282 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Jul 04 07:15:44 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Tue Jul 05 16:12:34 2011 +0000 @@ -102,6 +102,8 @@ String river_km(); + String uesk_profile_distance(); + String location_distance_state(); String distance_state();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Jul 04 07:15:44 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Tue Jul 05 16:12:34 2011 +0000 @@ -55,6 +55,7 @@ type = Type wq_value = W/Q/D river_km = River-Km +uesk_profile_distance = Distance [m] wqTitle = Input for W/Q Data wqadaptedTitle = Input for W/Q Data
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Jul 04 07:15:44 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Tue Jul 05 16:12:34 2011 +0000 @@ -55,6 +55,7 @@ type = Typ wq_value = W/Q/D river_km = Fluss-Km +uesk_profile_distance = Abstand [m] wqTitle = Eingabe f\u00fcr W/Q Daten wqadaptedTitle = Eingabe f\u00fcr W/Q Daten
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Jul 04 07:15:44 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Tue Jul 05 16:12:34 2011 +0000 @@ -53,6 +53,7 @@ type = Type wq_value = W/Q/D river_km = River-Km +uesk_profile_distance = Distance [m] wqTitle = Input for W/Q Data wqadaptedTitle = Input for W/Q Data
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/AdvanceHandler.java Tue Jul 05 16:12:34 2011 +0000 @@ -0,0 +1,13 @@ +package de.intevation.flys.client.client.event; + +import java.io.Serializable; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public interface AdvanceHandler extends Serializable { + + public void onAdvance(String target); +} +// 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/ContinuePanel.java Tue Jul 05 16:12:34 2011 +0000 @@ -0,0 +1,94 @@ +package de.intevation.flys.client.client.ui; + +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.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.LinkItem; +import com.smartgwt.client.widgets.form.fields.events.ClickEvent; +import com.smartgwt.client.widgets.form.fields.events.ClickHandler; + +import de.intevation.flys.client.shared.model.ArtifactDescription; +import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataList; + +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.event.AdvanceHandler; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class ContinuePanel extends AbstractUIProvider { + + protected static FLYSConstants MSG = GWT.create(FLYSConstants.class); + + protected List<AdvanceHandler> advHandlers; + + + @Override + public Canvas create(DataList dataList) { + DynamicForm form = new DynamicForm(); + form.setWidth(200); + form.setHeight(35); + + LinkItem next = new LinkItem(); + next.setShowTitle(false); + next.setLinkTitle(MSG.next()); + + final ArtifactDescription desc = artifact.getArtifactDescription(); + final String[] reachable = desc.getReachableStates(); + + next.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent e) { + fireOnAdvance(reachable[0]); + } + }); + + form.setFields(next); + + return form; + } + + + @Override + public Canvas createOld(DataList dataList) { + Canvas c = new Canvas(); + c.setHeight(1); + c.setWidth(1); + + return c; + } + + + @Override + protected Data[] getData() { + return new Data[0]; + } + + + public void addAdvanceHandler(AdvanceHandler handler) { + if (advHandlers == null) { + advHandlers = new ArrayList<AdvanceHandler>(); + } + + if (handler != null) { + advHandlers.add(handler); + } + } + + + public void fireOnAdvance(String target) { + if (advHandlers == null || advHandlers.isEmpty()) { + return; + } + + for (AdvanceHandler handler: advHandlers) { + handler.onAdvance(target); + } + } +} +// 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 Mon Jul 04 07:15:44 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Tue Jul 05 16:12:34 2011 +0000 @@ -30,6 +30,7 @@ import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYS; import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.event.AdvanceHandler; import de.intevation.flys.client.client.event.CollectionChangeEvent; import de.intevation.flys.client.client.event.CollectionChangeHandler; import de.intevation.flys.client.client.event.HasParameterChangeHandler; @@ -57,7 +58,7 @@ extends Tab implements StepBackHandler, StepForwardHandler, ParameterChangeHandler, HasParameterChangeHandler, CollectionChangeHandler, - OutputModesChangeHandler + OutputModesChangeHandler, AdvanceHandler { /** The message class that provides i18n strings.*/ protected FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -329,6 +330,10 @@ public void addOldDatas(DataList[] old) { if (old != null && old.length > 0) { for (DataList o: old) { + if (o == null) { + continue; + } + if (!exists(o)) { GWT.log("Data '" + o.getLabel() + "' is new."); addOldData(o); @@ -343,6 +348,10 @@ public boolean exists(DataList data) { + if (data == null) { + return false; + } + String stateName = data.getState(); for (DataList o: old) { @@ -399,6 +408,10 @@ if (current != null && uiProvider != null) { Canvas c = uiProvider.create(current); + currentItems.addMember(c); + } + else if (uiProvider != null) { + Canvas c = uiProvider.create(null); c.setLayoutAlign(VerticalAlignment.TOP); currentItems.addMember(c); @@ -470,6 +483,31 @@ } + public void onAdvance(final String target) { + Config config = Config.getInstance(); + final String serverUrl = config.getServerUrl(); + final String locale = config.getLocale(); + + advanceService.advance(serverUrl, locale, artifact, target, + new AsyncCallback<Artifact>() { + public void onFailure(Throwable caught) { + GWT.log("Could not go to '" + target + "'"); + SC.warn(MSG.getString(caught.getMessage())); + } + + public void onSuccess(Artifact artifact) { + GWT.log("Successfully advanced to '" + target + "'"); + + old.clear(); + oldItems.removeMembers(oldItems.getMembers()); + + setArtifact(artifact); + } + } + ); + } + + /** * Implements the onCollectionChange() method to do update the GUI after the * parameterization has changed. @@ -501,8 +539,22 @@ setCurrentData(currentData, provider); } else { - // we have reached a final state with no more user input - setCurrentData(null, null); + String[] reachable = desc.getReachableStates(); + if (reachable != null && reachable.length > 0) { + // We have reached a final state with the option to step to + // further to a next state. But in the current state, no user + // data is required. + UIProvider ui = UIProviderFactory.getProvider("continue"); + ui.setArtifact(art); + + ((ContinuePanel) ui).addAdvanceHandler(this); + + setCurrentData(null, ui); + } + else { + // we have reached a final state with no more user input + setCurrentData(null, null); + } } addOldDatas(desc.getOldData());
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java Mon Jul 04 07:15:44 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java Tue Jul 05 16:12:34 2011 +0000 @@ -121,6 +121,7 @@ Label label = new Label(d.getDescription()); label.setValign(VerticalAlignment.TOP); label.setHeight(20); + label.setWidth(400); SelectItem combobox = new SelectItem(d.getLabel()); combobox.setWidth(250);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Mon Jul 04 07:15:44 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Tue Jul 05 16:12:34 2011 +0000 @@ -31,6 +31,9 @@ else if (uiProvider.equals("river_panel")) { return new LinkSelection(); } + else if (uiProvider.equals("continue")) { + return new ContinuePanel(); + } else { return new SelectProvider(); }