Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java @ 854:67c678903280
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
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 02 Sep 2011 13:20:06 +0000 |
parents | f43d06d6a4a2 |
children | 9f07f67f60a5 |
comparison
equal
deleted
inserted
replaced
853:3d379e6b9a5f | 854:67c678903280 |
---|---|
1 package de.intevation.flys.client.client.ui.chart; | 1 package de.intevation.flys.client.client.ui.chart; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 | 4 |
5 import com.smartgwt.client.types.Alignment; | |
6 import com.smartgwt.client.widgets.Canvas; | |
7 import com.google.gwt.user.client.rpc.AsyncCallback; | |
5 import com.smartgwt.client.types.ListGridFieldType; | 8 import com.smartgwt.client.types.ListGridFieldType; |
9 import com.smartgwt.client.widgets.grid.ListGrid; | |
6 import com.smartgwt.client.widgets.grid.ListGridField; | 10 import com.smartgwt.client.widgets.grid.ListGridField; |
11 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
7 import com.smartgwt.client.widgets.layout.VLayout; | 12 import com.smartgwt.client.widgets.layout.VLayout; |
13 import com.smartgwt.client.widgets.layout.HLayout; | |
14 import com.smartgwt.client.widgets.form.fields.SpinnerItem; | |
15 import com.smartgwt.client.widgets.form.DynamicForm; | |
16 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; | |
17 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; | |
8 | 18 |
19 import de.intevation.flys.client.client.Config; | |
20 import de.intevation.flys.client.shared.model.Artifact; | |
9 import de.intevation.flys.client.shared.model.Collection; | 21 import de.intevation.flys.client.shared.model.Collection; |
10 import de.intevation.flys.client.shared.model.Theme; | 22 import de.intevation.flys.client.shared.model.Theme; |
11 import de.intevation.flys.client.shared.model.OutputMode; | 23 import de.intevation.flys.client.shared.model.OutputMode; |
12 | 24 |
13 import de.intevation.flys.client.client.FLYSConstants; | 25 import de.intevation.flys.client.client.FLYSConstants; |
14 import de.intevation.flys.client.client.ui.ThemePanel; | 26 import de.intevation.flys.client.client.ui.ThemePanel; |
27 | |
28 import de.intevation.flys.client.client.services.FeedService; | |
29 import de.intevation.flys.client.client.services.FeedServiceAsync; | |
15 | 30 |
16 | 31 |
17 /** | 32 /** |
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 33 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
19 */ | 34 */ |
21 | 36 |
22 /** The interface that provides i18n messages. */ | 37 /** The interface that provides i18n messages. */ |
23 private FLYSConstants MSG = GWT.create(FLYSConstants.class); | 38 private FLYSConstants MSG = GWT.create(FLYSConstants.class); |
24 | 39 |
25 | 40 |
26 public static final String GRID_FIELD_ACTIVE = "active"; | 41 public static final String GRID_FIELD_ACTIVE = "active"; |
27 public static final String GRID_FIELD_NAME = "name"; | 42 public static final String GRID_FIELD_NAME = "name"; |
43 public static final String GRID_FIELD_ACTIONS = "actions"; | |
28 | 44 |
45 FeedServiceAsync feedService = GWT.create( | |
46 de.intevation.flys.client.client.services.FeedService.class); | |
29 | 47 |
30 public ChartThemePanel(Collection collection, OutputMode mode) { | 48 public ChartThemePanel(Collection collection, OutputMode mode) { |
31 super(collection, mode); | 49 super(collection, mode); |
32 | 50 |
33 initGrid(); | 51 initGrid(); |
34 initLayout(); | 52 initLayout(); |
35 | 53 |
36 updateGrid(); | 54 updateGrid(); |
55 } | |
56 | |
57 | |
58 /** | |
59 * Create and configure the Grid to display. | |
60 */ | |
61 protected ListGrid createGrid() { | |
62 ListGrid list = new ListGrid() { | |
63 @Override | |
64 protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) { | |
65 GWT.log("createRecordComponent! " + this.getFieldName(colNum)); | |
66 | |
67 String fieldName = this.getFieldName(colNum); | |
68 | |
69 if (fieldName.equals("actions")) { | |
70 GWT.log("GG UU II: Put actopms"); | |
71 HLayout recordCanvas = new HLayout(3); | |
72 recordCanvas.setHeight(22); | |
73 recordCanvas.setAlign(Alignment.CENTER); | |
74 // Grid Cell Widgets example | |
75 SpinnerItem spinnerItem = new SpinnerItem(); | |
76 spinnerItem.setShowTitle(false); | |
77 spinnerItem.setTitle("Waterlevel-Spinner"); | |
78 spinnerItem.setWidth(50); | |
79 spinnerItem.setDefaultValue(5); | |
80 spinnerItem.setMin(130); | |
81 spinnerItem.setMax(1000); | |
82 spinnerItem.setStep(5f); | |
83 Config config = Config.getInstance(); | |
84 final String serverUrl = config.getServerUrl(); | |
85 final String locale = config.getLocale(); | |
86 | |
87 spinnerItem.addChangedHandler(new ChangedHandler() { | |
88 @Override | |
89 public void onChanged(ChangedEvent ce) { | |
90 // artifact instead of null | |
91 // data[] instead of null | |
92 feedService.feed(serverUrl, locale, null, null, | |
93 new AsyncCallback<Artifact>() { | |
94 public void onFailure(Throwable caught) { | |
95 GWT.log("Could not feed artifact"); | |
96 // TODO SC.warn | |
97 } | |
98 public void onSuccess(Artifact artifact) { | |
99 GWT.log("Successfully fed"); | |
100 //TODO and now? | |
101 } | |
102 }); | |
103 } | |
104 } | |
105 ); | |
106 | |
107 DynamicForm formWrap = new DynamicForm(); | |
108 formWrap.setFields(spinnerItem); | |
109 formWrap.setTitlePrefix(""); | |
110 formWrap.setTitleSuffix(""); | |
111 recordCanvas.addMember(formWrap); | |
112 return recordCanvas; | |
113 } | |
114 else { | |
115 return null; | |
116 } | |
117 } | |
118 }; | |
119 list.setCanResizeFields(true); | |
120 list.setShowRecordComponents(true); | |
121 list.setShowRecordComponentsByCell(true); | |
122 list.setShowAllRecords(true); | |
123 return list; | |
37 } | 124 } |
38 | 125 |
39 | 126 |
40 /** | 127 /** |
41 * Initializes the layout of this panel. | 128 * Initializes the layout of this panel. |
59 * Initializes the components (columns) of the theme grid. | 146 * Initializes the components (columns) of the theme grid. |
60 */ | 147 */ |
61 protected void initGrid() { | 148 protected void initGrid() { |
62 list.setCanEdit(true); | 149 list.setCanEdit(true); |
63 list.setCanSort(false); | 150 list.setCanSort(false); |
64 list.setShowRecordComponents(false); | 151 //list.setShowRecordComponents(false); |
65 list.setShowRecordComponentsByCell(true); | 152 list.setShowRecordComponentsByCell(true); |
66 list.setShowHeader(true); | 153 list.setShowHeader(true); |
67 list.setShowHeaderContextMenu(false); | 154 list.setShowHeaderContextMenu(false); |
68 list.setWidth100(); | 155 list.setWidth100(); |
69 list.setHeight100(); | 156 list.setHeight100(); |
75 | 162 |
76 ListGridField name = new ListGridField( | 163 ListGridField name = new ListGridField( |
77 GRID_FIELD_NAME, MSG.chart_themepanel_header_themes()); | 164 GRID_FIELD_NAME, MSG.chart_themepanel_header_themes()); |
78 name.setType(ListGridFieldType.TEXT); | 165 name.setType(ListGridFieldType.TEXT); |
79 | 166 |
80 list.setFields(active, name); | 167 // TODO Visibility of this Field (~"column") shall depend on |
168 // availability of facets allowing for actions. | |
169 ListGridField actions = new ListGridField(GRID_FIELD_ACTIONS, | |
170 GRID_FIELD_ACTIONS, 60); | |
171 | |
172 list.setFields(active, name, actions); | |
81 } | 173 } |
82 | 174 |
83 | 175 |
84 @Override | 176 @Override |
85 public void activateTheme(Theme theme, boolean active) { | 177 public void activateTheme(Theme theme, boolean active) { |