changeset 4270:cde9a6fe1844

Refactor ParameterList to use new InfoPanel base class By using the base class it will be possible to show either a gauge info or a measurement station info with only small adjustments.
author Björn Ricks <bjoern.ricks@intevation.de>
date Fri, 26 Oct 2012 12:26:01 +0200
parents 0c766c475805
children 6c776f102e03
files flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java
diffstat 1 files changed, 37 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Fri Oct 26 12:22:06 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Fri Oct 26 12:26:01 2012 +0200
@@ -112,7 +112,7 @@
     protected VLayout report;
     protected VLayout helperPanel;
     protected VLayout tablePanel;
-    protected GaugePanel gaugePanel;
+    protected InfoPanel infoPanel;
     protected Canvas  reportPanel;
 
     private SectionStack stack;
@@ -752,17 +752,11 @@
             }
         }
         if (art instanceof WINFOArtifact) {
-            String river = desc.getRiver();
-
-            if (river != null) {
-                renderGaugeInfo(desc.getRiver(), desc.getOldData());
-            }
-            else {
-                hideGaugePanel();
-            }
+            createGaugePanel();
+            renderInfo(desc.getRiver(), desc.getOldData());
         }
         else {
-            removeGaugePanel();
+            removeInfoPanel();
         }
 
         addOldDatas(
@@ -944,49 +938,51 @@
 
     private void createGaugePanel() {
         GWT.log("ParameterList - createGaugePanel");
-        if (gaugePanel == null) {
-            gaugePanel = new GaugePanel(flys);
-            gaugePanel.setWidth100();
-            gaugePanel.setHeight100();
+        if (infoPanel == null) {
+            infoPanel = new GaugePanel(flys);
+            infoPanel.setWidth100();
+            infoPanel.setHeight100();
         }
     }
 
-    private void addGaugePanel() {
-        GWT.log("ParameterList - addGaugePanel");
-        createGaugePanel();
-        stack.addSection(gaugePanel.getSection(), 0);
+    private void showInfoPanel() {
+        GWT.log("ParameterList - showInfoPanel");
+
+        /* Don't add InfoPanel twice */
+        SectionStackSection exists = stack.getSection(InfoPanel.SECTION_ID);
+        if (exists == null) {
+            stack.addSection(infoPanel.getSection(), 0);
+        }
+
+        infoPanel.show();
     }
 
-    private void showGaugePanel() {
-        GWT.log("ParameterList - showGaugePanel");
+    private void hideInfoPanel() {
+        GWT.log("ParameterList - hideInfoPanel");
 
-        /* Don't add GaugePanel twice */
-        SectionStackSection exists = stack.getSection(GaugePanel.SECTION_ID);
-        if (exists == null) {
-            addGaugePanel();
-        }
-
-        gaugePanel.show();
-    }
-
-    private void hideGaugePanel() {
-        GWT.log("ParameterList - hideGaugePanel");
-
-        if (gaugePanel != null) {
-            gaugePanel.hide();
+        if (infoPanel != null) {
+            infoPanel.hide();
         }
     }
 
-    private void removeGaugePanel() {
-        GWT.log("ParameterList - removeGaugePanel");
-        stack.removeSection(GaugePanel.SECTION_ID);
+    private void removeInfoPanel() {
+        GWT.log("ParameterList - removeInfoPanel");
+        stack.removeSection(InfoPanel.SECTION_ID);
     }
 
 
-    private void renderGaugeInfo(String river, DataList[] data) {
-        showGaugePanel();
-        gaugePanel.setRiver(river);
-        gaugePanel.setData(data);
+    private void renderInfo(String river, DataList[] data) {
+        GWT.log("ParameterList - renderInfo");
+
+        if (river != null) {
+            showInfoPanel();
+            infoPanel.setRiver(river);
+            infoPanel.setData(data);
+        }
+        else {
+            GWT.log("ParameterList - renderInfo no river");
+            hideInfoPanel();
+        }
     }
 
 }

http://dive4elements.wald.intevation.org