[jbpm-commits] JBoss JBPM SVN: r4584 - projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Apr 20 10:23:39 EDT 2009


Author: heiko.braun at jboss.com
Date: 2009-04-20 10:23:39 -0400 (Mon, 20 Apr 2009)
New Revision: 4584

Added:
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/AbstractContextAwareAction.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/StartNewInstanceAction.java
Modified:
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/InstanceListView.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadDefinitionsAction.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadInstancesAction.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java
   projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditorNavigation.java
Log:
Re-implement start new instance

Added: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/AbstractContextAwareAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/AbstractContextAwareAction.java	                        (rev 0)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/AbstractContextAwareAction.java	2009-04-20 14:23:39 UTC (rev 4584)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.v2.process;
+
+import com.mvc4g.client.ActionInterface;
+import org.jboss.bpm.console.client.ApplicationContext;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+abstract class AbstractContextAwareAction implements ActionInterface
+{
+  ApplicationContext appContext;
+
+  public AbstractContextAwareAction(ApplicationContext appContext)
+  {
+    this.appContext = appContext;
+  }
+}

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java	2009-04-20 13:11:35 UTC (rev 4583)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/DefinitionListView.java	2009-04-20 14:23:39 UTC (rev 4584)
@@ -21,14 +21,13 @@
  */
 package org.jboss.bpm.console.client.v2.process;
 
+import com.google.gwt.user.client.ui.ChangeListener;
 import com.google.gwt.user.client.ui.ClickListener;
 import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.user.client.ui.ChangeListener;
 import com.mvc4g.client.Controller;
 import com.mvc4g.client.Event;
 import com.mvc4g.client.ViewInterface;
 import org.gwt.mosaic.ui.client.ListBox;
-import org.gwt.mosaic.ui.client.MessageBox;
 import org.gwt.mosaic.ui.client.ToolBar;
 import org.gwt.mosaic.ui.client.ToolButton;
 import org.gwt.mosaic.ui.client.layout.BoxLayout;
@@ -43,7 +42,7 @@
 /**
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
-public class DefinitionListView extends LayoutPanel
+class DefinitionListView extends LayoutPanel
     implements ViewInterface, LazyPanel
 {
   public final static String ID = DefinitionListView.class.getName();

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/InstanceListView.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/InstanceListView.java	2009-04-20 13:11:35 UTC (rev 4583)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/InstanceListView.java	2009-04-20 14:23:39 UTC (rev 4584)
@@ -41,7 +41,7 @@
 /**
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
-public class InstanceListView extends LayoutPanel implements ViewInterface
+class InstanceListView extends LayoutPanel implements ViewInterface
 {
   public final static String ID = InstanceListView.class.getName();
 
@@ -110,12 +110,30 @@
         )
     );
 
+    toolBar.addSeparator();
+
+    toolBar.add(
+        new ToolButton("Start new instance", new ClickListener() {
+          public void onClick(Widget sender) {
+            controller.handleEvent(
+                new Event(
+                    StartNewInstanceAction.ID,
+                    getCurrentDefinition()
+                )
+            );
+          }
+        }
+        )
+    );
+
+
     toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
 
     instanceList.add(toolBox, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
     instanceList.add(listBox, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
 
     this.add(instanceList);
+    
   }
 
   private ProcessDefinitionRef getCurrentDefinition()
@@ -130,18 +148,18 @@
 
 
   public void update(final ProcessDefinitionRef def, List<ProcessInstanceRef> instances)
-  {    
+  {
     this.currentDefinition = def;
 
     final DefaultListModel<ProcessInstanceRef> model =
         (DefaultListModel<ProcessInstanceRef>) listBox.getModel();
     model.clear();
-    
+
     for(ProcessInstanceRef inst : instances)
     {
       model.add(inst);
     }
-    
+
     // layout again
     this.invalidate();
   }

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadDefinitionsAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadDefinitionsAction.java	2009-04-20 13:11:35 UTC (rev 4583)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadDefinitionsAction.java	2009-04-20 14:23:39 UTC (rev 4584)
@@ -37,15 +37,13 @@
  *
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
-public class LoadDefinitionsAction implements ActionInterface
+class LoadDefinitionsAction extends AbstractContextAwareAction
 {
   public final static String ID = LoadDefinitionsAction.class.getName();
 
-  ApplicationContext appContext;
-
   public LoadDefinitionsAction(ApplicationContext appContext)
   {
-    this.appContext = appContext;
+    super(appContext);
   }
 
   public void execute(final Controller controller, Object object)

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadInstancesAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadInstancesAction.java	2009-04-20 13:11:35 UTC (rev 4583)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/LoadInstancesAction.java	2009-04-20 14:23:39 UTC (rev 4584)
@@ -21,13 +21,12 @@
  */
 package org.jboss.bpm.console.client.v2.process;
 
-import com.mvc4g.client.ActionInterface;
-import com.mvc4g.client.Controller;
 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.model.ProcessInstanceRef;
-import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
 import org.jboss.bpm.console.client.model.DTOParser;
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
 import org.jboss.bpm.console.client.util.JSONRequest;
 import org.jboss.bpm.console.client.util.JSONRequestHandler;
 
@@ -36,16 +35,13 @@
 /**
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
-public class LoadInstancesAction implements ActionInterface
+class LoadInstancesAction extends AbstractContextAwareAction
 {
-
   public final static String ID = LoadInstancesAction.class.getName();
 
-  private ApplicationContext appContext;
-
   public LoadInstancesAction(ApplicationContext appContext)
   {
-    this.appContext = appContext;
+    super(appContext);    
   }
 
   public void execute(final Controller controller, Object object)

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java	2009-04-20 13:11:35 UTC (rev 4583)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditor.java	2009-04-20 14:23:39 UTC (rev 4584)
@@ -66,7 +66,8 @@
       // create and register actions
       addAction(LoadDefinitionsAction.ID, new LoadDefinitionsAction(appContext));
       addAction(LoadInstancesAction.ID, new LoadInstancesAction(appContext));
-
+      addAction(StartNewInstanceAction.ID, new StartNewInstanceAction(appContext));
+      
       // tab Listener
       tabPanel.addTabListener(
           new TabListener()

Modified: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditorNavigation.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditorNavigation.java	2009-04-20 13:11:35 UTC (rev 4583)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/ProcessEditorNavigation.java	2009-04-20 14:23:39 UTC (rev 4584)
@@ -30,7 +30,7 @@
 /**
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
-public class ProcessEditorNavigation extends Tree
+class ProcessEditorNavigation extends Tree
 {
 
   public ProcessEditorNavigation(final ApplicationContext appContext)

Added: projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/StartNewInstanceAction.java
===================================================================
--- projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/StartNewInstanceAction.java	                        (rev 0)
+++ projects/gwt-console/branches/hbraun/war/src/main/java/org/jboss/bpm/console/client/v2/process/StartNewInstanceAction.java	2009-04-20 14:23:39 UTC (rev 4584)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.v2.process;
+
+import com.mvc4g.client.Controller;
+import com.mvc4g.client.Event;
+import com.google.gwt.http.client.*;
+import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+class StartNewInstanceAction extends AbstractContextAwareAction
+{
+  public final static String ID = StartNewInstanceAction.class.getName();
+
+  public StartNewInstanceAction(ApplicationContext appContext)
+  {
+    super(appContext);
+  }
+
+  public void execute(final Controller controller, Object object)
+  {
+    final ProcessDefinitionRef def = (ProcessDefinitionRef)object;
+
+    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);
+        }
+
+        public void onResponseReceived(Request request, Response response) {
+          if (200 == response.getStatusCode()) {
+
+            // 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
+            );
+          }
+        }
+      });
+    }
+    catch (RequestException e)
+    {
+      // Couldn't connect to server
+      handleError(e);
+    }
+  }
+
+  private void handleError(Throwable t)
+  {
+    // Couldn't connect to server
+      appContext.displayMessage("Failed to start new instance. " +
+          "RequestException( "+t.getClass() +"): "+
+          t.getMessage(),
+          true
+      );
+  }
+}




More information about the jbpm-commits mailing list