diff flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java @ 788:dfbc6693247e

Integrated a stacked panel on the right side of the ParameterList that enables users to see calculation results and the helper panel at the same time. flys-client/trunk@2289 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 06 Jul 2011 12:31:32 +0000
parents 3ae0facd4cab
children e8be9a188e64
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Tue Jul 05 17:28:04 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Wed Jul 06 12:31:32 2011 +0000
@@ -9,9 +9,12 @@
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
 import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.types.VisibilityMode;
 import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.SectionStack;
+import com.smartgwt.client.widgets.layout.SectionStackSection;
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.tab.Tab;
 
@@ -99,8 +102,8 @@
     protected VLayout currentItems;
     protected VLayout exportModes;
     protected VLayout report;
-    protected Canvas  helperPanel;
-    protected Canvas  tablePanel;
+    protected VLayout helperPanel;
+    protected VLayout tablePanel;
     protected Canvas  reportPanel;
 
     public ParameterList(FLYS flys, CollectionView cView, String title) {
@@ -153,7 +156,6 @@
 
     protected void init() {
         HLayout rootLayout = new HLayout();
-        tablePanel = new Canvas();
         rootLayout.setMembersMargin(20);
 
         VLayout left = new VLayout();
@@ -177,13 +179,8 @@
         reportPanel.setHeight("*");
         report.addMember(reportPanel);
 
-        // This canvas is used to render helper widgets
-        helperPanel = new Canvas();
-        helperPanel.setWidth("*");
-        helperPanel.setHeight100();
-
         rootLayout.addMember(left);
-        rootLayout.addMember(helperPanel);
+        rootLayout.addMember(createSectionStack());
 
         topLayout.addMember(rootLayout);
         if (artifact == null) {
@@ -196,6 +193,56 @@
     }
 
 
+    protected SectionStack createSectionStack() {
+        SectionStack stack = new SectionStack();
+        stack.setHeight100();
+        stack.setCanResizeSections(true);
+        stack.setVisibilityMode(VisibilityMode.MULTIPLE);
+
+        // This canvas is used to render helper widgets
+        final SectionStackSection helperSection = new SectionStackSection();
+        helperSection.setExpanded(false);
+        helperSection.setTitle(MSG.helperPanelTitle());
+        helperPanel = new VLayout() {
+            public void addMember(Canvas component) {
+                super.addMember(component);
+                helperSection.setExpanded(true);
+            }
+
+            public void removeMembers(Canvas[] components) {
+                super.removeMembers(components);
+                helperSection.setExpanded(false);
+            }
+        };
+        helperPanel.setWidth100();
+        helperPanel.setHeight100();
+        helperSection.setItems(helperPanel);
+
+        // This canvas is used to render calculation results
+        final SectionStackSection tableSection = new SectionStackSection();
+        tableSection.setExpanded(false);
+        tableSection.setTitle(MSG.calcTableTitle());
+        tablePanel = new VLayout() {
+            public void addMember(Canvas component) {
+                super.addMember(component);
+                tableSection.setExpanded(true);
+            }
+
+            public void removeMembers(Canvas[] components) {
+                super.removeMembers(components);
+                tableSection.setExpanded(false);
+            }
+        };
+        tablePanel.setHeight100();
+        tablePanel.setWidth100();
+        tableSection.setItems(tablePanel);
+
+        stack.setSections(helperSection, tableSection);
+
+        return stack;
+    }
+
+
     protected void setArtifact(Artifact artifact) {
         Artifact tmp  = this.artifact;
         this.artifact = artifact;
@@ -517,8 +564,9 @@
     public void onParameterChange(ParameterChangeEvent event) {
         GWT.log("ParameterList.onParameterChange");
 
-        for (Canvas c: helperPanel.getChildren()) {
-            helperPanel.removeChild(c);
+        Canvas[] c = helperPanel.getMembers();
+        if (c != null && c.length > 0) {
+            helperPanel.removeMembers(c);
         }
 
         Artifact art             = event.getNewValue();
@@ -681,24 +729,33 @@
      *
      * @param table The table data panel.
      */
-    public void setPanel (TableDataPanel table) {
-        tablePanel = table.create();
-        tablePanel.setHeight100();
-        tablePanel.setWidth100();
-        helperPanel.addChild(tablePanel);
+    public void setTable(TableDataPanel table) {
+        removeTable();
+
+        Canvas c = table.create();
+        c.setHeight100();
+        c.setWidth100();
+
+        tablePanel.addMember(c);
+    }
+
+
+    public boolean hasTable() {
+        Canvas[] members = tablePanel.getMembers();
+
+        return members != null && members.length > 0;
     }
 
 
     /**
      * Removes the table from the parameter list.
      */
-    public void removePanel() {
-        topLayout.removeMember(tablePanel);
-    }
+    public void removeTable() {
+        Canvas[] members = tablePanel.getMembers();
 
-
-    public boolean hasPanel() {
-        return topLayout.hasMember(tablePanel);
+        if (members != null && members.length > 0) {
+            tablePanel.removeMembers(members);
+        }
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org