Mercurial > dive4elements > river
changeset 1303:84c50f1d939b
Added the option for the MapThemePanel to listen to Theme move events.
flys-client/trunk@2936 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 11 Oct 2011 11:50:58 +0000 |
parents | 17e7d5e437fb |
children | 18b0414bde44 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java |
diffstat | 3 files changed, 60 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo@intevation.de> + + * 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 <ingo@intevation.de> * src/main/webapp/FLYS.html: Import OpenLayers 2.11.
--- 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--); }
--- 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 :