# HG changeset patch # User Ingo Weinzierl # Date 1318333858 0 # Node ID 84c50f1d939b26d8f3ff1678ee52061f244348ee # Parent 17e7d5e437fb3061484bf285131ca9a30e719734 Added the option for the MapThemePanel to listen to Theme move events. flys-client/trunk@2936 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 17e7d5e437fb -r 84c50f1d939b flys-client/ChangeLog --- a/flys-client/ChangeLog Mon Oct 10 15:29:39 2011 +0000 +++ b/flys-client/ChangeLog Tue Oct 11 11:50:58 2011 +0000 @@ -1,3 +1,15 @@ +2011-10-11 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java: Added + a method fireThemeMoved which is called after a Theme in this panel is + moved. + + * src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java: + Added in internal interface ThemeMovedCallback which might be used to + listen to theme move events. Therefore, MapThemePanel overrides the + fireThemeMoved method and calls onThemeMoved() on ThemeMovedCallback if + it exists. + 2011-10-10 Ingo Weinzierl * src/main/webapp/FLYS.html: Import OpenLayers 2.11. diff -r 17e7d5e437fb -r 84c50f1d939b flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Mon Oct 10 15:29:39 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Tue Oct 11 11:50:58 2011 +0000 @@ -255,6 +255,19 @@ } + /** + * This method should be defined in subclasses that wants to listen to this + * event. + * + * @param theme The theme that is moved. + * @param oldIdx The index of the theme before it was moved. + * @param newIdx The index of the theme after it was moved. + */ + protected void fireThemeMoved(Theme theme, int oldIdx, int newIdx) { + // TODO Implement in subclasses + } + + @Override public void onMove(OnMoveEvent event) { int type = event.getType(); @@ -291,6 +304,7 @@ for (ListGridRecord record: records) { Theme theme = ((FacetRecord) record).getTheme(); + fireThemeMoved(theme, theme.getPosition(), idx); themeList.setThemePosition(theme, idx++); } @@ -315,6 +329,7 @@ for (int i = 0; i < records.length ; i++) { Theme theme = ((FacetRecord) records[i]).getTheme(); + fireThemeMoved(theme, theme.getPosition(), newPos[i]); themeList.setThemePosition(theme, newPos[i]); } @@ -339,6 +354,7 @@ for (int i = records.length-1; i >= 0; i--) { Theme theme = ((FacetRecord) records[i]).getTheme(); + fireThemeMoved(theme, theme.getPosition(), newPos[i]); themeList.setThemePosition(theme, newPos[i]); } @@ -358,6 +374,7 @@ for (int i = records.length-1; i >= 0; i--) { Theme theme = ((FacetRecord) records[i]).getTheme(); + fireThemeMoved(theme, theme.getPosition(), idx); themeList.setThemePosition(theme, idx--); } diff -r 17e7d5e437fb -r 84c50f1d939b flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java Mon Oct 10 15:29:39 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java Tue Oct 11 11:50:58 2011 +0000 @@ -24,11 +24,17 @@ } + public interface ThemeMovedCallback { + void onThemeMoved(Theme theme, int oldIdx, int newIdx); + } + + private FLYSConstants MSG = GWT.create(FLYSConstants.class); - protected ActivateCallback activateCallback; + protected ActivateCallback activateCallback; + protected ThemeMovedCallback themeMovedCallback; public static final String GRID_FIELD_ACTIVE = "active"; @@ -39,13 +45,24 @@ public MapThemePanel( - Collection collection, - OutputMode mode, - ActivateCallback activateCallback) - { + Collection collection, + OutputMode mode, + ActivateCallback activateCallback + ) { + this(collection, mode, activateCallback, null); + } + + + public MapThemePanel( + Collection collection, + OutputMode mode, + ActivateCallback activateCallback, + ThemeMovedCallback themeMovedCallback + ) { super(collection, mode); - this.activateCallback = activateCallback; + this.activateCallback = activateCallback; + this.themeMovedCallback = themeMovedCallback; initGrid(); initLayout(); @@ -100,5 +117,13 @@ theme.setActive(active ? 1 : 0); } + + + @Override + protected void fireThemeMoved(Theme theme, int oldIdx, int newIdx) { + if (themeMovedCallback != null) { + themeMovedCallback.onThemeMoved(theme, oldIdx, newIdx); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :