# HG changeset patch # User Ingo Weinzierl # Date 1306323274 0 # Node ID 0785a8ba5e6dddcf99492f97114122a19eb83ebc # Parent 2e02db03e5766badced020cbc3a11b706fd0afa5 Implemented the first step of a theme control panel for charts. flys-client/trunk@2002 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 2e02db03e576 -r 0785a8ba5e6d flys-client/ChangeLog --- a/flys-client/ChangeLog Wed May 25 11:30:46 2011 +0000 +++ b/flys-client/ChangeLog Wed May 25 11:34:34 2011 +0000 @@ -1,3 +1,20 @@ +2011-05-25 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java: + New. This ListRecord is used to display facets in grids. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java: + New. This panel contains elements to control the themes of a chart. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java: + Added i18n strings for the ChartThemePanel. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java: + The left side of this panel is filled with the ChartThemePanel now. + 2011-05-25 Ingo Weinzierl * src/main/java/de/intevation/flys/client/server/meta/Converter.java, diff -r 2e02db03e576 -r 0785a8ba5e6d flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed May 25 11:30:46 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed May 25 11:34:34 2011 +0000 @@ -168,6 +168,8 @@ String wst(); + String chart_themepanel_header_themes(); + // ERRORS String error_create_artifact(); diff -r 2e02db03e576 -r 0785a8ba5e6d flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed May 25 11:30:46 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed May 25 11:34:34 2011 +0000 @@ -80,6 +80,7 @@ dataexport = Datenexport csv = CSV wst = WST +chart_themepanel_header_themes = Theme error_empty_state = Required inputs are missing. error_invalid_double_value = Wrong format for a floating point number. diff -r 2e02db03e576 -r 0785a8ba5e6d flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed May 25 11:30:46 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed May 25 11:34:34 2011 +0000 @@ -80,6 +80,7 @@ dataexport = Datenexport csv = CSV wst = WST +chart_themepanel_header_themes = Thema error_empty_state = Es wurden nicht alle ben\u00d6tigten Daten eingegeben. error_invalid_double_value = Falsches Format f\u00fc eine Flie\u00dfkommazahl. diff -r 2e02db03e576 -r 0785a8ba5e6d flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Wed May 25 11:30:46 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Wed May 25 11:34:34 2011 +0000 @@ -50,7 +50,7 @@ wqQ = Q [m³/s] wqSingle = Single values wqRange = Range -untiWNN = W [NN+m] +unitWNN = W [NN+m] unitWSingle = cm unitWFrom = cm - unitWTo = cm a @@ -65,13 +65,22 @@ buttonNext = Next imageBack = images/back_en.png +imageSave = images/save.gif discharge_curve = Discharge Curves at Gauges computed_discharge_curve = Discharge Curve longitudinal_section = Longitudinal Section Curve duration_curve = Duration Curve +discharge_longitudinal_section = Discharge Longitudinal Section + waterlevel_export = Waterlevel Export -discharge_longitudinal_section = Discharge Longitudinal Section +computed_dischargecurve_export = Discharge Curve Export +discharge_longitudinal_section_export = Discharge Longitudinal Section Export +durationcurve_export = Duration Curve Export +dataexport = Datenexport +csv = CSV +wst = WST +chart_themepanel_header_themes = Theme error_empty_state = Required inputs are missing. error_invalid_double_value = Wrong format for a floating point number. @@ -83,7 +92,7 @@ error_create_collection = Error while creating a new collection. error_describe_collection = Error while fetching the projects state. error_no_rivers_found = Error while reading supported rivers. -error_no_such_user = Error - no such user. +error_no_such_user = Error - no such user found. error_not_logged_in = You need to log in before you are allowed to start your work. error_load_parameterization = Could not load the parameterization. @@ -97,3 +106,8 @@ error_feed_no_calculation_mode = No calculation method chosen. error_feed_no_such_river = The selected river is not provided. error_feed_no_river_selected = No river selected. +error_feed_no_wq_mode_selected = No W/Q mode selected. +error_feed_q_values_invalid = Selected Q values are outside the valid range. +error_feed_w_values_invalid = Selected W values are outside the valid range. + +error_no_meta_data_found = No meta data found. diff -r 2e02db03e576 -r 0785a8ba5e6d flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Wed May 25 11:30:46 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Wed May 25 11:34:34 2011 +0000 @@ -84,7 +84,7 @@ hLayout.addMember(right); right.addChild(createChartPanel()); - left.addChild(createThemeControlPanel()); + left.addChild(new ChartThemePanel(collection, mode)); tbarPanel.addChild( createTBarPanel(collectionView)); diff -r 2e02db03e576 -r 0785a8ba5e6d flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java Wed May 25 11:34:34 2011 +0000 @@ -0,0 +1,144 @@ +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 Ingo Weinzierl + */ +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 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 : diff -r 2e02db03e576 -r 0785a8ba5e6d flys-client/src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java Wed May 25 11:34:34 2011 +0000 @@ -0,0 +1,53 @@ +package de.intevation.flys.client.shared.model; + +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import de.intevation.flys.client.shared.model.Facet; + + +/** + * @author Ingo Weinzierl + */ +public class FacetRecord extends ListGridRecord { + + protected boolean active; + + protected Facet facet; + + + public FacetRecord(Facet facet) { + this.facet = facet; + + setActive(true); + setName(facet.getName()); + } + + + public Facet getFacet() { + return facet; + } + + + public void setName(String name) { + // TODO Add a setter method setName() to Facet + // facet.setName(name); + setAttribute("name", name); + } + + + public String getName() { + return getAttribute("name"); + } + + + public boolean getActive() { + return getAttributeAsBoolean("active"); + } + + + public void setActive(boolean active) { + this.active = active; + setAttribute("active", active); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :