[jbpm-commits] JBoss JBPM SVN: r4588 - in projects/gwt-console/branches/hbraun/war/src/main: java/org/jboss/bpm/console/client/process and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Apr 20 13:08:23 EDT 2009


Author: heiko.braun at jboss.com
Date: 2009-04-20 13:08:22 -0400 (Mon, 20 Apr 2009)
New Revision: 4588

Added:
   projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/images/loading-circle.gif
Modified:
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/Header.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/StartNewInstanceAction.java
   projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/console.css
   projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/images/loading.gif
Log:
Implement loading status

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/Header.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/Header.java	2009-04-20 16:11:30 UTC (rev 4587)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/Header.java	2009-04-20 17:08:22 UTC (rev 4588)
@@ -22,23 +22,32 @@
 package org.jboss.bpm.console.client;
 
 import com.google.gwt.user.client.ui.*;
+import com.google.gwt.user.client.Timer;
 import com.mvc4g.client.Controller;
 import com.mvc4g.client.ViewInterface;
 
 import java.util.List;
 
+import org.gwt.mosaic.ui.client.layout.LayoutPanel;
+
 /**
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
 public class Header extends HorizontalPanel implements ViewInterface
 {
+  public final static String ID = Header.class.getName();
+
   private ApplicationContext appContext;
   private Controller controller;
+  private Image loadingImage;
 
-  public final static String ID = Header.class.getName();
+  // avoid flickering image
+  final Timer turnOffLoading = new Timer() {
+    public void run() {
+      loadingImage.setVisible(false);
+    }
+  };
 
-  private Image loading;
-  
   public Header(ApplicationContext appContext, String username, List<String> roles)
   {
     super();
@@ -47,7 +56,7 @@
     this.setStyleName("bpm-header");
 
     this.appContext = appContext;
-    
+
     createInfoPanel();
   }
 
@@ -57,9 +66,15 @@
     p.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
     p.setStyleName("bpm-header-userinfo");
 
-    loading = new Image("images/loading.gif");
+    // load status image
+    LayoutPanel loadingImageContainer = new LayoutPanel();
+    loadingImageContainer.setStyleName("bpm-loading-image");
+    loadingImage = new Image("images/loading.gif");
+    loadingImageContainer.add(loadingImage);
+    
     setLoading(false);
 
+    // account info
     Image img = new Image("images/icons/05.png");
     HTML html = new HTML(appContext.getAuthentication().getUsername());
 
@@ -73,13 +88,13 @@
     }
     );
 
-    p.add(loading);
+    p.add(loadingImageContainer);
     p.add(img);
     p.add(html);
     p.add(btn);
 
     this.add(p);
-        
+
   }
 
 
@@ -88,8 +103,11 @@
     this.controller = controller;
   }
 
-  public void setLoading(boolean b)
+  public void setLoading(boolean doDisplay)
   {
-    loading.setVisible(b);
+    if(doDisplay)
+      loadingImage.setVisible(doDisplay);
+    else
+      turnOffLoading.schedule(1000);
   }
 }

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java	2009-04-20 16:11:30 UTC (rev 4587)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java	2009-04-20 17:08:22 UTC (rev 4588)
@@ -57,40 +57,37 @@
 
     controller.handleEvent( LoadingStatusAction.ON );
 
-    try
+    JSONRequest.get(
+        url, new JSONRequestHandler()
     {
-      JSONRequest.get(
-          url, new JSONRequestHandler()
+      public void onRequestComplete(JavaScriptObject json)
       {
-        public void onRequestComplete(JavaScriptObject json)
+        try
         {
           if (json == null) {
             appContext.displayMessage("Couldn't retrieve process definition data", true);
             return;
           }
 
-          List<ProcessDefinitionRef> definitions = null;
-          try
-          {
-            definitions = DTOParser.parseProcessDefinitions(json);
-          }
-          catch (Throwable e)
-          {
-            e.printStackTrace();
-            appContext.displayMessage(e.getMessage(), true);
-          }
-
-
+          List<ProcessDefinitionRef> definitions = DTOParser.parseProcessDefinitions(json);
           DefinitionListView view = (DefinitionListView) controller.getView(DefinitionListView.ID);
           view.update(definitions);
 
           appContext.displayMessage("Loaded " + definitions.size() + " process definitions", false);
+
         }
+        catch (Throwable e)
+        {
+          e.printStackTrace();
+          appContext.displayMessage(e.getMessage(), true);
+        }
+        finally
+        {
+          controller.handleEvent( LoadingStatusAction.OFF );
+        }
       }
-      );
     }
-    finally{
-      controller.handleEvent( LoadingStatusAction.OFF );
-    }
+    );
+
   }
 }

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java	2009-04-20 16:11:30 UTC (rev 4587)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java	2009-04-20 17:08:22 UTC (rev 4588)
@@ -24,6 +24,7 @@
 import com.google.gwt.core.client.JavaScriptObject;
 import com.mvc4g.client.Controller;
 import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.LoadingStatusAction;
 import org.jboss.bpm.console.client.model.DTOParser;
 import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
 import org.jboss.bpm.console.client.model.ProcessInstanceRef;
@@ -35,7 +36,7 @@
 /**
  * Force loading of a process instance list.
  * Triggered through {@link org.jboss.bpm.console.client.model.ProcessDefinitionRef}.
- * 
+ *
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
 class LoadInstancesAction extends AbstractContextAwareAction
@@ -44,7 +45,7 @@
 
   public LoadInstancesAction(ApplicationContext appContext)
   {
-    super(appContext);    
+    super(appContext);
   }
 
   /**
@@ -58,32 +59,35 @@
 
     String url = appContext.getUrlBuilder().getProcessInstancesURL(def.getId());
 
+    controller.handleEvent( LoadingStatusAction.ON );
+
     JSONRequest.get(
         url, new JSONRequestHandler()
     {
       public void onRequestComplete(JavaScriptObject json)
       {
-        if (json == null) {
-          appContext.displayMessage("Couldn't retrieve process instance data", true);
-          return;
-        }
-
-        List<ProcessInstanceRef> instances = null;
         try
         {
-          instances = DTOParser.parseProcessInstances(json);
+          if (json == null) {
+            appContext.displayMessage("Couldn't retrieve process instance data", true);
+            return;
+          }
+
+          List<ProcessInstanceRef> instances = DTOParser.parseProcessInstances(json);
+          InstanceListView view = (InstanceListView) controller.getView(InstanceListView.ID);
+          view.update(def, instances);
+
+          appContext.displayMessage("Loaded " + instances.size() + " process instances", false);
         }
         catch (Throwable e)
         {
           e.printStackTrace();
           appContext.displayMessage(e.getMessage(), true);
         }
-
-
-        InstanceListView view = (InstanceListView) controller.getView(InstanceListView.ID);
-        view.update(def, instances);
-
-        appContext.displayMessage("Loaded " + instances.size() + " process instances", false);
+        finally
+        {
+          controller.handleEvent( LoadingStatusAction.OFF );
+        }
       }
     }
     );

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/StartNewInstanceAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/StartNewInstanceAction.java	2009-04-20 16:11:30 UTC (rev 4587)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/process/StartNewInstanceAction.java	2009-04-20 17:08:22 UTC (rev 4588)
@@ -25,12 +25,13 @@
 import com.mvc4g.client.Event;
 import com.google.gwt.http.client.*;
 import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.LoadingStatusAction;
 import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
 
 /**
  * Starts a new process instance.
  * Triggered through {@link org.jboss.bpm.console.client.model.ProcessDefinitionRef}
- * 
+ *
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
 class StartNewInstanceAction extends AbstractContextAwareAction
@@ -54,46 +55,61 @@
     String url = appContext.getUrlBuilder().getStartNewInstanceURL(def.getId());
     RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));
 
-    try {
-      Request request = builder.sendRequest(null, new RequestCallback() {
-        public void onError(Request request, Throwable exception) {
-          // Couldn't connect to server (could be timeout, SOP violation, etc.)
-          handleError(exception);
-        }
+    try
+    {
+      controller.handleEvent( LoadingStatusAction.ON );
 
-        public void onResponseReceived(Request request, Response response) {
-          if (200 == response.getStatusCode()) {
+      Request request = builder.sendRequest(null,
+          new RequestCallback()
+          {
+            public void onError(Request request, Throwable exception) {
+              // Couldn't connect to server (could be timeout, SOP violation, etc.)
+              handleError(exception);
+              controller.handleEvent( LoadingStatusAction.OFF );
+            }
 
-            // force reload instance list
-            controller.handleEvent(
-                new Event(LoadInstancesAction.ID, def)
-            );
+            public void onResponseReceived(Request request, Response response) {
+              try
+              {
+                if (200 == response.getStatusCode()) {
 
-          } else {
-            // Handle the error.  Can get the status text from response.getStatusText()
-            appContext.displayMessage("Failed to start new instance. " +
-                "HTTP " + response.getStatusCode()+
-                ": " +response.getText(),
-                true
-            );
-          }
-        }
-      });
+                  // force reload instance list
+                  controller.handleEvent(
+                      new Event(LoadInstancesAction.ID, def)
+                  );
+
+                } else {
+                  // Handle the error.  Can get the status text from response.getStatusText()
+                  appContext.displayMessage("Failed to start new instance. " +
+                      "HTTP " + response.getStatusCode()+
+                      ": " +response.getText(),
+                      true
+                  );
+                }
+              }
+              finally
+              {
+                controller.handleEvent( LoadingStatusAction.OFF );
+              }
+            }
+          });
     }
     catch (RequestException e)
     {
       // Couldn't connect to server
       handleError(e);
+      controller.handleEvent( LoadingStatusAction.OFF );
     }
   }
 
   private void handleError(Throwable t)
   {
     // Couldn't connect to server
-      appContext.displayMessage("Failed to start new instance. " +
-          "RequestException( "+t.getClass() +"): "+
-          t.getMessage(),
-          true
-      );
+    appContext.displayMessage("Failed to start new instance. " +
+        "RequestException( "+t.getClass() +"): "+
+        t.getMessage(),
+        true
+    );
+
   }
 }

Modified: projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/console.css
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/console.css	2009-04-20 16:11:30 UTC (rev 4587)
+++ projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/console.css	2009-04-20 17:08:22 UTC (rev 4588)
@@ -51,6 +51,12 @@
 
 }
 
+.bpm-loading-image {
+  background-color:#ffffff;    
+  width:16px;
+  height:16px;
+}
+
 .bpm-ProcessImage {
   border: 0px;
 }

Added: projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/images/loading-circle.gif
===================================================================
(Binary files differ)


Property changes on: projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/images/loading-circle.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: projects/gwt-console/branches/hbraun/war/src/main/resources/org/jboss/bpm/console/public/images/loading.gif
===================================================================
(Binary files differ)




More information about the jbpm-commits mailing list