[jbpm-commits] JBoss JBPM SVN: r5186 - in projects/gwt-console/trunk/gui: 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
Thu Jul 2 07:50:43 EDT 2009
Author: heiko.braun at jboss.com
Date: 2009-07-02 07:50:43 -0400 (Thu, 02 Jul 2009)
New Revision: 5186
Added:
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceDataView.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/UpdateInstanceDataAction.java
Modified:
projects/gwt-console/trunk/gui/war/pom.xml
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceDetailView.java
projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml
projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
Log:
Fix JBPM-2236: View data associated with a process
Modified: projects/gwt-console/trunk/gui/war/pom.xml
===================================================================
--- projects/gwt-console/trunk/gui/war/pom.xml 2009-07-02 11:45:22 UTC (rev 5185)
+++ projects/gwt-console/trunk/gui/war/pom.xml 2009-07-02 11:50:43 UTC (rev 5186)
@@ -302,7 +302,7 @@
<version>${version}</version>
</dependency>
</dependencies>
- <build>
+ <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceDataView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceDataView.java (rev 0)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceDataView.java 2009-07-02 11:50:43 UTC (rev 5186)
@@ -0,0 +1,188 @@
+/*
+ * 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 com.google.gwt.user.client.Window;
+import com.google.gwt.xml.client.*;
+import com.mvc4g.client.Controller;
+import com.mvc4g.client.ViewInterface;
+import org.gwt.mosaic.ui.client.ListBox;
+import org.gwt.mosaic.ui.client.ScrollLayoutPanel;
+import org.gwt.mosaic.ui.client.CaptionLayoutPanel;
+import org.gwt.mosaic.ui.client.layout.LayoutPanel;
+import org.gwt.mosaic.ui.client.list.DefaultListModel;
+import org.jboss.bpm.console.client.LazyPanel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class InstanceDataView extends LayoutPanel implements ViewInterface, LazyPanel
+{
+ public final static String ID = InstanceDataView.class.getName();
+
+ private Controller controller;
+
+ private ListBox listBox;
+
+ private String instanceId;
+
+ private boolean isInitialized;
+
+ public InstanceDataView()
+ {
+ super();
+ this.setPadding(5);
+ }
+
+ public void initialize()
+ {
+ if(!isInitialized)
+ {
+ listBox =
+ new ListBox<Node>(
+ new String[] {
+ "Key", "XSD Type", "Java Type", "Value"}
+ );
+
+ listBox.setCellRenderer(new ListBox.CellRenderer<DataEntry>() {
+ public void renderCell(ListBox<DataEntry> listBox, int row, int column,
+ DataEntry item) {
+ switch (column) {
+ case 0:
+ listBox.setText(row, column, item.key);
+ break;
+ case 1:
+ listBox.setText(row, column, item.xsd);
+ break;
+ case 2:
+ listBox.setText(row,column, item.java);
+ break;
+ case 3:
+ listBox.setText(row,column, item.value);
+ break;
+ default:
+ throw new RuntimeException("Unexpected column size");
+ }
+ }
+ });
+
+ this.add(listBox);
+
+ this.isInitialized = true;
+ }
+ }
+
+ public boolean isInitialized()
+ {
+ return isInitialized;
+ }
+
+ public void setController(Controller controller)
+ {
+ this.controller = controller;
+ }
+
+ public void update(String instanceId, Document xml)
+ {
+ this.instanceId = instanceId;
+ parseMessage(xml);
+ }
+
+ private void parseMessage(Document messageDom)
+ {
+ try
+ {
+ // parse the XML document into a DOM
+ //Document messageDom = XMLParser.parse(messageXml);
+
+ Node dataSetNode = messageDom.getElementsByTagName("dataset").item(0);
+ List<Node> dataNodeList = filterChildNodes(dataSetNode.getChildNodes());
+ List<DataEntry> data = new ArrayList<DataEntry>();
+
+ for(Node n : dataNodeList)
+ {
+ DataEntry d = new DataEntry();
+ NamedNodeMap atts = n.getAttributes();
+
+ Node valueNode = filterChildNodes(n.getChildNodes()).get(0); // expected to have just one child‚
+ NamedNodeMap attsChild = valueNode.getAttributes();
+
+ d.key = atts.getNamedItem("key").getNodeValue();
+ d.xsd = attsChild.getNamedItem("xsi:type").getNodeValue();
+ d.java = atts.getNamedItem("javaType").getNodeValue();
+ d.value = valueNode.getFirstChild().getNodeValue(); // text element is first child
+
+ data.add(d);
+ }
+
+ bindData(data);
+ }
+ catch (DOMException e)
+ {
+ Window.alert("Could not parse XML document.");
+ }
+
+ }
+
+ private void bindData(List<DataEntry> data)
+ {
+ initialize();
+
+ final DefaultListModel<DataEntry> model =
+ (DefaultListModel<DataEntry>) listBox.getModel();
+ model.clear();
+
+ for(DataEntry d : data)
+ {
+ model.add(d);
+ }
+
+ // layout again
+ this.layout();
+ }
+
+ private List<Node> filterChildNodes(NodeList childNodes)
+ {
+ List<Node> result = new ArrayList<Node>();
+
+ for(int i=0; i<childNodes.getLength(); i++)
+ {
+ Node n = childNodes.item(i);
+ if(n.getNodeType()!=Node.ELEMENT_NODE) // skip #text
+ continue;
+ else
+ result.add(n);
+ }
+ return result;
+ }
+
+ private class DataEntry
+ {
+ String key;
+ String xsd;
+ String java;
+ String value;
+ }
+}
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceDetailView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceDetailView.java 2009-07-02 11:45:22 UTC (rev 5185)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceDetailView.java 2009-07-02 11:50:43 UTC (rev 5186)
@@ -28,6 +28,7 @@
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.WindowCloseListener;
+import com.google.gwt.user.client.WindowResizeListener;
import org.gwt.mosaic.ui.client.CaptionLayoutPanel;
import org.gwt.mosaic.ui.client.WindowPanel;
import org.gwt.mosaic.ui.client.Caption;
@@ -55,14 +56,20 @@
private ProcessInstanceRef currentInstance;
- private Button activityBtn;
+ private Button diagramBtn;
- private WindowPanel windowPanel;
+ private Button instanceDataBtn;
+ private WindowPanel diagramWindowPanel;
+
+ private WindowPanel instanceDataWindowPanel;
+
private ApplicationContext appContext;
private ActivityDiagramView diagramView;
+ private InstanceDataView instanceDataView;
+
private boolean hasDiagramPlugin;
private SimpleDateFormat dateFormat = new SimpleDateFormat();
@@ -81,14 +88,15 @@
this.add(grid, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
- activityBtn = new Button("Diagram",
+ LayoutPanel buttonPanel = new LayoutPanel(new BoxLayout(BoxLayout.Orientation.VERTICAL) );
+ diagramBtn = new Button("Diagram",
new ClickListener()
{
public void onClick(Widget widget)
{
if(currentInstance!=null)
{
- createActivityWindow(currentInstance);
+ createDiagramWindow(currentInstance);
controller.handleEvent(
new Event(LoadActivityDiagramAction.ID, currentInstance)
);
@@ -97,20 +105,39 @@
}
);
- activityBtn.setEnabled(false);
- this.add(activityBtn);
+ diagramBtn.setEnabled(false);
+ buttonPanel.add(diagramBtn);
+ instanceDataBtn = new Button("Instance Data",
+ new ClickListener()
+ {
+ public void onClick(Widget widget)
+ {
+ if(currentInstance!=null)
+ {
+ createDataWindow(currentInstance);
+ controller.handleEvent(
+ new Event(UpdateInstanceDataAction.ID, currentInstance.getId())
+ );
+ }
+ }
+ }
+ );
+ instanceDataBtn.setEnabled(false);
+ buttonPanel.add(instanceDataBtn);
+ this.add(buttonPanel);
+
// plugin availability
this.hasDiagramPlugin =
ServerPlugins.has("org.jboss.bpm.console.server.plugin.GraphViewerPlugin");
}
- private void createActivityWindow(ProcessInstanceRef inst)
+ private void createDiagramWindow(ProcessInstanceRef inst)
{
- windowPanel = new WindowPanel("Process Instance Activity");
- windowPanel.setAnimationEnabled(true);
- windowPanel.setSize("320px", "240px");
+ diagramWindowPanel = new WindowPanel("Process Instance Activity");
+ diagramWindowPanel.setAnimationEnabled(true);
+ diagramWindowPanel.setSize("320px", "240px");
LayoutPanel layout = new LayoutPanel(new BoxLayout(BoxLayout.Orientation.VERTICAL));
layout.setStyleName("bpm-window-layout");
@@ -120,9 +147,9 @@
header.setStyleName("bpm-label-header");
layout.add(header, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
- windowPanel.addWindowCloseListener(new WindowCloseListener() {
+ diagramWindowPanel.addWindowCloseListener(new WindowCloseListener() {
public void onWindowClosed() {
- windowPanel = null;
+ diagramWindowPanel = null;
}
@@ -133,23 +160,65 @@
layout.add(diagramView, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
- windowPanel.setWidget(layout);
+ diagramWindowPanel.setWidget(layout);
- WindowUtil.addMaximizeButton(windowPanel, Caption.CaptionRegion.RIGHT);
- WindowUtil.addMinimizeButton(windowPanel, Caption.CaptionRegion.RIGHT);
+ WindowUtil.addMaximizeButton(diagramWindowPanel, Caption.CaptionRegion.RIGHT);
+ WindowUtil.addMinimizeButton(diagramWindowPanel, Caption.CaptionRegion.RIGHT);
// display
- windowPanel.center();
+ diagramWindowPanel.center();
}
+ private void createDataWindow(ProcessInstanceRef inst)
+ {
+ instanceDataWindowPanel = new WindowPanel("Process Instance Data: "+inst.getId());
+ instanceDataWindowPanel.setAnimationEnabled(true);
+ instanceDataWindowPanel.setSize("320px", "240px");
+
+
+ instanceDataWindowPanel.addWindowCloseListener(new WindowCloseListener() {
+ public void onWindowClosed() {
+ instanceDataWindowPanel = null;
+
+ }
+
+ public String onWindowClosing() {
+ return null;
+ }
+ });
+
+ instanceDataWindowPanel.addWindowResizeListener(
+ new WindowResizeListener() {
+
+ public void onWindowResized(int i, int i1)
+ {
+ instanceDataView.invalidate();
+ }
+ }
+ );
+
+ instanceDataWindowPanel.setWidget(instanceDataView);
+
+ WindowUtil.addMaximizeButton(instanceDataWindowPanel, Caption.CaptionRegion.RIGHT);
+ WindowUtil.addMinimizeButton(instanceDataWindowPanel, Caption.CaptionRegion.RIGHT);
+
+ // display
+ instanceDataWindowPanel.center();
+
+ }
+
public void setController(Controller controller)
{
this.controller = controller;
this.diagramView = new ActivityDiagramView();
+ this.instanceDataView = new InstanceDataView();
+
controller.addView(ActivityDiagramView.ID, diagramView);
- controller.addAction(LoadActivityDiagramAction.ID, new LoadActivityDiagramAction(appContext));
+ controller.addView(InstanceDataView.ID, instanceDataView);
+ controller.addAction(LoadActivityDiagramAction.ID, new LoadActivityDiagramAction(appContext));
+ controller.addAction(UpdateInstanceDataAction.ID, new UpdateInstanceDataAction(appContext));
}
public void update(ProcessInstanceRef instance)
@@ -167,14 +236,17 @@
grid.update(values);
if(hasDiagramPlugin)
- this.activityBtn.setEnabled(true);
+ this.diagramBtn.setEnabled(true);
+
+ instanceDataBtn.setEnabled(true);
}
public void clearView()
{
grid.clear();
this.currentInstance = null;
- this.activityBtn.setEnabled(false);
+ this.diagramBtn.setEnabled(false);
+ instanceDataBtn.setEnabled(false);
}
}
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/UpdateInstanceDataAction.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/UpdateInstanceDataAction.java (rev 0)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/UpdateInstanceDataAction.java 2009-07-02 11:50:43 UTC (rev 5186)
@@ -0,0 +1,70 @@
+/*
+ * 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.common.AbstractRESTAction;
+import org.jboss.bpm.console.client.ApplicationContext;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.xml.client.Document;
+import com.google.gwt.xml.client.XMLParser;
+import com.mvc4g.client.Controller;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class UpdateInstanceDataAction extends AbstractRESTAction
+{
+
+ public final static String ID = UpdateInstanceDataAction.class.getName();
+
+ public UpdateInstanceDataAction(ApplicationContext appContetext)
+ {
+ super(appContetext);
+ }
+
+ public String getId()
+ {
+ return ID;
+ }
+
+ public String getUrl(Object event)
+ {
+ String id = (String)event;
+ return appContext.getUrlBuilder().getInstanceDataURL(id);
+ }
+
+ public RequestBuilder.Method getRequestMethod()
+ {
+ return RequestBuilder.GET;
+ }
+
+ public void handleSuccessfulResponse(final Controller controller, final Object event, Response response)
+ {
+ String id = (String)event;
+ String xml = response.getText();
+ System.out.println(xml);
+ Document messageDom = XMLParser.parse(xml);
+ InstanceDataView view = (InstanceDataView)controller.getView(InstanceDataView.ID);
+ view.update(id, messageDom);
+ }
+}
Modified: projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml 2009-07-02 11:45:22 UTC (rev 5185)
+++ projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml 2009-07-02 11:50:43 UTC (rev 5186)
@@ -5,6 +5,7 @@
<inherits name='com.google.gwt.json.JSON'/>
<inherits name="com.google.gwt.i18n.I18N"/>
<inherits name="com.google.gwt.user.ImageBundle"/>
+ <inherits name="com.google.gwt.xml.XML" />
<!-- Add gwt-log support, default level `DEBUG` -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" />
Modified: projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
===================================================================
--- projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2009-07-02 11:45:22 UTC (rev 5185)
+++ projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2009-07-02 11:50:43 UTC (rev 5186)
@@ -100,6 +100,10 @@
return config.getConsoleServerUrl() + "/rs/process/instance/" + instanceId + "/delete";
}
+ public String getInstanceDataURL(String instanceId)
+ {
+ return config.getConsoleServerUrl() + "/rs/process/instance/" + instanceId + "/dataset";
+ }
public String getStartNewInstanceURL(String processId)
{
More information about the jbpm-commits
mailing list