Author: heiko.braun(a)jboss.com
Date: 2010-04-21 05:24:39 -0400 (Wed, 21 Apr 2010)
New Revision: 1035
Added:
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/SignalExecutionAction.java
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/events/SignalInstanceEvent.java
Modified:
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java
bpm-console/trunk/server/war/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
bpm-console/trunk/shared/rpc/src/main/java/org/jboss/bpm/console/client/model/TokenReference.java
Log:
BPMC-40: re-enable signalling from the bpm console
Modified:
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
===================================================================
---
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2010-04-20
12:13:58 UTC (rev 1034)
+++
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2010-04-21
09:24:39 UTC (rev 1035)
@@ -164,8 +164,8 @@
public String getExecutionSignalUrl(TokenReference tok, String signal)
{
- String encodedSignal = URL.encode(signal);
- return config.getConsoleServerUrl() + "/rs/process/tokens/" + tok.getId() +
"/transition?signal=" + encodedSignal;
+// String encodedSignal = URL.encode(signal);
+ return config.getConsoleServerUrl() + "/rs/process/tokens/" + tok.getId() +
"/transition?signal=" + signal;
}
public String getAvailableActorsUrl(String actorId)
Modified:
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java
===================================================================
---
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java 2010-04-20
12:13:58 UTC (rev 1034)
+++
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java 2010-04-21
09:24:39 UTC (rev 1035)
@@ -21,31 +21,45 @@
*/
package org.jboss.bpm.console.client.process;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.ui.Button;
-import com.mvc4g.client.Controller;
-import com.mvc4g.client.Event;
-import com.mvc4g.client.ViewInterface;
+import java.util.ArrayList;
+import java.util.List;
+
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.event.RowSelectionEvent;
import org.gwt.mosaic.ui.client.event.RowSelectionHandler;
-import org.gwt.mosaic.ui.client.layout.*;
+import org.gwt.mosaic.ui.client.layout.BorderLayout;
+import org.gwt.mosaic.ui.client.layout.BorderLayoutData;
+import org.gwt.mosaic.ui.client.layout.BoxLayout;
+import org.gwt.mosaic.ui.client.layout.BoxLayoutData;
+import org.gwt.mosaic.ui.client.layout.MosaicPanel;
import org.gwt.mosaic.ui.client.list.DefaultListModel;
import org.jboss.bpm.console.client.ApplicationContext;
-import org.jboss.bpm.console.client.common.*;
+import org.jboss.bpm.console.client.common.DataDriven;
+import org.jboss.bpm.console.client.common.IFrameWindowCallback;
+import org.jboss.bpm.console.client.common.IFrameWindowPanel;
+import org.jboss.bpm.console.client.common.LoadingOverlay;
+import org.jboss.bpm.console.client.common.WidgetWindowPanel;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.client.model.TokenReference;
import org.jboss.bpm.console.client.process.events.InstanceEvent;
+import org.jboss.bpm.console.client.process.events.SignalInstanceEvent;
import org.jboss.bpm.console.client.util.SimpleDateFormat;
import org.jboss.errai.workspaces.client.api.ProvisioningCallback;
import org.jboss.errai.workspaces.client.api.WidgetProvider;
import org.jboss.errai.workspaces.client.framework.Registry;
-import java.util.ArrayList;
-import java.util.List;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+import com.mvc4g.client.Controller;
+import com.mvc4g.client.Event;
+import com.mvc4g.client.ViewInterface;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -78,8 +92,19 @@
MosaicPanel panel;
- private Button startBtn, terminateBtn, deleteBtn;
+ private Button startBtn, terminateBtn, deleteBtn, signalBtn;
+
+ // elements needed to signal waiting execution
+ private List<TokenReference> tokensToSignal = null;
+
+ private WidgetWindowPanel signalWindowPanel;
+
+ private ListBox<TokenReference> listBoxTokens = null;
+
+ private List<TextBox> signalTextBoxes = null;
+ private ListBox<String> listBoxTokenSignals;
+
public void provideWidget(ProvisioningCallback callback)
{
@@ -144,6 +169,13 @@
if(index!=-1)
{
ProcessInstanceRef item = listBox.getItem(index);
+
+ // enable or disable signal button depending on current activity
+ if (isSignalable(item)) {
+ signalBtn.setEnabled(true);
+ } else {
+ signalBtn.setEnabled(false);
+ }
// update details
controller.handleEvent(
@@ -306,14 +338,25 @@
}
}
);
+
+ signalBtn = new Button("Signal", new ClickHandler()
+ {
+ public void onClick(ClickEvent clickEvent)
+ {
+ createSignalWindow();
+ }
+ }
+ );
if(!isRiftsawInstance) // riftsaw doesn't support instance operations
{
toolBar.add(startBtn);
+ toolBar.add(signalBtn);
toolBar.add(deleteBtn);
startBtn.setEnabled(false);
deleteBtn.setEnabled(false);
+ signalBtn.setEnabled(false);
}
// terminate works on any BPM Engine
@@ -356,6 +399,7 @@
controller.addView(InstanceDetailView.ID, detailsView);
controller.addAction(UpdateInstanceDetailAction.ID, new
UpdateInstanceDetailAction());
controller.addAction(ClearInstancesAction.ID, new ClearInstancesAction());
+ controller.addAction(SignalExecutionAction.ID, new SignalExecutionAction());
layout.add(detailsView, new BorderLayoutData(BorderLayout.Region.SOUTH,10,200));
panel.add(layout);
@@ -392,6 +436,7 @@
startBtn.setEnabled(false);
terminateBtn.setEnabled(false);
deleteBtn.setEnabled(false);
+ signalBtn.setEnabled(false);
}
public void update(Object... data)
@@ -442,5 +487,195 @@
// layout again
panel.invalidate();
}
+
+ private boolean isSignalable(ProcessInstanceRef processInstance) {
+
+ tokensToSignal = new ArrayList<TokenReference>();
+
+ // first check if the parent execution is signalable
+ if (processInstance.getRootToken() != null &&
processInstance.getRootToken().canBeSignaled()) {
+ tokensToSignal.add(processInstance.getRootToken());
+
+ } else if (processInstance.getRootToken() != null &&
processInstance.getRootToken().getChildren() != null) {
+ // next verify children
+ collectSignalableTokens(processInstance.getRootToken(), tokensToSignal);
+ }
+
+ if (tokensToSignal.size() > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private void collectSignalableTokens(TokenReference tokenParent,
List<TokenReference> tokensToSignal) {
+ if (tokenParent.getChildren() != null) {
+ for (TokenReference token : tokenParent.getChildren()) {
+ if (token.canBeSignaled()) {
+ tokensToSignal.add(token);
+ }
+
+ collectSignalableTokens(token, tokensToSignal);
+ }
+ }
+ }
+
+ private void createSignalWindow()
+ {
+ signalTextBoxes = new ArrayList<TextBox>();
+
+ MosaicPanel layout = new MosaicPanel(new BoxLayout(BoxLayout.Orientation.VERTICAL));
+ layout.setStyleName("bpm-window-layout");
+ layout.setPadding(5);
+ // toolbar
+ final MosaicPanel toolBox = new MosaicPanel();
+ toolBox.setPadding(0);
+ toolBox.setWidgetSpacing(5);
+ toolBox.setLayout(new BoxLayout(BoxLayout.Orientation.HORIZONTAL));
+
+ final ToolBar toolBar = new ToolBar();
+ toolBar.add(
+ new Button("Signal", new ClickHandler() {
+
+ public void onClick(ClickEvent clickEvent)
+ {
+ int selectedToken = listBoxTokens.getSelectedIndex();
+ int selectedSignal = listBoxTokenSignals.getSelectedIndex();
+ if (selectedToken != -1 && selectedSignal != -1) {
+
+ controller.handleEvent(
+ new Event(SignalExecutionAction.ID,
+ new SignalInstanceEvent(getCurrentDefinition(),
getSelection(), listBoxTokens.getItem(selectedToken),
listBoxTokenSignals.getItem(selectedSignal), selectedToken)));
+
+ } else {
+ MessageBox.alert("Incomplete selection", "Please select both
token and signal name");
+ }
+
+
+ }
+ }
+ )
+ );
+
+ toolBar.add(
+ new Button("Cancel", new ClickHandler() {
+
+ public void onClick(ClickEvent clickEvent)
+ {
+
+ signalWindowPanel.close();
+ }
+ }
+ )
+ );
+
+ Label header = new Label("Available tokens to signal: ");
+ header.setStyleName("bpm-label-header");
+ layout.add(header, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+
+ toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+
+ layout.add(toolBox, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+
+ listBoxTokens = new ListBox<TokenReference>(new String[] { "Id",
"Name" });
+
+
+ listBoxTokens.setCellRenderer(new ListBox.CellRenderer<TokenReference>() {
+
+ public void renderCell(ListBox<TokenReference> listBox, int row, int column,
TokenReference item) {
+ switch (column) {
+ case 0:
+ listBox.setText(row, column, item.getId());
+ break;
+ case 1:
+ listBox.setText(row, column, item.getName() == null ? item.getCurrentNodeName()
: item.getName());
+ break;
+ default:
+ throw new RuntimeException("Unexpected column size");
+ }
+ }
+ });
+
+ listBoxTokens.addRowSelectionHandler(
+ new RowSelectionHandler()
+ {
+ public void onRowSelection(RowSelectionEvent rowSelectionEvent)
+ {
+ int index = listBoxTokens.getSelectedIndex();
+ if(index!=-1)
+ {
+ TokenReference item = listBoxTokens.getItem(index);
+ renderAvailableSignals(item);
+
+ }
+ }
+ }
+ );
+
+ renderSignalListBox(-1);
+ layout.add(listBoxTokens, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
+
+ Label headerSignals = new Label("Available signal names");
+ headerSignals.setStyleName("bpm-label-header");
+ layout.add(headerSignals, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+
+ listBoxTokenSignals = new ListBox<String>(new String[] { "Signal
name" });
+
+
+ listBoxTokenSignals.setCellRenderer(new ListBox.CellRenderer<String>() {
+
+ public void renderCell(ListBox<String> listBox, int row, int column, String
item) {
+ switch (column) {
+ case 0:
+ listBox.setText(row, column, item);
+ break;
+
+ default:
+ throw new RuntimeException("Unexpected column size");
+ }
+ }
+ });
+
+
+
+ layout.add(listBoxTokenSignals, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
+
+ signalWindowPanel = new WidgetWindowPanel(
+ "Signal proces from wait state",
+ layout, true
+ );
+
+ }
+
+ public void renderSignalListBox(int i) {
+ // remove currently signaled token
+ if (i > -1) {
+ tokensToSignal.remove(i);
+ }
+
+ // if available token list is empty close window
+ if (tokensToSignal.isEmpty()) {
+ signalWindowPanel.close();
+ }
+
+ // display all remaining token possible to signal
+ ((DefaultListModel<TokenReference>)listBoxTokens.getModel()).clear();
+ for (TokenReference token : tokensToSignal) {
+ ((DefaultListModel<TokenReference>)listBoxTokens.getModel()).add(token);
+ }
+
+ // clear available signal list box
+ if (listBoxTokenSignals != null) {
+ ((DefaultListModel<String>)listBoxTokenSignals.getModel()).clear();
+ }
+ }
+
+ private void renderAvailableSignals(TokenReference item) {
+ ((DefaultListModel<String>)listBoxTokenSignals.getModel()).clear();
+ for (String signal : item.getAvailableSignals()) {
+ ((DefaultListModel<String>)listBoxTokenSignals.getModel()).add(signal);
+ }
+ }
+
}
Added:
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/SignalExecutionAction.java
===================================================================
---
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/SignalExecutionAction.java
(rev 0)
+++
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/SignalExecutionAction.java 2010-04-21
09:24:39 UTC (rev 1035)
@@ -0,0 +1,89 @@
+/*
+ * 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.process;
+
+import org.jboss.bpm.console.client.URLBuilder;
+import org.jboss.bpm.console.client.common.AbstractRESTAction;
+import org.jboss.bpm.console.client.process.events.SignalInstanceEvent;
+
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.user.client.Timer;
+import com.mvc4g.client.Controller;
+import com.mvc4g.client.Event;
+
+
+/**
+ * Signals execution
+ *
+ * @author Maciej Swiderski <swiderski.maciej(a)gmail.com>
+ */
+class SignalExecutionAction extends AbstractRESTAction
+{
+ public final static String ID = SignalExecutionAction.class.getName();
+
+ public String getId()
+ {
+ return ID;
+ }
+
+ public String getUrl(Object event)
+ {
+ final SignalInstanceEvent def = (SignalInstanceEvent)event;
+ if (def.getSignalName() == null || "".equals(def.getSignalName())) {
+ return URLBuilder.getInstance().getExecutionSignalUrl(def.getToken());
+ } else {
+ {
+ return URLBuilder.getInstance().getExecutionSignalUrl(def.getToken(),
def.getSignalName());
+ }
+ }
+ }
+
+ public RequestBuilder.Method getRequestMethod()
+ {
+ return RequestBuilder.POST;
+ }
+
+ public void handleSuccessfulResponse(final Controller controller, final Object event,
Response response)
+ {
+ final SignalInstanceEvent def = (SignalInstanceEvent)event;
+ InstanceListView view = (InstanceListView) controller.getView(InstanceListView.ID);
+ if(view!=null) view.renderSignalListBox(def.getIndex());
+
+ // delay reload of instance list to avoid incorrect activity being fetched
+ // for instance when going through decision node
+ Timer t = new Timer()
+ {
+ @Override
+ public void run()
+ {
+ // force reload instance list
+ controller.handleEvent(
+ new Event(UpdateInstancesAction.ID, def.getDefinition())
+ );
+ }
+ };
+
+ t.schedule(500);
+
+ }
+}
Added:
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/events/SignalInstanceEvent.java
===================================================================
---
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/events/SignalInstanceEvent.java
(rev 0)
+++
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/events/SignalInstanceEvent.java 2010-04-21
09:24:39 UTC (rev 1035)
@@ -0,0 +1,65 @@
+/*
+ * 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.process.events;
+
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.client.model.TokenReference;
+
+/**
+ *
+ * @author Maciej Swiderski <swiderski.maciej(a)gmail.com>
+ *
+ */
+public class SignalInstanceEvent extends InstanceEvent {
+
+
+ private String signalName;
+
+ private TokenReference token;
+
+ private int index;
+
+
+
+ public int getIndex() {
+ return index;
+ }
+
+ public SignalInstanceEvent(ProcessDefinitionRef definition, ProcessInstanceRef
instance, TokenReference token, String signalName, int index) {
+ super(definition, instance);
+
+ this.signalName = signalName;
+ this.token = token;
+ this.index = index;
+ }
+
+ public String getSignalName() {
+ return signalName;
+ }
+
+
+ public TokenReference getToken() {
+ return token;
+ }
+
+}
Modified:
bpm-console/trunk/server/war/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
===================================================================
---
bpm-console/trunk/server/war/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java 2010-04-20
12:13:58 UTC (rev 1034)
+++
bpm-console/trunk/server/war/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java 2010-04-21
09:24:39 UTC (rev 1035)
@@ -21,10 +21,31 @@
*/
package org.jboss.bpm.console.server;
-import com.google.gson.Gson;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.bpm.console.client.model.*;
+import org.jboss.bpm.console.client.model.ActiveNodeInfo;
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessDefinitionRefWrapper;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRefWrapper;
import org.jboss.bpm.console.server.gson.GsonFactory;
import org.jboss.bpm.console.server.integration.ManagementFactory;
import org.jboss.bpm.console.server.integration.ProcessManagement;
@@ -35,14 +56,7 @@
import org.jboss.bpm.console.server.util.Payload2XML;
import org.jboss.bpm.console.server.util.RsComment;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import com.google.gson.Gson;
/**
* REST server module for accessing process related data.
@@ -263,6 +277,11 @@
@QueryParam("signal")
String signalName)
{
+ try {
+ id = URLDecoder.decode(id, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
log.debug("Signal token " + id + " -> " + signalName);
if ("default transition".equals(signalName))
@@ -279,6 +298,11 @@
@PathParam("id")
String id)
{
+ try {
+ id = URLDecoder.decode(id, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
log.debug("Signal token " + id);
getProcessManagement().signalExecution(id, null);
Modified:
bpm-console/trunk/shared/rpc/src/main/java/org/jboss/bpm/console/client/model/TokenReference.java
===================================================================
---
bpm-console/trunk/shared/rpc/src/main/java/org/jboss/bpm/console/client/model/TokenReference.java 2010-04-20
12:13:58 UTC (rev 1034)
+++
bpm-console/trunk/shared/rpc/src/main/java/org/jboss/bpm/console/client/model/TokenReference.java 2010-04-21
09:24:39 UTC (rev 1035)
@@ -39,7 +39,7 @@
private List<TokenReference> children = new ArrayList<TokenReference>();
private List<String> availableSignals = new ArrayList<String>();
- private boolean canBeSignaled = true;
+ private boolean canBeSignaled = false;
public TokenReference()
{