Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java @ 2954:b9433322fcaf
Add alpha transp. and fix exceptions on unknown style attributes.
flys-client/trunk@4934 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 11 Jul 2012 12:04:25 +0000 |
parents | cd068ff7966d |
children | 36cd7d88551a |
comparison
equal
deleted
inserted
replaced
2953:75e9eab05ee4 | 2954:b9433322fcaf |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | |
3 import java.util.Arrays; | |
4 import java.util.Map; | |
5 import java.util.LinkedHashMap; | |
6 import java.util.Set; | |
7 import java.util.Iterator; | |
8 | 2 |
9 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
10 import com.google.gwt.user.client.rpc.AsyncCallback; | 4 import com.google.gwt.user.client.rpc.AsyncCallback; |
11 | 5 import com.smartgwt.client.types.Alignment; |
12 import com.smartgwt.client.util.SC; | 6 import com.smartgwt.client.util.SC; |
13 | 7 import com.smartgwt.client.widgets.Button; |
8 import com.smartgwt.client.widgets.Canvas; | |
14 import com.smartgwt.client.widgets.Window; | 9 import com.smartgwt.client.widgets.Window; |
15 import com.smartgwt.client.widgets.Canvas; | 10 import com.smartgwt.client.widgets.events.ClickEvent; |
16 import com.smartgwt.client.widgets.layout.VLayout; | 11 import com.smartgwt.client.widgets.events.ClickHandler; |
17 import com.smartgwt.client.widgets.layout.HLayout; | |
18 import com.smartgwt.client.widgets.Button; | |
19 import com.smartgwt.client.widgets.form.DynamicForm; | 12 import com.smartgwt.client.widgets.form.DynamicForm; |
20 import com.smartgwt.client.widgets.form.fields.FormItem; | 13 import com.smartgwt.client.widgets.form.events.ItemChangedEvent; |
14 import com.smartgwt.client.widgets.form.events.ItemChangedHandler; | |
21 import com.smartgwt.client.widgets.form.fields.CheckboxItem; | 15 import com.smartgwt.client.widgets.form.fields.CheckboxItem; |
22 import com.smartgwt.client.widgets.form.fields.ColorPickerItem; | 16 import com.smartgwt.client.widgets.form.fields.ColorPickerItem; |
17 import com.smartgwt.client.widgets.form.fields.FormItem; | |
23 import com.smartgwt.client.widgets.form.fields.SelectItem; | 18 import com.smartgwt.client.widgets.form.fields.SelectItem; |
24 import com.smartgwt.client.widgets.form.fields.StaticTextItem; | 19 import com.smartgwt.client.widgets.form.fields.StaticTextItem; |
25 | |
26 import com.smartgwt.client.widgets.events.ClickEvent; | |
27 import com.smartgwt.client.widgets.events.ClickHandler; | |
28 import com.smartgwt.client.widgets.form.events.ItemChangedEvent; | |
29 import com.smartgwt.client.widgets.form.events.ItemChangedHandler; | |
30 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; | 20 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; |
31 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; | 21 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; |
32 | 22 import com.smartgwt.client.widgets.layout.HLayout; |
33 import com.smartgwt.client.types.Alignment; | 23 import com.smartgwt.client.widgets.layout.VLayout; |
34 | 24 |
25 import de.intevation.flys.client.client.Config; | |
26 import de.intevation.flys.client.client.FLYSConstants; | |
27 import de.intevation.flys.client.client.services.CollectionItemAttributeService; | |
28 import de.intevation.flys.client.client.services.CollectionItemAttributeServiceAsync; | |
29 import de.intevation.flys.client.client.services.ThemeListingService; | |
30 import de.intevation.flys.client.client.services.ThemeListingServiceAsync; | |
35 import de.intevation.flys.client.shared.model.Collection; | 31 import de.intevation.flys.client.shared.model.Collection; |
36 import de.intevation.flys.client.shared.model.CollectionItemAttribute; | 32 import de.intevation.flys.client.shared.model.CollectionItemAttribute; |
33 import de.intevation.flys.client.shared.model.FacetRecord; | |
37 import de.intevation.flys.client.shared.model.Style; | 34 import de.intevation.flys.client.shared.model.Style; |
38 import de.intevation.flys.client.shared.model.StyleSetting; | 35 import de.intevation.flys.client.shared.model.StyleSetting; |
39 import de.intevation.flys.client.shared.model.FacetRecord; | |
40 import de.intevation.flys.client.shared.model.Theme; | 36 import de.intevation.flys.client.shared.model.Theme; |
41 | 37 |
42 import de.intevation.flys.client.client.services.CollectionItemAttributeServiceAsync; | 38 import java.util.Arrays; |
43 import de.intevation.flys.client.client.services.CollectionItemAttributeService; | 39 import java.util.Iterator; |
44 import de.intevation.flys.client.client.services.ThemeListingServiceAsync; | 40 import java.util.LinkedHashMap; |
45 import de.intevation.flys.client.client.services.ThemeListingService; | 41 import java.util.Map; |
46 | 42 import java.util.Set; |
47 import de.intevation.flys.client.client.ui.ThemePanel; | |
48 | |
49 import de.intevation.flys.client.client.FLYSConstants; | |
50 import de.intevation.flys.client.client.Config; | |
51 | 43 |
52 /** | 44 /** |
53 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 45 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
54 */ | 46 */ |
55 public class StyleEditorWindow | 47 public class StyleEditorWindow |
112 | 104 |
113 styleChooser.setTitleStyle("color:#000;"); | 105 styleChooser.setTitleStyle("color:#000;"); |
114 styleChooser.setTitleAlign(Alignment.LEFT); | 106 styleChooser.setTitleAlign(Alignment.LEFT); |
115 styleChooser.setValue("aktuell"); | 107 styleChooser.setValue("aktuell"); |
116 styleChooser.addChangedHandler(new ChangedHandler() { | 108 styleChooser.addChangedHandler(new ChangedHandler() { |
109 @Override | |
117 public void onChanged(ChangedEvent ce) { | 110 public void onChanged(ChangedEvent ce) { |
118 String value = ce.getValue().toString(); | 111 String value = ce.getValue().toString(); |
119 Style s = null; | 112 Style s = null; |
120 if (value.equals("aktuell")) { | 113 if (value.equals("aktuell")) { |
121 s = current; | 114 s = current; |
158 Config config = Config.getInstance(); | 151 Config config = Config.getInstance(); |
159 String locale = config.getLocale(); | 152 String locale = config.getLocale(); |
160 | 153 |
161 Theme theme = facet.getTheme(); | 154 Theme theme = facet.getTheme(); |
162 Style style = attributes.getStyle(theme.getFacet(), theme.getIndex()); | 155 Style style = attributes.getStyle(theme.getFacet(), theme.getIndex()); |
156 if(style == null) { | |
157 GWT.log("StyleEditorWindow.init(): style == null"); | |
158 return; | |
159 } | |
163 String name = style.getName(); | 160 String name = style.getName(); |
164 this.current = style; | 161 this.current = style; |
165 | 162 |
166 themeListingService.list( | 163 themeListingService.list( |
167 locale, | 164 locale, |
168 name, | 165 name, |
169 new AsyncCallback<Map<String, Style> >() { | 166 new AsyncCallback<Map<String, Style> >() { |
167 @Override | |
170 public void onFailure(Throwable caught) { | 168 public void onFailure(Throwable caught) { |
171 GWT.log("No listloaded."); | 169 GWT.log("No listloaded."); |
172 } | 170 } |
171 @Override | |
173 public void onSuccess(Map<String, Style> list) { | 172 public void onSuccess(Map<String, Style> list) { |
174 GWT.log("Successfully loaded list."); | 173 GWT.log("Successfully loaded list."); |
175 | 174 |
176 styleGroups = list; | 175 styleGroups = list; |
177 Set keys = list.keySet(); | 176 Set<String> keys = list.keySet(); |
178 LinkedHashMap<String, String> valueMap = | 177 LinkedHashMap<String, String> valueMap = |
179 new LinkedHashMap<String, String>(); | 178 new LinkedHashMap<String, String>(); |
180 valueMap.put("aktuell", "Aktuell"); | 179 valueMap.put("aktuell", "Aktuell"); |
181 Iterator i = keys.iterator(); | 180 Iterator<String> iter = keys.iterator(); |
182 while (i.hasNext()) { | 181 while (iter.hasNext()) { |
183 String s = i.next().toString(); | 182 String s = iter.next().toString(); |
184 Style tmp = styleGroups.get(s); | 183 Style tmp = styleGroups.get(s); |
185 tmp.setFacet(current.getFacet()); | 184 tmp.setFacet(current.getFacet()); |
186 tmp.setIndex(current.getIndex()); | 185 tmp.setIndex(current.getIndex()); |
187 valueMap.put(s, s); | 186 valueMap.put(s, s); |
188 } | 187 } |
199 HLayout buttons = new HLayout(); | 198 HLayout buttons = new HLayout(); |
200 Button accept = new Button(MSG.label_ok()); | 199 Button accept = new Button(MSG.label_ok()); |
201 Button cancel = new Button(MSG.label_cancel()); | 200 Button cancel = new Button(MSG.label_cancel()); |
202 cancel.addClickHandler(this); | 201 cancel.addClickHandler(this); |
203 accept.addClickHandler(new ClickHandler() { | 202 accept.addClickHandler(new ClickHandler() { |
203 @Override | |
204 public void onClick(ClickEvent e) { | 204 public void onClick(ClickEvent e) { |
205 saveStyle(); | 205 saveStyle(); |
206 } | 206 } |
207 }); | 207 }); |
208 | 208 |
235 | 235 |
236 /** | 236 /** |
237 * this method is called when the user aborts theming. | 237 * this method is called when the user aborts theming. |
238 * @param event The event. | 238 * @param event The event. |
239 */ | 239 */ |
240 @Override | |
240 public void onClick(ClickEvent event) { | 241 public void onClick(ClickEvent event) { |
241 this.hide(); | 242 this.hide(); |
242 } | 243 } |
243 | 244 |
244 | 245 |
451 } | 452 } |
452 f.setTitleStyle("color:#000;"); | 453 f.setTitleStyle("color:#000;"); |
453 f.setTitleAlign(Alignment.LEFT); | 454 f.setTitleAlign(Alignment.LEFT); |
454 df.setFields(f); | 455 df.setFields(f); |
455 df.addItemChangedHandler(new ItemChangedHandler() { | 456 df.addItemChangedHandler(new ItemChangedHandler() { |
457 @Override | |
456 public void onItemChanged(ItemChangedEvent e) { | 458 public void onItemChanged(ItemChangedEvent e) { |
457 String name = e.getItem().getName(); | 459 String name = e.getItem().getName(); |
458 String newValue = e.getNewValue().toString(); | 460 String newValue = e.getNewValue().toString(); |
459 setNewValue(name, newValue); | 461 setNewValue(name, newValue); |
460 } | 462 } |
553 this.collection, | 555 this.collection, |
554 attributes.getArtifact(), | 556 attributes.getArtifact(), |
555 locale, | 557 locale, |
556 attributes, | 558 attributes, |
557 new AsyncCallback<Void>() { | 559 new AsyncCallback<Void>() { |
560 @Override | |
558 public void onFailure (Throwable caught) { | 561 public void onFailure (Throwable caught) { |
559 GWT.log("Could not set Collection item attributes."); | 562 GWT.log("Could not set Collection item attributes."); |
560 } | 563 } |
564 @Override | |
561 public void onSuccess(Void v) { | 565 public void onSuccess(Void v) { |
562 GWT.log("Successfully saved collection item attributes."); | 566 GWT.log("Successfully saved collection item attributes."); |
563 panel.requestRedraw(); | 567 panel.requestRedraw(); |
564 } | 568 } |
565 }); | 569 }); |