annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ModuleSelection.java @ 8872:60278b5fe4d9

Just c comment describing an existing bug
author gernotbelger
date Wed, 07 Feb 2018 12:03:21 +0100
parents c26fb37899ca
children 7ebe5d463740
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5967
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5967
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.client.ui;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
11 import java.util.Collection;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
12 import java.util.HashMap;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
13 import java.util.LinkedHashMap;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
14 import java.util.LinkedList;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
15 import java.util.List;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
16 import java.util.Map;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
17 import java.util.Map.Entry;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
19 import org.dive4elements.river.client.client.Config;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
20 import org.dive4elements.river.client.client.FLYSConstants;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
21 import org.dive4elements.river.client.client.services.ModuleService;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.river.client.client.services.ModuleServiceAsync;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
23 import org.dive4elements.river.client.shared.model.Data;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
24 import org.dive4elements.river.client.shared.model.DataItem;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
25 import org.dive4elements.river.client.shared.model.DataList;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
26 import org.dive4elements.river.client.shared.model.DefaultData;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
27 import org.dive4elements.river.client.shared.model.DefaultDataItem;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
28 import org.dive4elements.river.client.shared.model.Module;
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
29 import org.dive4elements.river.client.shared.model.ModuleGroup;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
31 import com.google.gwt.core.client.GWT;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
32 import com.google.gwt.user.client.rpc.AsyncCallback;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
33 import com.smartgwt.client.types.VerticalAlignment;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
34 import com.smartgwt.client.util.SC;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
35 import com.smartgwt.client.widgets.Canvas;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
36 import com.smartgwt.client.widgets.Label;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
37 import com.smartgwt.client.widgets.form.DynamicForm;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
38 import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
39 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
40 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
41 import com.smartgwt.client.widgets.layout.HLayout;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
42 import com.smartgwt.client.widgets.layout.LayoutSpacer;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
43 import com.smartgwt.client.widgets.layout.VLayout;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 /**
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 * The ModuleSelection combines the river selection and the module selection in
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 * one widget. It will display a vertical splitted widget - the upper part will
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 * render checkboxes for each module, the lower one will display a combobox at
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 * the left and a map panel on the right to choose the river.
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 *
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 */
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 public class ModuleSelection extends MapSelection {
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
4131
360e22afb98b Cosmetics, warnings and minor TODOs.
Christian Lins <christian.lins@intevation.de>
parents: 3530
diff changeset
55 private static final long serialVersionUID = -5634831815175543328L;
360e22afb98b Cosmetics, warnings and minor TODOs.
Christian Lins <christian.lins@intevation.de>
parents: 3530
diff changeset
56
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 /** The message class that provides i18n strings.*/
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
58 private FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
3518
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
59
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
60 /** The ModuleService used to retrieve the available modules of a user.*/
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
61 private ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
63 private Map<String, List<String> > modulesRiverMap = new LinkedHashMap<String, List<String> >();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
64
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
65 private Map<String, Module> modulesByName = new HashMap<String, Module>();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
66
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
67 private Map<ModuleGroup, List<Module>> modulesByGroup = new LinkedHashMap<ModuleGroup, List<Module>>();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
68
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
69 private Map<ModuleGroup, RadioGroupItem> groupToRadios = new LinkedHashMap<ModuleGroup, RadioGroupItem>();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
70
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
71 private Map<ModuleGroup, Canvas> groupToCanvas = new LinkedHashMap<ModuleGroup, Canvas>();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
72
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
73 private Map<String, HLayout> rivers = null;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
74
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
75 private VLayout radioPanel;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
76
8872
60278b5fe4d9 Just c comment describing an existing bug
gernotbelger
parents: 8870
diff changeset
77 /* TODO: seems that it needs to be static for the callback, is this really necessary?
60278b5fe4d9 Just c comment describing an existing bug
gernotbelger
parents: 8870
diff changeset
78 * FIXME: this is (most probable) the reason for the following bug:
60278b5fe4d9 Just c comment describing an existing bug
gernotbelger
parents: 8870
diff changeset
79 * - open two different new projects
60278b5fe4d9 Just c comment describing an existing bug
gernotbelger
parents: 8870
diff changeset
80 * - select in both windows two differenz modules (e.g. w-info in the first, m-info in the second)
60278b5fe4d9 Just c comment describing an existing bug
gernotbelger
parents: 8870
diff changeset
81 * - now click on a river in each window
60278b5fe4d9 Just c comment describing an existing bug
gernotbelger
parents: 8870
diff changeset
82 * ---> both windows will now show the calculations of the same module (i.e. either both m-info, or both w-info; not one m-info the the other w-info as it should).
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
83 * */
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
84 private static Module selectedModule = null;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
85
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 public ModuleSelection() {
3518
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
87 readModules();
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 /**
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 * This method returns a widget that renders the checkboxes for each module
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 * and the MapSelection that lets the user choose the river.
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 *
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 * @param data The provided rivers.
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 *
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 * @return the module selection combined with the river selection.
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 */
4131
360e22afb98b Cosmetics, warnings and minor TODOs.
Christian Lins <christian.lins@intevation.de>
parents: 3530
diff changeset
98 @Override
51
a2923d63f530 Introduced a data structure DataList to manage to list of Data objects of a single state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 45
diff changeset
99 public Canvas create(DataList data) {
3518
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
100 GWT.log("ModuleSelection - create()");
6133
3ff2a4317167 Added JavaScript callback to get the selected module in native JavaScript code.
Raimund Renkert <rrenkert@intevation.de>
parents: 6119
diff changeset
101 createCallback();
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 VLayout newLayout = new VLayout();
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 newLayout.setMembersMargin(10);
282
e92f7ef455d6 Show rivers as links instead of a combobox.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 211
diff changeset
104 newLayout.setAlign(VerticalAlignment.TOP);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 Canvas moduleSelection = createWidget();
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106
282
e92f7ef455d6 Show rivers as links instead of a combobox.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 211
diff changeset
107 moduleSelection.setHeight(100);
e92f7ef455d6 Show rivers as links instead of a combobox.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 211
diff changeset
108 newLayout.setHeight(70);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 newLayout.addMember(moduleSelection);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 return newLayout;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
3518
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
114 private void readModules() {
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
115 Config config = Config.getInstance();
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
116 String locale = config.getLocale();
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
117
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
118 moduleService.list(locale, new AsyncCallback<Module[]>() {
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
119 @Override
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
120 public void onFailure(Throwable caught) {
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
121 GWT.log("Could not recieve a list of modules.");
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
122 SC.warn(MSG.getString(caught.getMessage()));
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
123 }
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
124
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
125 @Override
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
126 public void onSuccess(Module[] newmodules) {
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
127 GWT.log("Retrieved " + newmodules.length + " modules.");
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
128 setModules(newmodules);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
129 updateRadioPanels();
3518
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
130 }
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
131 });
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
132 }
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
133
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
134 // TODO: bad. Too much knowledge spread over the application.
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
135 // TODO: instead, e.g. use a controller that knows both (ModuleSelection and LinkSelection) and let him do this kind of things
8528
f7d1a7e66b12 (issue1795) Handle modules configuration for any module
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7763
diff changeset
136 private void checkRivers(String selected) {
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
137 if (rivers == null || rivers.isEmpty() || /*modules == null || */ selected == null )
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
138 return;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
139
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
140 final List<String> allowedRivers = modulesRiverMap.get(selected);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
141 if ( allowedRivers == null )
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
142 GWT.log("No configured rivers for module: " + selected);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
143
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
144 for (final Map.Entry<String, HLayout> s: rivers.entrySet()) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
145 if (allowedRivers == null || !allowedRivers.contains(s.getKey())) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
146 s.getValue().hide();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
147 } else {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
148 s.getValue().show();
8528
f7d1a7e66b12 (issue1795) Handle modules configuration for any module
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7763
diff changeset
149 }
f7d1a7e66b12 (issue1795) Handle modules configuration for any module
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7763
diff changeset
150 }
f7d1a7e66b12 (issue1795) Handle modules configuration for any module
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7763
diff changeset
151 }
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
152
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
153 protected final void setModules(Module[] newmodules) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
154 modulesRiverMap.clear();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
155
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
156 if( newmodules == null )
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
157 return;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
158
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
159 for(final Module module : newmodules) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
160 final String name = module.getName();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
161
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
162 /* remember rivers per module */
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
163 modulesRiverMap.put(name, module.getRivers());
3530
8c9c202292fe Set the default value of the RadioGroupItem if a loaded module is selected
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3518
diff changeset
164
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
165 /* hash by name */
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
166 modulesByName.put(name, module);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
167
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
168 /* hash by group */
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
169 final ModuleGroup group = module.getGroup();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
170 if( !modulesByGroup.containsKey( group ) )
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
171 modulesByGroup.put(group, new LinkedList<Module>());
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
172
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
173 final List<Module> modulesGroup = modulesByGroup.get(group);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
174 modulesGroup.add(module);
3518
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
175 }
33ed40aa1201 User ModuleService to get all modules for a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2522
diff changeset
176 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 /**
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 * Creates a widget that displays a checkbox for each module.
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180 *
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 * @return a widget with checkboxes.
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 */
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 protected Canvas createWidget() {
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
184
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
185 final HLayout layout = new HLayout();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
186
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
187 radioPanel = new VLayout();
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
189 final Label label = new Label(MESSAGES.module_selection());
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 label.setWidth(50);
282
e92f7ef455d6 Show rivers as links instead of a combobox.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 211
diff changeset
191 label.setHeight(25);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 layout.addMember(label);
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
194 layout.addMember(radioPanel);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
195
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
196 updateRadioPanels();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
197
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 return layout;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
201 protected final void updateRadioPanels() {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
202
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
203 /* first clear existing panels, if any exist */
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
204 final Collection<Canvas> oldforms = groupToCanvas.values();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
205 for (Canvas oldCanvas : oldforms) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
206 radioPanel.removeMember(oldCanvas);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
207 oldCanvas.destroy();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
208 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
209
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
210 groupToCanvas.clear();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
211 groupToRadios.clear();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
212 selectedModule = null;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
213
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
214 if( radioPanel == null )
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
215 return;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
216
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
217 /* now create radio items per group */
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
218 int count = 0;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
219 for (final Entry<ModuleGroup, List<Module>> groupEntry : modulesByGroup.entrySet()) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
220
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
221 final ModuleGroup group = groupEntry.getKey();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
222 final List<Module> groupModule = groupEntry.getValue();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
223
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
224 final HLayout groupPanel = new HLayout();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
225
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
226 if( group.showGroupFrame() )
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
227 {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
228 final LayoutSpacer spacer = new LayoutSpacer();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
229 spacer.setWidth(25);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
230 groupPanel.addMember(spacer);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
231
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
232 final Label label = new Label(group.toString());
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
233 label.setWidth(25);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
234 label.setHeight(25);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
235 groupPanel.addMember(label);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
236 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
237
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
238 final DynamicForm groupForm = new DynamicForm();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
239
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
240 final RadioGroupItem moduleRadio = new RadioGroupItem("modulegroup" + count++);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
241 moduleRadio.setShowTitle(false);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
242 moduleRadio.setVertical(true);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
243
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
244 moduleRadio.addChangeHandler(new ChangeHandler() {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
245 @Override
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
246 public void onChange(ChangeEvent event) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
247 final String selectedModuleName = (String) event.getValue();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
248 handleModuleSelected(selectedModuleName);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
249 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
250 });
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
251
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
252 groupForm.setItems(moduleRadio);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
253 groupPanel.addMember(groupForm);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
254
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
255 final LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
256 for(final Module module : groupModule) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
257 values.put(module.getName(), module.getLocalizedName());
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
258 if (module.isSelected()) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
259 GWT.log("Module " + module.getName() + " is selected.");
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
260 selectedModule = module;
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
261 moduleRadio.setValue(module.getName());
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
262 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
263 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
264
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
265 this.groupToRadios.put( group, moduleRadio );
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
266 this.groupToCanvas.put( group, groupPanel );
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
267
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
268 moduleRadio.setValueMap(values);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
269
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
270
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
271 radioPanel.addMember(groupPanel);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
272 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
273
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
274 checkRivers(getSelectedModule());
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
275 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
276
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
277 protected void handleModuleSelected(final String selectedModuleName) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
278
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
279 /* remember selected module for later */
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
280 selectedModule = modulesByName.get(selectedModuleName);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
281
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
282 /* because radios might in different radio-groups, we need to de-select them manually */
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
283 final ModuleGroup group = selectedModule.getGroup();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
284
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
285 for (final Entry<ModuleGroup, RadioGroupItem> entry : groupToRadios.entrySet()) {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
286 final ModuleGroup radioGroup = entry.getKey();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
287
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
288 if( !group.equals(radioGroup))
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
289 {
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
290 final RadioGroupItem groupRadio = entry.getValue();
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
291 groupRadio.setValue((String)null);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
292 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
293 }
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
294
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
295 checkRivers(selectedModuleName);
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
296 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
297
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298 /**
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
299 * This method prepares the data of two widgets - the module selection and
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
300 * the river selection. The returning field will contain the Data that
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
301 * represents the module selection at first position, the second position
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
302 * stores the Data object that represents the river selection.
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
303 *
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
304 * @return the Data that was chosen in this widget.
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
305 */
4131
360e22afb98b Cosmetics, warnings and minor TODOs.
Christian Lins <christian.lins@intevation.de>
parents: 3530
diff changeset
306 @Override
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
307 protected Data[] getData() {
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
308
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
309 final Module module = selectedModule;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
310
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
311 final DataItem[] items = new DefaultDataItem[] { new DefaultDataItem(module.getLocalizedName(), module.getLocalizedName(), module.getName()) };
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
312
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
313 final Data data = new DefaultData("module", null, null, items);
282
e92f7ef455d6 Show rivers as links instead of a combobox.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 211
diff changeset
314 return new Data[] {data};
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
315 }
5928
34392dc16546 Implemented interaction design in project startup page.
Raimund Renkert <rrenkert@intevation.de>
parents: 5861
diff changeset
316
6119
0b9f0d37fe6e We have a much faster interactive image map!
Raimund Renkert <rrenkert@intevation.de>
parents: 5993
diff changeset
317 public void setRivers(Map<String, HLayout> rivers) {
5928
34392dc16546 Implemented interaction design in project startup page.
Raimund Renkert <rrenkert@intevation.de>
parents: 5861
diff changeset
318 this.rivers = rivers;
34392dc16546 Implemented interaction design in project startup page.
Raimund Renkert <rrenkert@intevation.de>
parents: 5861
diff changeset
319 }
6133
3ff2a4317167 Added JavaScript callback to get the selected module in native JavaScript code.
Raimund Renkert <rrenkert@intevation.de>
parents: 6119
diff changeset
320
3ff2a4317167 Added JavaScript callback to get the selected module in native JavaScript code.
Raimund Renkert <rrenkert@intevation.de>
parents: 6119
diff changeset
321 private native void createCallback() /*-{
3ff2a4317167 Added JavaScript callback to get the selected module in native JavaScript code.
Raimund Renkert <rrenkert@intevation.de>
parents: 6119
diff changeset
322 $wnd.getModule = @org.dive4elements.river.client.client.ui.ModuleSelection::getSelectedModule();
3ff2a4317167 Added JavaScript callback to get the selected module in native JavaScript code.
Raimund Renkert <rrenkert@intevation.de>
parents: 6119
diff changeset
323 }-*/;
3ff2a4317167 Added JavaScript callback to get the selected module in native JavaScript code.
Raimund Renkert <rrenkert@intevation.de>
parents: 6119
diff changeset
324
3ff2a4317167 Added JavaScript callback to get the selected module in native JavaScript code.
Raimund Renkert <rrenkert@intevation.de>
parents: 6119
diff changeset
325 private static String getSelectedModule() {
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
326 if (selectedModule == null) {
8528
f7d1a7e66b12 (issue1795) Handle modules configuration for any module
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7763
diff changeset
327 return null;
f7d1a7e66b12 (issue1795) Handle modules configuration for any module
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7763
diff changeset
328 }
8870
c26fb37899ca Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui.
gernotbelger
parents: 8856
diff changeset
329 return selectedModule.getName();
6133
3ff2a4317167 Added JavaScript callback to get the selected module in native JavaScript code.
Raimund Renkert <rrenkert@intevation.de>
parents: 6119
diff changeset
330 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
331 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
332 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org