comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java @ 30:5709bd8f4d7c

Added a new widget that combines the module and the river selection. Users can now choose the desired plugin and river in one step. flys-client/trunk@1433 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 09 Mar 2011 09:41:45 +0000
parents
children 7142386e86c2
comparison
equal deleted inserted replaced
29:44c63e7fd0d0 30:5709bd8f4d7c
1 package de.intevation.flys.client.client.ui;
2
3 import com.google.gwt.core.client.GWT;
4
5 import com.smartgwt.client.widgets.Canvas;
6 import com.smartgwt.client.widgets.IButton;
7 import com.smartgwt.client.widgets.Label;
8 import com.smartgwt.client.widgets.form.DynamicForm;
9 import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
10 import com.smartgwt.client.widgets.layout.HLayout;
11 import com.smartgwt.client.widgets.layout.VLayout;
12
13 import de.intevation.flys.client.shared.model.Data;
14 import de.intevation.flys.client.shared.model.DataItem;
15 import de.intevation.flys.client.shared.model.DefaultData;
16 import de.intevation.flys.client.shared.model.DefaultDataItem;
17
18 import de.intevation.flys.client.client.FLYSMessages;
19
20 /**
21 * The ModuleSelection combines the river selection and the module selection in
22 * one widget. It will display a vertical splitted widget - the upper part will
23 * render checkboxes for each module, the lower one will display a combobox at
24 * the left and a map panel on the right to choose the river.
25 *
26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
27 */
28 public class ModuleSelection extends MapSelection {
29
30 /** The message class that provides i18n strings.*/
31 protected FLYSMessages MESSAGES = GWT.create(FLYSMessages.class);
32
33 /** The module checkboxes.*/
34 protected RadioGroupItem radio;
35
36
37 /**
38 * The default constructor.
39 */
40 public ModuleSelection() {
41 }
42
43
44 /**
45 * This method returns a widget that renders the checkboxes for each module
46 * and the MapSelection that lets the user choose the river.
47 *
48 * @param data The provided rivers.
49 *
50 * @return the module selection combined with the river selection.
51 */
52 public Canvas create(Data data) {
53 VLayout newLayout = new VLayout();
54 newLayout.setMembersMargin(10);
55
56 Canvas moduleSelection = createWidget();
57 Canvas riverSelection = super.createWidget(data);
58 IButton go = new IButton(MESSAGES.next(), this);
59
60 moduleSelection.setHeight(25);
61
62 newLayout.addMember(moduleSelection);
63 newLayout.addMember(riverSelection);
64 newLayout.addMember(go);
65
66 return newLayout;
67 }
68
69
70 /**
71 * Creates a widget that displays a checkbox for each module.
72 *
73 * @return a widget with checkboxes.
74 */
75 protected Canvas createWidget() {
76 HLayout layout = new HLayout();
77
78 Label label = new Label(MESSAGES.module_selection());
79 DynamicForm form = new DynamicForm();
80
81 radio = new RadioGroupItem("plugin");
82
83 label.setWidth(50);
84
85 radio.setShowTitle(false);
86 radio.setVertical(false);
87 radio.setValueMap(
88 messages.winfo(),
89 messages.minfo(),
90 messages.map(),
91 messages.fix());
92
93 form.setFields(radio);
94
95 layout.addMember(label);
96 layout.addMember(form);
97
98 return layout;
99 }
100
101
102 /**
103 * This method prepares the data of two widgets - the module selection and
104 * the river selection. The returning field will contain the Data that
105 * represents the module selection at first position, the second position
106 * stores the Data object that represents the river selection.
107 *
108 * @return the Data that was chosen in this widget.
109 */
110 protected Data[] getData() {
111 Data[] river = super.getData();
112
113 String module = radio.getValueAsString();
114
115 DataItem[] items = new DefaultDataItem[1];
116 items[0] = new DefaultDataItem(module, module, module);
117
118 Data data = new DefaultData("module", null, null, items, null);
119
120 return new Data[] {data, river[0]};
121 }
122 }
123 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org