Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 908:a680ccec5dd6
Create new collections initially when starting a new project.
flys-client/trunk@2765 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 15 Sep 2011 15:55:30 +0000 |
parents | c0e13cf826d7 |
children | 89a47098bcbd |
comparison
equal
deleted
inserted
replaced
907:24d15c2e0da3 | 908:a680ccec5dd6 |
---|---|
116 * <i>collection</i>. | 116 * <i>collection</i>. |
117 * | 117 * |
118 * @param collection The collection to be displayed. | 118 * @param collection The collection to be displayed. |
119 */ | 119 */ |
120 public CollectionView(FLYS flys) { | 120 public CollectionView(FLYS flys) { |
121 // do this first because it takes longer than the other stuff in here. | |
122 User user = flys.getCurrentUser(); | |
123 createNewCollection(user.identifier()); | |
124 | |
121 this.flys = flys; | 125 this.flys = flys; |
122 this.tabs = new TabSet(); | 126 this.tabs = new TabSet(); |
123 this.outputTabs = new HashMap<String, OutputTab>(); | 127 this.outputTabs = new HashMap<String, OutputTab>(); |
124 this.handlers = new ArrayList<CollectionChangeHandler>(); | 128 this.handlers = new ArrayList<CollectionChangeHandler>(); |
125 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); | 129 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); |
219 SC.warn(messages.getString(caught.getMessage())); | 223 SC.warn(messages.getString(caught.getMessage())); |
220 } | 224 } |
221 | 225 |
222 public void onSuccess(Collection collection) { | 226 public void onSuccess(Collection collection) { |
223 GWT.log("Successfully created a new collection."); | 227 GWT.log("Successfully created a new collection."); |
224 | |
225 setCollection(collection); | 228 setCollection(collection); |
226 | |
227 Artifact artifact = getArtifact(); | |
228 addArtifactToCollection(artifact); | |
229 // Load recommendations, if any. | |
230 ArtifactDescription desc = | |
231 artifact.getArtifactDescription(); | |
232 Recommendation[] recom = desc.getRecommendations(); | |
233 | |
234 if (recom != null && collection != null) { | |
235 loadRecommendedArtifacts(recom); | |
236 } | |
237 } | 229 } |
238 }); | 230 }); |
239 } | 231 } |
240 | 232 |
241 | 233 |
357 | 349 |
358 if (recom != null && collection != null) { | 350 if (recom != null && collection != null) { |
359 loadRecommendedArtifacts(recom); | 351 loadRecommendedArtifacts(recom); |
360 } | 352 } |
361 | 353 |
362 if (outs != null && c == null) { | 354 if (c != null) { |
363 User user = getFlys().getCurrentUser(); | |
364 createNewCollection(user.identifier()); | |
365 } | |
366 else if (c != null) { | |
367 Config config = Config.getInstance(); | 355 Config config = Config.getInstance(); |
368 String url = config.getServerUrl(); | 356 String url = config.getServerUrl(); |
369 String locale = config.getLocale(); | 357 String locale = config.getLocale(); |
370 | 358 |
371 describeCollectionService.describe(c.identifier(), url, locale, | 359 describeCollectionService.describe(c.identifier(), url, locale, |
397 public Collection getCollection() { | 385 public Collection getCollection() { |
398 return collection; | 386 return collection; |
399 } | 387 } |
400 | 388 |
401 | 389 |
390 protected void setCollection(Collection collection) { | |
391 setCollection(collection, false); | |
392 } | |
393 | |
394 | |
402 /** | 395 /** |
403 * Set the current collection. | 396 * Set the current collection. |
404 * | 397 * |
405 * @param collection The new collection. | 398 * @param collection The new collection. |
406 */ | 399 */ |
407 protected void setCollection(Collection collection) { | 400 protected void setCollection(Collection collection, boolean suppress) { |
408 if (collection != null && this.collection == null) { | 401 if (collection != null && this.collection == null) { |
409 flys.getWorkspace().addView(collection.identifier(), this); | 402 flys.getWorkspace().addView(collection.identifier(), this); |
410 } | 403 } |
411 | 404 |
412 Collection tmp = this.collection; | 405 Collection tmp = this.collection; |
413 this.collection = collection; | 406 this.collection = collection; |
414 | 407 |
415 setTitle(collection.getName() + " (UUID: " + collection.identifier() + ")"); | 408 setTitle(collection.getName() + " (UUID: " + collection.identifier() + ")"); |
416 fireCollectionChangeEvent(tmp, this.collection); | 409 |
410 if (!suppress) { | |
411 fireCollectionChangeEvent(tmp, this.collection); | |
412 } | |
417 } | 413 } |
418 | 414 |
419 | 415 |
420 public void onCollectionChange(CollectionChangeEvent event) { | 416 public void onCollectionChange(CollectionChangeEvent event) { |
421 if (artifactsQueue > 0) { | 417 if (artifactsQueue > 0) { |
553 destroy(); | 549 destroy(); |
554 } | 550 } |
555 } | 551 } |
556 | 552 |
557 | 553 |
558 protected void addArtifactToCollection(final Artifact artifact) { | 554 public void addArtifactToCollection(final Artifact artifact) { |
559 Config config = Config.getInstance(); | 555 Config config = Config.getInstance(); |
560 final String url = config.getServerUrl(); | 556 final String url = config.getServerUrl(); |
561 final String locale = config.getLocale(); | 557 final String locale = config.getLocale(); |
562 final Collection collection = getCollection(); | 558 final Collection collection = getCollection(); |
563 | 559 |