changeset 867:6a2ed979dfcf

Added new UIProvider "DatacageTwinPanel", pass user via UIProviderFactory. flys-client/trunk@2674 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 08 Sep 2011 11:12:21 +0000
parents 593e6c49c6ee
children 439068365cde
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.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 4 files changed, 114 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Sep 08 11:04:25 2011 +0000
+++ b/flys-client/ChangeLog	Thu Sep 08 11:12:21 2011 +0000
@@ -1,3 +1,18 @@
+2011-09-08	Felix Wolfsteller	<felix.wolfsteller@intevation.de> 
+
+	Added new UIProvider "DatacageTwinPanel"/ "datacage_twin_panel" (stub). As the
+	Datacage needs to know a user, Modified UIProviderFactory to accept user in
+	calls to getProvider.
+
+	* src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java:
+	  New. Display two DatacageWidgets.
+
+	* src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java
+	  (getProvider): Added "user" argument, create DatacageTwinPanel if asked to.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ParameterList.java:
+	  Pass user argument in call to UIProverFactory.getProvider().
+
 2011-09-08	Felix Wolfsteller	<felix.wolfsteller@intevation.de> 
 
 	Added w_differences translation.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java	Thu Sep 08 11:12:21 2011 +0000
@@ -0,0 +1,90 @@
+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.shared.model.User;
+
+import de.intevation.flys.client.client.FLYSConstants;
+
+// TODO Probably better to branch off AbstractUIProvider.
+public class DatacageTwinPanel extends TextProvider {
+
+    protected static FLYSConstants MSG = GWT.create(FLYSConstants.class);
+
+    protected String dataName;
+
+    protected User user;
+
+
+    public DatacageTwinPanel(User user) {
+        super();
+        this.user = user;
+    }
+
+
+    @Override
+    public Canvas create(DataList dataList) {
+        GWT.log("createData()");
+        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(50);
+        DatacageWidget baseDataCage = new DatacageWidget(this.artifact, user);
+        DatacageWidget modDataCage = new DatacageWidget(this.artifact, user);
+        baseDataCage.setHeight(250);
+        modDataCage.setHeight(250);
+        layout.addMember(baseDataCage);
+        layout.addMember(modDataCage);
+
+        /*layout.addMember(label);*/
+        layout.addMember(widget);
+        layout.addMember(submit);
+        layout.setMembersMargin(10);
+        this.helperContainer.addMember(layout);
+
+//        return layout;
+        return new VLayout();
+    }
+
+
+    public Canvas createWidget() {
+        HLayout layout = new HLayout();
+        layout.setMembersMargin(10);
+
+        layout.addMember(createForm());
+        layout.addMember(new DatacageWidget());
+        // TODO: fetch current user!
+        // TODO: fetch collection view!
+        /*layout.addMember(
+            new DatacageButton(
+                MSG.databasket(), artifact, null, null));
+                */
+
+        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/ParameterList.java	Thu Sep 08 11:04:25 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Thu Sep 08 11:12:21 2011 +0000
@@ -469,7 +469,7 @@
 
             if (oldStorage.get(state) == null) {
                 String     provider   = dataList.getUIProvider();
-                UIProvider uiprovider = UIProviderFactory.getProvider(provider);
+                UIProvider uiprovider = UIProviderFactory.getProvider(provider, flys.getCurrentUser());
                 ((HasStepBackHandlers) uiprovider).addStepBackHandler(this);
 
                 Canvas c = uiprovider.createOld(dataList);
@@ -671,7 +671,7 @@
         if (currentData != null) {
             // the user has to enter some attributes
             String uiProvider   = currentData.getUIProvider();
-            UIProvider provider = UIProviderFactory.getProvider(uiProvider);
+            UIProvider provider = UIProviderFactory.getProvider(uiProvider, flys.getCurrentUser());
 
             provider.setContainer(helperPanel);
             provider.setArtifact(art);
@@ -687,7 +687,7 @@
                 // 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");
+                UIProvider ui = UIProviderFactory.getProvider("continue", null);
                 ui.setArtifact(art);
 
                 ((ContinuePanel) ui).addAdvanceHandler(this);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java	Thu Sep 08 11:04:25 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java	Thu Sep 08 11:12:21 2011 +0000
@@ -1,11 +1,13 @@
 package de.intevation.flys.client.client.ui;
 
+import de.intevation.flys.client.shared.model.User;
+
 public class UIProviderFactory {
 
     private UIProviderFactory() {
     }
 
-    public static UIProvider getProvider(String uiProvider) {
+    public static UIProvider getProvider(String uiProvider, User user) {
       System.out.println("Provider: " + uiProvider);
         if (uiProvider == null || uiProvider.equals("")) {
             return new SelectProvider();
@@ -40,6 +42,9 @@
         else if (uiProvider.equals("datacage_panel")) {
             return new DatacagePanel();
         }
+        else if (uiProvider.equals("datacage_twin_panel")) {
+            return new DatacageTwinPanel(user);
+        }
         else if (uiProvider.equals("auto_integer")) {
             return new AutoIntegerPanel();
         }

http://dive4elements.wald.intevation.org