Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java @ 598:031357c3e23e
Added stubs to set the name and ttl of a collection and to delete a collection.
flys-client/trunk@2202 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 22 Jun 2011 11:47:07 +0000 |
parents | 14e5e51a7de4 |
children | 1dbffe4c6d12 |
comparison
equal
deleted
inserted
replaced
597:14e5e51a7de4 | 598:031357c3e23e |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | 2 |
3 import java.util.Date; | 3 import java.util.Date; |
4 import java.util.Map; | 4 import java.util.Map; |
5 import java.util.MissingResourceException; | |
5 | 6 |
6 import com.google.gwt.core.client.GWT; | 7 import com.google.gwt.core.client.GWT; |
7 import com.google.gwt.i18n.client.DateTimeFormat; | 8 import com.google.gwt.i18n.client.DateTimeFormat; |
8 import com.google.gwt.user.client.Timer; | 9 import com.google.gwt.user.client.Timer; |
9 import com.google.gwt.user.client.rpc.AsyncCallback; | 10 import com.google.gwt.user.client.rpc.AsyncCallback; |
41 import de.intevation.flys.client.client.Config; | 42 import de.intevation.flys.client.client.Config; |
42 import de.intevation.flys.client.client.FLYS; | 43 import de.intevation.flys.client.client.FLYS; |
43 import de.intevation.flys.client.client.FLYSConstants; | 44 import de.intevation.flys.client.client.FLYSConstants; |
44 import de.intevation.flys.client.client.event.CollectionChangeEvent; | 45 import de.intevation.flys.client.client.event.CollectionChangeEvent; |
45 import de.intevation.flys.client.client.event.CollectionChangeHandler; | 46 import de.intevation.flys.client.client.event.CollectionChangeHandler; |
47 import de.intevation.flys.client.client.services.DeleteCollectionService; | |
48 import de.intevation.flys.client.client.services.DeleteCollectionServiceAsync; | |
49 import de.intevation.flys.client.client.services.SetCollectionNameService; | |
50 import de.intevation.flys.client.client.services.SetCollectionNameServiceAsync; | |
51 import de.intevation.flys.client.client.services.SetCollectionTTLService; | |
52 import de.intevation.flys.client.client.services.SetCollectionTTLServiceAsync; | |
46 import de.intevation.flys.client.client.services.UserCollectionsService; | 53 import de.intevation.flys.client.client.services.UserCollectionsService; |
47 import de.intevation.flys.client.client.services.UserCollectionsServiceAsync; | 54 import de.intevation.flys.client.client.services.UserCollectionsServiceAsync; |
48 | 55 |
49 | 56 |
50 /** | 57 /** |
66 private FLYSConstants messages = GWT.create(FLYSConstants.class); | 73 private FLYSConstants messages = GWT.create(FLYSConstants.class); |
67 | 74 |
68 /** The UserService used to retrieve information about the current user. */ | 75 /** The UserService used to retrieve information about the current user. */ |
69 protected UserCollectionsServiceAsync userCollectionsService = | 76 protected UserCollectionsServiceAsync userCollectionsService = |
70 GWT.create(UserCollectionsService.class); | 77 GWT.create(UserCollectionsService.class); |
78 | |
79 /** The service used to set the name of a project.*/ | |
80 protected SetCollectionNameServiceAsync nameService = | |
81 GWT.create(SetCollectionNameService.class); | |
82 | |
83 /** The service used to set the name of a project.*/ | |
84 protected SetCollectionTTLServiceAsync ttlService = | |
85 GWT.create(SetCollectionTTLService.class); | |
86 | |
87 /** The service used to set the name of a project.*/ | |
88 protected DeleteCollectionServiceAsync deleteService = | |
89 GWT.create(DeleteCollectionService.class); | |
71 | 90 |
72 /** A pointer to the FLYS instance.*/ | 91 /** A pointer to the FLYS instance.*/ |
73 protected FLYS flys; | 92 protected FLYS flys; |
74 | 93 |
75 /** The user whose projects should be displayed.*/ | 94 /** The user whose projects should be displayed.*/ |
208 }); | 227 }); |
209 | 228 |
210 MenuItem del = new MenuItem(messages.delete_project()); | 229 MenuItem del = new MenuItem(messages.delete_project()); |
211 del.addClickHandler(new ClickHandler() { | 230 del.addClickHandler(new ClickHandler() { |
212 public void onClick(MenuItemClickEvent evt) { | 231 public void onClick(MenuItemClickEvent evt) { |
213 SC.warn("Removing projects is not implemented."); | 232 deleteCollection(record.getCollection()); |
214 } | 233 } |
215 }); | 234 }); |
216 | 235 |
217 MenuItem rename = new MenuItem(messages.rename_project()); | 236 MenuItem rename = new MenuItem(messages.rename_project()); |
218 rename.addClickHandler(new ClickHandler() { | 237 rename.addClickHandler(new ClickHandler() { |
301 } | 320 } |
302 | 321 |
303 GWT.log("Update Collection name: " + c.identifier()); | 322 GWT.log("Update Collection name: " + c.identifier()); |
304 GWT.log("=> New name = " + c.getName()); | 323 GWT.log("=> New name = " + c.getName()); |
305 | 324 |
306 // TODO IMPLEMENT ME | 325 Config config = Config.getInstance(); |
326 nameService.setName(c, config.getServerUrl(), new AsyncCallback<Void>(){ | |
327 public void onFailure(Throwable caught) { | |
328 String msg = caught.getMessage(); | |
329 | |
330 try { | |
331 SC.warn(messages.getString(msg)); | |
332 } | |
333 catch (MissingResourceException mre) { | |
334 SC.warn(msg); | |
335 } | |
336 } | |
337 | |
338 public void onSuccess(Void v) { | |
339 updateUserCollections(); | |
340 } | |
341 }); | |
307 } | 342 } |
308 | 343 |
309 | 344 |
310 /** | 345 /** |
311 * Set the ttl of the collection <i>c</i> to a new value. If the update | 346 * Set the ttl of the collection <i>c</i> to a new value. If the update |
319 } | 354 } |
320 | 355 |
321 GWT.log("Update Collection TTL: " + c.identifier()); | 356 GWT.log("Update Collection TTL: " + c.identifier()); |
322 GWT.log("=> New ttl = " + c.getTTL()); | 357 GWT.log("=> New ttl = " + c.getTTL()); |
323 | 358 |
324 // TODO IMPLEMENT ME | 359 Config config = Config.getInstance(); |
360 ttlService.setTTL(c, config.getServerUrl(), new AsyncCallback<Void>() { | |
361 public void onFailure(Throwable caught) { | |
362 String msg = caught.getMessage(); | |
363 | |
364 try { | |
365 SC.warn(messages.getString(msg)); | |
366 } | |
367 catch (MissingResourceException mre) { | |
368 SC.warn(msg); | |
369 } | |
370 } | |
371 | |
372 public void onSuccess(Void v) { | |
373 updateUserCollections(); | |
374 } | |
375 }); | |
376 } | |
377 | |
378 | |
379 /** | |
380 * Delete the collection <i>c</i>. | |
381 * | |
382 * @param c The Collection that should be deleted. | |
383 */ | |
384 protected void deleteCollection(Collection c) { | |
385 if (c == null) { | |
386 return; | |
387 } | |
388 | |
389 GWT.log("Delete Collection: " + c.identifier()); | |
390 | |
391 Config config = Config.getInstance(); | |
392 deleteService.delete(c, config.getServerUrl(), new AsyncCallback<Void>(){ | |
393 public void onFailure(Throwable caught) { | |
394 String msg = caught.getMessage(); | |
395 | |
396 try { | |
397 SC.warn(messages.getString(msg)); | |
398 } | |
399 catch (MissingResourceException mre) { | |
400 SC.warn(msg); | |
401 } | |
402 } | |
403 | |
404 public void onSuccess(Void v) { | |
405 updateUserCollections(); | |
406 } | |
407 }); | |
325 } | 408 } |
326 | 409 |
327 | 410 |
328 protected void updateUserCollections() { | 411 protected void updateUserCollections() { |
329 GWT.log("==> ProjectList updates user collections!"); | 412 GWT.log("==> ProjectList updates user collections!"); |
333 String locale = config.getLocale(); | 416 String locale = config.getLocale(); |
334 | 417 |
335 userCollectionsService.getUserCollections(url, locale, user.identifier(), | 418 userCollectionsService.getUserCollections(url, locale, user.identifier(), |
336 new AsyncCallback<Collection[]>() { | 419 new AsyncCallback<Collection[]>() { |
337 public void onFailure(Throwable caught) { | 420 public void onFailure(Throwable caught) { |
338 GWT.log("Could not recieve a list of user collections."); | 421 String msg = caught.getMessage(); |
339 GWT.log(caught.getMessage()); | 422 |
423 try { | |
424 SC.warn(messages.getString(msg)); | |
425 } | |
426 catch (MissingResourceException mre) { | |
427 SC.warn(msg); | |
428 } | |
340 } | 429 } |
341 | 430 |
342 public void onSuccess(Collection[] collections) { | 431 public void onSuccess(Collection[] collections) { |
343 int num = collections != null ? collections.length : 0; | 432 int num = collections != null ? collections.length : 0; |
344 | 433 |