changeset 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 def13f23bb27
children 3a8884e06aaa
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java
diffstat 4 files changed, 78 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Aug 20 08:25:58 2012 +0000
+++ b/flys-client/ChangeLog	Wed Aug 22 12:29:33 2012 +0000
@@ -1,3 +1,10 @@
+2012-08-22	Christian Lins	<christian.lins@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/FLYS.java,
+	  src/main/java/de/intevation/flys/client/client/ui/ProjectList.java,
+	  src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  Delete empty project after closing the CollectionView (#785).
+
 2012-08-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Mon Aug 20 08:25:58 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Wed Aug 22 12:29:33 2012 +0000
@@ -1,28 +1,17 @@
 package de.intevation.flys.client.client;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
 import com.google.gwt.core.client.EntryPoint;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.shared.UmbrellaException;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.xml.client.XMLParser;
-
 import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.HTMLPane;
 import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.HTMLPane;
-import com.smartgwt.client.widgets.layout.VLayout;
-import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.events.CloseClickEvent;
 import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.events.CloseClickEvent;
-
-import de.intevation.flys.client.shared.model.Artifact;
-import de.intevation.flys.client.shared.model.Collection;
-import de.intevation.flys.client.shared.model.CollectionItem;
-import de.intevation.flys.client.shared.model.River;
-import de.intevation.flys.client.shared.model.User;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.client.event.CollectionChangeEvent;
 import de.intevation.flys.client.client.event.CollectionChangeHandler;
@@ -37,12 +26,21 @@
 import de.intevation.flys.client.client.services.UserService;
 import de.intevation.flys.client.client.services.UserServiceAsync;
 import de.intevation.flys.client.client.ui.CollectionView;
+import de.intevation.flys.client.client.ui.FLYSFooter;
 import de.intevation.flys.client.client.ui.FLYSHeader;
 import de.intevation.flys.client.client.ui.FLYSView;
 import de.intevation.flys.client.client.ui.FLYSWorkspace;
 import de.intevation.flys.client.client.ui.MainMenu;
 import de.intevation.flys.client.client.ui.ProjectList;
-import de.intevation.flys.client.client.ui.FLYSFooter;
+import de.intevation.flys.client.shared.model.Artifact;
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.shared.model.CollectionItem;
+import de.intevation.flys.client.shared.model.River;
+import de.intevation.flys.client.shared.model.User;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
 
 
 /**
@@ -102,6 +100,7 @@
     /**
      * This is the entry point method.
      */
+    @Override
     public void onModuleLoad() {
         openProjects = new ArrayList<String>();
 
@@ -141,11 +140,13 @@
         getRivers();
 
         userService.getCurrentUser(locale, new AsyncCallback<User>() {
+            @Override
             public void onFailure(Throwable caught) {
                 GWT.log("Could not find a logged in user.");
                 SC.warn(MSG.getString(caught.getMessage()));
             }
 
+            @Override
             public void onSuccess(User user) {
                 GWT.log("Found a user. Set '"+ user.getName() + "'");
                 setCurrentUser(user);
@@ -258,11 +259,13 @@
         String locale = config.getLocale();
 
         riverService.list(locale, new AsyncCallback<River[]>() {
+            @Override
             public void onFailure(Throwable caught) {
                 GWT.log("Could not recieve a list of rivers.");
                 SC.warn(MSG.getString(caught.getMessage()));
             }
 
+            @Override
             public void onSuccess(River[] newRivers) {
                 GWT.log("Retrieved " + newRivers.length + " new rivers.");
                 rivers = newRivers;
@@ -335,10 +338,12 @@
 
         describeCollectionService.describe(collectionID, locale,
             new AsyncCallback<Collection>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     SC.warn(MSG.getString(caught.getMessage()));
                 }
 
+                @Override
                 public void onSuccess(Collection c) {
                     final Collection collection = c;
 
@@ -369,11 +374,13 @@
                         item.identifier(),
                         item.hash(),
                         new AsyncCallback<Artifact>() {
+                            @Override
                             public void onFailure(Throwable caught) {
                                 unlockProject(collectionID);
                                 SC.warn(MSG.getString(caught.getMessage()));
                             }
 
+                            @Override
                             public void onSuccess(Artifact artifact) {
                                 CollectionView view = new CollectionView(
                                     FLYS.this, collection, artifact);
@@ -408,11 +415,13 @@
 
         artifactService.create(locale, factory, null,
             new AsyncCallback<Artifact>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not create the new artifact.");
                     SC.warn(MSG.getString(caught.getMessage()));
                 }
 
+                @Override
                 public void onSuccess(Artifact artifact) {
                     GWT.log("Successfully created a new artifact.");
                 }
@@ -420,6 +429,7 @@
     }
 
 
+    @Override
     public void onCollectionChange(CollectionChangeEvent event) {
         Collection oldC = event.getOldValue();
 
@@ -444,6 +454,7 @@
             this.uuid = uuid;
         }
 
+        @Override
         public void onCloseClick(CloseClickEvent event) {
             flys.closeProject(uuid);
         }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Mon Aug 20 08:25:58 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed Aug 22 12:29:33 2012 +0000
@@ -635,7 +635,12 @@
     @Override
     public void onCloseClick(CloseClickEvent event) {
         if (collection != null) {
-            flys.closeProject(collection.identifier());
+            if(artifact != null) {
+                flys.closeProject(collection.identifier());
+            }
+            else {
+                flys.getProjectList().deleteCollection(collection);
+            }
         }
         else {
             hide();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java	Mon Aug 20 08:25:58 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java	Wed Aug 22 12:29:33 2012 +0000
@@ -1,13 +1,9 @@
 package de.intevation.flys.client.client.ui;
 
 import com.google.gwt.core.client.GWT;
-
 import com.google.gwt.i18n.client.DateTimeFormat;
-
 import com.google.gwt.user.client.Timer;
-
 import com.google.gwt.user.client.rpc.AsyncCallback;
-
 import com.smartgwt.client.types.Alignment;
 import com.smartgwt.client.types.ListGridEditEvent;
 import com.smartgwt.client.types.ListGridFieldType;
@@ -15,19 +11,15 @@
 import com.smartgwt.client.types.SortArrow;
 import com.smartgwt.client.types.SortDirection;
 import com.smartgwt.client.types.VerticalAlignment;
-
 import com.smartgwt.client.util.BooleanCallback;
 import com.smartgwt.client.util.SC;
-
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
-
 import com.smartgwt.client.widgets.grid.CellFormatter;
 import com.smartgwt.client.widgets.grid.HoverCustomizer;
 import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
-
 import com.smartgwt.client.widgets.grid.events.CellClickEvent;
 import com.smartgwt.client.widgets.grid.events.CellClickHandler;
 import com.smartgwt.client.widgets.grid.events.CellDoubleClickEvent;
@@ -38,26 +30,21 @@
 import com.smartgwt.client.widgets.grid.events.HeaderDoubleClickHandler;
 import com.smartgwt.client.widgets.grid.events.RowContextClickEvent;
 import com.smartgwt.client.widgets.grid.events.RowContextClickHandler;
-
 import com.smartgwt.client.widgets.layout.VLayout;
-
 import com.smartgwt.client.widgets.menu.Menu;
 import com.smartgwt.client.widgets.menu.MenuItem;
 import com.smartgwt.client.widgets.menu.MenuItemSeparator;
-
 import com.smartgwt.client.widgets.menu.events.ClickHandler;
 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
 
 import de.intevation.flys.client.client.Config;
 import de.intevation.flys.client.client.FLYS;
 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.event.FilterHandler;
 import de.intevation.flys.client.client.event.RangeFilterEvent;
 import de.intevation.flys.client.client.event.StringFilterEvent;
-
 import de.intevation.flys.client.client.services.AddArtifactService;
 import de.intevation.flys.client.client.services.AddArtifactServiceAsync;
 import de.intevation.flys.client.client.services.ArtifactService;
@@ -76,7 +63,6 @@
 import de.intevation.flys.client.client.services.SetCollectionTTLServiceAsync;
 import de.intevation.flys.client.client.services.UserCollectionsService;
 import de.intevation.flys.client.client.services.UserCollectionsServiceAsync;
-
 import de.intevation.flys.client.shared.model.Artifact;
 import de.intevation.flys.client.shared.model.Collection;
 import de.intevation.flys.client.shared.model.CollectionItem;
@@ -119,7 +105,7 @@
     public static final String COLUMN_FAVORITE_WIDTH = "75px";
 
     /** The interface that provides i18n messages. */
-    private FLYSConstants messages = GWT.create(FLYSConstants.class);
+    private final FLYSConstants messages = GWT.create(FLYSConstants.class);
 
     /** The UserService used to retrieve information about the current user. */
     protected UserCollectionsServiceAsync userCollectionsService =
@@ -189,8 +175,8 @@
         this.flys = flys;
         this.user = user;
 
-        filteredCollections = new ArrayList();
-        collections = new ArrayList();
+        filteredCollections = new ArrayList<Collection>();
+        collections = new ArrayList<Collection>();
         grid = new ListGrid();
         initGrid();
         init();
@@ -225,6 +211,7 @@
         grid.setFields(date, name, fav);
 
         grid.addHeaderDoubleClickHandler(new HeaderDoubleClickHandler() {
+            @Override
             public void onHeaderDoubleClick(HeaderDoubleClickEvent event) {
                 // Cancel the event.
                 return;
@@ -233,6 +220,7 @@
 
         // Add a handler to set / unset the favorite state of a project.
         grid.addCellClickHandler(new CellClickHandler() {
+            @Override
             public void onCellClick(CellClickEvent event) {
                 if (event.getColNum() != 2) {
                     return;
@@ -248,6 +236,7 @@
 
         // Add a handler to open a project.
         grid.addCellDoubleClickHandler(new CellDoubleClickHandler() {
+            @Override
             public void onCellDoubleClick(CellDoubleClickEvent e) {
                 CollectionRecord record = (CollectionRecord) e.getRecord();
                 String uuid = record != null
@@ -259,6 +248,7 @@
 
         // Add a handler to open a context menu.
         grid.addRowContextClickHandler(new RowContextClickHandler() {
+            @Override
             public void onRowContextClick(RowContextClickEvent event) {
                 CollectionRecord record = (CollectionRecord) event.getRecord();
 
@@ -313,6 +303,7 @@
 
         MenuItem open = new MenuItem(messages.open_project());
         open.addClickHandler(new ClickHandler() {
+            @Override
             public void onClick(MenuItemClickEvent evt) {
                 getFlys().openProject(record.getCollection().identifier());
             }
@@ -320,8 +311,10 @@
 
         MenuItem del = new MenuItem(messages.delete_project());
         del.addClickHandler(new ClickHandler() {
+            @Override
             public void onClick(MenuItemClickEvent evt) {
                 SC.ask(messages.really_delete(), new BooleanCallback() {
+                    @Override
                     public void execute(Boolean value) {
                         if (value) {
                             deleteCollection(record.getCollection());
@@ -333,6 +326,7 @@
 
         MenuItem rename = new MenuItem(messages.rename_project());
         rename.addClickHandler(new ClickHandler() {
+            @Override
             public void onClick(MenuItemClickEvent evt) {
                 int row = grid.getRecordIndex(record);
                 grid.startEditing(row, 1, false);
@@ -341,6 +335,7 @@
 
         MenuItem clone = new MenuItem(messages.clone_project());
         clone.addClickHandler(new ClickHandler() {
+            @Override
             public void onClick(MenuItemClickEvent evt) {
                 cloneProject(record.getCollection());
             }
@@ -395,6 +390,7 @@
     }
 
 
+    @Override
     public void onFilterCriteriaChanged(StringFilterEvent event) {
         String search = event.getFilter();
         if (search != null && search.length() > 0) {
@@ -411,11 +407,13 @@
     }
 
 
+    @Override
     public void onFilterCriteriaChanged(RangeFilterEvent event) {
         //Empty. No Ranges to filter.
     }
 
 
+    @Override
     public void onCollectionChange(CollectionChangeEvent event) {
         if (event.getOldValue() == null) {
             updateUserCollections();
@@ -423,6 +421,7 @@
     }
 
 
+    @Override
     public void onEditComplete(EditCompleteEvent event) {
         if (event.getColNum() != 1) {
             return;
@@ -433,7 +432,7 @@
         CollectionRecord r = (CollectionRecord) grid.getRecord(row);
         Collection       c = r.getCollection();
 
-        Map newValues = event.getNewValues();
+        Map<?, ?> newValues = event.getNewValues();
         String name   = (String) newValues.get("name");
 
         int maxLength = getMaxNameLength();
@@ -471,6 +470,7 @@
         GWT.log("=> New name = " + c.getName());
 
         nameService.setName(c, new AsyncCallback<Void>(){
+            @Override
             public void onFailure(Throwable caught) {
                 String msg = caught.getMessage();
 
@@ -482,6 +482,7 @@
                 }
             }
 
+            @Override
             public void onSuccess(Void v) {
                 updateUserCollections();
                 if(flys.getWorkspace().hasView(c.identifier())) {
@@ -507,6 +508,7 @@
         GWT.log("=> New ttl = " + c.getTTL());
 
         ttlService.setTTL(c, new AsyncCallback<Void>() {
+            @Override
             public void onFailure(Throwable caught) {
                 String msg = caught.getMessage();
 
@@ -518,6 +520,7 @@
                 }
             }
 
+            @Override
             public void onSuccess(Void v) {
                 updateUserCollections();
             }
@@ -530,7 +533,7 @@
      *
      * @param c The Collection that should be deleted.
      */
-    protected void deleteCollection(final Collection c) {
+    public void deleteCollection(final Collection c) {
         if (c == null) {
             return;
         }
@@ -538,6 +541,7 @@
         GWT.log("Delete Collection: " + c.identifier());
 
         deleteService.delete(c, new AsyncCallback<Void>(){
+            @Override
             public void onFailure(Throwable caught) {
                 String msg = caught.getMessage();
 
@@ -549,6 +553,7 @@
                 }
             }
 
+            @Override
             public void onSuccess(Void v) {
                 flys.getWorkspace().destroyProject(c.identifier());
                 updateUserCollections();
@@ -565,6 +570,7 @@
 
         userCollectionsService.getUserCollections(locale, user.identifier(),
             new AsyncCallback<Collection[]>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     String msg = caught.getMessage();
 
@@ -576,6 +582,7 @@
                     }
                 }
 
+                @Override
                 public void onSuccess(Collection[] collections) {
                     int num = collections != null ? collections.length : 0;
 
@@ -692,6 +699,7 @@
         date.setCanEdit(false);
 
         date.setCellFormatter(new CellFormatter() {
+            @Override
             public String format(Object value, ListGridRecord rec, int r, int c) {
                 if (value == null) {
                     return null;
@@ -723,6 +731,7 @@
         name.setType(ListGridFieldType.TEXT);
         name.setShowHover(true);
         name.setHoverCustomizer(new HoverCustomizer() {
+            @Override
             public String hoverHTML(
                 Object         value,
                 ListGridRecord record,
@@ -771,12 +780,14 @@
 
         describeCollectionService.describe(c.identifier(), locale,
             new AsyncCallback<Collection>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not DESCRIBE collection.");
                     SC.warn(messages.getString(caught.getMessage()));
                 }
 
 
+                @Override
                 public void onSuccess(Collection newCollection) {
                     GWT.log("Successfully DESCRIBED collection.");
                     String uuid = getMasterArtifact(newCollection);
@@ -808,11 +819,13 @@
         createArtifactService.create(
             locale, factory, recommendation,
             new AsyncCallback<Artifact>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Error loading recommendations: " +
                         caught.getMessage());
                 }
 
+                @Override
                 public void onSuccess(Artifact artifact) {
                     GWT.log("Created new artifact: " + artifact.getUuid());
                     createCollection(artifact);
@@ -836,10 +849,12 @@
             master.identifier(),
             master.hash(),
             new AsyncCallback<Artifact>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     SC.warn(MSG.getString(caught.getMessage()));
                 }
 
+                @Override
                 public void onSuccess(Artifact artifact) {
                     cloneArtifact(uuid, artifact, locale);
                 }
@@ -856,11 +871,13 @@
             locale,
             ownerid,
             new AsyncCallback<Collection>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not create the new collection.");
                     SC.warn(messages.getString(caught.getMessage()));
                 }
 
+                @Override
                 public void onSuccess(Collection collection) {
                     GWT.log("Successfully created a new collection.");
                     addArtifactToCollection(artifact, collection);
@@ -877,11 +894,13 @@
         addArtifactService.add(
             c, a, locale,
             new AsyncCallback<Collection>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("An error occured while adding artifact.");
                     SC.warn(messages.getString(caught.getMessage()));
                 }
 
+                @Override
                 public void onSuccess(Collection newColl) {
                     String name = cloneCollection.getName();
                     if(name == null || name.equals("")) {

http://dive4elements.wald.intevation.org