Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 30:5709bd8f4d7c
Added a new widget that combines the module and the river selection. Users can now choose the desired plugin and river in one step.
flys-client/trunk@1433 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 09 Mar 2011 09:41:45 +0000 |
parents | c19985f75118 |
children | 88c530c25968 |
comparison
equal
deleted
inserted
replaced
29:44c63e7fd0d0 | 30:5709bd8f4d7c |
---|---|
21 | 21 |
22 import de.intevation.flys.client.shared.model.Artifact; | 22 import de.intevation.flys.client.shared.model.Artifact; |
23 import de.intevation.flys.client.shared.model.ArtifactDescription; | 23 import de.intevation.flys.client.shared.model.ArtifactDescription; |
24 import de.intevation.flys.client.shared.model.Collection; | 24 import de.intevation.flys.client.shared.model.Collection; |
25 import de.intevation.flys.client.shared.model.Data; | 25 import de.intevation.flys.client.shared.model.Data; |
26 import de.intevation.flys.client.shared.model.DataItem; | |
27 import de.intevation.flys.client.shared.model.DefaultData; | |
28 import de.intevation.flys.client.shared.model.DefaultDataItem; | |
26 import de.intevation.flys.client.shared.model.DefaultCollection; | 29 import de.intevation.flys.client.shared.model.DefaultCollection; |
30 import de.intevation.flys.client.shared.model.River; | |
27 | 31 |
28 import de.intevation.flys.client.client.Config; | 32 import de.intevation.flys.client.client.Config; |
29 import de.intevation.flys.client.client.FLYS; | 33 import de.intevation.flys.client.client.FLYS; |
30 import de.intevation.flys.client.client.FLYSMessages; | 34 import de.intevation.flys.client.client.FLYSMessages; |
31 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; | 35 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; |
36 import de.intevation.flys.client.client.event.CollectionChangeHandler; | 40 import de.intevation.flys.client.client.event.CollectionChangeHandler; |
37 import de.intevation.flys.client.client.services.ArtifactService; | 41 import de.intevation.flys.client.client.services.ArtifactService; |
38 import de.intevation.flys.client.client.services.ArtifactServiceAsync; | 42 import de.intevation.flys.client.client.services.ArtifactServiceAsync; |
39 import de.intevation.flys.client.client.services.CreateCollectionService; | 43 import de.intevation.flys.client.client.services.CreateCollectionService; |
40 import de.intevation.flys.client.client.services.CreateCollectionServiceAsync; | 44 import de.intevation.flys.client.client.services.CreateCollectionServiceAsync; |
45 import de.intevation.flys.client.client.ui.ModuleSelection; | |
41 | 46 |
42 | 47 |
43 /** | 48 /** |
44 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 49 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
45 */ | 50 */ |
69 protected List<CollectionChangeHandler> handlers; | 74 protected List<CollectionChangeHandler> handlers; |
70 | 75 |
71 /** The collection to be displayed.*/ | 76 /** The collection to be displayed.*/ |
72 protected Collection collection; | 77 protected Collection collection; |
73 | 78 |
79 /** The artifact that handles the parameterization.*/ | |
80 protected Artifact artifact; | |
81 | |
74 protected TabSet tabs; | 82 protected TabSet tabs; |
75 | 83 |
76 /** The parameter tab.*/ | 84 /** The parameter tab.*/ |
77 protected Tab parameterTab; | 85 protected Tab parameterTab; |
78 | 86 |
199 return collection.getArtifactLength() == 0 ? true : false; | 207 return collection.getArtifactLength() == 0 ? true : false; |
200 } | 208 } |
201 | 209 |
202 | 210 |
203 /** | 211 /** |
204 * This method creates a Canvas displaying the plugins of FLYS. | 212 * This method creates a Canvas displaying the plugins of FLYS combined with |
205 * | 213 * a widget to select a river. |
206 * @return a Canvas that displays the plugins of FLYS. | 214 * |
215 * @return a Canvas that displays the supported plugins and rivers of FLYS. | |
207 */ | 216 */ |
208 protected Canvas renderNew() { | 217 protected Canvas renderNew() { |
209 VLayout newLayout = new VLayout(); | 218 River[] rivers = flys.getRivers(); |
210 | 219 DataItem[] items = new DataItem[rivers.length]; |
211 DynamicForm form = new DynamicForm(); | 220 |
212 RadioGroupItem radio = new RadioGroupItem("plugin"); | 221 int i = 0; |
213 | 222 for (River river: rivers) { |
214 radio.setShowTitle(false); | 223 String name = river.getName(); |
215 radio.setVertical(false); | 224 items[i++] = new DefaultDataItem(name, null, name); |
216 radio.setValueMap( | 225 } |
217 messages.winfo(), | 226 |
218 messages.minfo(), | 227 Data data = new DefaultData( |
219 messages.map(), | 228 "RIVER", "RIVER SELECTION", null, items, null); |
220 messages.fix()); | 229 |
221 | 230 ModuleSelection widget = new ModuleSelection(); |
222 form.setFields(radio); | 231 HasStepForwardHandlers handler = (HasStepForwardHandlers) widget; |
223 | 232 |
224 IButton go = new IButton(messages.next()); | 233 handler.addStepForwardHandler(new StepForwardHandler() { |
225 go.addClickHandler(new ClickHandler() { | 234 public void onStepForward(StepForwardEvent event) { |
226 public void onClick(ClickEvent event) { | 235 Data[] data = event.getData(); |
236 | |
237 DataItem[] moduleItems = data[0].getItems(); | |
238 DataItem[] riversItems = data[1].getItems(); | |
239 | |
240 String module = moduleItems[0].getStringValue(); | |
241 String river = riversItems[0].getStringValue(); | |
242 | |
227 String serverUrl = Config.getInstance().getServerUrl(); | 243 String serverUrl = Config.getInstance().getServerUrl(); |
228 | |
229 artifactService.create( | 244 artifactService.create( |
230 serverUrl, "winfo", | 245 serverUrl, module.toLowerCase(), |
231 new AsyncCallback<Artifact>() { | 246 new AsyncCallback<Artifact>() { |
232 public void onFailure(Throwable caught) { | 247 public void onFailure(Throwable caught) { |
233 GWT.log("Could not create the new artifact."); | 248 GWT.log("Could not create the new artifact."); |
234 GWT.log(caught.getMessage()); | 249 GWT.log(caught.getMessage()); |
235 } | 250 } |
236 | 251 |
237 public void onSuccess(Artifact artifact) { | 252 public void onSuccess(Artifact artifact) { |
238 GWT.log("Successfully created a new artifact."); | 253 GWT.log("Successfully created a new artifact."); |
239 Collection c = new DefaultCollection("TODO"); | 254 setArtifact(artifact); |
240 | 255 |
241 c.addArtifact(artifact); | 256 GWT.log("TODO: FEED WITH RIVER!"); |
242 setCollection(c); | |
243 } | 257 } |
244 }); | 258 }); |
245 } | 259 } |
246 }); | 260 }); |
247 | 261 |
248 newLayout.addMember(form); | 262 return widget.create(data); |
249 newLayout.addMember(go); | 263 } |
250 | 264 |
251 return newLayout; | 265 |
266 /** | |
267 * Set the current artifact that is the master of the parameterization. | |
268 * | |
269 * @param artifact The new artifact. | |
270 */ | |
271 protected void setArtifact(Artifact artifact) { | |
272 this.artifact = artifact; | |
252 } | 273 } |
253 | 274 |
254 | 275 |
255 /** | 276 /** |
256 * Set the current collection. | 277 * Set the current collection. |