Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
5814:f145a0ce38f2 | 5815:2aabd9752d5e |
---|---|
6 import com.smartgwt.client.types.VerticalAlignment; | 6 import com.smartgwt.client.types.VerticalAlignment; |
7 import com.smartgwt.client.util.SC; | 7 import com.smartgwt.client.util.SC; |
8 import com.smartgwt.client.widgets.Canvas; | 8 import com.smartgwt.client.widgets.Canvas; |
9 import com.smartgwt.client.widgets.Label; | 9 import com.smartgwt.client.widgets.Label; |
10 import com.smartgwt.client.widgets.form.DynamicForm; | 10 import com.smartgwt.client.widgets.form.DynamicForm; |
11 import com.smartgwt.client.widgets.form.fields.LinkItem; | |
11 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; | 12 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; |
13 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; | |
14 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; | |
12 import com.smartgwt.client.widgets.layout.HLayout; | 15 import com.smartgwt.client.widgets.layout.HLayout; |
13 import com.smartgwt.client.widgets.layout.VLayout; | 16 import com.smartgwt.client.widgets.layout.VLayout; |
14 | 17 |
15 import de.intevation.flys.client.client.Config; | 18 import de.intevation.flys.client.client.Config; |
16 import de.intevation.flys.client.client.FLYSConstants; | 19 import de.intevation.flys.client.client.FLYSConstants; |
21 import de.intevation.flys.client.shared.model.DataList; | 24 import de.intevation.flys.client.shared.model.DataList; |
22 import de.intevation.flys.client.shared.model.DefaultData; | 25 import de.intevation.flys.client.shared.model.DefaultData; |
23 import de.intevation.flys.client.shared.model.DefaultDataItem; | 26 import de.intevation.flys.client.shared.model.DefaultDataItem; |
24 import de.intevation.flys.client.shared.model.Module; | 27 import de.intevation.flys.client.shared.model.Module; |
25 | 28 |
29 import java.util.ArrayList; | |
26 import java.util.LinkedHashMap; | 30 import java.util.LinkedHashMap; |
31 import java.util.List; | |
32 import java.util.Map; | |
27 | 33 |
28 /** | 34 /** |
29 * The ModuleSelection combines the river selection and the module selection in | 35 * The ModuleSelection combines the river selection and the module selection in |
30 * one widget. It will display a vertical splitted widget - the upper part will | 36 * one widget. It will display a vertical splitted widget - the upper part will |
31 * render checkboxes for each module, the lower one will display a combobox at | 37 * render checkboxes for each module, the lower one will display a combobox at |
35 */ | 41 */ |
36 public class ModuleSelection extends MapSelection { | 42 public class ModuleSelection extends MapSelection { |
37 | 43 |
38 private static final long serialVersionUID = -5634831815175543328L; | 44 private static final long serialVersionUID = -5634831815175543328L; |
39 | 45 |
46 private List<String> fixRivers; | |
47 private List<String> minfoRivers; | |
48 | |
40 /** The message class that provides i18n strings.*/ | 49 /** The message class that provides i18n strings.*/ |
41 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); | 50 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); |
42 | 51 |
43 /** The module checkboxes.*/ | 52 /** The module checkboxes.*/ |
44 protected RadioGroupItem radio; | 53 protected RadioGroupItem radio; |
45 | 54 |
46 /** */ | 55 /** */ |
47 protected Module[] modules; | 56 protected Module[] modules; |
48 | 57 |
58 /** */ | |
59 protected Map<String, LinkItem> rivers; | |
60 | |
49 /** The ModuleService used to retrieve the available modules of a user.*/ | 61 /** The ModuleService used to retrieve the available modules of a user.*/ |
50 protected ModuleServiceAsync moduleService = GWT.create(ModuleService.class); | 62 protected ModuleServiceAsync moduleService = GWT.create(ModuleService.class); |
51 | 63 |
52 | 64 |
53 /** | 65 /** |
54 * The default constructor. | 66 * The default constructor. |
55 */ | 67 */ |
56 public ModuleSelection() { | 68 public ModuleSelection() { |
69 rivers = null; | |
70 //TODO: put all the rivers into a config file, or something. | |
71 fixRivers = new ArrayList(); | |
72 fixRivers.add("Rhein"); | |
73 fixRivers.add("Elbe"); | |
74 fixRivers.add("Donau"); | |
75 | |
76 minfoRivers = new ArrayList<String>(); | |
77 minfoRivers.add("Elbe"); | |
78 minfoRivers.add("Rhein"); | |
79 minfoRivers.add("Oder"); | |
80 | |
57 readModules(); | 81 readModules(); |
58 } | 82 } |
59 | 83 |
60 | 84 |
61 /** | 85 /** |
132 Label label = new Label(MESSAGES.module_selection()); | 156 Label label = new Label(MESSAGES.module_selection()); |
133 DynamicForm form = new DynamicForm(); | 157 DynamicForm form = new DynamicForm(); |
134 | 158 |
135 radio = new RadioGroupItem("plugin"); | 159 radio = new RadioGroupItem("plugin"); |
136 | 160 |
161 radio.addChangeHandler(new ChangeHandler() { | |
162 @Override | |
163 public void onChange(ChangeEvent event) { | |
164 String selected = (String)event.getValue(); | |
165 if (!rivers.isEmpty()) { | |
166 for (Map.Entry<String, LinkItem> s: rivers.entrySet()) { | |
167 if (selected.equals("minfo") && !minfoRivers.contains(s.getKey())) { | |
168 s.getValue().hide(); | |
169 } | |
170 else if (selected.equals("fixanalysis") && !fixRivers.contains(s.getKey())) { | |
171 s.getValue().hide(); | |
172 } | |
173 else { | |
174 s.getValue().show(); | |
175 } | |
176 } | |
177 } | |
178 } | |
179 }); | |
137 label.setWidth(50); | 180 label.setWidth(50); |
138 label.setHeight(25); | 181 label.setHeight(25); |
139 | 182 |
140 | 183 |
141 radio.setShowTitle(false); | 184 radio.setShowTitle(false); |
170 | 213 |
171 Data data = new DefaultData("module", null, null, items); | 214 Data data = new DefaultData("module", null, null, items); |
172 | 215 |
173 return new Data[] {data}; | 216 return new Data[] {data}; |
174 } | 217 } |
218 | |
219 public void setRivers(Map<String, LinkItem> rivers) { | |
220 this.rivers = rivers; | |
221 } | |
175 } | 222 } |
176 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 223 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |