Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Wed Jun 22 10:14:57 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Wed Jun 22 11:47:07 2011 +0000 @@ -2,6 +2,7 @@ import java.util.Date; import java.util.Map; +import java.util.MissingResourceException; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.DateTimeFormat; @@ -43,6 +44,12 @@ import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.event.CollectionChangeEvent; import de.intevation.flys.client.client.event.CollectionChangeHandler; +import de.intevation.flys.client.client.services.DeleteCollectionService; +import de.intevation.flys.client.client.services.DeleteCollectionServiceAsync; +import de.intevation.flys.client.client.services.SetCollectionNameService; +import de.intevation.flys.client.client.services.SetCollectionNameServiceAsync; +import de.intevation.flys.client.client.services.SetCollectionTTLService; +import de.intevation.flys.client.client.services.SetCollectionTTLServiceAsync; import de.intevation.flys.client.client.services.UserCollectionsService; import de.intevation.flys.client.client.services.UserCollectionsServiceAsync; @@ -69,6 +76,18 @@ protected UserCollectionsServiceAsync userCollectionsService = GWT.create(UserCollectionsService.class); + /** The service used to set the name of a project.*/ + protected SetCollectionNameServiceAsync nameService = + GWT.create(SetCollectionNameService.class); + + /** The service used to set the name of a project.*/ + protected SetCollectionTTLServiceAsync ttlService = + GWT.create(SetCollectionTTLService.class); + + /** The service used to set the name of a project.*/ + protected DeleteCollectionServiceAsync deleteService = + GWT.create(DeleteCollectionService.class); + /** A pointer to the FLYS instance.*/ protected FLYS flys; @@ -210,7 +229,7 @@ MenuItem del = new MenuItem(messages.delete_project()); del.addClickHandler(new ClickHandler() { public void onClick(MenuItemClickEvent evt) { - SC.warn("Removing projects is not implemented."); + deleteCollection(record.getCollection()); } }); @@ -303,7 +322,23 @@ GWT.log("Update Collection name: " + c.identifier()); GWT.log("=> New name = " + c.getName()); - // TODO IMPLEMENT ME + Config config = Config.getInstance(); + nameService.setName(c, config.getServerUrl(), new AsyncCallback<Void>(){ + public void onFailure(Throwable caught) { + String msg = caught.getMessage(); + + try { + SC.warn(messages.getString(msg)); + } + catch (MissingResourceException mre) { + SC.warn(msg); + } + } + + public void onSuccess(Void v) { + updateUserCollections(); + } + }); } @@ -321,7 +356,55 @@ GWT.log("Update Collection TTL: " + c.identifier()); GWT.log("=> New ttl = " + c.getTTL()); - // TODO IMPLEMENT ME + Config config = Config.getInstance(); + ttlService.setTTL(c, config.getServerUrl(), new AsyncCallback<Void>() { + public void onFailure(Throwable caught) { + String msg = caught.getMessage(); + + try { + SC.warn(messages.getString(msg)); + } + catch (MissingResourceException mre) { + SC.warn(msg); + } + } + + public void onSuccess(Void v) { + updateUserCollections(); + } + }); + } + + + /** + * Delete the collection <i>c</i>. + * + * @param c The Collection that should be deleted. + */ + protected void deleteCollection(Collection c) { + if (c == null) { + return; + } + + GWT.log("Delete Collection: " + c.identifier()); + + Config config = Config.getInstance(); + deleteService.delete(c, config.getServerUrl(), new AsyncCallback<Void>(){ + public void onFailure(Throwable caught) { + String msg = caught.getMessage(); + + try { + SC.warn(messages.getString(msg)); + } + catch (MissingResourceException mre) { + SC.warn(msg); + } + } + + public void onSuccess(Void v) { + updateUserCollections(); + } + }); } @@ -335,8 +418,14 @@ userCollectionsService.getUserCollections(url, locale, user.identifier(), new AsyncCallback<Collection[]>() { public void onFailure(Throwable caught) { - GWT.log("Could not recieve a list of user collections."); - GWT.log(caught.getMessage()); + String msg = caught.getMessage(); + + try { + SC.warn(messages.getString(msg)); + } + catch (MissingResourceException mre) { + SC.warn(msg); + } } public void onSuccess(Collection[] collections) {