Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java @ 1503:3304608baf35
Issue 433.
Allways load original chart settings when opening the dialog.
flys-client/trunk@3632 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 09 Jan 2012 17:07:17 +0000 |
parents | d1223d93dd68 |
children | 02a9104c0451 |
comparison
equal
deleted
inserted
replaced
1502:d1223d93dd68 | 1503:3304608baf35 |
---|---|
35 import de.intevation.flys.client.shared.model.PropertySetting; | 35 import de.intevation.flys.client.shared.model.PropertySetting; |
36 import de.intevation.flys.client.shared.model.BooleanProperty; | 36 import de.intevation.flys.client.shared.model.BooleanProperty; |
37 import de.intevation.flys.client.shared.model.DoubleProperty; | 37 import de.intevation.flys.client.shared.model.DoubleProperty; |
38 import de.intevation.flys.client.shared.model.IntegerProperty; | 38 import de.intevation.flys.client.shared.model.IntegerProperty; |
39 import de.intevation.flys.client.shared.model.StringProperty; | 39 import de.intevation.flys.client.shared.model.StringProperty; |
40 import de.intevation.flys.client.shared.model.Settings; | |
40 import de.intevation.flys.client.shared.model.OutputSettings; | 41 import de.intevation.flys.client.shared.model.OutputSettings; |
41 import de.intevation.flys.client.shared.model.Collection; | 42 import de.intevation.flys.client.shared.model.Collection; |
42 import de.intevation.flys.client.client.utils.Validator; | 43 import de.intevation.flys.client.client.utils.Validator; |
43 | 44 |
44 import de.intevation.flys.client.client.services.CollectionAttributeService; | 45 import de.intevation.flys.client.client.services.CollectionAttributeService; |
64 protected TabSet tabs; | 65 protected TabSet tabs; |
65 | 66 |
66 /** The collection */ | 67 /** The collection */ |
67 protected Collection collection; | 68 protected Collection collection; |
68 | 69 |
69 /** The output settings */ | 70 /** The cloned output settings */ |
70 protected OutputSettings settings; | 71 protected OutputSettings settings; |
72 | |
73 /** The original output settings */ | |
74 protected OutputSettings origSettings; | |
71 | 75 |
72 | 76 |
73 /** | 77 /** |
74 * Setup editor dialog. | 78 * Setup editor dialog. |
75 * @param callerTab The tab called the editor window. | 79 * @param callerTab The tab called the editor window. |
90 setCanDragResize(true); | 94 setCanDragResize(true); |
91 | 95 |
92 Config config = Config.getInstance(); | 96 Config config = Config.getInstance(); |
93 collection = tab.getCollectionView().getCollection(); | 97 collection = tab.getCollectionView().getCollection(); |
94 String outputName = tab.getOutputName(); | 98 String outputName = tab.getOutputName(); |
95 settings = (OutputSettings)collection.getSettings(outputName); | 99 origSettings = (OutputSettings)collection.getSettings(outputName); |
96 | 100 |
101 settings = (OutputSettings)origSettings.clone(); | |
97 if (settings == null) { | 102 if (settings == null) { |
98 return; | 103 return; |
99 } | 104 } |
100 List<String> list = settings.getCategories(); | 105 List<String> list = settings.getCategories(); |
101 | 106 |
102 for (int i = 0; i < list.size(); i++) { | 107 for (int i = 0; i < list.size(); i++) { |
103 Tab t = new Tab(MSG.getString(list.get(i))); | 108 Tab t = new Tab(MSG.getString(list.get(i))); |
104 List<Property> props = settings.getSettings(list.get(i)); | 109 List<Property> props = settings.getSettings(list.get(i)); |
110 List<Property> origProps = origSettings.getSettings(list.get(i)); | |
105 VLayout layout = new VLayout(); | 111 VLayout layout = new VLayout(); |
106 for (int j = 0; j < props.size(); j++) { | 112 for (int j = 0; j < props.size(); j++) { |
107 if (props.get(j) instanceof PropertyGroup) { | 113 if (props.get(j) instanceof PropertyGroup) { |
108 layout.addMember(generatePropertyGroup(props.get(j))); | 114 layout.addMember(generatePropertyGroup(props.get(j), |
115 origProps.get(j))); | |
109 } | 116 } |
110 else if (props.get(j) instanceof PropertySetting) { | 117 else if (props.get(j) instanceof PropertySetting) { |
111 PropertySetting p = (PropertySetting)props.get(j); | 118 PropertySetting p = (PropertySetting)props.get(j); |
112 if (p.getAttribute("display").equals("false")) { | 119 if (p.getAttribute("display").equals("false")) { |
113 continue; | 120 continue; |
114 } | 121 } |
115 layout.addMember(generatePropertySetting(props.get(j))); | 122 layout.addMember(generatePropertySetting(props.get(j), |
123 origProps.get(j))); | |
116 } | 124 } |
117 } | 125 } |
118 t.setPane(layout); | 126 t.setPane(layout); |
119 tabs.addTab(t); | 127 tabs.addTab(t); |
120 } | 128 } |
150 /** | 158 /** |
151 * This method is called when the user aborts theming. | 159 * This method is called when the user aborts theming. |
152 * @param event The event. | 160 * @param event The event. |
153 */ | 161 */ |
154 public void onClick(ClickEvent event) { | 162 public void onClick(ClickEvent event) { |
155 this.hide(); | 163 this.destroy(); |
156 } | 164 } |
157 | 165 |
158 | 166 |
159 /** | 167 /** |
160 * | 168 * |
161 */ | 169 */ |
162 protected Canvas generatePropertyGroup(Property group) { | 170 protected Canvas generatePropertyGroup(Property group, Property orig) { |
163 PropertyGroup pg = (PropertyGroup)group; | 171 PropertyGroup pg = (PropertyGroup)group; |
164 List<Property> list = pg.getProperties(); | 172 PropertyGroup origPg = (PropertyGroup)orig; |
165 | 173 |
166 if (pg.getName().equals("axis")) { | 174 if (pg.getName().equals("axis")) { |
167 Label scale = new Label(MSG.scale() + " :"); | 175 Label scale = new Label(MSG.scale() + " :"); |
168 scale.setHeight(25); | 176 scale.setHeight(25); |
169 scale.setMargin(2); | 177 scale.setMargin(2); |
173 form2.setNumCols(6); | 181 form2.setNumCols(6); |
174 | 182 |
175 StringProperty label = | 183 StringProperty label = |
176 (StringProperty)pg.getPropertyByName("label"); | 184 (StringProperty)pg.getPropertyByName("label"); |
177 FormItem title = createStringProperty(label); | 185 FormItem title = createStringProperty(label); |
186 title.setValue( | |
187 ((StringProperty)origPg.getPropertyByName("label")).getValue()); | |
178 | 188 |
179 IntegerProperty fontsize = | 189 IntegerProperty fontsize = |
180 (IntegerProperty)pg.getPropertyByName("font-size"); | 190 (IntegerProperty)pg.getPropertyByName("font-size"); |
181 FormItem fs = createIntegerProperty(fontsize); | 191 FormItem fs = createIntegerProperty(fontsize); |
182 fs.setAttribute("internalType", "integer"); | 192 fs.setAttribute("internalType", "integer"); |
183 fs.addChangedHandler(new Validator()); | 193 fs.addChangedHandler(new Validator()); |
194 fs.setValue( | |
195 ((IntegerProperty) | |
196 origPg.getPropertyByName("font-size")).getValue()); | |
184 | 197 |
185 DoubleProperty upper = | 198 DoubleProperty upper = |
186 (DoubleProperty)pg.getPropertyByName("upper"); | 199 (DoubleProperty)pg.getPropertyByName("upper"); |
187 final FormItem range1 = createDoubleProperty(upper); | 200 final FormItem range1 = createDoubleProperty(upper); |
188 range1.setAttribute("internalType", "double"); | 201 range1.setAttribute("internalType", "double"); |
189 range1.addChangedHandler(new Validator()); | 202 range1.addChangedHandler(new Validator()); |
190 range1.setWidth(70); | 203 range1.setWidth(70); |
204 range1.setValue( | |
205 ((DoubleProperty)origPg.getPropertyByName("upper")).getValue()); | |
191 | 206 |
192 DoubleProperty lower = | 207 DoubleProperty lower = |
193 (DoubleProperty)pg.getPropertyByName("lower"); | 208 (DoubleProperty)pg.getPropertyByName("lower"); |
194 final FormItem range2 = createDoubleProperty(lower); | 209 final FormItem range2 = createDoubleProperty(lower); |
195 range2.setAttribute("internalType", "double"); | 210 range2.setAttribute("internalType", "double"); |
196 range2.addChangedHandler(new Validator()); | 211 range2.addChangedHandler(new Validator()); |
197 range2.setWidth(70); | 212 range2.setWidth(70); |
213 range2.setValue( | |
214 ((DoubleProperty)origPg.getPropertyByName("lower")).getValue()); | |
198 | 215 |
199 BooleanProperty fixation = | 216 BooleanProperty fixation = |
200 (BooleanProperty)pg.getPropertyByName("fixation"); | 217 (BooleanProperty)pg.getPropertyByName("fixation"); |
201 FormItem fix = createBooleanProperty(fixation); | 218 FormItem fix = createBooleanProperty(fixation); |
219 fix.setValue( | |
220 ((BooleanProperty) | |
221 origPg.getPropertyByName("fixation")).getValue()); | |
202 fix.addChangedHandler(new ChangedHandler() { | 222 fix.addChangedHandler(new ChangedHandler() { |
203 public void onChanged(ChangedEvent e) { | 223 public void onChanged(ChangedEvent e) { |
204 if ((Boolean)e.getValue()) { | 224 if ((Boolean)e.getValue()) { |
205 range1.enable(); | 225 range1.enable(); |
206 range2.enable(); | 226 range2.enable(); |
225 | 245 |
226 HLayout scaleLayout = new HLayout(); | 246 HLayout scaleLayout = new HLayout(); |
227 scaleLayout.setHeight(30); | 247 scaleLayout.setHeight(30); |
228 scaleLayout.addMember(scale); | 248 scaleLayout.addMember(scale); |
229 scaleLayout.addMember(form2); | 249 scaleLayout.addMember(form2); |
230 scaleLayout.addStyleName("property-dialog-axis"); | 250 scaleLayout.setStyleName("property-dialog-axis"); |
231 | 251 |
232 VLayout root = new VLayout(); | 252 VLayout root = new VLayout(); |
233 root.addMember(form1); | 253 root.addMember(form1); |
234 root.addMember(scaleLayout); | 254 root.addMember(scaleLayout); |
235 root.setHeight(90); | 255 root.setHeight(90); |
241 | 261 |
242 | 262 |
243 /** | 263 /** |
244 * | 264 * |
245 */ | 265 */ |
246 protected DynamicForm generatePropertySetting(Property setting) { | 266 protected DynamicForm generatePropertySetting( |
267 Property setting, | |
268 Property orig) | |
269 { | |
247 PropertySetting s = (PropertySetting)setting; | 270 PropertySetting s = (PropertySetting)setting; |
248 DynamicForm form = new DynamicForm(); | 271 DynamicForm form = new DynamicForm(); |
249 FormItem item = new FormItem(); | 272 FormItem item = new FormItem(); |
250 if (setting instanceof BooleanProperty) { | 273 if (setting instanceof BooleanProperty) { |
251 item = createBooleanProperty((BooleanProperty)setting); | 274 item = createBooleanProperty((BooleanProperty)setting); |
275 item.setValue(((BooleanProperty)orig).getValue()); | |
252 } | 276 } |
253 else if (setting instanceof DoubleProperty) { | 277 else if (setting instanceof DoubleProperty) { |
254 item = createDoubleProperty((DoubleProperty)setting); | 278 item = createDoubleProperty((DoubleProperty)setting); |
255 item.setAttribute("internalType", "double"); | 279 item.setAttribute("internalType", "double"); |
256 item.addChangedHandler(new Validator()); | 280 item.addChangedHandler(new Validator()); |
281 item.setValue(((DoubleProperty)orig).getValue()); | |
257 } | 282 } |
258 else if (setting instanceof IntegerProperty) { | 283 else if (setting instanceof IntegerProperty) { |
259 item = createIntegerProperty((IntegerProperty)setting); | 284 item = createIntegerProperty((IntegerProperty)setting); |
260 item.setAttribute("internalType", "integer"); | 285 item.setAttribute("internalType", "integer"); |
261 item.addChangedHandler(new Validator()); | 286 item.addChangedHandler(new Validator()); |
287 item.setValue(((IntegerProperty)orig).getValue()); | |
262 } | 288 } |
263 else if (setting instanceof StringProperty) { | 289 else if (setting instanceof StringProperty) { |
264 item = createStringProperty((StringProperty)setting); | 290 item = createStringProperty((StringProperty)setting); |
291 item.setValue(((StringProperty)orig).getValue()); | |
265 } | 292 } |
266 form.setFields(item); | 293 form.setFields(item); |
267 return form; | 294 return form; |
268 } | 295 } |
269 | 296 |
277 name = name.replace("-", "_"); | 304 name = name.replace("-", "_"); |
278 } | 305 } |
279 TextItem item = new TextItem(); | 306 TextItem item = new TextItem(); |
280 item.setTitle(MSG.getString(name)); | 307 item.setTitle(MSG.getString(name)); |
281 item.setTitleAlign(Alignment.LEFT); | 308 item.setTitleAlign(Alignment.LEFT); |
282 item.setValue(sp.getValue()); | |
283 item.addChangedHandler(new ChangedHandler() { | 309 item.addChangedHandler(new ChangedHandler() { |
284 public void onChanged(ChangedEvent e) { | 310 public void onChanged(ChangedEvent e) { |
285 String val; | 311 String val; |
286 if (e.getValue() == null) { | 312 if (e.getValue() == null) { |
287 val = ""; | 313 val = ""; |
307 | 333 |
308 CheckboxItem item = new CheckboxItem("item", MSG.getString(name)); | 334 CheckboxItem item = new CheckboxItem("item", MSG.getString(name)); |
309 item.setLabelAsTitle(true); | 335 item.setLabelAsTitle(true); |
310 item.setTitleStyle("color:#000;"); | 336 item.setTitleStyle("color:#000;"); |
311 item.setTitleAlign(Alignment.LEFT); | 337 item.setTitleAlign(Alignment.LEFT); |
312 if(bp.getValue().equals("true")) { | 338 /* if(bp.getValue().equals("true")) { |
313 item.setValue(true); | 339 item.setValue(true); |
314 } | 340 } |
315 else { | 341 else { |
316 item.setValue(false); | 342 item.setValue(false); |
317 } | 343 }*/ |
318 item.addChangedHandler(new ChangedHandler() { | 344 item.addChangedHandler(new ChangedHandler() { |
319 public void onChanged(ChangedEvent e) { | 345 public void onChanged(ChangedEvent e) { |
320 String val; | 346 String val; |
321 if (e.getValue() == null) { | 347 if (e.getValue() == null) { |
322 val = ""; | 348 val = ""; |
341 } | 367 } |
342 | 368 |
343 TextItem item = new TextItem(); | 369 TextItem item = new TextItem(); |
344 item.setTitle(MSG.getString(name)); | 370 item.setTitle(MSG.getString(name)); |
345 item.setTitleAlign(Alignment.LEFT); | 371 item.setTitleAlign(Alignment.LEFT); |
346 item.setValue(dp.getValue()); | |
347 item.addChangedHandler(new ChangedHandler() { | 372 item.addChangedHandler(new ChangedHandler() { |
348 public void onChanged(ChangedEvent e) { | 373 public void onChanged(ChangedEvent e) { |
349 String val; | 374 String val; |
350 if (e.getValue() == null) { | 375 if (e.getValue() == null) { |
351 val = ""; | 376 val = ""; |
370 } | 395 } |
371 | 396 |
372 TextItem item = new TextItem(); | 397 TextItem item = new TextItem(); |
373 item.setTitle(MSG.getString(name)); | 398 item.setTitle(MSG.getString(name)); |
374 item.setTitleAlign(Alignment.LEFT); | 399 item.setTitleAlign(Alignment.LEFT); |
375 item.setValue(ip.getValue()); | |
376 item.addChangedHandler(new ChangedHandler() { | 400 item.addChangedHandler(new ChangedHandler() { |
377 public void onChanged(ChangedEvent e) { | 401 public void onChanged(ChangedEvent e) { |
378 String val; | 402 String val; |
379 if (e.getValue() == null) { | 403 if (e.getValue() == null) { |
380 val = ""; | 404 val = ""; |
393 final Config config = Config.getInstance(); | 417 final Config config = Config.getInstance(); |
394 final String loc = config.getLocale(); | 418 final String loc = config.getLocale(); |
395 | 419 |
396 GWT.log("PropertiesEditor.updateCollection via RPC now"); | 420 GWT.log("PropertiesEditor.updateCollection via RPC now"); |
397 | 421 |
422 Settings s = settings; | |
423 collection.addSettings(this.tab.getOutputName(), s); | |
398 updater.update(collection, loc, new AsyncCallback<Collection>() { | 424 updater.update(collection, loc, new AsyncCallback<Collection>() { |
399 public void onFailure(Throwable caught) { | 425 public void onFailure(Throwable caught) { |
400 GWT.log("Could not update collection attributes."); | 426 GWT.log("Could not update collection attributes."); |
401 SC.warn(MSG.getString(caught.getMessage())); | 427 SC.warn(MSG.getString(caught.getMessage())); |
402 } | 428 } |
405 } | 431 } |
406 }); | 432 }); |
407 } | 433 } |
408 | 434 |
409 protected void updateChartTab() { | 435 protected void updateChartTab() { |
410 this.hide(); | |
411 this.tab.updateChartInfo(); | 436 this.tab.updateChartInfo(); |
412 this.tab.updateChartPanel(); | 437 this.tab.updateChartPanel(); |
438 this.destroy(); | |
413 } | 439 } |
414 | 440 |
415 | 441 |
416 protected boolean isDialogValid() { | 442 protected boolean isDialogValid() { |
417 boolean valid = true; | 443 boolean valid = true; |