diff flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java @ 5815:2aabd9752d5e interaktive-karte

Initial interaction model for riverselection on image map.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 24 Apr 2013 15:14:56 +0200
parents 360e22afb98b
children
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java	Wed Apr 24 15:13:09 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java	Wed Apr 24 15:14:56 2013 +0200
@@ -8,7 +8,10 @@
 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.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
@@ -23,7 +26,10 @@
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.shared.model.Module;
 
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * The ModuleSelection combines the river selection and the module selection in
@@ -37,6 +43,9 @@
 
     private static final long serialVersionUID = -5634831815175543328L;
 
+    private List<String> fixRivers;
+    private List<String> minfoRivers;
+
     /** The message class that provides i18n strings.*/
     protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
 
@@ -46,6 +55,9 @@
     /** */
     protected Module[] modules;
 
+    /** */
+    protected Map<String, LinkItem> rivers;
+
     /** The ModuleService used to retrieve the available modules of a user.*/
     protected ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
 
@@ -54,6 +66,18 @@
      * The default constructor.
      */
     public ModuleSelection() {
+        rivers = null;
+        //TODO: put all the rivers into a config file, or something.
+        fixRivers = new ArrayList();
+        fixRivers.add("Rhein");
+        fixRivers.add("Elbe");
+        fixRivers.add("Donau");
+
+        minfoRivers = new ArrayList<String>();
+        minfoRivers.add("Elbe");
+        minfoRivers.add("Rhein");
+        minfoRivers.add("Oder");
+
         readModules();
     }
 
@@ -134,6 +158,25 @@
 
         radio = new RadioGroupItem("plugin");
 
+        radio.addChangeHandler(new ChangeHandler() {
+            @Override
+            public void onChange(ChangeEvent event) {
+                String selected = (String)event.getValue();
+                if (!rivers.isEmpty()) {
+                    for (Map.Entry<String, LinkItem> s: rivers.entrySet()) {
+                        if (selected.equals("minfo") && !minfoRivers.contains(s.getKey())) {
+                            s.getValue().hide();
+                        }
+                        else if (selected.equals("fixanalysis") && !fixRivers.contains(s.getKey())) {
+                            s.getValue().hide();
+                        }
+                        else {
+                            s.getValue().show();
+                        }
+                    }
+                }
+            }
+        });
         label.setWidth(50);
         label.setHeight(25);
 
@@ -172,5 +215,9 @@
 
         return new Data[] {data};
     }
+    
+    public void setRivers(Map<String, LinkItem> rivers) {
+        this.rivers = rivers;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org