# HG changeset patch # User Felix Wolfsteller # Date 1314969606 0 # Node ID 67c67890328078a55aa72ce482a8106b38f58f8b # Parent 3d379e6b9a5f7cb723b7847e988775628808d46f Refactored to allow specialized controls within the ChartThemePanel, stubby first steps towards such a control (bound to FeedService). flys-client/trunk@2641 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3d379e6b9a5f -r 67c678903280 flys-client/ChangeLog --- a/flys-client/ChangeLog Fri Sep 02 13:14:43 2011 +0000 +++ b/flys-client/ChangeLog Fri Sep 02 13:20:06 2011 +0000 @@ -1,3 +1,19 @@ +2011-09-02 Felix Wolfsteller + + Refactored to allow specialized controls within the ChartThemePanel, stubby + first steps towards such a control (bound to FeedService). + + * src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java: + Minor cosmetics. + (createGrid): + Extracted (trivial) to allow more concrete implementations in subclasses. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java + (createGrid): + Implementation, add a spinner that could talk with feedservice. + (initGrid): + Added new "actions" field. + 2011-09-02 Felix Wolfsteller Minor Cosmetics. diff -r 3d379e6b9a5f -r 67c678903280 flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Fri Sep 02 13:14:43 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Fri Sep 02 13:20:06 2011 +0000 @@ -31,8 +31,10 @@ public abstract class ThemePanel -extends Canvas -implements OnMoveHandler, EditCompleteHandler, HasOutputParameterChangeHandlers +extends Canvas +implements OnMoveHandler, + EditCompleteHandler, + HasOutputParameterChangeHandlers { protected CollectionAttributeServiceAsync updater = GWT.create(CollectionAttributeService.class); @@ -48,13 +50,18 @@ protected ListGrid list; + /** + * Setup Grid, navigation bar. + * @param collection Collection for which to show themes. + */ public ThemePanel(Collection collection, OutputMode mode) { this.collection = collection; this.mode = mode; - this.list = new ListGrid(); + + this.list = createGrid(); + this.outHandlers = new ArrayList(); this.navigation = new ThemeNavigationPanel(); - this.navigation.addOnMoveHandler(this); } @@ -176,6 +183,12 @@ } + /** + * Create and configure the Grid to display. + */ + protected ListGrid createGrid() { + return new ListGrid(); + } /** diff -r 3d379e6b9a5f -r 67c678903280 flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java Fri Sep 02 13:14:43 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java Fri Sep 02 13:20:06 2011 +0000 @@ -2,10 +2,22 @@ import com.google.gwt.core.client.GWT; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.widgets.Canvas; +import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.ListGridFieldType; +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 com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.form.fields.SpinnerItem; +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.Theme; import de.intevation.flys.client.shared.model.OutputMode; @@ -13,6 +25,9 @@ import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.ui.ThemePanel; +import de.intevation.flys.client.client.services.FeedService; +import de.intevation.flys.client.client.services.FeedServiceAsync; + /** * @author Ingo Weinzierl @@ -23,9 +38,12 @@ private FLYSConstants MSG = GWT.create(FLYSConstants.class); - public static final String GRID_FIELD_ACTIVE = "active"; - public static final String GRID_FIELD_NAME = "name"; + public static final String GRID_FIELD_ACTIVE = "active"; + public static final String GRID_FIELD_NAME = "name"; + public static final String GRID_FIELD_ACTIONS = "actions"; + FeedServiceAsync feedService = GWT.create( + de.intevation.flys.client.client.services.FeedService.class); public ChartThemePanel(Collection collection, OutputMode mode) { super(collection, mode); @@ -38,6 +56,75 @@ /** + * Create and configure the Grid to display. + */ + protected ListGrid createGrid() { + ListGrid list = new ListGrid() { + @Override + protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) { + GWT.log("createRecordComponent! " + this.getFieldName(colNum)); + + String fieldName = this.getFieldName(colNum); + + if (fieldName.equals("actions")) { + GWT.log("GG UU II: Put actopms"); + HLayout recordCanvas = new HLayout(3); + recordCanvas.setHeight(22); + recordCanvas.setAlign(Alignment.CENTER); + // Grid Cell Widgets example + SpinnerItem spinnerItem = new SpinnerItem(); + spinnerItem.setShowTitle(false); + spinnerItem.setTitle("Waterlevel-Spinner"); + spinnerItem.setWidth(50); + spinnerItem.setDefaultValue(5); + spinnerItem.setMin(130); + spinnerItem.setMax(1000); + spinnerItem.setStep(5f); + Config config = Config.getInstance(); + final String serverUrl = config.getServerUrl(); + final String locale = config.getLocale(); + + spinnerItem.addChangedHandler(new ChangedHandler() { + @Override + public void onChanged(ChangedEvent ce) { + // artifact instead of null + // data[] instead of null + feedService.feed(serverUrl, locale, null, null, + new AsyncCallback() { + public void onFailure(Throwable caught) { + GWT.log("Could not feed artifact"); + // TODO SC.warn + } + public void onSuccess(Artifact artifact) { + GWT.log("Successfully fed"); + //TODO and now? + } + }); + } + } + ); + + DynamicForm formWrap = new DynamicForm(); + formWrap.setFields(spinnerItem); + formWrap.setTitlePrefix(""); + formWrap.setTitleSuffix(""); + recordCanvas.addMember(formWrap); + return recordCanvas; + } + else { + return null; + } + } + }; + list.setCanResizeFields(true); + list.setShowRecordComponents(true); + list.setShowRecordComponentsByCell(true); + list.setShowAllRecords(true); + return list; + } + + + /** * Initializes the layout of this panel. */ protected void initLayout() { @@ -61,7 +148,7 @@ protected void initGrid() { list.setCanEdit(true); list.setCanSort(false); - list.setShowRecordComponents(false); + //list.setShowRecordComponents(false); list.setShowRecordComponentsByCell(true); list.setShowHeader(true); list.setShowHeaderContextMenu(false); @@ -77,7 +164,12 @@ GRID_FIELD_NAME, MSG.chart_themepanel_header_themes()); name.setType(ListGridFieldType.TEXT); - list.setFields(active, name); + // TODO Visibility of this Field (~"column") shall depend on + // availability of facets allowing for actions. + ListGridField actions = new ListGridField(GRID_FIELD_ACTIONS, + GRID_FIELD_ACTIONS, 60); + + list.setFields(active, name, actions); }