Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java @ 4184:03de5c424f95
Fix warnings and minor TODOs in flys-client.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 19 Oct 2012 09:29:57 +0200 |
parents | 8a16ff3b9a7f |
children | af2aa716152f |
comparison
equal
deleted
inserted
replaced
4183:1755a1bfe5ce | 4184:03de5c424f95 |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | 2 |
6 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
7 import com.google.gwt.user.client.rpc.AsyncCallback; | 4 import com.google.gwt.user.client.rpc.AsyncCallback; |
8 | 5 |
6 import com.smartgwt.client.util.BooleanCallback; | |
9 import com.smartgwt.client.util.SC; | 7 import com.smartgwt.client.util.SC; |
10 import com.smartgwt.client.util.BooleanCallback; | |
11 import com.smartgwt.client.widgets.Canvas; | 8 import com.smartgwt.client.widgets.Canvas; |
12 import com.smartgwt.client.widgets.grid.ListGrid; | 9 import com.smartgwt.client.widgets.grid.ListGrid; |
13 import com.smartgwt.client.widgets.grid.ListGridRecord; | 10 import com.smartgwt.client.widgets.grid.ListGridRecord; |
14 import com.smartgwt.client.widgets.grid.events.EditCompleteEvent; | 11 import com.smartgwt.client.widgets.grid.events.EditCompleteEvent; |
15 import com.smartgwt.client.widgets.grid.events.EditCompleteHandler; | 12 import com.smartgwt.client.widgets.grid.events.EditCompleteHandler; |
18 import com.smartgwt.client.widgets.menu.Menu; | 15 import com.smartgwt.client.widgets.menu.Menu; |
19 import com.smartgwt.client.widgets.menu.MenuItem; | 16 import com.smartgwt.client.widgets.menu.MenuItem; |
20 import com.smartgwt.client.widgets.menu.events.ClickHandler; | 17 import com.smartgwt.client.widgets.menu.events.ClickHandler; |
21 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; | 18 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; |
22 | 19 |
23 import de.intevation.flys.client.shared.model.Collection; | |
24 import de.intevation.flys.client.shared.model.CollectionItemAttribute; | |
25 import de.intevation.flys.client.shared.model.FacetRecord; | |
26 import de.intevation.flys.client.shared.model.OutputMode; | |
27 import de.intevation.flys.client.shared.model.Theme; | |
28 import de.intevation.flys.client.shared.model.ThemeList; | |
29 | |
30 import de.intevation.flys.client.client.Config; | 20 import de.intevation.flys.client.client.Config; |
31 import de.intevation.flys.client.client.FLYSConstants; | 21 import de.intevation.flys.client.client.FLYSConstants; |
32 import de.intevation.flys.client.client.event.HasOutputParameterChangeHandlers; | 22 import de.intevation.flys.client.client.event.HasOutputParameterChangeHandlers; |
33 import de.intevation.flys.client.client.event.HasRedrawRequestHandlers; | 23 import de.intevation.flys.client.client.event.HasRedrawRequestHandlers; |
34 import de.intevation.flys.client.client.event.OnMoveEvent; | 24 import de.intevation.flys.client.client.event.OnMoveEvent; |
35 import de.intevation.flys.client.client.event.OnMoveHandler; | 25 import de.intevation.flys.client.client.event.OnMoveHandler; |
36 import de.intevation.flys.client.client.event.OutputParameterChangeEvent; | 26 import de.intevation.flys.client.client.event.OutputParameterChangeEvent; |
37 import de.intevation.flys.client.client.event.OutputParameterChangeHandler; | 27 import de.intevation.flys.client.client.event.OutputParameterChangeHandler; |
38 import de.intevation.flys.client.client.event.RedrawRequestHandler; | |
39 import de.intevation.flys.client.client.event.RedrawRequestEvent; | 28 import de.intevation.flys.client.client.event.RedrawRequestEvent; |
40 import de.intevation.flys.client.client.event.RedrawRequestEvent.Type; | 29 import de.intevation.flys.client.client.event.RedrawRequestEvent.Type; |
30 import de.intevation.flys.client.client.event.RedrawRequestHandler; | |
41 import de.intevation.flys.client.client.services.CollectionAttributeService; | 31 import de.intevation.flys.client.client.services.CollectionAttributeService; |
42 import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; | 32 import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; |
43 import de.intevation.flys.client.client.services.CollectionItemAttributeService; | 33 import de.intevation.flys.client.client.services.CollectionItemAttributeService; |
44 import de.intevation.flys.client.client.services.CollectionItemAttributeServiceAsync; | 34 import de.intevation.flys.client.client.services.CollectionItemAttributeServiceAsync; |
35 import de.intevation.flys.client.shared.model.Collection; | |
36 import de.intevation.flys.client.shared.model.CollectionItemAttribute; | |
37 import de.intevation.flys.client.shared.model.FacetRecord; | |
38 import de.intevation.flys.client.shared.model.OutputMode; | |
39 import de.intevation.flys.client.shared.model.Theme; | |
40 import de.intevation.flys.client.shared.model.ThemeList; | |
41 | |
42 import java.util.ArrayList; | |
43 import java.util.List; | |
45 | 44 |
46 /** | 45 /** |
47 * ThemePanel on the left in CollectionView. | 46 * ThemePanel on the left in CollectionView. |
48 * Contains control widgets for "themes", which are plotted in a diagram (chart). | 47 * Contains control widgets for "themes", which are plotted in a diagram (chart). |
49 * | 48 * |
91 ) { | 90 ) { |
92 this.mode = mode; | 91 this.mode = mode; |
93 this.list = createGrid(); | 92 this.list = createGrid(); |
94 this.view = view; | 93 this.view = view; |
95 list.addRowContextClickHandler(new RowContextClickHandler() { | 94 list.addRowContextClickHandler(new RowContextClickHandler() { |
95 @Override | |
96 public void onRowContextClick(RowContextClickEvent event) { | 96 public void onRowContextClick(RowContextClickEvent event) { |
97 ListGridRecord[] records = list.getSelection(); | 97 ListGridRecord[] records = list.getSelectedRecords(); |
98 | 98 |
99 Menu menu = null; | 99 Menu menu = null; |
100 | 100 |
101 if (records == null || records.length == 0) { | 101 if (records == null || records.length == 0) { |
102 return; | 102 return; |
162 /** | 162 /** |
163 * Registers a new OutputParameterChangeHandler. | 163 * Registers a new OutputParameterChangeHandler. |
164 * | 164 * |
165 * @param h The new handler. | 165 * @param h The new handler. |
166 */ | 166 */ |
167 @Override | |
167 public void addOutputParameterChangeHandler(OutputParameterChangeHandler h){ | 168 public void addOutputParameterChangeHandler(OutputParameterChangeHandler h){ |
168 if (h != null) { | 169 if (h != null) { |
169 outHandlers.add(h); | 170 outHandlers.add(h); |
170 } | 171 } |
171 } | 172 } |
174 /** | 175 /** |
175 * Registers a RedrawRequestHandler. | 176 * Registers a RedrawRequestHandler. |
176 * | 177 * |
177 * @param h The new handler. | 178 * @param h The new handler. |
178 */ | 179 */ |
180 @Override | |
179 public void addRedrawRequestHandler(RedrawRequestHandler h){ | 181 public void addRedrawRequestHandler(RedrawRequestHandler h){ |
180 if (h != null) { | 182 if (h != null) { |
181 redrawRequestHandlers.add(h); | 183 redrawRequestHandlers.add(h); |
182 } | 184 } |
183 } | 185 } |
296 | 298 |
297 // Don't forget to enable the panel after the request has finished! | 299 // Don't forget to enable the panel after the request has finished! |
298 disable(); | 300 disable(); |
299 | 301 |
300 updater.update(getCollection(), loc, new AsyncCallback<Collection>() { | 302 updater.update(getCollection(), loc, new AsyncCallback<Collection>() { |
303 @Override | |
301 public void onFailure(Throwable caught) { | 304 public void onFailure(Throwable caught) { |
302 GWT.log("Could not update collection attributes."); | 305 GWT.log("Could not update collection attributes."); |
303 SC.warn(MSG.getString(caught.getMessage())); | 306 SC.warn(MSG.getString(caught.getMessage())); |
304 | 307 |
305 enable(); | 308 enable(); |
306 } | 309 } |
307 | 310 |
308 | 311 |
312 @Override | |
309 public void onSuccess(Collection collection) { | 313 public void onSuccess(Collection collection) { |
310 setCollection(collection); | 314 setCollection(collection); |
311 | 315 |
312 enable(); | 316 enable(); |
313 } | 317 } |
384 /** The properties menu item (opens style editor on click). */ | 388 /** The properties menu item (opens style editor on click). */ |
385 protected MenuItem createPropertiesItem(final ListGridRecord[] records) { | 389 protected MenuItem createPropertiesItem(final ListGridRecord[] records) { |
386 MenuItem properties = new MenuItem(MSG.properties()); | 390 MenuItem properties = new MenuItem(MSG.properties()); |
387 | 391 |
388 properties.addClickHandler(new ClickHandler() { | 392 properties.addClickHandler(new ClickHandler() { |
393 @Override | |
389 public void onClick(MenuItemClickEvent evt) { | 394 public void onClick(MenuItemClickEvent evt) { |
390 GWT.log("clicked properties"); | 395 GWT.log("clicked properties"); |
391 for (ListGridRecord record: records) { | 396 for (ListGridRecord record: records) { |
392 openStyleEditor((FacetRecord) record); | 397 openStyleEditor((FacetRecord) record); |
393 } | 398 } |
400 | 405 |
401 protected MenuItem createActivateItem(final ListGridRecord[] records) { | 406 protected MenuItem createActivateItem(final ListGridRecord[] records) { |
402 MenuItem activate = new MenuItem(MSG.activateTheme()); | 407 MenuItem activate = new MenuItem(MSG.activateTheme()); |
403 | 408 |
404 activate.addClickHandler(new ClickHandler() { | 409 activate.addClickHandler(new ClickHandler() { |
410 @Override | |
405 public void onClick(MenuItemClickEvent evt) { | 411 public void onClick(MenuItemClickEvent evt) { |
406 for (ListGridRecord record: records) { | 412 for (ListGridRecord record: records) { |
407 FacetRecord facet = (FacetRecord) record; | 413 FacetRecord facet = (FacetRecord) record; |
408 activateTheme(facet.getTheme(), true); | 414 activateTheme(facet.getTheme(), true); |
409 } | 415 } |
418 | 424 |
419 protected MenuItem createDeactivateItem(final ListGridRecord[] records) { | 425 protected MenuItem createDeactivateItem(final ListGridRecord[] records) { |
420 MenuItem deactivate = new MenuItem(MSG.deactivateTheme()); | 426 MenuItem deactivate = new MenuItem(MSG.deactivateTheme()); |
421 | 427 |
422 deactivate.addClickHandler(new ClickHandler() { | 428 deactivate.addClickHandler(new ClickHandler() { |
429 @Override | |
423 public void onClick(MenuItemClickEvent evt) { | 430 public void onClick(MenuItemClickEvent evt) { |
424 for (ListGridRecord record: records) { | 431 for (ListGridRecord record: records) { |
425 FacetRecord facet = (FacetRecord) record; | 432 FacetRecord facet = (FacetRecord) record; |
426 activateTheme(facet.getTheme(), false); | 433 activateTheme(facet.getTheme(), false); |
427 } | 434 } |
449 /** Create menu item for removing theme(s). Will ask for confirmation. */ | 456 /** Create menu item for removing theme(s). Will ask for confirmation. */ |
450 protected MenuItem createRemoveItem(final ListGridRecord[] records) { | 457 protected MenuItem createRemoveItem(final ListGridRecord[] records) { |
451 MenuItem remove = new MenuItem(MSG.removeTheme()); | 458 MenuItem remove = new MenuItem(MSG.removeTheme()); |
452 | 459 |
453 remove.addClickHandler(new ClickHandler() { | 460 remove.addClickHandler(new ClickHandler() { |
461 @Override | |
454 public void onClick(MenuItemClickEvent evt) { | 462 public void onClick(MenuItemClickEvent evt) { |
455 SC.ask(MSG.askThemeRemove(), new BooleanCallback() { | 463 SC.ask(MSG.askThemeRemove(), new BooleanCallback() { |
456 @Override | 464 @Override |
457 public void execute(Boolean value) { | 465 public void execute(Boolean value) { |
458 if (value) { | 466 if (value) { |
495 * @param theme The theme that is moved. | 503 * @param theme The theme that is moved. |
496 * @param oldIdx The index of the theme before it was moved. | 504 * @param oldIdx The index of the theme before it was moved. |
497 * @param newIdx The index of the theme after it was moved. | 505 * @param newIdx The index of the theme after it was moved. |
498 */ | 506 */ |
499 protected void fireThemeMoved(Theme theme, int oldIdx, int newIdx) { | 507 protected void fireThemeMoved(Theme theme, int oldIdx, int newIdx) { |
500 // TODO Implement in subclasses | 508 // Do nothing |
501 } | 509 } |
502 | 510 |
503 | 511 |
504 @Override | 512 @Override |
505 public void onMove(OnMoveEvent event) { | 513 public void onMove(OnMoveEvent event) { |
506 int type = event.getType(); | 514 int type = event.getType(); |
507 | 515 |
508 GWT.log("ThemePanel.onMove: " + type); | 516 GWT.log("ThemePanel.onMove: " + type); |
509 | 517 |
510 ListGridRecord[] records = list.getSelection(); | 518 ListGridRecord[] records = list.getSelectedRecords(); |
511 | 519 |
512 if (records == null || records.length == 0) { | 520 if (records == null || records.length == 0) { |
513 GWT.log("ThemePanel.onMove: No records selected."); | 521 GWT.log("ThemePanel.onMove: No records selected."); |
514 return; | 522 return; |
515 } | 523 } |
624 itemAttributeService.getCollectionItemAttribute( | 632 itemAttributeService.getCollectionItemAttribute( |
625 this.getCollection(), | 633 this.getCollection(), |
626 artifact, | 634 artifact, |
627 locale, | 635 locale, |
628 new AsyncCallback<CollectionItemAttribute>() { | 636 new AsyncCallback<CollectionItemAttribute>() { |
637 @Override | |
629 public void onFailure (Throwable caught) { | 638 public void onFailure (Throwable caught) { |
630 SC.warn(MSG.getString(caught.getMessage())); | 639 SC.warn(MSG.getString(caught.getMessage())); |
631 } | 640 } |
641 @Override | |
632 public void onSuccess(CollectionItemAttribute cia) { | 642 public void onSuccess(CollectionItemAttribute cia) { |
633 GWT.log("Successfully loaded collectionitem attributes."); | 643 GWT.log("Successfully loaded collectionitem attributes."); |
634 showStyleEditor(cia, record); | 644 showStyleEditor(cia, record); |
635 } | 645 } |
636 }); | 646 }); |