annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java @ 2540:e75b15818435

Added a style chooser to the style editor to provide predefined styles and implemented a service to request theme styles. flys-client/trunk@4471 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 23 May 2012 08:59:49 +0000
parents 8f36d4b5890c
children d632a6526ad9
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
1451
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
3 import java.util.Arrays;
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
4 import java.util.Map;
1341
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
5 import java.util.LinkedHashMap;
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
6 import java.util.Set;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
7 import java.util.Iterator;
1341
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
8
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
9 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
10 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
11
1499
0372797fc9cf Avoid NPE in StyleEditorWindow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1495
diff changeset
12 import com.smartgwt.client.util.SC;
0372797fc9cf Avoid NPE in StyleEditorWindow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1495
diff changeset
13
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
14 import com.smartgwt.client.widgets.Window;
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
15 import com.smartgwt.client.widgets.Canvas;
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
16 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
17 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
18 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
19 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
20 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
21 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
22 import com.smartgwt.client.widgets.form.fields.ColorPickerItem;
1341
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
23 import com.smartgwt.client.widgets.form.fields.SelectItem;
1337
9bf72f84728d Show theme name in static text field.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1336
diff changeset
24 import com.smartgwt.client.widgets.form.fields.StaticTextItem;
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
25
a95e82d6bcc1 Refactored the code to create 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 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
27 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
28 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
29 import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
30 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
31 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
32
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
33 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
34
a95e82d6bcc1 Refactored the code to create 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.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
36 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
37 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
38 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
39 import de.intevation.flys.client.shared.model.FacetRecord;
1326
974c6b3700de Use the theme index to identify the correct style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1309
diff changeset
40 import de.intevation.flys.client.shared.model.Theme;
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
41
a95e82d6bcc1 Refactored the code to create 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 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
43 import de.intevation.flys.client.client.services.CollectionItemAttributeService;
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
44 import de.intevation.flys.client.client.services.ThemeListingServiceAsync;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
45 import de.intevation.flys.client.client.services.ThemeListingService;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
46
1336
ceb989d64cd2 Request redraw on style attribute change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1333
diff changeset
47 import de.intevation.flys.client.client.ui.ThemePanel;
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
48
a95e82d6bcc1 Refactored the code to create 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 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
50 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
51
a95e82d6bcc1 Refactored the code to create 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 * @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
54 */
a95e82d6bcc1 Refactored the code to create 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 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
56 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
57 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
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 /** 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
60 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
61
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
62 /** The collection. */
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
63 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
64
1336
ceb989d64cd2 Request redraw on style attribute change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1333
diff changeset
65 /** The parent ThemePanel. */
ceb989d64cd2 Request redraw on style attribute change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1333
diff changeset
66 protected ThemePanel panel;
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
67
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
68 /** The attributes. */
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
69 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
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 /** 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
72 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
73
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
74 /** Main layout. */
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
75 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
76
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
77 protected VLayout properties;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
78 protected Canvas container;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
79
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
80 protected Map<String, Style> styleGroups;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
81
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
82 protected Style current;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
83
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
84 protected SelectItem styleChooser;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
85
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
86 /** 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
87 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
88 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
89
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
90 /** The service used to request a list of themes. */
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
91 protected ThemeListingServiceAsync themeListingService =
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
92 GWT.create(ThemeListingService.class);
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
93
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
94 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
95 * Setup editor dialog.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
96 * @param collection The collection the current theme belongs to.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
97 * @param attributes The collection attributes.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
98 * @param facet The selected facet.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
99 */
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
100 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
101 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
102 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
103 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
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 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
106 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
107 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
108 this.layout = new VLayout();
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
109 this.properties = new VLayout();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
110 this.container = new Canvas();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
111 this.styleChooser = new SelectItem("style", "Style");
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
112
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
113 styleChooser.setTitleStyle("color:#000;");
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
114 styleChooser.setTitleAlign(Alignment.LEFT);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
115 styleChooser.setValue("aktuell");
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
116 styleChooser.addChangedHandler(new ChangedHandler() {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
117 public void onChanged(ChangedEvent ce) {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
118 String value = ce.getValue().toString();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
119 Style s = null;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
120 if (value.equals("aktuell")) {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
121 s = current;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
122 }
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
123 else if (styleGroups.containsKey(value)) {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
124 s = styleGroups.get(value);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
125 }
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
126
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
127 if (s != null) {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
128 setNewStyle(s);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
129 properties.removeMember(container);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
130 container = createPropertyGrid(s);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
131 properties.addMember(container);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
132 }
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
133 }
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
134 });
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
135
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
136 DynamicForm f = new DynamicForm();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
137 f.setFields(styleChooser);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
138 f.setColWidths("40%", "60%");
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
139
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
140 layout.addMember(f);
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
141 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
142 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
143 }
a95e82d6bcc1 Refactored the code to create 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
a95e82d6bcc1 Refactored the code to create 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
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
146 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
147 * Initialize the window and set the layout.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
148 */
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
149 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
150 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
151 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
152 setCanDragResize(true);
1381
4459901e4ec0 Updated the theme editor window layout.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1380
diff changeset
153 layout.setMargin(10);
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
154
a95e82d6bcc1 Refactored the code to create 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 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
156 layout.setHeight100();
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
157
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
158 Config config = Config.getInstance();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
159 String locale = config.getLocale();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
160
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
161 Theme theme = facet.getTheme();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
162 Style style = attributes.getStyle(theme.getFacet(), theme.getIndex());
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
163 String name = style.getName();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
164 this.current = style;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
165
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
166 themeListingService.list(
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
167 locale,
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
168 name,
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
169 new AsyncCallback<Map<String, Style> >() {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
170 public void onFailure(Throwable caught) {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
171 GWT.log("No listloaded.");
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
172 }
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
173 public void onSuccess(Map<String, Style> list) {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
174 GWT.log("Successfully loaded list.");
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
175
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
176 styleGroups = list;
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
177 Set keys = list.keySet();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
178 LinkedHashMap<String, String> valueMap =
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
179 new LinkedHashMap<String, String>();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
180 valueMap.put("aktuell", "Aktuell");
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
181 Iterator i = keys.iterator();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
182 while (i.hasNext()) {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
183 String s = i.next().toString();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
184 Style tmp = styleGroups.get(s);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
185 tmp.setFacet(facet.getTheme().getFacet());
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
186 tmp.setIndex(0);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
187 valueMap.put(s, s);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
188 }
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
189 styleChooser.setValueMap(valueMap);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
190 }
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
191 });
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
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
a95e82d6bcc1 Refactored the code to create 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
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
195 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
196 * Initialize the static window content like buttons and main layout.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
197 */
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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
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
a95e82d6bcc1 Refactored the code to create 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 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
210 buttons.addMember(cancel);
1381
4459901e4ec0 Updated the theme editor window layout.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1380
diff changeset
211 buttons.setAlign(Alignment.CENTER);
4459901e4ec0 Updated the theme editor window layout.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1380
diff changeset
212 buttons.setHeight(30);
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
213
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
214 Theme theme = facet.getTheme();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
215 Style style = attributes.getStyle(theme.getFacet(), theme.getIndex());
1348
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
216
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
217 container = createPropertyGrid(style);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
218 properties.addMember(container);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
219 layout.addMember(properties);
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
220 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
221 addItem(layout);
2472
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
222 setWidth(400);
1381
4459901e4ec0 Updated the theme editor window layout.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1380
diff changeset
223 setHeight(410);
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
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
a95e82d6bcc1 Refactored the code to create 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
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
227 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
228 * Setter for the parent panel.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
229 * @param panel The panel.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
230 */
1336
ceb989d64cd2 Request redraw on style attribute change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1333
diff changeset
231 public void setThemePanel (ThemePanel panel) {
ceb989d64cd2 Request redraw on style attribute change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1333
diff changeset
232 this.panel = panel;
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
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
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
236 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
237 * this method is called when the user aborts theming.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
238 * @param event The event.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
239 */
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
240 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
241 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
242 }
a95e82d6bcc1 Refactored the code to create 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
a95e82d6bcc1 Refactored the code to create 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
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
245 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
246 * This method creates the property grid for available styling attributes.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
247 * @return The layout containing the UI elements.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
248 */
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
249 protected VLayout createPropertyGrid(Style style) {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
250 VLayout vl = new VLayout();
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
251
1337
9bf72f84728d Show theme name in static text field.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1336
diff changeset
252 StaticTextItem name = new StaticTextItem("name", "Name");
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
253 name.setValue(facet.getName());
2472
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
254 name.setTitleStyle("color:#000;");
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
255 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
256 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
257 name.setShowDisabled(false);
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
258
1450
bb91cdf8407b Minor refactoring to ease addition of new style-fields (are now added automically).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
259 DynamicForm form = new DynamicForm();
bb91cdf8407b Minor refactoring to ease addition of new style-fields (are now added automically).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
260 form.setFields(name);
2472
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
261 form.setColWidths("40%", "60%");
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
262
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
263
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
264 vl.addMember(form);
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
265
1499
0372797fc9cf Avoid NPE in StyleEditorWindow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1495
diff changeset
266 if (style == null) {
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
267 SC.warn("No style found.");
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
268 return vl;
1499
0372797fc9cf Avoid NPE in StyleEditorWindow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1495
diff changeset
269 }
0372797fc9cf Avoid NPE in StyleEditorWindow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1495
diff changeset
270
1451
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
271 // Done via array to keep the order.
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
272 String[] sets = {"showlines",
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
273 "showpoints",
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
274 "linetype",
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
275 "linesize",
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
276 "linecolor",
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
277 "font",
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
278 "textstyle",
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
279 "textsize",
1495
bd6c8b06cb94 Improved the StyledEditorWindow to support a list of pointsizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1479
diff changeset
280 "pointsize",
1451
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
281 "textcolor",
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
282 "textorientation",
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
283 "backgroundcolor",
2499
8f36d4b5890c Define order for linelabel theme properties.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2472
diff changeset
284 "showbackground",
8f36d4b5890c Define order for linelabel theme properties.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2472
diff changeset
285 "showlinelabel",
8f36d4b5890c Define order for linelabel theme properties.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2472
diff changeset
286 "linelabelfont",
8f36d4b5890c Define order for linelabel theme properties.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2472
diff changeset
287 "linelabelcolor",
8f36d4b5890c Define order for linelabel theme properties.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2472
diff changeset
288 "linelabelsize",
8f36d4b5890c Define order for linelabel theme properties.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2472
diff changeset
289 "linelabelstyle",
8f36d4b5890c Define order for linelabel theme properties.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2472
diff changeset
290 "linelabelshowbg",
8f36d4b5890c Define order for linelabel theme properties.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2472
diff changeset
291 "linelabelbgcolor"};
1451
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
292
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
293 for (String settingName: sets) {
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
294 StyleSetting set = style.getSetting(settingName);
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
295
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
296 if (set == null) {
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
297 continue;
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
298 }
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
299
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
300 DynamicForm property = createPropertyUI(
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
301 set.getDisplayName(),
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
302 set.getName(),
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
303 set.getType(),
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
304 set.getDefaultValue());
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
305 vl.addMember(property);
1451
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
306 }
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
307
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
308 // Add settings not in whitelist above.
1450
bb91cdf8407b Minor refactoring to ease addition of new style-fields (are now added automically).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
309 for (StyleSetting set: style.getSettings()) {
1380
2d617c48ca5f Issue 400.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1360
diff changeset
310
1451
bc830e564b6d Restore feature that was optimized away by last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1450
diff changeset
311 if (Arrays.asList(sets).contains(set.getName()) || set == null) {
1380
2d617c48ca5f Issue 400.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1360
diff changeset
312 continue;
2d617c48ca5f Issue 400.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1360
diff changeset
313 }
2d617c48ca5f Issue 400.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1360
diff changeset
314
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
315 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
316 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
317 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
318 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
319 set.getDefaultValue());
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
320 vl.addMember(property);
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
321 }
1450
bb91cdf8407b Minor refactoring to ease addition of new style-fields (are now added automically).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
322
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
323 return vl;
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
324 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
325
1336
ceb989d64cd2 Request redraw on style attribute change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1333
diff changeset
326
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
327 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
328 * Create a property form.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
329 * @param dname The display name.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
330 * @param name The property name.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
331 * @param type The property type.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
332 * @param value The current value.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
333 *
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
334 * @return The dynamic form for the attribute property.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
335 */
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
336 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
337 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
338 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
339 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
340 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
341 {
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
342 DynamicForm df = new DynamicForm();
2472
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
343 df.setColWidths("40%", "60%");
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
344
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
345 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
346 if(type.equals("int")) {
1479
2f525f54e429 Issue 427.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1451
diff changeset
347 f = new SelectItem(name, MSG.getString(name));
1348
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
348 if (name.equals("linesize")) {
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
349 f = createLineSizeUI(f);
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
350 }
2499
8f36d4b5890c Define order for linelabel theme properties.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2472
diff changeset
351 else if (name.equals("textsize") || name.equals("linelabelsize")) {
1348
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
352 LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
353 valueMap.put("3", "3");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
354 valueMap.put("5", "5");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
355 valueMap.put("8", "8");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
356 valueMap.put("10", "10");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
357 valueMap.put("12", "12");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
358 valueMap.put("14", "14");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
359 valueMap.put("18", "18");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
360 valueMap.put("24", "24");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
361 f.setValueMap(valueMap);
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
362 }
1495
bd6c8b06cb94 Improved the StyledEditorWindow to support a list of pointsizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1479
diff changeset
363 else if (name.equals("pointsize")) {
bd6c8b06cb94 Improved the StyledEditorWindow to support a list of pointsizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1479
diff changeset
364 LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
bd6c8b06cb94 Improved the StyledEditorWindow to support a list of pointsizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1479
diff changeset
365 valueMap.put("1", "1");
2433
47a7bdfb4d37 fix flys/issue613 . cap max point size.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1499
diff changeset
366 valueMap.put("2", "2");
1495
bd6c8b06cb94 Improved the StyledEditorWindow to support a list of pointsizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1479
diff changeset
367 valueMap.put("3", "3");
2433
47a7bdfb4d37 fix flys/issue613 . cap max point size.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1499
diff changeset
368 valueMap.put("4", "4");
1495
bd6c8b06cb94 Improved the StyledEditorWindow to support a list of pointsizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1479
diff changeset
369 valueMap.put("5", "5");
2433
47a7bdfb4d37 fix flys/issue613 . cap max point size.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1499
diff changeset
370 valueMap.put("6", "6");
1495
bd6c8b06cb94 Improved the StyledEditorWindow to support a list of pointsizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1479
diff changeset
371 valueMap.put("7", "7");
bd6c8b06cb94 Improved the StyledEditorWindow to support a list of pointsizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1479
diff changeset
372 f.setValueMap(valueMap);
bd6c8b06cb94 Improved the StyledEditorWindow to support a list of pointsizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1479
diff changeset
373 }
1341
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
374 f.setValue(value);
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
375 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
376 else if (type.equals("boolean")) {
1359
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
377 if(name.equals("textorientation")) {
1479
2f525f54e429 Issue 427.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1451
diff changeset
378 f = new SelectItem(name, MSG.getString(name));
1359
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
379 LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
380 valueMap.put("true", "horizontal");
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
381 valueMap.put("false", "vertical");
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
382 f.setValueMap(valueMap);
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
383 f.setValue(value);
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
384 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
385 else {
1479
2f525f54e429 Issue 427.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1451
diff changeset
386 CheckboxItem c = new CheckboxItem(name, MSG.getString(name));
1359
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
387 if(value.equals("true")) {
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
388 c.setValue(true);
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
389 }
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
390 else {
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
391 c.setValue(false);
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
392 }
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
393 c.setLabelAsTitle(true);
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
394 f = c;
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
395 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
396 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
397 else if (type.equals("Color")) {
1479
2f525f54e429 Issue 427.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1451
diff changeset
398 ColorPickerItem c = new ColorPickerItem(name, MSG.getString(name));
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
399 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
400 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
401 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
402 else if (type.equals("Dash")) {
1479
2f525f54e429 Issue 427.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1451
diff changeset
403 f = new SelectItem(name, MSG.getString(name));
1341
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
404 LinkedHashMap<String, String> valueIcons = new LinkedHashMap<String, String>();
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
405 f.setImageURLPrefix(GWT.getHostPageBaseURL() + "images/linestyle-dash-");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
406 f.setImageURLSuffix(".png");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
407 f.setValueIconHeight(20);
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
408 f.setValueIconWidth(80);
1348
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
409 LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
1341
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
410 valueMap.put("10", "");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
411 valueMap.put("10,5", "");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
412 valueMap.put("20,10", "");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
413 valueMap.put("30,10", "");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
414 valueMap.put("20,5,15,5", "");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
415 valueIcons.put("10", "10");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
416 valueIcons.put("10,5", "10-5");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
417 valueIcons.put("20,10", "20-10");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
418 valueIcons.put("30,10", "30-10");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
419 valueIcons.put("20,5,15,5", "20-5-15-5");
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
420 f.setValueIcons(valueIcons);
e26088566e8a Use images for line type and line size selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1339
diff changeset
421 f.setValueMap(valueMap);
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
422 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
423 }
1348
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
424 else if (type.equals("Font")) {
1479
2f525f54e429 Issue 427.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1451
diff changeset
425 f = new SelectItem(name, MSG.getString(name));
1348
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
426 LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
427 valueMap.put("arial", "<span style='font-family:arial'>Arial</span>");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
428 valueMap.put("courier", "<span style='font-family:courier'>Courier</span>");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
429 valueMap.put("verdana", "<span style='font-family:verdana'>Verdana</span>");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
430 valueMap.put("times", "<span style='font-family:times'>Times</span>");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
431 f.setValueMap(valueMap);
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
432 f.setValue(value);
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
433 }
1359
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
434 else if (type.equals("Style")) {
1479
2f525f54e429 Issue 427.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1451
diff changeset
435 f = new SelectItem(name, MSG.getString(name));
1359
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
436 LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
437 valueMap.put("standard", "<span style='font-style:normal'>Normal</span>");
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
438 valueMap.put("bold", "<span style='font-weight:bold'>Bold</span>");
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
439 valueMap.put("italic", "<span style='font-style:italic'>Italic</span>");
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
440 f.setValueMap(valueMap);
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
441 f.setValue(value);
5ebcf5b3fc10 Display new attributes in editor window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1357
diff changeset
442 }
2458
208f923032ac Issue 493.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2433
diff changeset
443 else if (type.equals("Symbol")) {
208f923032ac Issue 493.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2433
diff changeset
444 //create an empty element as long as this property can not be
208f923032ac Issue 493.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2433
diff changeset
445 //changed.
208f923032ac Issue 493.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2433
diff changeset
446 f = new StaticTextItem("");
208f923032ac Issue 493.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2433
diff changeset
447 }
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
448 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
449 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
450 }
2472
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
451 f.setTitleStyle("color:#000;");
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
452 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
453 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
454 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
455 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
456 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
457 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
458 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
459 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
460 });
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
461
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
462 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
463 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
464
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
465
1348
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
466 protected FormItem createLineSizeUI(FormItem f) {
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
467 LinkedHashMap<String, String> valueIcons = new LinkedHashMap<String, String>();
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
468 f.setImageURLPrefix(GWT.getHostPageBaseURL() + "images/linestyle-");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
469 f.setImageURLSuffix("px.png");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
470 f.setValueIconHeight(20);
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
471 f.setValueIconWidth(80);
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
472 LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
473 valueMap.put("1", "");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
474 valueMap.put("2", "");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
475 valueMap.put("3", "");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
476 valueMap.put("4", "");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
477 valueMap.put("5", "");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
478 valueMap.put("6", "");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
479 valueMap.put("7", "");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
480 valueMap.put("8", "");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
481 valueIcons.put("1", "1");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
482 valueIcons.put("2", "2");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
483 valueIcons.put("3", "3");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
484 valueIcons.put("4", "4");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
485 valueIcons.put("5", "5");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
486 valueIcons.put("6", "6");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
487 valueIcons.put("7", "7");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
488 valueIcons.put("8", "8");
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
489 f.setValueIcons(valueIcons);
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
490 f.setValueMap(valueMap);
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
491 return f;
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
492 }
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
493
fb224f54c643 Prepared editor UI for annotation styling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1345
diff changeset
494
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
495 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
496 * Static method to convert a color from RGB to HTML notation.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
497 * @param rgb String in RGB notation.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
498 *
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
499 * @return String in HTML notation.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
500 */
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
501 protected static String rgbToHtml(String rgb) {
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
502 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
503 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
504 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
505 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
506 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
507 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
508 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
509 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
510 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
511 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
512 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
513 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
514 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
515 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
516 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
517 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
518 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
519 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
520 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
521 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
522
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
523
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
524 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
525 * Static method to convert a color from HTML to RGB notation.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
526 * @param html String in HTML notation.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
527 *
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
528 * @return String in RGB notation.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
529 */
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
530 protected static String htmlToRgb(String html) {
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
531 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
532 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
533 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
534
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
535 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
536 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
537 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
538
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
539 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
540 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
541
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
542
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
543 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
544 * Saves the current style attributes and requests a redraw.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
545 */
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
546 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
547 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
548 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
549 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
550
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
551 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
552 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
553 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
554 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
555 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
556 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
557 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
558 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
559 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
560 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
561 GWT.log("Successfully saved collection item attributes.");
1336
ceb989d64cd2 Request redraw on style attribute change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1333
diff changeset
562 panel.requestRedraw();
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
563 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
564 });
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
565
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
566
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
567 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
568 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
569
1333
1627a28c4504 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1326
diff changeset
570
1345
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
571 /**
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
572 * Sets a new value for an attribute.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
573 * @param name Attribute name.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
574 * @param value The new value.
92074508a387 Added documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1341
diff changeset
575 */
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
576 protected final void setNewValue(String name, String value) {
1326
974c6b3700de Use the theme index to identify the correct style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1309
diff changeset
577 Theme t = facet.getTheme();
974c6b3700de Use the theme index to identify the correct style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1309
diff changeset
578 Style s = attributes.getStyle(t.getFacet(), t.getIndex());
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
579 StyleSetting set = s.getSetting(name);
2472
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
580 String type = set.getType();
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
581
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
582 if(name.indexOf("color") != -1
75d19d46c3cd Prepared the style editor for WSPLGEN themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2458
diff changeset
583 || (type != null && type.toLowerCase().indexOf("color") > -1)) {
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
584 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
585 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
586 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
587 }
2540
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
588
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
589
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
590 protected final void setNewStyle(Style style) {
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
591 Theme t = facet.getTheme();
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
592 Style s = attributes.getStyle(t.getFacet(), t.getIndex());
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
593 attributes.removeStyle(s.getName());
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
594 attributes.appendStyle(style);
e75b15818435 Added a style chooser to the style editor to provide predefined styles and
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2499
diff changeset
595 }
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
596 }
a95e82d6bcc1 Refactored the code to create a context menu and a style editor so that it is also available for maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
597 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org