comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 2983:725470fc57d2

Add "Manage themes" button to ChartToolbar and MapToolbar. flys-client/trunk@4991 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Fri, 13 Jul 2012 11:31:25 +0000
parents 1780841d79af
children 6d749af6a9c2
comparison
equal deleted inserted replaced
2982:d2a54ae0016b 2983:725470fc57d2
1 package de.intevation.flys.client.client.ui; 1 package de.intevation.flys.client.client.ui;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5 import java.util.List;
6 import java.util.Map;
7 import java.util.Set;
8 import java.util.Stack;
9 2
10 import com.google.gwt.core.client.GWT; 3 import com.google.gwt.core.client.GWT;
11 import com.google.gwt.user.client.rpc.AsyncCallback; 4 import com.google.gwt.user.client.rpc.AsyncCallback;
12
13 import com.smartgwt.client.util.SC; 5 import com.smartgwt.client.util.SC;
14 import com.smartgwt.client.widgets.Window; 6 import com.smartgwt.client.widgets.Window;
15 import com.smartgwt.client.widgets.events.CloseClickEvent; 7 import com.smartgwt.client.widgets.events.CloseClickEvent;
16 import com.smartgwt.client.widgets.events.CloseClickHandler; 8 import com.smartgwt.client.widgets.events.CloseClickHandler;
17 import com.smartgwt.client.widgets.layout.Layout; 9 import com.smartgwt.client.widgets.layout.Layout;
18 import com.smartgwt.client.widgets.layout.VLayout; 10 import com.smartgwt.client.widgets.layout.VLayout;
19 import com.smartgwt.client.widgets.tab.TabSet; 11 import com.smartgwt.client.widgets.tab.TabSet;
20 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; 12 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
21 13
14 import de.intevation.flys.client.client.Config;
15 import de.intevation.flys.client.client.FLYS;
16 import de.intevation.flys.client.client.FLYSConstants;
17 import de.intevation.flys.client.client.event.CollectionChangeEvent;
18 import de.intevation.flys.client.client.event.CollectionChangeHandler;
19 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers;
20 import de.intevation.flys.client.client.event.HasOutputModesChangeHandlers;
21 import de.intevation.flys.client.client.event.OutputModesChangeEvent;
22 import de.intevation.flys.client.client.event.OutputModesChangeHandler;
23 import de.intevation.flys.client.client.event.ParameterChangeEvent;
24 import de.intevation.flys.client.client.event.ParameterChangeHandler;
25 import de.intevation.flys.client.client.services.AddArtifactService;
26 import de.intevation.flys.client.client.services.AddArtifactServiceAsync;
27 import de.intevation.flys.client.client.services.ArtifactService;
28 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
29 import de.intevation.flys.client.client.services.CollectionAttributeService;
30 import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync;
31 import de.intevation.flys.client.client.services.CreateCollectionService;
32 import de.intevation.flys.client.client.services.CreateCollectionServiceAsync;
33 import de.intevation.flys.client.client.services.DescribeCollectionService;
34 import de.intevation.flys.client.client.services.DescribeCollectionServiceAsync;
35 import de.intevation.flys.client.client.services.LoadArtifactService;
36 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync;
22 import de.intevation.flys.client.shared.model.Artifact; 37 import de.intevation.flys.client.shared.model.Artifact;
23 import de.intevation.flys.client.shared.model.ArtifactDescription; 38 import de.intevation.flys.client.shared.model.ArtifactDescription;
24 import de.intevation.flys.client.shared.model.Collection; 39 import de.intevation.flys.client.shared.model.Collection;
25 import de.intevation.flys.client.shared.model.ExportMode; 40 import de.intevation.flys.client.shared.model.ExportMode;
26 import de.intevation.flys.client.shared.model.OutputMode; 41 import de.intevation.flys.client.shared.model.OutputMode;
27 import de.intevation.flys.client.shared.model.Recommendation; 42 import de.intevation.flys.client.shared.model.Recommendation;
28 import de.intevation.flys.client.shared.model.ReportMode; 43 import de.intevation.flys.client.shared.model.ReportMode;
29 import de.intevation.flys.client.shared.model.User; 44 import de.intevation.flys.client.shared.model.User;
30 45
31 import de.intevation.flys.client.client.Config; 46 import java.util.ArrayList;
32 import de.intevation.flys.client.client.FLYS; 47 import java.util.HashMap;
33 import de.intevation.flys.client.client.FLYSConstants; 48 import java.util.List;
34 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; 49 import java.util.Map;
35 import de.intevation.flys.client.client.event.HasOutputModesChangeHandlers; 50 import java.util.Set;
36 import de.intevation.flys.client.client.event.CollectionChangeEvent; 51 import java.util.Stack;
37 import de.intevation.flys.client.client.event.CollectionChangeHandler;
38 import de.intevation.flys.client.client.event.OutputModesChangeEvent;
39 import de.intevation.flys.client.client.event.OutputModesChangeHandler;
40 import de.intevation.flys.client.client.event.ParameterChangeEvent;
41 import de.intevation.flys.client.client.event.ParameterChangeHandler;
42 import de.intevation.flys.client.client.services.ArtifactService;
43 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
44 import de.intevation.flys.client.client.services.AddArtifactService;
45 import de.intevation.flys.client.client.services.AddArtifactServiceAsync;
46 import de.intevation.flys.client.client.services.CollectionAttributeService;
47 import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync;
48 import de.intevation.flys.client.client.services.CreateCollectionService;
49 import de.intevation.flys.client.client.services.CreateCollectionServiceAsync;
50 import de.intevation.flys.client.client.services.DescribeCollectionService;
51 import de.intevation.flys.client.client.services.DescribeCollectionServiceAsync;
52 import de.intevation.flys.client.client.services.LoadArtifactService;
53 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync;
54 52
55 53
56 /** 54 /**
57 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 55 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
58 */ 56 */
216 214
217 /** 215 /**
218 * This method handles the initial layout stuff. 216 * This method handles the initial layout stuff.
219 */ 217 */
220 protected void init() { 218 protected void init() {
221 setWidth(750); 219 setWidth(950);
222 setHeight(600); 220 setHeight(650);
223 221
224 layout.setWidth100(); 222 layout.setWidth100();
225 223
226 setCanDragReposition(true); 224 setCanDragReposition(true);
227 setCanDragResize(true); 225 setCanDragResize(true);
251 249
252 createCollectionService.create( 250 createCollectionService.create(
253 locale, 251 locale,
254 ownerId, 252 ownerId,
255 new AsyncCallback<Collection>() { 253 new AsyncCallback<Collection>() {
254 @Override
256 public void onFailure(Throwable caught) { 255 public void onFailure(Throwable caught) {
257 GWT.log("Could not create the new collection."); 256 GWT.log("Could not create the new collection.");
258 SC.warn(messages.getString(caught.getMessage())); 257 SC.warn(messages.getString(caught.getMessage()));
259 } 258 }
260 259
260 @Override
261 public void onSuccess(Collection collection) { 261 public void onSuccess(Collection collection) {
262 GWT.log("Successfully created a new collection."); 262 GWT.log("Successfully created a new collection.");
263 setCollection(collection); 263 setCollection(collection);
264 } 264 }
265 }); 265 });
274 /** 274 /**
275 * This method registers a new CollectionChangeHandler. 275 * This method registers a new CollectionChangeHandler.
276 * 276 *
277 * @param handler The new CollectionChangeHandler. 277 * @param handler The new CollectionChangeHandler.
278 */ 278 */
279 @Override
279 public void addCollectionChangeHandler(CollectionChangeHandler handler) { 280 public void addCollectionChangeHandler(CollectionChangeHandler handler) {
280 if (handler != null) { 281 if (handler != null) {
281 handlers.add(handler); 282 handlers.add(handler);
282 } 283 }
283 } 284 }
286 /** 287 /**
287 * This method registers a new OutputModesChangeHandler. 288 * This method registers a new OutputModesChangeHandler.
288 * 289 *
289 * @param handler The new OutputModesChangeHandler. 290 * @param handler The new OutputModesChangeHandler.
290 */ 291 */
292 @Override
291 public void addOutputModesChangeHandler(OutputModesChangeHandler handler) { 293 public void addOutputModesChangeHandler(OutputModesChangeHandler handler) {
292 if (handler != null) { 294 if (handler != null) {
293 outHandlers.add(handler); 295 outHandlers.add(handler);
294 } 296 }
295 } 297 }
371 * Implements the onCollectionChange() method to do update the GUI after the 373 * Implements the onCollectionChange() method to do update the GUI after the
372 * parameterization has changed. 374 * parameterization has changed.
373 * 375 *
374 * @param event The ParameterChangeEvent. 376 * @param event The ParameterChangeEvent.
375 */ 377 */
378 @Override
376 public void onParameterChange(ParameterChangeEvent event) { 379 public void onParameterChange(ParameterChangeEvent event) {
377 GWT.log("CollectionView.onParameterChange"); 380 GWT.log("CollectionView.onParameterChange");
378 setArtifact(event.getNewValue()); 381 setArtifact(event.getNewValue());
379 } 382 }
380 383
390 Config config = Config.getInstance(); 393 Config config = Config.getInstance();
391 String locale = config.getLocale(); 394 String locale = config.getLocale();
392 395
393 describeCollectionService.describe(c.identifier(), locale, 396 describeCollectionService.describe(c.identifier(), locale,
394 new AsyncCallback<Collection>() { 397 new AsyncCallback<Collection>() {
398 @Override
395 public void onFailure(Throwable caught) { 399 public void onFailure(Throwable caught) {
396 GWT.log("Could not DESCRIBE collection."); 400 GWT.log("Could not DESCRIBE collection.");
397 SC.warn(messages.getString(caught.getMessage())); 401 SC.warn(messages.getString(caught.getMessage()));
398 } 402 }
399 403
400 404
405 @Override
401 public void onSuccess(Collection newCollection) { 406 public void onSuccess(Collection newCollection) {
402 GWT.log("Successfully DESCRIBED collection."); 407 GWT.log("Successfully DESCRIBED collection.");
403 boolean loaded = true; 408 boolean loaded = true;
404 for (Recommendation r: recom) { 409 for (Recommendation r: recom) {
405 if(!newCollection.loadedRecommendation(r)) { 410 if(!newCollection.loadedRecommendation(r)) {
457 fireCollectionChangeEvent(tmp, this.collection); 462 fireCollectionChangeEvent(tmp, this.collection);
458 } 463 }
459 } 464 }
460 465
461 466
467 @Override
462 public void onCollectionChange(CollectionChangeEvent event) { 468 public void onCollectionChange(CollectionChangeEvent event) {
463 if (artifactsQueue > 0) { 469 if (artifactsQueue > 0) {
464 GWT.log("Do not update UI because we are still loading Artifacts."); 470 GWT.log("Do not update UI because we are still loading Artifacts.");
465 return; 471 return;
466 } 472 }
481 487
482 updateView(); 488 updateView();
483 } 489 }
484 490
485 491
492 @Override
486 public void onOutputModesChange(OutputModesChangeEvent event) { 493 public void onOutputModesChange(OutputModesChangeEvent event) {
487 clearOutputTabs(); 494 clearOutputTabs();
488 OutputMode[] outs = event.getOutputModes(); 495 OutputMode[] outs = event.getOutputModes();
489 496
490 if (outs == null) { 497 if (outs == null) {
584 } 591 }
585 } 592 }
586 } 593 }
587 594
588 595
596 @Override
589 public void onCloseClick(CloseClickEvent event) { 597 public void onCloseClick(CloseClickEvent event) {
590 if (collection != null) { 598 if (collection != null) {
591 flys.closeProject(collection.identifier()); 599 flys.closeProject(collection.identifier());
592 } 600 }
593 else { 601 else {
603 final Collection collection = getCollection(); 611 final Collection collection = getCollection();
604 612
605 addArtifactService.add( 613 addArtifactService.add(
606 collection, artifact, locale, 614 collection, artifact, locale,
607 new AsyncCallback<Collection>() { 615 new AsyncCallback<Collection>() {
616 @Override
608 public void onFailure(Throwable caught) { 617 public void onFailure(Throwable caught) {
609 GWT.log("An error occured while adding artifact."); 618 GWT.log("An error occured while adding artifact.");
610 SC.warn(messages.getString(caught.getMessage())); 619 SC.warn(messages.getString(caught.getMessage()));
611 } 620 }
612 621
622 @Override
613 public void onSuccess(Collection newCollection) { 623 public void onSuccess(Collection newCollection) {
614 GWT.log("Successfully added artifacts."); 624 GWT.log("Successfully added artifacts.");
615 setCollection(newCollection, true); 625 setCollection(newCollection, true);
616 } 626 }
617 } 627 }
626 636
627 collection.addRecommendations(newRecommendations); 637 collection.addRecommendations(newRecommendations);
628 638
629 updater.update(collection, locale, 639 updater.update(collection, locale,
630 new AsyncCallback<Collection>() { 640 new AsyncCallback<Collection>() {
641 @Override
631 public void onFailure(Throwable caught) { 642 public void onFailure(Throwable caught) {
632 newRecommendations.removeAllElements(); 643 newRecommendations.removeAllElements();
633 setCollection(collection); 644 setCollection(collection);
634 645
635 GWT.log("An error occured while saving recommendations."); 646 GWT.log("An error occured while saving recommendations.");
636 // TODO POPUP WARNING 647 // TODO POPUP WARNING
637 } 648 }
638 649
650 @Override
639 public void onSuccess(Collection newCol) { 651 public void onSuccess(Collection newCol) {
640 GWT.log("Successfully saved recommendations."); 652 GWT.log("Successfully saved recommendations.");
641 newRecommendations.removeAllElements(); 653 newRecommendations.removeAllElements();
642 setCollection(newCol); 654 setCollection(newCol);
643 } 655 }
676 collection, 688 collection,
677 recommendations, 689 recommendations,
678 null, 690 null,
679 locale, 691 locale,
680 new AsyncCallback<Artifact[]>() { 692 new AsyncCallback<Artifact[]>() {
693 @Override
681 public void onFailure(Throwable caught) { 694 public void onFailure(Throwable caught) {
682 GWT.log("Error loading recommendations: " + 695 GWT.log("Error loading recommendations: " +
683 caught.getMessage()); 696 caught.getMessage());
684 } 697 }
685 698
699 @Override
686 public void onSuccess(Artifact[] artifacts) { 700 public void onSuccess(Artifact[] artifacts) {
687 GWT.log("Loaded artifacts: " + artifacts.length); 701 GWT.log("Loaded artifacts: " + artifacts.length);
688 addRecommendationsToCollection(); 702 addRecommendationsToCollection();
689 } 703 }
690 }); 704 });

http://dive4elements.wald.intevation.org