Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java @ 524:ba238f917b94
The theme list information stored in the attribute of a collection is read and added in form of Themes and ThemeLists to the Collection.
flys-client/trunk@2003 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 25 May 2011 13:42:04 +0000 |
parents | 0785a8ba5e6d |
children | 96e60e0a4345 |
line wrap: on
line source
package de.intevation.flys.client.client.ui.chart; import java.util.List; import com.google.gwt.core.client.GWT; import com.smartgwt.client.types.ListGridFieldType; 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.Facet; 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.FLYSConstants; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ChartThemePanel extends Canvas implements EditCompleteHandler { /** The interface that provides i18n messages. */ private FLYSConstants MSG = GWT.create(FLYSConstants.class); public static final String GRID_FIELD_ACTIVE = "active"; public static final String GRID_FIELD_NAME = "name"; protected Collection collection; protected OutputMode mode; protected ListGrid list; public ChartThemePanel(Collection collection, OutputMode mode) { this.collection = collection; this.mode = mode; this.list = new ListGrid(); initGrid(); initLayout(); updateGrid(); } /** * Initializes the layout of this panel. */ protected void initLayout() { setWidth100(); setHeight100(); VLayout layout = new VLayout(); layout.setWidth100(); layout.setHeight100(); layout.addMember(list); addChild(layout); } /** * Initializes the components (columns) of the theme grid. */ 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); } /** * 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() { clearGrid(); ThemeList themeList = collection.getThemeList(mode.getName()); 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)); } } /** * 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); // TODO Save modified facets } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :