changeset 3353:08f8524a81ad

Lock the screen when the parameterization of a Collection's master Artifact changes. flys-client/trunk@5036 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 18 Jul 2012 12:12:46 +0000
parents 2f533220af1c
children 22f39c2d7a72
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java
diffstat 3 files changed, 72 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Jul 18 09:57:21 2012 +0000
+++ b/flys-client/ChangeLog	Wed Jul 18 12:12:46 2012 +0000
@@ -1,3 +1,15 @@
+2012-07-18  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  Added public methods to lock and unlock the CollectionView. Locking the
+	  view means, a semi transparent layer prevents the user to use the
+	  control elements in the CollectionView. In addition to the semi
+	  transparent layer, a progress image is displayed.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ParameterList.java:
+	  Lock the CollectionView when StepBack and StepForward events are fired.
+	  Unlock the screen on success or failure.
+
 2012-07-18	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed Jul 18 09:57:21 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed Jul 18 12:12:46 2012 +0000
@@ -2,10 +2,14 @@
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Img;
 import com.smartgwt.client.widgets.Window;
 import com.smartgwt.client.widgets.events.CloseClickEvent;
 import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.Layout;
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.tab.TabSet;
@@ -111,6 +115,8 @@
 
     /** The layout. */
     protected Layout layout;
+    
+    protected VLayout lockScreen;
 
     protected int artifactsQueue;
     protected int recommendationQueue;
@@ -319,6 +325,39 @@
             handler.onOutputModesChange(new OutputModesChangeEvent(outputs));
         }
     }
+    
+    
+    public void lockUI() {
+        if (lockScreen == null) {
+            lockScreen = new VLayout();
+            lockScreen.setWidth100();
+            lockScreen.setHeight100();
+            lockScreen.setBackgroundColor("#7f7f7f");
+            lockScreen.setOpacity(50);
+            lockScreen.setAlign(VerticalAlignment.CENTER);
+            lockScreen.setDefaultLayoutAlign(VerticalAlignment.CENTER);
+        
+            HLayout inner = new HLayout();
+            inner.setAlign(Alignment.CENTER);
+            inner.setDefaultLayoutAlign(Alignment.CENTER);
+            inner.setOpacity(100);
+            
+            Img img = new Img(
+                GWT.getHostPageBaseURL() + messages.loadingImg(),
+                25, 25);
+            
+            inner.addMember(img);
+            
+            lockScreen.addMember(inner);
+        }
+        
+        layout.addChild(lockScreen);
+    }
+    
+    
+    public void unlockUI() {
+        layout.removeChild(lockScreen);
+    }
 
 
     /**
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Wed Jul 18 09:57:21 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Wed Jul 18 12:12:46 2012 +0000
@@ -330,6 +330,7 @@
 
         handler.addStepForwardHandler(new StepForwardHandler() {
             public void onStepForward(StepForwardEvent event) {
+                lockUI();
                 Data[] data = event.getData();
 
                 DataItem[] moduleItems = data[0].getItems();
@@ -340,6 +341,7 @@
 
                 if (module == null) {
                     // TODO throw / show error!
+                    unlockUI();
                     return;
                 }
 
@@ -355,6 +357,7 @@
                     locale, module.toLowerCase(), null,
                     new AsyncCallback<Artifact>() {
                         public void onFailure(Throwable caught) {
+                            unlockUI();
                             GWT.log("Could not create the new artifact.");
                             SC.warn(MSG.getString(caught.getMessage()));
                         }
@@ -365,6 +368,7 @@
                             forwardService.go(locale, artifact, feedData,
                             new AsyncCallback<Artifact>() {
                                 public void onFailure(Throwable caught) {
+                                    unlockUI();
                                     GWT.log("Could not feed the artifact.");
                                     SC.warn(caught.getMessage());
                                 }
@@ -374,6 +378,7 @@
                                     old.clear();
                                     cView.addArtifactToCollection(artifact);
                                     setArtifact(artifact);
+                                    unlockUI();
                                 }
                             });
                         }
@@ -582,6 +587,7 @@
      */
     public void onStepForward(StepForwardEvent event) {
         GWT.log("CollectionView - onStepForward()");
+        lockUI();
 
         Config config = Config.getInstance();
         String locale = config.getLocale();
@@ -589,6 +595,7 @@
         forwardService.go(locale, artifact, event.getData(),
             new AsyncCallback<Artifact>() {
                 public void onFailure(Throwable caught) {
+                    unlockUI();
                     GWT.log("Could not feed the artifact.");
                     SC.warn(MSG.getString(caught.getMessage()));
                 }
@@ -598,6 +605,7 @@
                     old.clear();
 
                     setArtifact(artifact, true);
+                    unlockUI();
                 }
         });
     }
@@ -610,6 +618,7 @@
      * @param e The StepBackEvent that holds the identifier of the target state.
      */
     public void onStepBack(StepBackEvent e) {
+        lockUI();
         final String target    = e.getTarget();
 
         Config config          = Config.getInstance();
@@ -618,6 +627,7 @@
         advanceService.advance(locale, artifact, target,
             new AsyncCallback<Artifact>() {
                 public void onFailure(Throwable caught) {
+                    unlockUI();
                     GWT.log("Could not go back to '" + target + "'");
                     SC.warn(MSG.getString(caught.getMessage()));
                 }
@@ -628,6 +638,7 @@
                     old.clear();
 
                     setArtifact(artifact, false);
+                    unlockUI();
                 }
             }
         );
@@ -874,5 +885,15 @@
     public void registerCollectionViewTabHandler (TabSelectedHandler tsh) {
         this.cView.registerTabHandler (tsh);
     }
+
+
+    protected void lockUI() {
+        cView.lockUI();
+    }
+
+
+    protected void unlockUI() {
+        cView.unlockUI();
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org