diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java	Wed Mar 09 09:41:45 2011 +0000
@@ -0,0 +1,123 @@
+package de.intevation.flys.client.client.ui;
+
+import com.google.gwt.core.client.GWT;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DefaultData;
+import de.intevation.flys.client.shared.model.DefaultDataItem;
+
+import de.intevation.flys.client.client.FLYSMessages;
+
+/**
+ * The ModuleSelection combines the river selection and the module selection in
+ * one widget. It will display a vertical splitted widget - the upper part will
+ * render checkboxes for each module, the lower one will display a combobox at
+ * the left and a map panel on the right to choose the river.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class ModuleSelection extends MapSelection {
+
+    /** The message class that provides i18n strings.*/
+    protected FLYSMessages MESSAGES = GWT.create(FLYSMessages.class);
+
+    /** The module checkboxes.*/
+    protected RadioGroupItem radio;
+
+
+    /**
+     * The default constructor.
+     */
+    public ModuleSelection() {
+    }
+
+
+    /**
+     * This method returns a widget that renders the checkboxes for each module
+     * and the MapSelection that lets the user choose the river.
+     *
+     * @param data The provided rivers.
+     *
+     * @return the module selection combined with the river selection.
+     */
+    public Canvas create(Data data) {
+        VLayout newLayout = new VLayout();
+        newLayout.setMembersMargin(10);
+
+        Canvas moduleSelection = createWidget();
+        Canvas riverSelection  = super.createWidget(data);
+        IButton go             = new IButton(MESSAGES.next(), this);
+
+        moduleSelection.setHeight(25);
+
+        newLayout.addMember(moduleSelection);
+        newLayout.addMember(riverSelection);
+        newLayout.addMember(go);
+
+        return newLayout;
+    }
+
+
+    /**
+     * Creates a widget that displays a checkbox for each module.
+     *
+     * @return a widget with checkboxes.
+     */
+    protected Canvas createWidget() {
+        HLayout layout = new HLayout();
+
+        Label      label = new Label(MESSAGES.module_selection());
+        DynamicForm form = new DynamicForm();
+
+        radio = new RadioGroupItem("plugin");
+
+        label.setWidth(50);
+
+        radio.setShowTitle(false);
+        radio.setVertical(false);
+        radio.setValueMap(
+            messages.winfo(),
+            messages.minfo(),
+            messages.map(),
+            messages.fix());
+
+        form.setFields(radio);
+
+        layout.addMember(label);
+        layout.addMember(form);
+
+        return layout;
+    }
+
+
+    /**
+     * This method prepares the data of two widgets - the module selection and
+     * the river selection. The returning field will contain the Data that
+     * represents the module selection at first position, the second position
+     * stores the Data object that represents the river selection.
+     *
+     * @return the Data that was chosen in this widget.
+     */
+    protected Data[] getData() {
+        Data[] river = super.getData();
+
+        String module = radio.getValueAsString();
+
+        DataItem[] items = new DefaultDataItem[1];
+        items[0]         = new DefaultDataItem(module, module, module);
+
+        Data       data  = new DefaultData("module", null, null, items, null);
+
+        return new Data[] {data, river[0]};
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org