changeset 611:854312c0528c

#21 Newly created projects cannot be opened twice. flys-client/trunk@2225 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 24 Jun 2011 09:20:22 +0000
parents ea2191b1299d
children e59f2569558e
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/chart/ChartOutputTab.java
diffstat 4 files changed, 51 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Jun 23 17:46:08 2011 +0000
+++ b/flys-client/ChangeLog	Fri Jun 24 09:20:22 2011 +0000
@@ -1,3 +1,17 @@
+2011-06-24  Ingo Weinzierl <ingo@intevation.de>
+
+	  flys/issue21 (Gleiches Projekt kann mehr als einmal gleichzeitig geƶffnet werden)
+
+	* src/main/java/de/intevation/flys/client/client/FLYS.java: Implements
+	  CollectionChangeHandler to lock new projects. In addition, there is a
+	  new method to close projects.
+
+	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  If this view contains a Collection, FLYS is used to close this window.
+	  FLYS needs to unlock the project before the view is destroyed.
+	  Otherwise - if no Collection has been created yet - this view destroys
+	  itself.
+
 2011-06-23  Ingo Weinzierl <ingo@intevation.de>
 
 	  flys/issue170 (Diagramm: Initiales Zoomen zeigt verschobenen Bereich)
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Thu Jun 23 17:46:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Fri Jun 24 09:20:22 2011 +0000
@@ -25,6 +25,8 @@
 import de.intevation.flys.client.shared.model.River;
 import de.intevation.flys.client.shared.model.User;
 
+import de.intevation.flys.client.client.event.CollectionChangeEvent;
+import de.intevation.flys.client.client.event.CollectionChangeHandler;
 import de.intevation.flys.client.client.services.ArtifactService;
 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
 import de.intevation.flys.client.client.services.DescribeCollectionService;
@@ -49,7 +51,7 @@
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class FLYS implements EntryPoint {
+public class FLYS implements EntryPoint, CollectionChangeHandler {
 
     /** The message class that provides i18n strings.*/
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
@@ -382,6 +384,12 @@
     }
 
 
+    public void closeProject(String uuid) {
+        unlockProject(uuid);
+        workspace.destroyProject(uuid);
+    }
+
+
     /**
      * Create a new Artifact.
      */
@@ -404,12 +412,22 @@
     }
 
 
+    public void onCollectionChange(CollectionChangeEvent event) {
+        Collection oldC = event.getOldValue();
+
+        if (oldC == null) {
+            Collection newC = event.getNewValue();
+            lockProject(newC.identifier());
+        }
+    }
+
+
 
     /**
      * This CloseClickHandler is used to remove lock on a specific Collection so
      * that is might be opened again.
      */
-    private class CloseCollectionViewHandler implements CloseClickHandler {
+    public class CloseCollectionViewHandler implements CloseClickHandler {
         protected FLYS   flys;
         protected String uuid;
 
@@ -419,8 +437,7 @@
         }
 
         public void onCloseClick(CloseClientEvent event) {
-            flys.unlockProject(uuid);
-            workspace.removeProject(uuid);
+            flys.closeProject(uuid);
         }
     }
 }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Thu Jun 23 17:46:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Fri Jun 24 09:20:22 2011 +0000
@@ -114,6 +114,7 @@
 
         addCollectionChangeHandler(this);
         addCollectionChangeHandler(parameterList);
+        addCollectionChangeHandler(flys);
         addOutputModesChangeHandler(this);
         addOutputModesChangeHandler(parameterList);
         addCloseClickHandler(this);
@@ -139,6 +140,7 @@
 
         addCollectionChangeHandler(this);
         addCollectionChangeHandler(parameterList);
+        addCollectionChangeHandler(flys);
         addOutputModesChangeHandler(this);
         addOutputModesChangeHandler(parameterList);
         addCloseClickHandler(this);
@@ -493,8 +495,13 @@
 
 
     public void onCloseClick(CloseClientEvent event) {
-        hide();
-        destroy();
+        if (collection != null) {
+            flys.closeProject(collection.identifier());
+        }
+        else {
+            hide();
+            destroy();
+        }
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Thu Jun 23 17:46:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Fri Jun 24 09:20:22 2011 +0000
@@ -307,7 +307,10 @@
         Axis xAxis = chartInfo.getXAxis(0);
         Axis yAxis = chartInfo.getYAxis(0);
 
+        GWT.log("ZOOM X");
         double[] x = zoomAxis(xAxis, factor);
+
+        GWT.log("ZOOM Y");
         double[] y = zoomAxis(yAxis, factor);
 
         zoom[0] = x[0];
@@ -324,12 +327,16 @@
         double min  = axis.getFrom();
         double max  = axis.getTo();
 
+        GWT.log("ZOOM CURRENT: " + min + " - " + max);
+
         double add = (max - min) / 100 * factor;
         add = add < 0 ? (-1) * add : add;
 
         min -= add;
         max += add;
 
+        GWT.log("ZOOM TO: " + min + " - " + max);
+
         return computeZoom(axis, min, max);
     }
 

http://dive4elements.wald.intevation.org