Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 100:95b30a5d6350
Bugfix: A collection view just creates a single time a new collection - even if we step back to a previous state and go forward afterwards.
flys-client/trunk@1614 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 30 Mar 2011 07:40:53 +0000 |
parents | fa3d9f79dff5 |
children | f7967d12ce6e |
comparison
equal
deleted
inserted
replaced
99:5c3d685546a6 | 100:95b30a5d6350 |
---|---|
32 import de.intevation.flys.client.client.event.ParameterChangeHandler; | 32 import de.intevation.flys.client.client.event.ParameterChangeHandler; |
33 import de.intevation.flys.client.client.services.AddArtifactService; | 33 import de.intevation.flys.client.client.services.AddArtifactService; |
34 import de.intevation.flys.client.client.services.AddArtifactServiceAsync; | 34 import de.intevation.flys.client.client.services.AddArtifactServiceAsync; |
35 import de.intevation.flys.client.client.services.CreateCollectionService; | 35 import de.intevation.flys.client.client.services.CreateCollectionService; |
36 import de.intevation.flys.client.client.services.CreateCollectionServiceAsync; | 36 import de.intevation.flys.client.client.services.CreateCollectionServiceAsync; |
37 import de.intevation.flys.client.client.services.DescribeCollectionService; | |
38 import de.intevation.flys.client.client.services.DescribeCollectionServiceAsync; | |
37 | 39 |
38 | 40 |
39 /** | 41 /** |
40 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 42 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
41 */ | 43 */ |
50 | 52 |
51 /** The AddArtifactService used to add an artifact to a collection. */ | 53 /** The AddArtifactService used to add an artifact to a collection. */ |
52 protected AddArtifactServiceAsync addArtifactService = | 54 protected AddArtifactServiceAsync addArtifactService = |
53 GWT.create(AddArtifactService.class); | 55 GWT.create(AddArtifactService.class); |
54 | 56 |
57 /** The DescribeCollectionService used to update the existing collection. */ | |
58 protected DescribeCollectionServiceAsync describeCollectionService = | |
59 GWT.create(DescribeCollectionService.class); | |
60 | |
55 /** The message class that provides i18n strings.*/ | 61 /** The message class that provides i18n strings.*/ |
56 protected FLYSMessages messages = GWT.create(FLYSMessages.class); | 62 protected FLYSMessages messages = GWT.create(FLYSMessages.class); |
57 | 63 |
58 /** The FLYS instance used to call services.*/ | 64 /** The FLYS instance used to call services.*/ |
59 protected FLYS flys; | 65 protected FLYS flys; |
83 * This constructor creates a new CollectionView that is used to display the | 89 * This constructor creates a new CollectionView that is used to display the |
84 * <i>collection</i>. | 90 * <i>collection</i>. |
85 * | 91 * |
86 * @param collection The collection to be displayed. | 92 * @param collection The collection to be displayed. |
87 */ | 93 */ |
88 public CollectionView(FLYS flys, Collection collection) { | 94 public CollectionView(FLYS flys) { |
89 this.flys = flys; | 95 this.flys = flys; |
90 this.collection = collection; | 96 this.tabs = new TabSet(); |
91 | 97 this.outputTabs = new HashMap<String, OutputTab>(); |
92 this.tabs = new TabSet(); | 98 this.handlers = new ArrayList<CollectionChangeHandler>(); |
93 this.outputTabs = new HashMap<String, OutputTab>(); | 99 this.layout = new VLayout(); |
94 this.handlers = new ArrayList<CollectionChangeHandler>(); | 100 this.parameterList = new ParameterList( |
95 this.layout = new VLayout(); | |
96 this.parameterList = new ParameterList( | |
97 flys, this, messages.new_project()); | 101 flys, this, messages.new_project()); |
98 | 102 |
99 addCollectionChangeHandler(this); | 103 addCollectionChangeHandler(this); |
100 | 104 |
101 parameterList.addParameterChangeHandler(this); | 105 parameterList.addParameterChangeHandler(this); |
132 * collection in the artifact server. | 136 * collection in the artifact server. |
133 * | 137 * |
134 * @param ownerId The uuid of the user that should own the new collection. | 138 * @param ownerId The uuid of the user that should own the new collection. |
135 */ | 139 */ |
136 protected void createNewCollection(String ownerId) { | 140 protected void createNewCollection(String ownerId) { |
141 GWT.log("CollectionView.createNewCollection"); | |
142 | |
137 Config config = Config.getInstance(); | 143 Config config = Config.getInstance(); |
138 final String serverUrl = config.getServerUrl(); | 144 final String serverUrl = config.getServerUrl(); |
139 | 145 |
140 createCollectionService.create( | 146 createCollectionService.create( |
141 serverUrl, ownerId, | 147 serverUrl, ownerId, |
236 * parameterization has changed. | 242 * parameterization has changed. |
237 * | 243 * |
238 * @param event The ParameterChangeEvent. | 244 * @param event The ParameterChangeEvent. |
239 */ | 245 */ |
240 public void onParameterChange(ParameterChangeEvent event) { | 246 public void onParameterChange(ParameterChangeEvent event) { |
241 GWT.log("Parameter have changed."); | 247 GWT.log("CollectionView.onParameterChange"); |
248 | |
242 Artifact art = event.getNewValue(); | 249 Artifact art = event.getNewValue(); |
243 ArtifactDescription desc = art.getArtifactDescription(); | 250 ArtifactDescription desc = art.getArtifactDescription(); |
244 OutputMode[] outs = desc.getOutputModes(); | 251 OutputMode[] outs = desc.getOutputModes(); |
245 | 252 |
246 setArtifact(art); | 253 setArtifact(art); |
247 clearOutputTabs(); | 254 clearOutputTabs(); |
248 | 255 |
249 if (outs != null) { | 256 Collection collection = getCollection(); |
257 | |
258 if (outs != null && collection == null) { | |
250 User user = getFlys().getCurrentUser(); | 259 User user = getFlys().getCurrentUser(); |
251 createNewCollection(user.identifier()); | 260 createNewCollection(user.identifier()); |
261 } | |
262 else if (outs != null && collection != null) { | |
263 Config config = Config.getInstance(); | |
264 String url = config.getServerUrl(); | |
265 | |
266 describeCollectionService.describe(collection.identifier(), url, | |
267 new AsyncCallback<Collection>() { | |
268 public void onFailure(Throwable caught) { | |
269 GWT.log("Could not DESCRIBE collection."); | |
270 GWT.log(caught.getMessage()); | |
271 } | |
272 | |
273 | |
274 public void onSuccess(Collection newCollection) { | |
275 GWT.log("Successfully DESCRIBED collection."); | |
276 setCollection(newCollection); | |
277 } | |
278 } | |
279 ); | |
252 } | 280 } |
253 else { | 281 else { |
254 updateView(); | 282 updateView(); |
255 } | 283 } |
256 } | 284 } |