annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java @ 1309:a95e82d6bcc1

Refactored the code to create a context menu and a style editor so that it is also available for maps. flys-client/trunk@2943 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 12 Oct 2011 08:53:17 +0000
parents
children 974c6b3700de
rev   line source
1309
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import com.google.gwt.core.client.GWT;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import com.google.gwt.user.client.rpc.AsyncCallback;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import com.smartgwt.client.widgets.Window;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import com.smartgwt.client.widgets.layout.VLayout;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import com.smartgwt.client.widgets.layout.HLayout;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import com.smartgwt.client.widgets.Button;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import com.smartgwt.client.widgets.form.DynamicForm;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import com.smartgwt.client.widgets.form.fields.FormItem;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import com.smartgwt.client.widgets.form.fields.CheckboxItem;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import com.smartgwt.client.widgets.form.fields.SpinnerItem;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import com.smartgwt.client.widgets.form.fields.ColorPickerItem;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import com.smartgwt.client.widgets.form.fields.TextItem;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import com.smartgwt.client.widgets.events.ClickEvent;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import com.smartgwt.client.widgets.events.ClickHandler;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import com.smartgwt.client.types.Alignment;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import de.intevation.flys.client.shared.model.Collection;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.flys.client.shared.model.CollectionItemAttribute;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.client.shared.model.Style;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 import de.intevation.flys.client.shared.model.StyleSetting;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 import de.intevation.flys.client.shared.model.FacetRecord;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 import de.intevation.flys.client.client.services.CollectionItemAttributeServiceAsync;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 import de.intevation.flys.client.client.services.CollectionItemAttributeService;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 import de.intevation.flys.client.client.ui.CollectionView;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 import de.intevation.flys.client.client.FLYSConstants;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 import de.intevation.flys.client.client.Config;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 /**
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 */
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 public class StyleEditorWindow
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 extends Window
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 implements ClickHandler
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 /** The interface that provides i18n messages. */
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 /** The collection */
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 protected Collection collection;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 /** The parent collection view */
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 protected CollectionView view;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 /** The attributes */
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 protected CollectionItemAttribute attributes;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 /** The selected facet. */
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 protected FacetRecord facet;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 /** Main layout */
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 protected VLayout layout;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 /** The service used to set collection item attributes. */
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 protected CollectionItemAttributeServiceAsync itemAttributeService =
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 GWT.create(CollectionItemAttributeService.class);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 public StyleEditorWindow (
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 Collection collection,
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 CollectionItemAttribute attributes,
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 FacetRecord facet)
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 this.collection = collection;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 this.attributes = attributes;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 this.facet = facet;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 this.layout = new VLayout();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 init();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 initPanels();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 protected void init() {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 setTitle(MSG.properties());
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 setWidth(270);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 setHeight(200);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 setCanDragReposition(true);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 setCanDragResize(true);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 setKeepInParentRect(true);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 layout.setWidth100();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 layout.setHeight100();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 protected void initPanels() {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 HLayout buttons = new HLayout();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 Button accept = new Button(MSG.label_ok());
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 Button cancel = new Button(MSG.label_cancel());
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 cancel.addClickHandler(this);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 accept.addClickHandler(new ClickHandler() {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 public void onClick(ClickEvent e) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 saveStyle();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 });
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 buttons.addMember(accept);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 buttons.addMember(cancel);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 buttons.setAlign(Alignment.RIGHT);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 layout.addMember(createPropertyGrid());;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 layout.addMember(buttons);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 addItem(layout);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 public void setCollectionView (CollectionView view) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 this.view = view;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 setParentElement(this.view.getParentElement());
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 public void onClick(ClickEvent event) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 this.hide();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 protected VLayout createPropertyGrid() {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 VLayout properties = new VLayout();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 Style s = attributes.getStyle(facet.getTheme().getFacet());
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 TextItem name = new TextItem("name", "Name");
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 name.setValue(facet.getName());
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 name.setTitleStyle("color:#000; width:120px");
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 name.setTitleAlign(Alignment.LEFT);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 name.setDisabled(true);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 name.setShowDisabled(false);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 DynamicForm f = new DynamicForm();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 f.setFields(name);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140 properties.addMember(f);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 for (int i = 0; i < s.getNumSettings(); i ++) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 final StyleSetting set = s.getSetting(i);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 DynamicForm property = createPropertyUI(
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 set.getDisplayName(),
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 set.getName(),
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 set.getType(),
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 set.getDefaultValue());
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 properties.addMember(property);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 return properties;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 protected DynamicForm createPropertyUI(
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 String dname,
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 String name,
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 String type,
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 String value)
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 DynamicForm df = new DynamicForm();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 FormItem f;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 if(type.equals("int")) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 SpinnerItem s = new SpinnerItem(name, dname);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 s.setMin(1);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 s.setMax(10);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 s.setValue(value);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 f = s;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 else if (type.equals("boolean")) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 CheckboxItem c = new CheckboxItem(name, dname);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 if(value.equals("true")) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 c.setValue(true);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 else {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 c.setValue(false);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 c.setLabelAsTitle(true);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 f = c;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 else if (type.equals("Color")) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 ColorPickerItem c = new ColorPickerItem(name, dname);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 c.setValue(rgbToHtml(value));
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 f = c;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186 else if (type.equals("Dash")) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187 f = new ComboBoxItem(name, dname);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 f.setValue(value);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 else {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 f = new FormItem();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 f.setTitleStyle("color:#000; width:120px");
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194 f.setTitleAlign(Alignment.LEFT);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 df.setFields(f);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 df.addItemChangedHandler(new ItemChangedHandler() {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 public void onItemChanged(ItemChangedEvent e) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 String name = e.getItem().getName();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 String newValue = e.getNewValue().toString();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 GWT.log("changed: " + name);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 setNewValue(name, newValue);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 });
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 return df;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 protected String rgbToHtml(String rgb) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 String[] parts = rgb.split(",");
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 int values[] = new int[parts.length];
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 for (int i = 0; i < parts.length; i++) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 parts[i] = parts[i].trim();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 try {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 values[i] = Integer.parseInt(parts[i]);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 catch(NumberFormatException nfe) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 return "#000000";
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 String hex = "#";
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 for (int i = 0; i < values.length; i++) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 if (values[i] < 16) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223 hex += "0";
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 hex += Integer.toHexString(values[i]);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227 return hex;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
230 protected String htmlToRgb(String html) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
231 if (!html.startsWith("#")) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232 return "0, 0, 0";
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
234
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235 int r = Integer.valueOf(html.substring(1, 3), 16);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236 int g = Integer.valueOf(html.substring(3, 5), 16);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237 int b = Integer.valueOf(html.substring(5, 7), 16);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239 return r + ", " + g + ", " + b;
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242 protected void saveStyle () {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 GWT.log("StyleEditorWindow.saveStyle()");
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244 Config config = Config.getInstance();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 String url = config.getServerUrl();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246 String locale = config.getLocale();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 itemAttributeService.setCollectionItemAttribute(
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 this.collection,
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 attributes.getArtifact(),
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251 url,
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 locale,
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 attributes,
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 new AsyncCallback<Void>() {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 public void onFailure (Throwable caught) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256 GWT.log("Could not set Collection item attributes.");
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 public void onSuccess(Void v) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259 GWT.log("Successfully saved collection item attributes.");
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261 });
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264 this.hide();
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 protected final void setNewValue(String name, String value) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 Style s = attributes.getStyle(facet.getTheme().getFacet());
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269 StyleSetting set = s.getSetting(name);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270 if(name.equals("linecolor")) {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 value = htmlToRgb(value);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 set.setDefaultValue(value);
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org