Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java @ 4568:bbd82bd8e541
flys-client: Cosmetics and warnings.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 19 Nov 2012 00:07:53 +0100 |
parents | 45f2b0778a3a |
children | b296d435fc69 |
comparison
equal
deleted
inserted
replaced
4567:5e6e89f19a37 | 4568:bbd82bd8e541 |
---|---|
1 package de.intevation.flys.client.client.ui.chart; | 1 package de.intevation.flys.client.client.ui.chart; |
2 | |
3 import com.google.gwt.core.client.GWT; | |
4 import com.google.gwt.user.client.rpc.AsyncCallback; | |
5 | |
6 import com.smartgwt.client.types.Alignment; | |
7 import com.smartgwt.client.util.SC; | |
8 import com.smartgwt.client.widgets.Button; | |
9 import com.smartgwt.client.widgets.Canvas; | |
10 import com.smartgwt.client.widgets.Label; | |
11 import com.smartgwt.client.widgets.Window; | |
12 import com.smartgwt.client.widgets.events.ClickEvent; | |
13 import com.smartgwt.client.widgets.events.ClickHandler; | |
14 import com.smartgwt.client.widgets.form.DynamicForm; | |
15 import com.smartgwt.client.widgets.form.fields.CheckboxItem; | |
16 import com.smartgwt.client.widgets.form.fields.FormItem; | |
17 import com.smartgwt.client.widgets.form.fields.SelectItem; | |
18 import com.smartgwt.client.widgets.form.fields.TextItem; | |
19 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; | |
20 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; | |
21 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; | |
22 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; | |
23 import com.smartgwt.client.widgets.layout.HLayout; | |
24 import com.smartgwt.client.widgets.layout.VLayout; | |
25 import com.smartgwt.client.widgets.tab.Tab; | |
26 import com.smartgwt.client.widgets.tab.TabSet; | |
27 | |
28 import de.intevation.flys.client.client.Config; | |
29 import de.intevation.flys.client.client.FLYSConstants; | |
30 import de.intevation.flys.client.client.services.CollectionAttributeService; | |
31 import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; | |
32 import de.intevation.flys.client.client.utils.DoubleValidator; | |
33 import de.intevation.flys.client.client.utils.IntegerValidator; | |
34 import de.intevation.flys.client.shared.model.BooleanProperty; | |
35 import de.intevation.flys.client.shared.model.Collection; | |
36 import de.intevation.flys.client.shared.model.DoubleProperty; | |
37 import de.intevation.flys.client.shared.model.IntegerProperty; | |
38 import de.intevation.flys.client.shared.model.OutputSettings; | |
39 import de.intevation.flys.client.shared.model.Property; | |
40 import de.intevation.flys.client.shared.model.PropertyGroup; | |
41 import de.intevation.flys.client.shared.model.PropertySetting; | |
42 import de.intevation.flys.client.shared.model.Settings; | |
43 import de.intevation.flys.client.shared.model.StringProperty; | |
2 | 44 |
3 import java.util.LinkedHashMap; | 45 import java.util.LinkedHashMap; |
4 import java.util.List; | 46 import java.util.List; |
5 import java.util.Map; | 47 import java.util.Map; |
6 | |
7 import com.google.gwt.core.client.GWT; | |
8 import com.google.gwt.user.client.rpc.AsyncCallback; | |
9 | |
10 import com.smartgwt.client.util.SC; | |
11 import com.smartgwt.client.widgets.Window; | |
12 import com.smartgwt.client.widgets.tab.TabSet; | |
13 import com.smartgwt.client.widgets.tab.Tab; | |
14 import com.smartgwt.client.widgets.layout.VLayout; | |
15 import com.smartgwt.client.widgets.layout.HLayout; | |
16 import com.smartgwt.client.widgets.Button; | |
17 import com.smartgwt.client.widgets.Label; | |
18 import com.smartgwt.client.widgets.Canvas; | |
19 | |
20 import com.smartgwt.client.widgets.form.DynamicForm; | |
21 import com.smartgwt.client.widgets.form.fields.FormItem; | |
22 import com.smartgwt.client.widgets.form.fields.CheckboxItem; | |
23 import com.smartgwt.client.widgets.form.fields.SelectItem; | |
24 import com.smartgwt.client.widgets.form.fields.TextItem; | |
25 | |
26 import com.smartgwt.client.widgets.events.ClickEvent; | |
27 import com.smartgwt.client.widgets.events.ClickHandler; | |
28 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; | |
29 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; | |
30 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; | |
31 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; | |
32 | |
33 import com.smartgwt.client.types.Alignment; | |
34 | |
35 import de.intevation.flys.client.client.Config; | |
36 import de.intevation.flys.client.client.FLYSConstants; | |
37 import de.intevation.flys.client.shared.model.Property; | |
38 import de.intevation.flys.client.shared.model.PropertyGroup; | |
39 import de.intevation.flys.client.shared.model.PropertySetting; | |
40 import de.intevation.flys.client.shared.model.BooleanProperty; | |
41 import de.intevation.flys.client.shared.model.DoubleProperty; | |
42 import de.intevation.flys.client.shared.model.IntegerProperty; | |
43 import de.intevation.flys.client.shared.model.StringProperty; | |
44 import de.intevation.flys.client.shared.model.Settings; | |
45 import de.intevation.flys.client.shared.model.OutputSettings; | |
46 import de.intevation.flys.client.shared.model.Collection; | |
47 import de.intevation.flys.client.client.utils.IntegerValidator; | |
48 import de.intevation.flys.client.client.utils.DoubleValidator; | |
49 | |
50 import de.intevation.flys.client.client.services.CollectionAttributeService; | |
51 import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; | |
52 | 48 |
53 /** | 49 /** |
54 * Dialog for the Chart-Properties, constructed from respective xml document. | 50 * Dialog for the Chart-Properties, constructed from respective xml document. |
55 * | 51 * |
56 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 52 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
100 protected void init() { | 96 protected void init() { |
101 setTitle(MSG.properties()); | 97 setTitle(MSG.properties()); |
102 setCanDragReposition(true); | 98 setCanDragReposition(true); |
103 setCanDragResize(true); | 99 setCanDragResize(true); |
104 | 100 |
105 Config config = Config.getInstance(); | |
106 collection = tab.getCollectionView().getCollection(); | 101 collection = tab.getCollectionView().getCollection(); |
107 String outputName = tab.getOutputName(); | 102 String outputName = tab.getOutputName(); |
108 origSettings = (OutputSettings)collection.getSettings(outputName); | 103 origSettings = (OutputSettings)collection.getSettings(outputName); |
109 | 104 |
110 settings = (OutputSettings)origSettings.clone(); | 105 settings = (OutputSettings)origSettings.clone(); |
138 | 133 |
139 Button accept = new Button(MSG.label_ok()); | 134 Button accept = new Button(MSG.label_ok()); |
140 Button cancel = new Button(MSG.label_cancel()); | 135 Button cancel = new Button(MSG.label_cancel()); |
141 cancel.addClickHandler(this); | 136 cancel.addClickHandler(this); |
142 accept.addClickHandler(new ClickHandler() { | 137 accept.addClickHandler(new ClickHandler() { |
138 @Override | |
143 public void onClick(ClickEvent e) { | 139 public void onClick(ClickEvent e) { |
144 if(isDialogValid()) { | 140 if(isDialogValid()) { |
145 updateCollection(); | 141 updateCollection(); |
146 } | 142 } |
147 else { | 143 else { |
167 | 163 |
168 /** | 164 /** |
169 * This method is called when the user aborts theming. | 165 * This method is called when the user aborts theming. |
170 * @param event The event. | 166 * @param event The event. |
171 */ | 167 */ |
168 @Override | |
172 public void onClick(ClickEvent event) { | 169 public void onClick(ClickEvent event) { |
173 this.destroy(); | 170 this.destroy(); |
174 } | 171 } |
175 | 172 |
176 | 173 |
177 /** | 174 /** |
178 * | 175 * |
179 */ | 176 */ |
180 protected Canvas generatePropertyGroup(Property group, Property orig) { | 177 protected Canvas generatePropertyGroup(Property group, Property orig) { |
181 Config config = Config.getInstance(); | |
182 String locale = config.getLocale(); | |
183 PropertyGroup pg = (PropertyGroup)group; | 178 PropertyGroup pg = (PropertyGroup)group; |
184 PropertyGroup origPg = (PropertyGroup)orig; | 179 PropertyGroup origPg = (PropertyGroup)orig; |
185 | 180 |
186 if (pg.getName().equals("axis")) { | 181 if (pg.getName().equals("axis")) { |
187 Label scale = new Label(MSG.scale() + " :"); | 182 Label scale = new Label(MSG.scale() + " :"); |
228 FormItem fix = createBooleanProperty(fixation); | 223 FormItem fix = createBooleanProperty(fixation); |
229 fix.setValue(((BooleanProperty) | 224 fix.setValue(((BooleanProperty) |
230 origPg.getPropertyByName("fixation")).getValue().booleanValue()); | 225 origPg.getPropertyByName("fixation")).getValue().booleanValue()); |
231 | 226 |
232 fix.addChangedHandler(new ChangedHandler() { | 227 fix.addChangedHandler(new ChangedHandler() { |
228 @Override | |
233 public void onChanged(ChangedEvent e) { | 229 public void onChanged(ChangedEvent e) { |
234 if ((Boolean)e.getValue()) { | 230 if ((Boolean)e.getValue()) { |
235 range1.enable(); | 231 range1.enable(); |
236 range2.enable(); | 232 range2.enable(); |
237 } | 233 } |
276 */ | 272 */ |
277 protected DynamicForm generatePropertySetting( | 273 protected DynamicForm generatePropertySetting( |
278 Property setting, | 274 Property setting, |
279 Property orig) | 275 Property orig) |
280 { | 276 { |
281 PropertySetting s = (PropertySetting)setting; | |
282 DynamicForm form = new DynamicForm(); | 277 DynamicForm form = new DynamicForm(); |
283 FormItem item = new FormItem(); | 278 FormItem item = new FormItem(); |
284 if (setting instanceof BooleanProperty) { | 279 if (setting instanceof BooleanProperty) { |
285 item = createBooleanProperty((BooleanProperty)setting); | 280 item = createBooleanProperty((BooleanProperty)setting); |
286 item.setValue(((BooleanProperty)orig).getValue().booleanValue()); | 281 item.setValue(((BooleanProperty)orig).getValue().booleanValue()); |
342 logoChooser.setTitleStyle("color:#000;"); | 337 logoChooser.setTitleStyle("color:#000;"); |
343 logoChooser.setTitleAlign(Alignment.LEFT); | 338 logoChooser.setTitleAlign(Alignment.LEFT); |
344 logoChooser.setTitle(MSG.getString(name)); | 339 logoChooser.setTitle(MSG.getString(name)); |
345 logoChooser.setTitleAlign(Alignment.LEFT); | 340 logoChooser.setTitleAlign(Alignment.LEFT); |
346 logoChooser.addBlurHandler(new BlurHandler() { | 341 logoChooser.addBlurHandler(new BlurHandler() { |
342 @Override | |
347 public void onBlur(BlurEvent e) { | 343 public void onBlur(BlurEvent e) { |
348 String val; | 344 String val; |
349 if (e.getItem().getValue() == null) { | 345 if (e.getItem().getValue() == null) { |
350 val = ""; | 346 val = ""; |
351 } | 347 } |
367 placeChooser.setTitleStyle("color:#000;"); | 363 placeChooser.setTitleStyle("color:#000;"); |
368 placeChooser.setTitleAlign(Alignment.LEFT); | 364 placeChooser.setTitleAlign(Alignment.LEFT); |
369 placeChooser.setTitle(MSG.getString(name)); | 365 placeChooser.setTitle(MSG.getString(name)); |
370 placeChooser.setTitleAlign(Alignment.LEFT); | 366 placeChooser.setTitleAlign(Alignment.LEFT); |
371 placeChooser.addBlurHandler(new BlurHandler() { | 367 placeChooser.addBlurHandler(new BlurHandler() { |
368 @Override | |
372 public void onBlur(BlurEvent e) { | 369 public void onBlur(BlurEvent e) { |
373 String val; | 370 String val; |
374 if (e.getItem().getValue() == null) { | 371 if (e.getItem().getValue() == null) { |
375 val = ""; | 372 val = ""; |
376 } | 373 } |
392 placeChooser.setTitleStyle("color:#000;"); | 389 placeChooser.setTitleStyle("color:#000;"); |
393 placeChooser.setTitleAlign(Alignment.LEFT); | 390 placeChooser.setTitleAlign(Alignment.LEFT); |
394 placeChooser.setTitle(MSG.getString(name)); | 391 placeChooser.setTitle(MSG.getString(name)); |
395 placeChooser.setTitleAlign(Alignment.LEFT); | 392 placeChooser.setTitleAlign(Alignment.LEFT); |
396 placeChooser.addBlurHandler(new BlurHandler() { | 393 placeChooser.addBlurHandler(new BlurHandler() { |
394 @Override | |
397 public void onBlur(BlurEvent e) { | 395 public void onBlur(BlurEvent e) { |
398 String val; | 396 String val; |
399 if (e.getItem().getValue() == null) { | 397 if (e.getItem().getValue() == null) { |
400 val = ""; | 398 val = ""; |
401 } | 399 } |
410 | 408 |
411 TextItem item = new TextItem(); | 409 TextItem item = new TextItem(); |
412 item.setTitle(MSG.getString(name)); | 410 item.setTitle(MSG.getString(name)); |
413 item.setTitleAlign(Alignment.LEFT); | 411 item.setTitleAlign(Alignment.LEFT); |
414 item.addBlurHandler(new BlurHandler() { | 412 item.addBlurHandler(new BlurHandler() { |
413 @Override | |
415 public void onBlur(BlurEvent e) { | 414 public void onBlur(BlurEvent e) { |
416 String val; | 415 String val; |
417 if (e.getItem().getValue() == null) { | 416 if (e.getItem().getValue() == null) { |
418 val = ""; | 417 val = ""; |
419 } | 418 } |
439 CheckboxItem item = new CheckboxItem("item", MSG.getString(name)); | 438 CheckboxItem item = new CheckboxItem("item", MSG.getString(name)); |
440 item.setLabelAsTitle(true); | 439 item.setLabelAsTitle(true); |
441 item.setTitleStyle("color:#000;"); | 440 item.setTitleStyle("color:#000;"); |
442 item.setTitleAlign(Alignment.LEFT); | 441 item.setTitleAlign(Alignment.LEFT); |
443 item.addBlurHandler(new BlurHandler() { | 442 item.addBlurHandler(new BlurHandler() { |
443 @Override | |
444 public void onBlur(BlurEvent e) { | 444 public void onBlur(BlurEvent e) { |
445 String val; | 445 String val; |
446 if (e.getItem().getValue() == null) { | 446 if (e.getItem().getValue() == null) { |
447 val = ""; | 447 val = ""; |
448 } | 448 } |
467 | 467 |
468 TextItem item = new TextItem(); | 468 TextItem item = new TextItem(); |
469 item.setTitle(MSG.getString(name)); | 469 item.setTitle(MSG.getString(name)); |
470 item.setTitleAlign(Alignment.LEFT); | 470 item.setTitleAlign(Alignment.LEFT); |
471 item.addBlurHandler(new BlurHandler() { | 471 item.addBlurHandler(new BlurHandler() { |
472 @Override | |
472 public void onBlur(BlurEvent e) { | 473 public void onBlur(BlurEvent e) { |
473 DoubleValidator validator = new DoubleValidator(); | 474 DoubleValidator validator = new DoubleValidator(); |
474 Map errors = e.getForm().getErrors(); | 475 Map errors = e.getForm().getErrors(); |
475 if(validator.validate(e.getItem(), errors)) { | 476 if(validator.validate(e.getItem(), errors)) { |
476 dp.setValueFromUI(e.getItem().getValue().toString()); | 477 dp.setValueFromUI(e.getItem().getValue().toString()); |
493 | 494 |
494 TextItem item = new TextItem(); | 495 TextItem item = new TextItem(); |
495 item.setTitle(MSG.getString(name)); | 496 item.setTitle(MSG.getString(name)); |
496 item.setTitleAlign(Alignment.LEFT); | 497 item.setTitleAlign(Alignment.LEFT); |
497 item.addBlurHandler(new BlurHandler() { | 498 item.addBlurHandler(new BlurHandler() { |
499 @Override | |
498 public void onBlur(BlurEvent e) { | 500 public void onBlur(BlurEvent e) { |
499 IntegerValidator validator = new IntegerValidator(); | 501 IntegerValidator validator = new IntegerValidator(); |
500 Map errors = e.getForm().getErrors(); | 502 Map errors = e.getForm().getErrors(); |
501 if(validator.validate(e.getItem(), errors)) { | 503 if(validator.validate(e.getItem(), errors)) { |
502 ip.setValue(e.getItem().getValue().toString()); | 504 ip.setValue(e.getItem().getValue().toString()); |
515 GWT.log("PropertiesEditor.updateCollection via RPC now"); | 517 GWT.log("PropertiesEditor.updateCollection via RPC now"); |
516 | 518 |
517 Settings s = settings; | 519 Settings s = settings; |
518 collection.addSettings(this.tab.getOutputName(), s); | 520 collection.addSettings(this.tab.getOutputName(), s); |
519 updater.update(collection, loc, new AsyncCallback<Collection>() { | 521 updater.update(collection, loc, new AsyncCallback<Collection>() { |
522 @Override | |
520 public void onFailure(Throwable caught) { | 523 public void onFailure(Throwable caught) { |
521 GWT.log("Could not update collection attributes."); | 524 GWT.log("Could not update collection attributes."); |
522 SC.warn(MSG.getString(caught.getMessage())); | 525 SC.warn(MSG.getString(caught.getMessage())); |
523 } | 526 } |
527 @Override | |
524 public void onSuccess(Collection collection) { | 528 public void onSuccess(Collection collection) { |
525 updateChartTab(); | 529 updateChartTab(); |
526 } | 530 } |
527 }); | 531 }); |
528 } | 532 } |