Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/CollectionView.java @ 9263:abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
Allows for distinct values stepping of sinfo flood duration.
author | gernotbelger |
---|---|
date | Tue, 17 Jul 2018 19:48:18 +0200 |
parents | 23945061daec |
children | c81cf7e2a770 |
comparison
equal
deleted
inserted
replaced
9262:fee5fa18361c | 9263:abf14917be32 |
---|---|
26 import org.dive4elements.river.client.client.event.OutputModesChangeHandler; | 26 import org.dive4elements.river.client.client.event.OutputModesChangeHandler; |
27 import org.dive4elements.river.client.client.event.ParameterChangeEvent; | 27 import org.dive4elements.river.client.client.event.ParameterChangeEvent; |
28 import org.dive4elements.river.client.client.event.ParameterChangeHandler; | 28 import org.dive4elements.river.client.client.event.ParameterChangeHandler; |
29 import org.dive4elements.river.client.client.services.AddArtifactService; | 29 import org.dive4elements.river.client.client.services.AddArtifactService; |
30 import org.dive4elements.river.client.client.services.AddArtifactServiceAsync; | 30 import org.dive4elements.river.client.client.services.AddArtifactServiceAsync; |
31 import org.dive4elements.river.client.client.services.ArtifactService; | |
32 import org.dive4elements.river.client.client.services.ArtifactServiceAsync; | |
33 import org.dive4elements.river.client.client.services.CollectionAttributeService; | 31 import org.dive4elements.river.client.client.services.CollectionAttributeService; |
34 import org.dive4elements.river.client.client.services.CollectionAttributeServiceAsync; | 32 import org.dive4elements.river.client.client.services.CollectionAttributeServiceAsync; |
35 import org.dive4elements.river.client.client.services.CreateCollectionService; | 33 import org.dive4elements.river.client.client.services.CreateCollectionService; |
36 import org.dive4elements.river.client.client.services.CreateCollectionServiceAsync; | 34 import org.dive4elements.river.client.client.services.CreateCollectionServiceAsync; |
37 import org.dive4elements.river.client.client.services.DescribeCollectionService; | 35 import org.dive4elements.river.client.client.services.DescribeCollectionService; |
60 | 58 |
61 /** | 59 /** |
62 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 60 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
63 */ | 61 */ |
64 public class CollectionView extends Window implements CollectionChangeHandler, HasCollectionChangeHandlers, OutputModesChangeHandler, HasOutputModesChangeHandlers, ParameterChangeHandler, CloseClickHandler { | 62 public class CollectionView extends Window implements CollectionChangeHandler, HasCollectionChangeHandlers, OutputModesChangeHandler, HasOutputModesChangeHandlers, ParameterChangeHandler, CloseClickHandler { |
63 | |
64 /** The message class that provides i18n strings. */ | |
65 private static final FLYSConstants messages = GWT.create(FLYSConstants.class); | |
66 | |
65 /** The ArtifactService used to communicate with the Artifact server. */ | 67 /** The ArtifactService used to communicate with the Artifact server. */ |
66 protected CreateCollectionServiceAsync createCollectionService = GWT.create(CreateCollectionService.class); | 68 private final CreateCollectionServiceAsync createCollectionService = GWT.create(CreateCollectionService.class); |
67 | |
68 /** The ArtifactService used to communicate with the Artifact server. */ | |
69 protected ArtifactServiceAsync createArtifactService = GWT.create(ArtifactService.class); | |
70 | 69 |
71 /** The AddArtifactService used to add an artifact to a collection. */ | 70 /** The AddArtifactService used to add an artifact to a collection. */ |
72 protected AddArtifactServiceAsync addArtifactService = GWT.create(AddArtifactService.class); | 71 private final AddArtifactServiceAsync addArtifactService = GWT.create(AddArtifactService.class); |
73 | 72 |
74 /** The DescribeCollectionService used to update the existing collection. */ | 73 /** The DescribeCollectionService used to update the existing collection. */ |
75 protected DescribeCollectionServiceAsync describeCollectionService = GWT.create(DescribeCollectionService.class); | 74 private final DescribeCollectionServiceAsync describeCollectionService = GWT.create(DescribeCollectionService.class); |
76 | 75 |
77 protected CollectionAttributeServiceAsync updater = GWT.create(CollectionAttributeService.class); | 76 private final CollectionAttributeServiceAsync updater = GWT.create(CollectionAttributeService.class); |
78 | 77 |
79 /** The LoadArtifactService used to load recommendations */ | 78 /** The LoadArtifactService used to load recommendations */ |
80 protected LoadArtifactServiceAsync loadArtifactService = GWT.create(LoadArtifactService.class); | 79 private final LoadArtifactServiceAsync loadArtifactService = GWT.create(LoadArtifactService.class); |
81 | |
82 /** The message class that provides i18n strings. */ | |
83 protected FLYSConstants messages = GWT.create(FLYSConstants.class); | |
84 | 80 |
85 /** The FLYS instance used to call services. */ | 81 /** The FLYS instance used to call services. */ |
86 protected FLYS flys; | 82 private final FLYS flys; |
87 | 83 |
88 /** The ParameterList. */ | 84 /** The ParameterList. */ |
89 protected ParameterList parameterList; | 85 private ParameterList parameterList; |
90 | 86 |
91 /** The list of CollectionChangeHandlers. */ | 87 /** The list of CollectionChangeHandlers. */ |
92 protected List<CollectionChangeHandler> handlers; | 88 private final List<CollectionChangeHandler> handlers; |
93 | 89 |
94 /** The list of OutputModesChangeHandlers. */ | 90 /** The list of OutputModesChangeHandlers. */ |
95 protected List<OutputModesChangeHandler> outHandlers; | 91 private final List<OutputModesChangeHandler> outHandlers; |
96 | 92 |
97 /** The collection to be displayed. */ | 93 /** The collection to be displayed. */ |
98 protected Collection collection; | 94 private Collection collection; |
99 | 95 |
100 /** The artifact that handles the parameterization. */ | 96 /** The artifact that handles the parameterization. */ |
101 protected Artifact artifact; | 97 private Artifact artifact; |
102 | 98 |
103 protected TabSet tabs; | 99 private final TabSet tabs; |
104 | 100 |
105 /** The output tab. */ | 101 /** The output tab. */ |
106 protected Map<String, OutputTab> outputTabs; | 102 private final Map<String, OutputTab> outputTabs; |
107 | 103 |
108 /** The layout. */ | 104 /** The layout. */ |
109 protected Layout layout; | 105 private final Layout layout; |
110 | 106 |
111 /** Layout to show spinning wheel of joy. */ | 107 /** Layout to show spinning wheel of joy. */ |
112 protected VLayout lockScreen; | 108 private VLayout lockScreen; |
113 | 109 |
114 protected int artifactsQueue; | 110 private final int artifactsQueue; |
115 protected int recommendationQueue; | 111 private final Stack<Recommendation> newRecommendations; |
116 protected Stack<Recommendation> newRecommendations; | |
117 | 112 |
118 /** Values for fix analysis charts */ | 113 /** Values for fix analysis charts */ |
119 protected double currentKm; | 114 private double currentKm; |
120 protected double minKm; | |
121 protected double maxKm; | |
122 protected double steps; | |
123 | 115 |
124 /** | 116 /** |
125 * This constructor creates a new CollectionView that is used to display the | 117 * This constructor creates a new CollectionView that is used to display the |
126 * <i>collection</i>. | 118 * <i>collection</i>. |
127 */ | 119 */ |
130 this.tabs = new TabSet(); | 122 this.tabs = new TabSet(); |
131 this.outputTabs = new HashMap<String, OutputTab>(); | 123 this.outputTabs = new HashMap<String, OutputTab>(); |
132 this.handlers = new ArrayList<CollectionChangeHandler>(); | 124 this.handlers = new ArrayList<CollectionChangeHandler>(); |
133 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); | 125 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); |
134 this.layout = new VLayout(); | 126 this.layout = new VLayout(); |
135 this.parameterList = new ParameterList(flys, this, this.messages.new_project()); | 127 this.parameterList = new ParameterList(flys, this, CollectionView.messages.new_project()); |
136 this.artifactsQueue = 0; | 128 this.artifactsQueue = 0; |
137 this.recommendationQueue = 0; | |
138 this.newRecommendations = new Stack<Recommendation>(); | 129 this.newRecommendations = new Stack<Recommendation>(); |
139 | 130 |
140 this.currentKm = -1d; | 131 this.currentKm = -1d; |
141 this.minKm = -1d; | |
142 this.maxKm = -1d; | |
143 this.steps = -1d; | |
144 | 132 |
145 addCollectionChangeHandler(this); | 133 addCollectionChangeHandler(this); |
146 addCollectionChangeHandler(this.parameterList); | 134 addCollectionChangeHandler(this.parameterList); |
147 addCollectionChangeHandler(flys); | 135 addCollectionChangeHandler(flys); |
148 addOutputModesChangeHandler(this); | 136 addOutputModesChangeHandler(this); |
167 this.handlers = new ArrayList<CollectionChangeHandler>(); | 155 this.handlers = new ArrayList<CollectionChangeHandler>(); |
168 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); | 156 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); |
169 this.layout = new VLayout(); | 157 this.layout = new VLayout(); |
170 | 158 |
171 this.currentKm = -1d; | 159 this.currentKm = -1d; |
172 this.minKm = -1d; | |
173 this.maxKm = -1d; | |
174 this.steps = -1d; | |
175 | 160 |
176 if (artifact != null) { | 161 if (artifact != null) { |
177 this.parameterList = new ParameterList(flys, this, | 162 this.parameterList = new ParameterList(flys, this, |
178 // FIXME: literally every information about the artifact is transported from the server side | 163 // FIXME: literally every information about the artifact is transported from the server side |
179 // but... the international name is resolved client-side.... Instead also transport the description of the artifact and | 164 // but... the international name is resolved client-side.... Instead also transport the description of the artifact and |
180 // use it! | 165 // use it! |
181 // FIXME: the same holds for a very few other international strings (e.g. names of facets used in Tabs) | 166 // FIXME: the same holds for a very few other international strings (e.g. names of facets used in Tabs) |
182 this.messages.getString(artifact.getName()), artifact); | 167 CollectionView.messages.getString(artifact.getName()), artifact); |
183 } else { | 168 } else { |
184 this.parameterList = new ParameterList(flys, this, this.messages.new_project()); | 169 this.parameterList = new ParameterList(flys, this, CollectionView.messages.new_project()); |
185 } | 170 } |
186 | 171 |
187 this.artifactsQueue = 0; | 172 this.artifactsQueue = 0; |
188 this.newRecommendations = new Stack<Recommendation>(); | 173 this.newRecommendations = new Stack<Recommendation>(); |
189 | 174 |
206 } | 191 } |
207 | 192 |
208 /** | 193 /** |
209 * This method handles the initial layout stuff. | 194 * This method handles the initial layout stuff. |
210 */ | 195 */ |
211 protected void init() { | 196 private void init() { |
212 setWidth(1010); | 197 setWidth(1010); |
213 setHeight(700); | 198 setHeight(700); |
214 | 199 |
215 setMaximized(true); | 200 setMaximized(true); |
216 | 201 |
227 | 212 |
228 this.layout.addMember(this.tabs); | 213 this.layout.addMember(this.tabs); |
229 this.tabs.addTab(this.parameterList); | 214 this.tabs.addTab(this.parameterList); |
230 } | 215 } |
231 | 216 |
232 protected FLYS getFlys() { | 217 private FLYS getFlys() { |
233 return this.flys; | 218 return this.flys; |
234 } | 219 } |
235 | 220 |
236 /** | 221 /** |
237 * This method registers a new CollectionChangeHandler. | 222 * This method registers a new CollectionChangeHandler. |
261 | 246 |
262 /** | 247 /** |
263 * This method calls the <code>onValueChange()</code> method of all | 248 * This method calls the <code>onValueChange()</code> method of all |
264 * registered ValueChangeHanders. | 249 * registered ValueChangeHanders. |
265 */ | 250 */ |
266 protected void fireCollectionChangeEvent(final Collection old, final Collection newCol) { | 251 private void fireCollectionChangeEvent(final Collection old, final Collection newCol) { |
267 for (final CollectionChangeHandler handler : this.handlers) { | 252 for (final CollectionChangeHandler handler : this.handlers) { |
268 handler.onCollectionChange(new CollectionChangeEvent(old, newCol)); | 253 handler.onCollectionChange(new CollectionChangeEvent(old, newCol)); |
269 } | 254 } |
270 } | 255 } |
271 | 256 |
272 protected void fireOutputModesChangeEvent(final OutputMode[] outputs) { | 257 private void fireOutputModesChangeEvent(final OutputMode[] outputs) { |
273 if (this.collection == null) { | 258 if (this.collection == null) { |
274 return; | 259 return; |
275 } | 260 } |
276 | 261 |
277 for (final OutputModesChangeHandler handler : this.outHandlers) { | 262 for (final OutputModesChangeHandler handler : this.outHandlers) { |
288 public void unlockUI() { | 273 public void unlockUI() { |
289 ScreenLock.unlockUI(this.layout, this.lockScreen); | 274 ScreenLock.unlockUI(this.layout, this.lockScreen); |
290 } | 275 } |
291 | 276 |
292 /** | 277 /** |
293 * This method returns true, if the Collection is new and no plugins has | |
294 * been chosen. | |
295 * | |
296 * @return true, if the Collection is new. | |
297 */ | |
298 public boolean isNew() { | |
299 return this.collection.hasItems(); | |
300 } | |
301 | |
302 /** | |
303 * Returns the artifact that is used for the parameterization. | 278 * Returns the artifact that is used for the parameterization. |
304 * | 279 * |
305 * @return the artifact that is used for the parameterization. | 280 * @return the artifact that is used for the parameterization. |
306 */ | 281 */ |
307 public Artifact getArtifact() { | 282 public Artifact getArtifact() { |
319 * The new artifact. | 294 * The new artifact. |
320 */ | 295 */ |
321 public void setArtifact(final Artifact artifact) { | 296 public void setArtifact(final Artifact artifact) { |
322 this.artifact = artifact; | 297 this.artifact = artifact; |
323 | 298 |
324 onArtifactChanged(artifact); | |
325 } | |
326 | |
327 public void onArtifactChanged(final Artifact artifact) { | |
328 artifactChanged(); | 299 artifactChanged(); |
329 | 300 |
330 if (artifact.isInBackground()) { | 301 if (artifact.isInBackground()) { |
331 final LoadingPanel p = new LoadingPanel(this, artifact); | 302 final LoadingPanel p = new LoadingPanel(this, artifact); |
332 p.addStepBackHandler(this.parameterList); | 303 p.addStepBackHandler(this.parameterList); |
344 public void onParameterChange(final ParameterChangeEvent event) { | 315 public void onParameterChange(final ParameterChangeEvent event) { |
345 GWT.log("CollectionView.onParameterChange"); | 316 GWT.log("CollectionView.onParameterChange"); |
346 setArtifact(event.getNewValue()); | 317 setArtifact(event.getNewValue()); |
347 } | 318 } |
348 | 319 |
349 protected void artifactChanged() { | 320 private void artifactChanged() { |
350 final Collection c = getCollection(); | 321 final Collection c = getCollection(); |
351 | 322 |
352 if (c != null) { | 323 if (c != null) { |
353 loadCollection(c); | 324 loadCollection(c); |
354 } else { | 325 } else { |
357 } | 328 } |
358 | 329 |
359 /** | 330 /** |
360 * Loads all information of a collection. | 331 * Loads all information of a collection. |
361 * If 'recommendations' present, load these. | 332 * If 'recommendations' present, load these. |
362 * | 333 * |
363 * @param c | 334 * @param c |
364 * the Collection | 335 * the Collection |
365 */ | 336 */ |
366 private void loadCollection(final Collection c) { | 337 private void loadCollection(final Collection c) { |
367 final ArtifactDescription desc = getArtifact().getArtifactDescription(); | 338 final ArtifactDescription desc = getArtifact().getArtifactDescription(); |
368 final Recommendation[] recom = desc.getRecommendations(); | 339 final Recommendation[] recom = desc.getRecommendations(); |
369 final Config config = Config.getInstance(); | 340 final String locale = Config.getInstance().getLocale(); |
370 final String locale = config.getLocale(); | |
371 | 341 |
372 this.describeCollectionService.describe(c.identifier(), locale, new AsyncCallback<Collection>() { | 342 this.describeCollectionService.describe(c.identifier(), locale, new AsyncCallback<Collection>() { |
373 @Override | 343 @Override |
374 public void onFailure(final Throwable caught) { | 344 public void onFailure(final Throwable caught) { |
375 GWT.log("Could not DESCRIBE collection."); | 345 GWT.log("Could not DESCRIBE collection."); |
401 */ | 371 */ |
402 public Collection getCollection() { | 372 public Collection getCollection() { |
403 return this.collection; | 373 return this.collection; |
404 } | 374 } |
405 | 375 |
406 protected void setCollection(final Collection collection) { | 376 private void setCollection(final Collection collection) { |
407 setCollection(collection, false); | 377 setCollection(collection, false); |
408 } | 378 } |
409 | 379 |
410 /** | 380 /** |
411 * Set the current collection. | 381 * Set the current collection. |
413 * @param collection | 383 * @param collection |
414 * The new collection. | 384 * The new collection. |
415 * @param suppress | 385 * @param suppress |
416 * Whether to fire a collectionchangeevent. | 386 * Whether to fire a collectionchangeevent. |
417 */ | 387 */ |
418 protected void setCollection(final Collection collection, final boolean suppress) { | 388 public void setCollection(final Collection collection, final boolean suppress) { |
419 if (collection != null && this.collection == null) { | 389 if (collection != null && this.collection == null) { |
420 this.flys.getWorkspace().addView(collection.identifier(), this); | 390 this.flys.getWorkspace().addView(collection.identifier(), this); |
421 } | 391 } |
422 | 392 |
423 final Collection tmp = this.collection; | 393 final Collection tmp = this.collection; |
424 this.collection = collection; | 394 this.collection = collection; |
425 | 395 |
426 setTitle(collection.getDisplayName()); | 396 if (collection != null) |
427 | 397 setTitle(collection.getDisplayName()); |
428 if (!suppress) { | 398 |
399 if (!suppress) | |
429 fireCollectionChangeEvent(tmp, this.collection); | 400 fireCollectionChangeEvent(tmp, this.collection); |
430 } | |
431 } | 401 } |
432 | 402 |
433 @Override | 403 @Override |
434 public void onCollectionChange(final CollectionChangeEvent event) { | 404 public void onCollectionChange(final CollectionChangeEvent event) { |
435 if (this.artifactsQueue > 0) { | 405 if (this.artifactsQueue > 0) { |
486 * Adds a new tab for the OutputMode <i>out</i>. | 456 * Adds a new tab for the OutputMode <i>out</i>. |
487 * | 457 * |
488 * @param name | 458 * @param name |
489 * The name and title of the output. | 459 * The name and title of the output. |
490 */ | 460 */ |
491 protected void addOutputTab(final String name, final OutputMode out) { | 461 private void addOutputTab(final String name, final OutputMode out) { |
492 if (out instanceof ExportMode) { | 462 if (out instanceof ExportMode) { |
493 final ExportMode export = (ExportMode) out; | 463 final ExportMode export = (ExportMode) out; |
494 | 464 |
495 if (export.getFacet("csv") != null && !this.parameterList.hasTable()) { | 465 if (export.getFacet("csv") != null && !this.parameterList.hasTable()) { |
496 final TableDataPanel p = new TableDataPanel(); | 466 final TableDataPanel p = new TableDataPanel(); |
507 return; | 477 return; |
508 } | 478 } |
509 | 479 |
510 GWT.log("Add new output tab for '" + name + "'"); | 480 GWT.log("Add new output tab for '" + name + "'"); |
511 | 481 |
512 final String title = this.messages.getString(name); | 482 final String title = CollectionView.messages.getString(name); |
513 final OutputTab tab = out.createOutputTab(title, getCollection(), this); | 483 final OutputTab tab = out.createOutputTab(title, getCollection(), this); |
514 | 484 |
515 if (tab != null) { | 485 if (tab != null) |
516 this.outputTabs.put(name, tab); | 486 this.outputTabs.put(name, tab); |
517 } | |
518 } | 487 } |
519 | 488 |
520 /** | 489 /** |
521 * Removes all output mode tabs from tab bar. | 490 * Removes all output mode tabs from tab bar. |
522 */ | 491 */ |
523 protected void clearOutputTabs() { | 492 private void clearOutputTabs() { |
524 GWT.log("Clear OutputTabs."); | 493 GWT.log("Clear OutputTabs."); |
525 | 494 |
526 final int num = this.tabs.getNumTabs(); | 495 final int num = this.tabs.getNumTabs(); |
527 | 496 |
528 for (int i = num - 1; i >= 1; i--) { | 497 for (int i = num - 1; i >= 1; i--) { |
533 } | 502 } |
534 | 503 |
535 /** | 504 /** |
536 * Update the view (refresh the list of old and current data). | 505 * Update the view (refresh the list of old and current data). |
537 */ | 506 */ |
538 protected void updateView() { | 507 private void updateView() { |
539 GWT.log("CollectionView.updateView()"); | 508 GWT.log("CollectionView.updateView()"); |
540 updateOutputTabs(); | 509 updateOutputTabs(); |
541 } | 510 } |
542 | 511 |
543 /** | 512 /** |
544 * This method is used to update the tabs to show specific output modes. | 513 * This method is used to update the tabs to show specific output modes. |
545 */ | 514 */ |
546 protected void updateOutputTabs() { | 515 private void updateOutputTabs() { |
547 GWT.log("Update output tabs."); | 516 GWT.log("Update output tabs."); |
548 if (this.outputTabs != null) { | 517 if (this.outputTabs != null) { |
549 final Set<String> keys = this.outputTabs.keySet(); | 518 final Set<String> keys = this.outputTabs.keySet(); |
550 | 519 |
551 for (final String key : keys) { | 520 for (final String key : keys) { |
567 destroy(); | 536 destroy(); |
568 } | 537 } |
569 } | 538 } |
570 | 539 |
571 public void addArtifactToCollection(final Artifact artifact) { | 540 public void addArtifactToCollection(final Artifact artifact) { |
572 final Config config = Config.getInstance(); | 541 final String locale = Config.getInstance().getLocale(); |
573 final String locale = config.getLocale(); | 542 |
574 final Collection collection = getCollection(); | 543 GWT.log("CollectionView.addArtifactToCollection " + this.collection); |
575 | 544 |
576 GWT.log("CollectionView.addArtifactToCollection " + collection); | 545 if (this.collection != null) { |
577 | 546 this.addArtifactService.add(this.collection, artifact, locale, new AsyncCallback<Collection>() { |
578 if (collection != null) { | |
579 this.addArtifactService.add(collection, artifact, locale, new AsyncCallback<Collection>() { | |
580 @Override | 547 @Override |
581 public void onFailure(final Throwable caught) { | 548 public void onFailure(final Throwable caught) { |
582 GWT.log("An error occured while adding artifact."); | 549 GWT.log("An error occured while adding artifact."); |
583 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); | 550 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); |
584 } | 551 } |
594 final Artifact art = artifact; | 561 final Artifact art = artifact; |
595 this.createCollectionService.create(locale, this.flys.getCurrentUser().identifier(), new AsyncCallback<Collection>() { | 562 this.createCollectionService.create(locale, this.flys.getCurrentUser().identifier(), new AsyncCallback<Collection>() { |
596 @Override | 563 @Override |
597 public void onFailure(final Throwable caught) { | 564 public void onFailure(final Throwable caught) { |
598 GWT.log("Could not create the new collection."); | 565 GWT.log("Could not create the new collection."); |
599 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); | 566 SC.warn(FLYS.getExceptionString(CollectionView.messages, caught)); |
600 } | 567 } |
601 | 568 |
602 @Override | 569 @Override |
603 public void onSuccess(final Collection collection) { | 570 public void onSuccess(final Collection collection) { |
604 GWT.log("Successfully created a new collection."); | 571 GWT.log("Successfully created a new collection."); |
618 } | 585 } |
619 }); | 586 }); |
620 } | 587 } |
621 } | 588 } |
622 | 589 |
623 protected void addRecommendationsToCollection() { | 590 private void addRecommendationsToCollection() { |
624 final Config config = Config.getInstance(); | 591 final String locale = Config.getInstance().getLocale(); |
625 final String locale = config.getLocale(); | 592 |
626 final Collection collection = getCollection(); | 593 this.collection.addRecommendations(this.newRecommendations); |
627 | 594 |
628 collection.addRecommendations(this.newRecommendations); | 595 this.updater.update(this.collection, locale, new AsyncCallback<Collection>() { |
629 | |
630 this.updater.update(collection, locale, new AsyncCallback<Collection>() { | |
631 @Override | 596 @Override |
632 public void onFailure(final Throwable caught) { | 597 public void onFailure(final Throwable caught) { |
633 CollectionView.this.newRecommendations.removeAllElements(); | 598 CollectionView.this.newRecommendations.removeAllElements(); |
634 setCollection(collection); | 599 setCollection(CollectionView.this.collection); |
635 | 600 |
636 GWT.log("An error occured while saving recommendations."); | 601 GWT.log("An error occured while saving recommendations."); |
637 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); | 602 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); |
638 } | 603 } |
639 | 604 |
644 setCollection(newCol); | 609 setCollection(newCol); |
645 } | 610 } |
646 }); | 611 }); |
647 } | 612 } |
648 | 613 |
649 protected void loadRecommendedArtifacts(final Recommendation[] recommendations) { | 614 private void loadRecommendedArtifacts(final Recommendation[] recommendations) { |
650 final Config config = Config.getInstance(); | 615 final String locale = Config.getInstance().getLocale(); |
651 final String locale = config.getLocale(); | |
652 final Collection collection = getCollection(); | |
653 | 616 |
654 final Artifact masterArtifact = getArtifact(); | 617 final Artifact masterArtifact = getArtifact(); |
655 | 618 |
656 if (recommendations == null) { | 619 if (recommendations == null) { |
657 GWT.log("WARNING: Currently no recommendations."); | 620 GWT.log("WARNING: Currently no recommendations."); |
658 return; | 621 return; |
659 } | 622 } |
660 | 623 |
661 for (final Recommendation recommendation : recommendations) { | 624 for (final Recommendation recommendation : recommendations) { |
662 if (collection.loadedRecommendation(recommendation)) { | 625 if (this.collection.loadedRecommendation(recommendation)) { |
663 continue; | 626 continue; |
664 } | 627 } |
665 this.newRecommendations.push(recommendation); | 628 this.newRecommendations.push(recommendation); |
666 | 629 |
667 // XXX: UGLY! If no reference artifact given use uuid of | 630 // XXX: UGLY! If no reference artifact given use uuid of |
670 recommendation.setMasterArtifact(masterArtifact.getUuid()); | 633 recommendation.setMasterArtifact(masterArtifact.getUuid()); |
671 } | 634 } |
672 | 635 |
673 } | 636 } |
674 | 637 |
675 this.loadArtifactService.loadMany(collection, recommendations, null, locale, new AsyncCallback<Artifact[]>() { | 638 this.loadArtifactService.loadMany(this.collection, recommendations, null, locale, new AsyncCallback<Artifact[]>() { |
676 @Override | 639 @Override |
677 public void onFailure(final Throwable caught) { | 640 public void onFailure(final Throwable caught) { |
678 GWT.log("Error loading recommendations: " + caught.getMessage()); | 641 GWT.log("Error loading recommendations: " + caught.getMessage()); |
679 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); | 642 SC.warn(FLYS.getExceptionString(CollectionView.messages, caught)); |
680 } | 643 } |
681 | 644 |
682 @Override | 645 @Override |
683 public void onSuccess(final Artifact[] artifacts) { | 646 public void onSuccess(final Artifact[] artifacts) { |
684 GWT.log("Loaded artifacts: " + artifacts.length); | 647 GWT.log("Loaded artifacts: " + artifacts.length); |
696 } | 659 } |
697 | 660 |
698 public double getCurrentKm() { | 661 public double getCurrentKm() { |
699 return this.currentKm; | 662 return this.currentKm; |
700 } | 663 } |
701 | |
702 public void setMinKm(final double km) { | |
703 this.minKm = km; | |
704 } | |
705 | |
706 public double getMinKm() { | |
707 return this.minKm; | |
708 } | |
709 | |
710 public void setMaxKm(final double km) { | |
711 this.maxKm = km; | |
712 } | |
713 | |
714 public double getMaxKm() { | |
715 return this.maxKm; | |
716 } | |
717 | |
718 public void setSteps(final double step) { | |
719 this.steps = step; | |
720 } | |
721 | |
722 public double getSteps() { | |
723 return this.steps; | |
724 } | |
725 } | 664 } |
726 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |