Mercurial > dive4elements > river
changeset 805:f43d06d6a4a2
Refactored code of theme panel and added a MapThemePanel.
flys-client/trunk@2366 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 07:52:19 +0000 (2011-07-20) |
parents | 374712890b94 |
children | e50da1f74e58 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemeNavigationPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ThemeNavigationPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java |
diffstat | 6 files changed, 537 insertions(+), 409 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Tue Jul 19 16:32:52 2011 +0000 +++ b/flys-client/ChangeLog Wed Jul 20 07:52:19 2011 +0000 @@ -1,3 +1,20 @@ +2011-07-20 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/chart/ThemeNavigationPanel.java, + src/main/java/de/intevation/flys/client/client/ui/ThemeNavigationPanel.java: + Moved the panel a package level higher. + + * src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java: New. + Abstract class that consists basically of the code that was removed from + ChartThemePanel. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java: + Sourced code base out to ThemePanel, so that's possible to reuse the + code for a MapThemePanel. + + * src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java: + New. A theme panel for the map widget. + 2011-07-19 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/shared/model/AttributedTheme.java:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemeNavigationPanel.java Wed Jul 20 07:52:19 2011 +0000 @@ -0,0 +1,103 @@ +package de.intevation.flys.client.client.ui; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.ImgButton; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.layout.HLayout; + +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.event.OnMoveEvent; +import de.intevation.flys.client.client.event.OnMoveHandler; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class ThemeNavigationPanel extends Canvas { + + public static final int PANEL_MARGIN = 5; + public static final int BUTTON_HEIGHT = 25; + public static final int BUTTON_MARGIN = 5; + + + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + + + protected List<OnMoveHandler> handlers; + + + public ThemeNavigationPanel() { + this.handlers = new ArrayList<OnMoveHandler>(); + + setWidth100(); + setHeight(BUTTON_HEIGHT); + setMargin(PANEL_MARGIN); + + HLayout layout = new HLayout(); + layout.setWidth100(); + layout.setHeight(BUTTON_HEIGHT); + layout.setMembersMargin(BUTTON_MARGIN); + + Canvas cu = createButton(MSG.theme_top(), OnMoveEvent.TOP); + Canvas u = createButton(MSG.theme_up(), OnMoveEvent.UP); + Canvas d = createButton(MSG.theme_down(), OnMoveEvent.DOWN); + Canvas cd = createButton(MSG.theme_bottom(), OnMoveEvent.BOTTOM); + + layout.addMember(cu); + layout.addMember(u); + layout.addMember(d); + layout.addMember(cd); + + addChild(layout); + } + + + protected Canvas createButton(final String title, final int moveType) { + String url = GWT.getHostPageBaseURL() + title; + + ImgButton b = new ImgButton(); + b.setSrc(url); + b.setHeight(BUTTON_HEIGHT); + b.setWidth(40); + b.setIconHeight(BUTTON_HEIGHT-10); + b.setShowDown(false); + b.setShowRollOver(false); + b.setShowDisabled(false); + b.setShowDisabledIcon(true); + b.setShowDownIcon(false); + b.setShowFocusedIcon(false); + b.setBackgroundColor("f2f2f2"); + b.setBorder("1px solid #A6ABB4"); + + b.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + fireOnMoveEvent(moveType); + } + }); + + return b; + } + + + protected void addOnMoveHandler(OnMoveHandler handler) { + if (handler != null) { + handlers.add(handler); + } + } + + + protected void fireOnMoveEvent(int type) { + OnMoveEvent event = new OnMoveEvent(type); + + for (OnMoveHandler handler: handlers) { + handler.onMove(event); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Wed Jul 20 07:52:19 2011 +0000 @@ -0,0 +1,324 @@ +package de.intevation.flys.client.client.ui; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; + +import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.grid.events.EditCompleteEvent; +import com.smartgwt.client.widgets.grid.events.EditCompleteHandler; + +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.shared.model.FacetRecord; +import de.intevation.flys.client.shared.model.OutputMode; +import de.intevation.flys.client.shared.model.Theme; +import de.intevation.flys.client.shared.model.ThemeList; + +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.event.HasOutputParameterChangeHandlers; +import de.intevation.flys.client.client.event.OnMoveEvent; +import de.intevation.flys.client.client.event.OnMoveHandler; +import de.intevation.flys.client.client.event.OutputParameterChangeEvent; +import de.intevation.flys.client.client.event.OutputParameterChangeHandler; +import de.intevation.flys.client.client.services.CollectionAttributeService; +import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; + + +public abstract class ThemePanel +extends Canvas +implements OnMoveHandler, EditCompleteHandler, HasOutputParameterChangeHandlers +{ + protected CollectionAttributeServiceAsync updater = + GWT.create(CollectionAttributeService.class); + + private FLYSConstants MSG = GWT.create(FLYSConstants.class); + + protected List<OutputParameterChangeHandler> outHandlers; + + protected Collection collection; + protected OutputMode mode; + + protected ThemeNavigationPanel navigation; + protected ListGrid list; + + + public ThemePanel(Collection collection, OutputMode mode) { + this.collection = collection; + this.mode = mode; + this.list = new ListGrid(); + this.outHandlers = new ArrayList<OutputParameterChangeHandler>(); + this.navigation = new ThemeNavigationPanel(); + + this.navigation.addOnMoveHandler(this); + } + + + public abstract void activateTheme(Theme theme, boolean active); + + + /** + * Replace the current collection with a new one. <b>NOTE: this operation + * triggers updateGrid() which modifies the themes in the grid.</b> + * + * @param collection The new collection object. + */ + protected void setCollection(Collection collection) { + this.collection = collection; + + updateGrid(); + } + + + /** + * Returns the ThemeList of the current collection and output mode. + * + * @return the current ThemeList. + */ + public ThemeList getThemeList() { + return collection.getThemeList(mode.getName()); + } + + + /** + * Registers a new OutputParameterChangeHandler. + * + * @param h The new handler. + */ + public void addOutputParameterChangeHandler(OutputParameterChangeHandler h){ + if (h != null) { + outHandlers.add(h); + } + } + + + /** + * Called when the attribution of an output changed. It informs the + * registered handlers about the changes. + */ + protected void fireOutputParameterChanged() { + OutputParameterChangeEvent evt = new OutputParameterChangeEvent(); + + for (OutputParameterChangeHandler handler: outHandlers) { + handler.onOutputParameterChanged(evt); + } + } + + + /** + * This method is used to clear the current theme grid and add new updated + * data. + */ + protected void updateGrid() { + GWT.log("ThemePanel.updateGrid"); + + clearGrid(); + + ThemeList themeList = getThemeList(); + + if (themeList == null) { + GWT.log("ERROR: No theme list."); + return; + } + + int count = themeList.getThemeCount(); + + for (int i = 1; i <= count; i++) { + Theme theme = themeList.getThemeAt(i); + + if (theme == null) { + continue; + } + + list.addData(new FacetRecord(theme)); + } + + fireOutputParameterChanged(); + } + + + /** + * This method triggers the CollectionAttributeService. Based on the current + * collectin settings, the attribute of the collection is modified or not. + * But in every case, we will get a new collection object - which might be + * the same as the current one. + */ + public void updateCollection() { + final Config config = Config.getInstance(); + final String url = config.getServerUrl(); + final String loc = config.getLocale(); + + GWT.log("ThemePanel.updateCollection via RPC now"); + + // don't forget to enable the panel after the request has finished! + disable(); + + updater.update(collection, url, loc, new AsyncCallback<Collection>() { + public void onFailure(Throwable caught) { + GWT.log("Could not update collection attributes."); + SC.warn(MSG.getString(caught.getMessage())); + + enable(); + } + + + public void onSuccess(Collection collection) { + setCollection(collection); + + enable(); + } + }); + } + + + + + /** + * A method that removes all records from theme grid. + */ + protected void clearGrid() { + ListGridRecord[] records = list.getRecords(); + + if (records == null || records.length == 0) { + return; + } + + for (ListGridRecord record: records) { + list.removeData(record); + } + } + + + /** + * This method is called after a cell in the theme grid has been modified. + * + * @param event The event that stores information about the modified record. + */ + @Override + public void onEditComplete(EditCompleteEvent event) { + GWT.log("Edited record."); + + int row = event.getRowNum(); + FacetRecord rec = (FacetRecord) list.getRecord(row); + + activateTheme(rec.getTheme(), rec.getActive()); + + updateCollection(); + } + + + @Override + public void onMove(OnMoveEvent event) { + int type = event.getType(); + + GWT.log("ThemePanel.onMove: " + type); + + ListGridRecord[] records = list.getSelection(); + + if (records == null || records.length == 0) { + GWT.log("ThemePanel.onMove: No records selected."); + return; + } + + switch (type) { + case 0: moveRecordsTop(records); break; + case 1: moveRecordsUp(records); break; + case 2: moveRecordsDown(records); break; + case 3: moveRecordsBottom(records); break; + } + + updateCollection(); + } + + + /** + * Moves the selected grid records (themes) to the top of the grid. + * + * @param records The selected themes in the list. Null not permitted. + */ + protected void moveRecordsTop(ListGridRecord[] records) { + ThemeList themeList = getThemeList(); + + int idx = 1; + + for (ListGridRecord record: records) { + Theme theme = ((FacetRecord) record).getTheme(); + themeList.setThemePosition(theme, idx++); + } + + updateGrid(); + } + + + /** + * Moves the selected grid records (themes) one step up. + * + * @param records The selected themes in the list. Null not permitted. + */ + protected void moveRecordsUp(ListGridRecord[] records) { + ThemeList themeList = getThemeList(); + + int[] newPos = new int[records.length]; + + for (int i = 0; i < records.length ; i++) { + Theme theme = ((FacetRecord) records[i]).getTheme(); + newPos[i] = theme.getPosition() - 1; + } + + for (int i = 0; i < records.length ; i++) { + Theme theme = ((FacetRecord) records[i]).getTheme(); + themeList.setThemePosition(theme, newPos[i]); + } + + updateGrid(); + } + + + /** + * Moves the selected grid records (themes) one step down. + * + * @param records The selected themes in the list. Null not permitted. + */ + protected void moveRecordsDown(ListGridRecord[] records) { + ThemeList themeList = getThemeList(); + + int[] newPos = new int[records.length]; + + for (int i = records.length-1; i >= 0; i--) { + Theme theme = ((FacetRecord) records[i]).getTheme(); + newPos[i] = theme.getPosition()+1; + } + + for (int i = records.length-1; i >= 0; i--) { + Theme theme = ((FacetRecord) records[i]).getTheme(); + themeList.setThemePosition(theme, newPos[i]); + } + + updateGrid(); + } + + + /** + * Moves the selected grid records (themes) to the bottom of the grid. + * + * @param records The selected themes in the list. Null not permitted. + */ + protected void moveRecordsBottom(ListGridRecord[] records) { + ThemeList themeList = getThemeList(); + + int idx = themeList.getThemeCount(); + + for (int i = records.length-1; i >= 0; i--) { + Theme theme = ((FacetRecord) records[i]).getTheme(); + themeList.setThemePosition(theme, idx--); + } + + updateGrid(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java Tue Jul 19 16:32:52 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java Wed Jul 20 07:52:19 2011 +0000 @@ -1,81 +1,34 @@ package de.intevation.flys.client.client.ui.chart; -import java.util.ArrayList; -import java.util.List; - import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.ListGridFieldType; -import com.smartgwt.client.util.SC; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.grid.events.EditCompleteEvent; -import com.smartgwt.client.widgets.grid.events.EditCompleteHandler; -import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.shared.model.Collection; -import de.intevation.flys.client.shared.model.FacetRecord; -import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.shared.model.Theme; -import de.intevation.flys.client.shared.model.ThemeList; +import de.intevation.flys.client.shared.model.OutputMode; -import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYSConstants; -import de.intevation.flys.client.client.event.HasOutputParameterChangeHandlers; -import de.intevation.flys.client.client.event.OnMoveEvent; -import de.intevation.flys.client.client.event.OnMoveHandler; -import de.intevation.flys.client.client.event.OutputParameterChangeEvent; -import de.intevation.flys.client.client.event.OutputParameterChangeHandler; -import de.intevation.flys.client.client.services.CollectionAttributeService; -import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; +import de.intevation.flys.client.client.ui.ThemePanel; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ -public class ChartThemePanel -extends Canvas -implements EditCompleteHandler, OnMoveHandler, - HasOutputParameterChangeHandlers -{ +public class ChartThemePanel extends ThemePanel { + /** The interface that provides i18n messages. */ private FLYSConstants MSG = GWT.create(FLYSConstants.class); - /** The service that is used to modify collection attributes.*/ - protected CollectionAttributeServiceAsync updater = - GWT.create(CollectionAttributeService.class); - - public static final String GRID_FIELD_ACTIVE = "active"; public static final String GRID_FIELD_NAME = "name"; - protected Collection collection; - - protected OutputMode mode; - - protected List<OutputParameterChangeHandler> outHandlers; - - protected ListGrid list; - - protected ChartOutputTab chartOut; - - protected ThemeNavigationPanel navigation; - - - public ChartThemePanel(Collection collection, OutputMode mode) { - this.collection = collection; - this.mode = mode; - this.outHandlers = new ArrayList<OutputParameterChangeHandler>(); - this.chartOut = chartOut; - this.list = new ListGrid(); - this.navigation = new ThemeNavigationPanel(); - this.navigation.addOnMoveHandler(this); + super(collection, mode); initGrid(); initLayout(); @@ -128,260 +81,9 @@ } - /** - * Replace the current collection with a new one. <b>NOTE: this operation - * triggers updateGrid() which modifies the themes in the grid.</b> - * - * @param collection The new collection object. - */ - protected void setCollection(Collection collection) { - this.collection = collection; - - updateGrid(); - } - - - /** - * Registers a new OutputParameterChangeHandler. - * - * @param h The new handler. - */ - public void addOutputParameterChangeHandler(OutputParameterChangeHandler h){ - if (h != null) { - outHandlers.add(h); - } - } - - - /** - * Returns the ThemeList of the current collection and output mode. - * - * @return the current ThemeList. - */ - public ThemeList getThemeList() { - return collection.getThemeList(mode.getName()); - } - - - /** - * A method that removes all records from theme grid. - */ - protected void clearGrid() { - ListGridRecord[] records = list.getRecords(); - - if (records == null || records.length == 0) { - return; - } - - for (ListGridRecord record: records) { - list.removeData(record); - } - } - - - /** - * This method is used to clear the current theme grid and add new updated - * data. - */ - protected void updateGrid() { - GWT.log("ChartThemePanel.updateGrid"); - - clearGrid(); - - ThemeList themeList = getThemeList(); - - if (themeList == null) { - GWT.log("ERROR: No theme list."); - return; - } - - int count = themeList.getThemeCount(); - - for (int i = 1; i <= count; i++) { - Theme theme = themeList.getThemeAt(i); - - if (theme == null) { - continue; - } - - list.addData(new FacetRecord(theme)); - } - - fireOutputParameterChanged(); - } - - - /** - * Called when the attribution of a chart changed. It informs the registered - * handlers about the changes. - */ - protected void fireOutputParameterChanged() { - OutputParameterChangeEvent evt = new OutputParameterChangeEvent(); - - for (OutputParameterChangeHandler handler: outHandlers) { - handler.onOutputParameterChanged(evt); - } - } - - - /** - * This method is called after a cell in the theme grid has been modified. - * - * @param event The event that stores information about the modified record. - */ - public void onEditComplete(EditCompleteEvent event) { - GWT.log("Edited record."); - - int row = event.getRowNum(); - FacetRecord rec = (FacetRecord) list.getRecord(row); - - Theme theme = rec.getTheme(); - theme.setActive(rec.getActive() ? 1 : 0); - - updateCollection(); - } - - - /** - * This method triggers the CollectionAttributeService. Based on the current - * collectin settings, the attribute of the collection is modified or not. - * But in every case, we will get a new collection object - which might be - * the same as the current one. - */ - public void updateCollection() { - final Config config = Config.getInstance(); - final String url = config.getServerUrl(); - final String loc = config.getLocale(); - - GWT.log("ChartThemePanel.updateCollection via RPC now"); - - // don't forget to enable the panel after the request has finished! - disable(); - - updater.update(collection, url, loc, new AsyncCallback<Collection>() { - public void onFailure(Throwable caught) { - GWT.log("Could not update collection attributes."); - SC.warn(MSG.getString(caught.getMessage())); - - enable(); - } - - - public void onSuccess(Collection collection) { - setCollection(collection); - - enable(); - } - }); - } - - - public void onMove(OnMoveEvent event) { - int type = event.getType(); - - GWT.log("ChartThemePanel.onMove: " + type); - - ListGridRecord[] records = list.getSelection(); - - if (records == null || records.length == 0) { - GWT.log("ChartThemePanel.onMove: No records selected."); - return; - } - - switch (type) { - case 0: moveRecordsTop(records); break; - case 1: moveRecordsUp(records); break; - case 2: moveRecordsDown(records); break; - case 3: moveRecordsBottom(records); break; - } - - updateCollection(); - } - - - /** - * Moves the selected grid records (themes) to the top of the grid. - * - * @param records The selected themes in the list. Null not permitted. - */ - protected void moveRecordsTop(ListGridRecord[] records) { - ThemeList themeList = getThemeList(); - - int idx = 1; - - for (ListGridRecord record: records) { - Theme theme = ((FacetRecord) record).getTheme(); - themeList.setThemePosition(theme, idx++); - } - - updateGrid(); - } - - - /** - * Moves the selected grid records (themes) one step up. - * - * @param records The selected themes in the list. Null not permitted. - */ - protected void moveRecordsUp(ListGridRecord[] records) { - ThemeList themeList = getThemeList(); - - int[] newPos = new int[records.length]; - - for (int i = 0; i < records.length ; i++) { - Theme theme = ((FacetRecord) records[i]).getTheme(); - newPos[i] = theme.getPosition() - 1; - } - - for (int i = 0; i < records.length ; i++) { - Theme theme = ((FacetRecord) records[i]).getTheme(); - themeList.setThemePosition(theme, newPos[i]); - } - - updateGrid(); - } - - - /** - * Moves the selected grid records (themes) one step down. - * - * @param records The selected themes in the list. Null not permitted. - */ - protected void moveRecordsDown(ListGridRecord[] records) { - ThemeList themeList = getThemeList(); - - int[] newPos = new int[records.length]; - - for (int i = records.length-1; i >= 0; i--) { - Theme theme = ((FacetRecord) records[i]).getTheme(); - newPos[i] = theme.getPosition()+1; - } - - for (int i = records.length-1; i >= 0; i--) { - Theme theme = ((FacetRecord) records[i]).getTheme(); - themeList.setThemePosition(theme, newPos[i]); - } - - updateGrid(); - } - - - /** - * Moves the selected grid records (themes) to the bottom of the grid. - * - * @param records The selected themes in the list. Null not permitted. - */ - protected void moveRecordsBottom(ListGridRecord[] records) { - ThemeList themeList = getThemeList(); - - int idx = themeList.getThemeCount(); - - for (int i = records.length-1; i >= 0; i--) { - Theme theme = ((FacetRecord) records[i]).getTheme(); - themeList.setThemePosition(theme, idx--); - } - - updateGrid(); + @Override + public void activateTheme(Theme theme, boolean active) { + theme.setActive(active ? 1 : 0); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ThemeNavigationPanel.java Tue Jul 19 16:32:52 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -package de.intevation.flys.client.client.ui.chart; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gwt.core.client.GWT; - -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.ImgButton; -import com.smartgwt.client.widgets.events.ClickEvent; -import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.layout.HLayout; - -import de.intevation.flys.client.client.FLYSConstants; -import de.intevation.flys.client.client.event.OnMoveEvent; -import de.intevation.flys.client.client.event.OnMoveHandler; - - -/** - * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> - */ -public class ThemeNavigationPanel extends Canvas { - - public static final int PANEL_MARGIN = 5; - public static final int BUTTON_HEIGHT = 25; - public static final int BUTTON_MARGIN = 5; - - - protected FLYSConstants MSG = GWT.create(FLYSConstants.class); - - - protected List<OnMoveHandler> handlers; - - - public ThemeNavigationPanel() { - this.handlers = new ArrayList<OnMoveHandler>(); - - setWidth100(); - setHeight(BUTTON_HEIGHT); - setMargin(PANEL_MARGIN); - - HLayout layout = new HLayout(); - layout.setWidth100(); - layout.setHeight(BUTTON_HEIGHT); - layout.setMembersMargin(BUTTON_MARGIN); - - Canvas cu = createButton(MSG.theme_top(), OnMoveEvent.TOP); - Canvas u = createButton(MSG.theme_up(), OnMoveEvent.UP); - Canvas d = createButton(MSG.theme_down(), OnMoveEvent.DOWN); - Canvas cd = createButton(MSG.theme_bottom(), OnMoveEvent.BOTTOM); - - layout.addMember(cu); - layout.addMember(u); - layout.addMember(d); - layout.addMember(cd); - - addChild(layout); - } - - - protected Canvas createButton(final String title, final int moveType) { - String url = GWT.getHostPageBaseURL() + title; - - ImgButton b = new ImgButton(); - b.setSrc(url); - b.setHeight(BUTTON_HEIGHT); - b.setWidth(40); - b.setIconHeight(BUTTON_HEIGHT-10); - b.setShowDown(false); - b.setShowRollOver(false); - b.setShowDisabled(false); - b.setShowDisabledIcon(true); - b.setShowDownIcon(false); - b.setShowFocusedIcon(false); - b.setBackgroundColor("f2f2f2"); - b.setBorder("1px solid #A6ABB4"); - - b.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { - fireOnMoveEvent(moveType); - } - }); - - return b; - } - - - protected void addOnMoveHandler(OnMoveHandler handler) { - if (handler != null) { - handlers.add(handler); - } - } - - - protected void fireOnMoveEvent(int type) { - OnMoveEvent event = new OnMoveEvent(type); - - for (OnMoveHandler handler: handlers) { - handler.onMove(event); - } - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java Wed Jul 20 07:52:19 2011 +0000 @@ -0,0 +1,85 @@ +package de.intevation.flys.client.client.ui.map; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.types.ListGridFieldType; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.shared.model.Theme; +import de.intevation.flys.client.shared.model.OutputMode; + +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.ui.ThemePanel; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class MapThemePanel extends ThemePanel { + + private FLYSConstants MSG = GWT.create(FLYSConstants.class); + + + public static final String GRID_FIELD_ACTIVE = "active"; + public static final String GRID_FIELD_NAME = "name"; + + + protected MapOutputTab mapOut; + + + public MapThemePanel(Collection collection, OutputMode mode) { + super(collection, mode); + + initGrid(); + initLayout(); + + updateGrid(); + } + + + protected void initLayout() { + setWidth100(); + setHeight100(); + + VLayout layout = new VLayout(); + layout.setWidth100(); + layout.setHeight100(); + + layout.addMember(list); + layout.addMember(navigation); + + addChild(layout); + } + + + protected void initGrid() { + list.setCanEdit(true); + list.setCanSort(false); + list.setShowRecordComponents(false); + list.setShowRecordComponentsByCell(true); + list.setShowHeader(true); + list.setShowHeaderContextMenu(false); + list.setWidth100(); + list.setHeight100(); + + list.addEditCompleteHandler(this); + + ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20); + active.setType(ListGridFieldType.BOOLEAN); + + ListGridField name = new ListGridField( + GRID_FIELD_NAME, MSG.chart_themepanel_header_themes()); + name.setType(ListGridFieldType.TEXT); + + list.setFields(active, name); + } + + + @Override + public void activateTheme(Theme theme, boolean active) { + theme.setActive(active ? 1 : 0); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :