Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java @ 523:0785a8ba5e6d
Implemented the first step of a theme control panel for charts.
flys-client/trunk@2002 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 25 May 2011 11:34:34 +0000 |
parents | |
children | ba238f917b94 |
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.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(); List<Facet> facets = mode.getFacets(); for (Facet facet: facets) { list.addData(new FacetRecord(facet)); } } /** * 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 :