Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 3501:0de0ef04bcdc
Delete empty project after closing CollectionView (#785).
flys-client/trunk@5234 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 22 Aug 2012 12:29:33 +0000 |
parents | 6b5920c7ea6e |
children | 6a8f83c538e3 |
comparison
equal
deleted
inserted
replaced
3500:def13f23bb27 | 3501:0de0ef04bcdc |
---|---|
1 package de.intevation.flys.client.client; | 1 package de.intevation.flys.client.client; |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 import java.util.Set; | |
6 | 2 |
7 import com.google.gwt.core.client.EntryPoint; | 3 import com.google.gwt.core.client.EntryPoint; |
8 import com.google.gwt.core.client.GWT; | 4 import com.google.gwt.core.client.GWT; |
9 import com.google.gwt.event.shared.UmbrellaException; | 5 import com.google.gwt.event.shared.UmbrellaException; |
10 import com.google.gwt.user.client.rpc.AsyncCallback; | 6 import com.google.gwt.user.client.rpc.AsyncCallback; |
11 import com.google.gwt.xml.client.XMLParser; | 7 import com.google.gwt.xml.client.XMLParser; |
12 | |
13 import com.smartgwt.client.util.SC; | 8 import com.smartgwt.client.util.SC; |
9 import com.smartgwt.client.widgets.HTMLPane; | |
14 import com.smartgwt.client.widgets.Window; | 10 import com.smartgwt.client.widgets.Window; |
15 import com.smartgwt.client.widgets.HTMLPane; | 11 import com.smartgwt.client.widgets.events.CloseClickEvent; |
12 import com.smartgwt.client.widgets.events.CloseClickHandler; | |
13 import com.smartgwt.client.widgets.layout.HLayout; | |
16 import com.smartgwt.client.widgets.layout.VLayout; | 14 import com.smartgwt.client.widgets.layout.VLayout; |
17 import com.smartgwt.client.widgets.layout.HLayout; | |
18 import com.smartgwt.client.widgets.events.CloseClickHandler; | |
19 import com.smartgwt.client.widgets.events.CloseClickEvent; | |
20 | |
21 import de.intevation.flys.client.shared.model.Artifact; | |
22 import de.intevation.flys.client.shared.model.Collection; | |
23 import de.intevation.flys.client.shared.model.CollectionItem; | |
24 import de.intevation.flys.client.shared.model.River; | |
25 import de.intevation.flys.client.shared.model.User; | |
26 | 15 |
27 import de.intevation.flys.client.client.event.CollectionChangeEvent; | 16 import de.intevation.flys.client.client.event.CollectionChangeEvent; |
28 import de.intevation.flys.client.client.event.CollectionChangeHandler; | 17 import de.intevation.flys.client.client.event.CollectionChangeHandler; |
29 import de.intevation.flys.client.client.services.ArtifactService; | 18 import de.intevation.flys.client.client.services.ArtifactService; |
30 import de.intevation.flys.client.client.services.ArtifactServiceAsync; | 19 import de.intevation.flys.client.client.services.ArtifactServiceAsync; |
35 import de.intevation.flys.client.client.services.RiverService; | 24 import de.intevation.flys.client.client.services.RiverService; |
36 import de.intevation.flys.client.client.services.RiverServiceAsync; | 25 import de.intevation.flys.client.client.services.RiverServiceAsync; |
37 import de.intevation.flys.client.client.services.UserService; | 26 import de.intevation.flys.client.client.services.UserService; |
38 import de.intevation.flys.client.client.services.UserServiceAsync; | 27 import de.intevation.flys.client.client.services.UserServiceAsync; |
39 import de.intevation.flys.client.client.ui.CollectionView; | 28 import de.intevation.flys.client.client.ui.CollectionView; |
29 import de.intevation.flys.client.client.ui.FLYSFooter; | |
40 import de.intevation.flys.client.client.ui.FLYSHeader; | 30 import de.intevation.flys.client.client.ui.FLYSHeader; |
41 import de.intevation.flys.client.client.ui.FLYSView; | 31 import de.intevation.flys.client.client.ui.FLYSView; |
42 import de.intevation.flys.client.client.ui.FLYSWorkspace; | 32 import de.intevation.flys.client.client.ui.FLYSWorkspace; |
43 import de.intevation.flys.client.client.ui.MainMenu; | 33 import de.intevation.flys.client.client.ui.MainMenu; |
44 import de.intevation.flys.client.client.ui.ProjectList; | 34 import de.intevation.flys.client.client.ui.ProjectList; |
45 import de.intevation.flys.client.client.ui.FLYSFooter; | 35 import de.intevation.flys.client.shared.model.Artifact; |
36 import de.intevation.flys.client.shared.model.Collection; | |
37 import de.intevation.flys.client.shared.model.CollectionItem; | |
38 import de.intevation.flys.client.shared.model.River; | |
39 import de.intevation.flys.client.shared.model.User; | |
40 | |
41 import java.util.ArrayList; | |
42 import java.util.List; | |
43 import java.util.Set; | |
46 | 44 |
47 | 45 |
48 /** | 46 /** |
49 * Entry point classes define <code>onModuleLoad()</code>. | 47 * Entry point classes define <code>onModuleLoad()</code>. |
50 * | 48 * |
100 | 98 |
101 | 99 |
102 /** | 100 /** |
103 * This is the entry point method. | 101 * This is the entry point method. |
104 */ | 102 */ |
103 @Override | |
105 public void onModuleLoad() { | 104 public void onModuleLoad() { |
106 openProjects = new ArrayList<String>(); | 105 openProjects = new ArrayList<String>(); |
107 | 106 |
108 //GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { | 107 //GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { |
109 // public void onUncaughtException(Throwable e) { | 108 // public void onUncaughtException(Throwable e) { |
139 String locale = config.getLocale(); | 138 String locale = config.getLocale(); |
140 | 139 |
141 getRivers(); | 140 getRivers(); |
142 | 141 |
143 userService.getCurrentUser(locale, new AsyncCallback<User>() { | 142 userService.getCurrentUser(locale, new AsyncCallback<User>() { |
143 @Override | |
144 public void onFailure(Throwable caught) { | 144 public void onFailure(Throwable caught) { |
145 GWT.log("Could not find a logged in user."); | 145 GWT.log("Could not find a logged in user."); |
146 SC.warn(MSG.getString(caught.getMessage())); | 146 SC.warn(MSG.getString(caught.getMessage())); |
147 } | 147 } |
148 | 148 |
149 @Override | |
149 public void onSuccess(User user) { | 150 public void onSuccess(User user) { |
150 GWT.log("Found a user. Set '"+ user.getName() + "'"); | 151 GWT.log("Found a user. Set '"+ user.getName() + "'"); |
151 setCurrentUser(user); | 152 setCurrentUser(user); |
152 | 153 |
153 menu.setCurrentUser(user); | 154 menu.setCurrentUser(user); |
256 protected void readRivers() { | 257 protected void readRivers() { |
257 Config config = Config.getInstance(); | 258 Config config = Config.getInstance(); |
258 String locale = config.getLocale(); | 259 String locale = config.getLocale(); |
259 | 260 |
260 riverService.list(locale, new AsyncCallback<River[]>() { | 261 riverService.list(locale, new AsyncCallback<River[]>() { |
262 @Override | |
261 public void onFailure(Throwable caught) { | 263 public void onFailure(Throwable caught) { |
262 GWT.log("Could not recieve a list of rivers."); | 264 GWT.log("Could not recieve a list of rivers."); |
263 SC.warn(MSG.getString(caught.getMessage())); | 265 SC.warn(MSG.getString(caught.getMessage())); |
264 } | 266 } |
265 | 267 |
268 @Override | |
266 public void onSuccess(River[] newRivers) { | 269 public void onSuccess(River[] newRivers) { |
267 GWT.log("Retrieved " + newRivers.length + " new rivers."); | 270 GWT.log("Retrieved " + newRivers.length + " new rivers."); |
268 rivers = newRivers; | 271 rivers = newRivers; |
269 } | 272 } |
270 }); | 273 }); |
333 Config config = Config.getInstance(); | 336 Config config = Config.getInstance(); |
334 final String locale = config.getLocale(); | 337 final String locale = config.getLocale(); |
335 | 338 |
336 describeCollectionService.describe(collectionID, locale, | 339 describeCollectionService.describe(collectionID, locale, |
337 new AsyncCallback<Collection>() { | 340 new AsyncCallback<Collection>() { |
341 @Override | |
338 public void onFailure(Throwable caught) { | 342 public void onFailure(Throwable caught) { |
339 SC.warn(MSG.getString(caught.getMessage())); | 343 SC.warn(MSG.getString(caught.getMessage())); |
340 } | 344 } |
341 | 345 |
346 @Override | |
342 public void onSuccess(Collection c) { | 347 public void onSuccess(Collection c) { |
343 final Collection collection = c; | 348 final Collection collection = c; |
344 | 349 |
345 if (collection.getItemLength() == 0) { | 350 if (collection.getItemLength() == 0) { |
346 CollectionView view = new CollectionView( | 351 CollectionView view = new CollectionView( |
367 getArtifactService.getArtifact( | 372 getArtifactService.getArtifact( |
368 locale, | 373 locale, |
369 item.identifier(), | 374 item.identifier(), |
370 item.hash(), | 375 item.hash(), |
371 new AsyncCallback<Artifact>() { | 376 new AsyncCallback<Artifact>() { |
377 @Override | |
372 public void onFailure(Throwable caught) { | 378 public void onFailure(Throwable caught) { |
373 unlockProject(collectionID); | 379 unlockProject(collectionID); |
374 SC.warn(MSG.getString(caught.getMessage())); | 380 SC.warn(MSG.getString(caught.getMessage())); |
375 } | 381 } |
376 | 382 |
383 @Override | |
377 public void onSuccess(Artifact artifact) { | 384 public void onSuccess(Artifact artifact) { |
378 CollectionView view = new CollectionView( | 385 CollectionView view = new CollectionView( |
379 FLYS.this, collection, artifact); | 386 FLYS.this, collection, artifact); |
380 | 387 |
381 view.addCollectionChangeHandler( | 388 view.addCollectionChangeHandler( |
406 Config config = Config.getInstance(); | 413 Config config = Config.getInstance(); |
407 String locale = config.getLocale(); | 414 String locale = config.getLocale(); |
408 | 415 |
409 artifactService.create(locale, factory, null, | 416 artifactService.create(locale, factory, null, |
410 new AsyncCallback<Artifact>() { | 417 new AsyncCallback<Artifact>() { |
418 @Override | |
411 public void onFailure(Throwable caught) { | 419 public void onFailure(Throwable caught) { |
412 GWT.log("Could not create the new artifact."); | 420 GWT.log("Could not create the new artifact."); |
413 SC.warn(MSG.getString(caught.getMessage())); | 421 SC.warn(MSG.getString(caught.getMessage())); |
414 } | 422 } |
415 | 423 |
424 @Override | |
416 public void onSuccess(Artifact artifact) { | 425 public void onSuccess(Artifact artifact) { |
417 GWT.log("Successfully created a new artifact."); | 426 GWT.log("Successfully created a new artifact."); |
418 } | 427 } |
419 }); | 428 }); |
420 } | 429 } |
421 | 430 |
422 | 431 |
432 @Override | |
423 public void onCollectionChange(CollectionChangeEvent event) { | 433 public void onCollectionChange(CollectionChangeEvent event) { |
424 Collection oldC = event.getOldValue(); | 434 Collection oldC = event.getOldValue(); |
425 | 435 |
426 if (oldC == null) { | 436 if (oldC == null) { |
427 Collection newC = event.getNewValue(); | 437 Collection newC = event.getNewValue(); |
442 public CloseCollectionViewHandler(FLYS flys, String uuid) { | 452 public CloseCollectionViewHandler(FLYS flys, String uuid) { |
443 this.flys = flys; | 453 this.flys = flys; |
444 this.uuid = uuid; | 454 this.uuid = uuid; |
445 } | 455 } |
446 | 456 |
457 @Override | |
447 public void onCloseClick(CloseClickEvent event) { | 458 public void onCloseClick(CloseClickEvent event) { |
448 flys.closeProject(uuid); | 459 flys.closeProject(uuid); |
449 } | 460 } |
450 } | 461 } |
451 } | 462 } |