Author: koen.aers(a)jboss.com
Date: 2010-12-13 16:07:04 -0500 (Mon, 13 Dec 2010)
New Revision: 27419
Added:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBoundsImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnDiagramImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnLabelImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnNotationFactory.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnShapeImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/figures/
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySectionBis.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/util/
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Details.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java
Removed:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/.classpath
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/META-INF/MANIFEST.MF
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/util/Bpmn2ResourceFactoryImpl.java
Log:
make export feature work
Modified: trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/.classpath
===================================================================
--- trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/.classpath 2010-12-13
21:04:34 UTC (rev 27418)
+++ trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/.classpath 2010-12-13
21:07:04 UTC (rev 27419)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="src-custom"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
Modified: trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/META-INF/MANIFEST.MF
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/META-INF/MANIFEST.MF 2010-12-13
21:04:34 UTC (rev 27418)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/META-INF/MANIFEST.MF 2010-12-13
21:07:04 UTC (rev 27419)
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.bpmn2.diagram; singleton:=true
+Bundle-SymbolicName: org.jboss.tools.bpmn2.process.diagram;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditorPlugin
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.bpmn2;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+import org.eclipse.ui.progress.IProgressConstants;
+
+public class Bpmn2PerspectiveFactory implements IPerspectiveFactory {
+
+ public void createInitialLayout(IPageLayout layout) {
+ String editorArea = layout.getEditorArea();
+
+ IFolderLayout folder= layout.createFolder("left", IPageLayout.LEFT,
(float)0.25, editorArea); //$NON-NLS-1$
+ folder.addView(JavaUI.ID_PACKAGES);
+ folder.addPlaceholder("org.eclipse.ui.navigator.ProjectExplorer");
+ folder.addPlaceholder(JavaUI.ID_TYPE_HIERARCHY);
+ folder.addPlaceholder("org.eclipse.ui.views.ResourceNavigator");
+
+ layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.BOTTOM, (float)0.70,
"left");
+
+ IFolderLayout bpmnFolder = layout.createFolder("bpmn", IPageLayout.BOTTOM,
(float)0.70, editorArea);
+ bpmnFolder.addView("org.jboss.tools.bpmn2.details");
+ bpmnFolder.addView("org.jboss.tools.bpmn2.definitions");
+
+ IFolderLayout outputfolder= layout.createFolder("bottom", IPageLayout.RIGHT,
(float)0.33, "bpmn"); //$NON-NLS-1$
+ outputfolder.addView(IPageLayout.ID_PROP_SHEET);
+ outputfolder.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
+ outputfolder.addPlaceholder(JavaUI.ID_JAVADOC_VIEW);
+ outputfolder.addPlaceholder(JavaUI.ID_SOURCE_VIEW);
+ outputfolder.addPlaceholder("org.eclipse.search.ui.views.SearchView");
+ outputfolder.addPlaceholder("org.eclipse.ui.console.ConsoleView");
+ outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS);
+ outputfolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
+
+ layout.addActionSet("org.eclipse.debug.ui.launchActionSet");
+ layout.addActionSet(JavaUI.ID_ACTION_SET);
+ layout.addActionSet(JavaUI.ID_ELEMENT_CREATION_ACTION_SET);
+ layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
+
+ // views - java
+ layout.addShowViewShortcut(JavaUI.ID_PACKAGES);
+ layout.addShowViewShortcut(JavaUI.ID_TYPE_HIERARCHY);
+ layout.addShowViewShortcut(JavaUI.ID_SOURCE_VIEW);
+ layout.addShowViewShortcut(JavaUI.ID_JAVADOC_VIEW);
+
+ // views - search
+ layout.addShowViewShortcut("org.eclipse.search.ui.views.SearchView");
+
+ // views - debugging
+ layout.addShowViewShortcut("org.eclipse.ui.console.ConsoleView");
+
+ // views - standard workbench
+ layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
+ layout.addShowViewShortcut("org.jbpm.gd.jpdl.overview");
+ layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+ layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+ layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
+ layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
+ layout.addShowViewShortcut(IProgressConstants.PROGRESS_VIEW_ID);
+
+ // new actions - Java project creation wizard
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewPackageCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewClassCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewEnumCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard");
//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.jbpm.ui.wizard.new.file"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.jboss.tools.bpmn2.process.diagram.part.Bpmn2CreationWizardID");//$NON-NLS-1$
+ }
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/Bpmn2PerspectiveFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,60 @@
+package org.jboss.tools.bpmn2.gmf.notation;
+
+import java.util.List;
+
+import org.eclipse.bpmn2.di.BPMNShape;
+import org.eclipse.dd.dc.Bounds;
+import org.eclipse.dd.dc.DcFactory;
+import org.eclipse.dd.dc.Point;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+import org.eclipse.gmf.runtime.notation.impl.RelativeBendpointsImpl;
+
+public class BpmnBendpointsImpl extends RelativeBendpointsImpl implements
+ RelativeBendpoints {
+
+ private Edge edge;
+
+ public void setEdge(Edge edge) {
+ this.edge = edge;
+ }
+
+ public Edge getEdge() {
+ return edge;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public void setPoints(List newPoints) {
+ if (edge != null && edge instanceof BpmnEdgeImpl) {
+ List<Point> waypoints = (((BpmnEdgeImpl)edge).getBPMNEdge()).getWaypoint();
+ waypoints.clear();
+ if (newPoints != null) {
+ for (Object object : newPoints) {
+ if (object instanceof RelativeBendpoint) {
+ RelativeBendpoint relativeBendPoint = (RelativeBendpoint)object;
+ Point absoluteBendpoint = DcFactory.eINSTANCE.createPoint();
+ BPMNShape source = getEdgeSource();
+ if (source != null) {
+ Bounds sourceBounds = ((BPMNShape)source).getBounds();
+ absoluteBendpoint.setX(sourceBounds.getX() + relativeBendPoint.getSourceX());
+ absoluteBendpoint.setY(sourceBounds.getY() + relativeBendPoint.getSourceY());
+ }
+ waypoints.add(absoluteBendpoint);
+ }
+ }
+ }
+ }
+ super.setPoints(newPoints);
+ }
+
+ private BPMNShape getEdgeSource() {
+ if (edge == null) return null;
+ View source = edge.getSource();
+ if (!(source instanceof BpmnShapeImpl)) return null;
+ return ((BpmnShapeImpl)source).getBPMNShape();
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBendpointsImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBoundsImpl.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnBoundsImpl.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBoundsImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBoundsImpl.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,122 @@
+package org.jboss.tools.bpmn2.gmf.notation;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.LayoutConstraint;
+import org.eclipse.gmf.runtime.notation.impl.BoundsImpl;
+
+public class BpmnBoundsImpl extends BoundsImpl implements Bounds {
+
+ org.eclipse.dd.dc.Bounds bpmnBounds = null;
+
+ public BpmnBoundsImpl(org.eclipse.dd.dc.Bounds bounds) {
+ this.bpmnBounds = bounds;
+ }
+
+ public void initialize(BpmnShapeImpl shape) {
+ assert shape != null;
+ super.setHeight((int)bpmnBounds.getHeight());
+ super.setWidth((int)bpmnBounds.getWidth());
+ LayoutConstraint layoutConstraint = shape.getLayoutConstraint();
+ if (layoutConstraint instanceof BpmnBoundsImpl) {
+ org.eclipse.dd.dc.Bounds bounds = getParentContainerBounds();
+ super.setX((int)(bpmnBounds.getX() - (bounds != null ? bounds.getX() : 0)));
+ super.setY((int)(bpmnBounds.getY() - (bounds != null ? bounds.getY() : 0)));
+ }
+ }
+
+ public org.eclipse.dd.dc.Bounds getBPMNBounds() {
+ return bpmnBounds;
+ }
+
+ public void setX(int newX) {
+ super.setX(newX);
+ bpmnBounds.setX(getAbsoluteX(newX));
+ adjustChildren();
+ }
+
+ public void setY(int newY) {
+ super.setY(newY);
+ bpmnBounds.setY(getAbsoluteY(newY));
+ adjustChildren();
+ }
+
+ public void setHeight(int newHeight) {
+ super.setHeight(newHeight);
+ bpmnBounds.setHeight(newHeight);
+ }
+
+ public void setWidth(int newWidth) {
+ super.setWidth(newWidth);
+ bpmnBounds.setWidth(newWidth);
+ }
+
+ private int getAbsoluteX(int x) {
+ int result = x;
+ org.eclipse.dd.dc.Bounds parentContainerBounds = getParentContainerBounds();
+ if (parentContainerBounds != null) {
+ result += parentContainerBounds.getX();
+ }
+ return result;
+ }
+
+ private int getAbsoluteY(int y) {
+ int result = y;
+ org.eclipse.dd.dc.Bounds parentContainerBounds = getParentContainerBounds();
+ if (parentContainerBounds != null) {
+ result += parentContainerBounds.getY();
+ }
+ return result;
+ }
+
+ private org.eclipse.dd.dc.Bounds getParentContainerBounds() {
+ org.eclipse.dd.dc.Bounds result = null;
+ BpmnShapeImpl parent = getParentContainer();
+ if (parent != null) {
+ LayoutConstraint layoutConstraint = parent.getLayoutConstraint();
+ if (layoutConstraint instanceof BpmnBoundsImpl) {
+ BpmnBoundsImpl bpmnBounds = (BpmnBoundsImpl)layoutConstraint;
+ result = bpmnBounds.getBPMNBounds();
+ }
+ }
+ return result;
+ }
+
+ private BpmnShapeImpl getParentContainer() {
+ BpmnShapeImpl parent = getParent();
+ if (parent != null) {
+ Object parentContainer = parent.eContainer();
+ if (parentContainer != null && parentContainer instanceof BpmnShapeImpl) {
+ return (BpmnShapeImpl)parentContainer;
+ }
+ }
+ return null;
+ }
+
+ private BpmnShapeImpl getParent() {
+ EObject parent = this.eContainer();
+ if (parent != null && parent instanceof BpmnShapeImpl) {
+ return (BpmnShapeImpl)parent;
+ }
+ return null;
+ }
+
+ private void adjustChildren() {
+ BpmnShapeImpl parent = getParent();
+ if (parent != null) {
+ for (Object child : parent.getChildren()) {
+ if (child instanceof BpmnShapeImpl) {
+ BpmnShapeImpl bpmnShape = (BpmnShapeImpl)child;
+ LayoutConstraint layoutConstraint = bpmnShape.getLayoutConstraint();
+ if (layoutConstraint != null && layoutConstraint instanceof BpmnBoundsImpl)
{
+ BpmnBoundsImpl bpmnBounds = (BpmnBoundsImpl)layoutConstraint;
+ // these calls reset the absolute coordinates of the adapted bounds object
+ bpmnBounds.setX(bpmnBounds.getX());
+ bpmnBounds.setY(bpmnBounds.getY());
+ }
+ }
+ }
+ }
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnBoundsImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnDiagramImpl.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnDiagramImpl.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnDiagramImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnDiagramImpl.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,181 @@
+package org.jboss.tools.bpmn2.gmf.notation;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.bpmn2.Artifact;
+import org.eclipse.bpmn2.FlowElement;
+import org.eclipse.bpmn2.FlowElementsContainer;
+import org.eclipse.bpmn2.Process;
+import org.eclipse.bpmn2.SubProcess;
+import org.eclipse.bpmn2.di.BPMNDiagram;
+import org.eclipse.bpmn2.di.BPMNEdge;
+import org.eclipse.bpmn2.di.BPMNShape;
+import org.eclipse.dd.di.DiagramElement;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.MeasurementUnit;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.impl.DiagramImpl;
+
+public class BpmnDiagramImpl extends DiagramImpl implements Diagram {
+
+ BPMNDiagram bpmnDiagram;
+
+ public BpmnDiagramImpl(BPMNDiagram diagram) {
+ this.bpmnDiagram = diagram;
+ initialize();
+ }
+
+ private void initialize() {
+ setType("bpmn2");
+ setElement(bpmnDiagram.getPlane().getBpmnElement());
+ setMeasurementUnit(MeasurementUnit.get("Pixel"));
+ initializeViews((FlowElementsContainer)this.getElement(), createViewMap());
+ }
+
+ private void initializeNodes(FlowElementsContainer parent, Map<EObject, View>
viewMap) {
+ for (FlowElement flowElement : parent.getFlowElements()) {
+ View view = viewMap.get(flowElement);
+ if (view == null) continue;
+ if (view instanceof BpmnShapeImpl) {
+ initializeShape(parent, flowElement, viewMap);
+ }
+ }
+ }
+
+ private void initializeArtifacts(FlowElementsContainer parent, Map<EObject, View>
viewMap) {
+ List<Artifact> artifacts = null;
+ if (parent instanceof Process) {
+ artifacts = ((Process)parent).getArtifacts();
+ } else if (parent instanceof SubProcess) {
+ artifacts = ((SubProcess)parent).getArtifacts();
+ }
+ if (artifacts == null) return;
+ for (Artifact artifact : artifacts) {
+ initializeShape(parent, artifact, viewMap);
+ }
+ }
+
+ private void initializeEdges(FlowElementsContainer parent, Map<EObject, View>
viewMap) {
+ for (FlowElement flowElement : parent.getFlowElements()) {
+ View view = viewMap.get(flowElement);
+ if (view == null) continue;
+ if (view instanceof BpmnEdgeImpl) {
+ initializeEdge(parent, flowElement, viewMap);
+ }
+ }
+ }
+
+ private void initializeViews(
+ FlowElementsContainer parent,
+ Map<EObject, View> viewMap) {
+ initializeNodes(parent, viewMap);
+ initializeArtifacts(parent, viewMap);
+ initializeEdges(parent, viewMap);
+ }
+
+ private void initializeEdge(FlowElementsContainer parent, EObject object,
Map<EObject, View> viewMap) {
+ View view = viewMap.get(object);
+ if (view != null && view instanceof BpmnEdgeImpl) {
+ BpmnEdgeImpl edge = (BpmnEdgeImpl)view;
+ View parentView = viewMap.get(parent);
+ if (parentView != null && parentView instanceof Diagram) {
+ edge.initialize((Diagram)parentView, viewMap);
+ }
+// EObject bpmnElement = edge.getElement();
+// if (bpmnElement instanceof SequenceFlow) {
+// SequenceFlow sequenceFlow = (SequenceFlow)bpmnElement;
+// FlowNode source = sequenceFlow.getSourceRef();
+// FlowNode target = sequenceFlow.getTargetRef();
+// View sourceView = viewMap.get(source);
+// View targetView = viewMap.get(target);
+// edge.setSource(sourceView);
+// edge.setTarget(targetView);
+// }
+ }
+ }
+
+ private void initializeShape(
+ FlowElementsContainer parent,
+ EObject object,
+ Map<EObject, View> viewMap) {
+ View view = viewMap.get(object);
+ if (view != null && view instanceof BpmnShapeImpl) {
+ BpmnShapeImpl shape = (BpmnShapeImpl)view;
+ View parentView = viewMap.get(parent);
+ if (parentView != null) {
+ shape.initialize(parentView);
+ if (shape.getElement() instanceof FlowElementsContainer) {
+ initializeViews((FlowElementsContainer)shape.getElement(), viewMap);
+ }
+ }
+ }
+ }
+
+ private Map<EObject, View> createViewMap() {
+ List<DiagramElement> diagramElements = bpmnDiagram.getPlane().getPlaneElement();
+ Map<EObject, View> result = new HashMap<EObject, View>();
+ result.put(bpmnDiagram.getPlane().getBpmnElement(), this);
+ for (DiagramElement diagramElement : diagramElements) {
+ if (diagramElement instanceof BPMNShape) {
+ BPMNShape bpmnShape = (BPMNShape)diagramElement;
+ BpmnShapeImpl shape = BpmnNotationFactory.INSTANCE.createShape(bpmnShape);
+ result.put(bpmnShape.getBpmnElement(), shape);
+ } else if (diagramElement instanceof BPMNEdge) {
+ BPMNEdge bpmnEdge = (BPMNEdge)diagramElement;
+ BpmnEdgeImpl edge = BpmnNotationFactory.INSTANCE.createEdge(bpmnEdge);
+ result.put(bpmnEdge.getBpmnElement(), edge);
+ }
+ }
+ return result;
+ }
+
+ public void eNotify(Notification notifier) {
+ if (notifier.getEventType() == Notification.REMOVE) {
+ Object feature = notifier.getFeature();
+ if (feature instanceof EReference) {
+ String name = ((EReference) feature).getName();
+ Object oldValue = notifier.getOldValue();
+ if ("children".equals(name) && oldValue instanceof BpmnShapeImpl) {
+ removeDiagramElement(((BpmnShapeImpl)oldValue).getBPMNShape());
+ } else if ("edges".equals(name) && oldValue instanceof
BpmnEdgeImpl) {
+ removeDiagramElement(((BpmnEdgeImpl)oldValue).getBPMNEdge());
+ }
+ }
+ }
+ super.eNotify(notifier);
+ }
+
+ public void insertChild(View child) {
+ super.insertChild(child);
+ if (child instanceof BpmnShapeImpl) {
+ insertShape((BpmnShapeImpl) child);
+ }
+ }
+
+ @Override
+ public void insertEdge(Edge edge) {
+ super.insertEdge(edge);
+ if (edge instanceof BpmnEdgeImpl) {
+ insertEdge((BpmnEdgeImpl)edge);
+ }
+ }
+
+ protected void insertEdge(BpmnEdgeImpl edge) {
+ bpmnDiagram.getPlane().getPlaneElement().add(edge.getBPMNEdge());
+ }
+
+ protected void insertShape(BpmnShapeImpl shape) {
+ bpmnDiagram.getPlane().getPlaneElement().add(shape.getBPMNShape());
+ }
+
+ protected void removeDiagramElement(DiagramElement elementToRemove) {
+ bpmnDiagram.getPlane().getPlaneElement().remove(elementToRemove);
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnDiagramImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,105 @@
+package org.jboss.tools.bpmn2.gmf.notation;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.bpmn2.BaseElement;
+import org.eclipse.bpmn2.FlowNode;
+import org.eclipse.bpmn2.SequenceFlow;
+import org.eclipse.bpmn2.di.BPMNEdge;
+import org.eclipse.dd.dc.Bounds;
+import org.eclipse.dd.dc.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Bendpoints;
+import org.eclipse.gmf.runtime.notation.Connector;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+import org.eclipse.gmf.runtime.notation.impl.ConnectorImpl;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2VisualIDRegistry;
+
+public class BpmnEdgeImpl extends ConnectorImpl implements Connector {
+
+ BPMNEdge bpmnEdge;
+
+ public BpmnEdgeImpl(BPMNEdge edge) {
+ this.bpmnEdge = edge;
+ }
+
+ public BPMNEdge getBPMNEdge() {
+ return bpmnEdge;
+ }
+
+ @Override
+ public void setElement(EObject newElement) {
+ super.setElement(newElement);
+ if (newElement instanceof BaseElement) {
+ bpmnEdge.setBpmnElement((BaseElement) newElement);
+ }
+ }
+
+ @Override
+ public void setBendpoints(Bendpoints bendpoints) {
+ if (bendpoints != null && bendpoints instanceof BpmnBendpointsImpl) {
+ BpmnBendpointsImpl bpmnBendpoints = (BpmnBendpointsImpl)bendpoints;
+ if (bpmnBendpoints.getEdge() != this) {
+ bpmnBendpoints.setEdge(this);
+ // force refresh of the points list
+ bpmnBendpoints.setPoints(bpmnBendpoints.getPoints());
+ }
+ }
+ super.setBendpoints(bendpoints);
+ }
+
+ public void initialize(Diagram parentView, Map<EObject, View> viewMap) {
+ initializeElement(viewMap);
+ initializeBendpoints();
+ setType(Bpmn2VisualIDRegistry.getType(
+ Bpmn2VisualIDRegistry.getLinkWithClassVisualID(getElement())));
+ parentView.insertEdge(this);
+ }
+
+ private void initializeBendpoints() {
+ RelativeBendpoints bendpoints =
BpmnNotationFactory.INSTANCE.createRelativeBendpoints();
+ List<Point> waypoints = getBPMNEdge().getWaypoint();
+ ArrayList<RelativeBendpoint> points = new
ArrayList<RelativeBendpoint>(waypoints.size());
+ for (Point waypoint : waypoints) {
+ float sourceX = 0, sourceY = 0, targetX = 0, targetY = 0;
+ View source = getSource();
+ if (source instanceof BpmnShapeImpl) {
+ Bounds bounds = ((BpmnShapeImpl)source).getBPMNShape().getBounds();
+ sourceX = waypoint.getX() - bounds.getX();
+ sourceY = waypoint.getY() - bounds.getY();
+ }
+ View target = getTarget();
+ if (target instanceof BpmnShapeImpl) {
+ Bounds bounds = ((BpmnShapeImpl)target).getBPMNShape().getBounds();
+ targetX = waypoint.getX() - bounds.getX();
+ targetY = waypoint.getY() - bounds.getY();
+ }
+ points.add(new RelativeBendpoint((int)sourceX, (int)sourceY, (int)targetX,
(int)targetY));
+ }
+ bendpoints.setPoints(points);
+ setBendpoints(bendpoints);
+
+ }
+
+ private void initializeElement(Map<EObject, View> viewMap) {
+ EObject element = bpmnEdge.getBpmnElement();
+ if (element != null) {
+ super.setElement(element);
+ }
+ if (element instanceof SequenceFlow) {
+ SequenceFlow sequenceFlow = (SequenceFlow)element;
+ FlowNode source = sequenceFlow.getSourceRef();
+ FlowNode target = sequenceFlow.getTargetRef();
+ View sourceView = viewMap.get(source);
+ View targetView = viewMap.get(target);
+ setSource(sourceView);
+ setTarget(targetView);
+ }
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnEdgeImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnLabelImpl.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnLabelImpl.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnLabelImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnLabelImpl.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,39 @@
+package org.jboss.tools.bpmn2.gmf.notation;
+
+import org.eclipse.bpmn2.di.BPMNLabel;
+import org.eclipse.dd.dc.Bounds;
+import org.eclipse.gmf.runtime.notation.DecorationNode;
+import org.eclipse.gmf.runtime.notation.LayoutConstraint;
+import org.eclipse.gmf.runtime.notation.impl.DecorationNodeImpl;
+
+public class BpmnLabelImpl extends DecorationNodeImpl implements DecorationNode {
+
+ BPMNLabel bpmnLabel;
+
+ public BpmnLabelImpl(BPMNLabel label) {
+ this.bpmnLabel = label;
+ initializeLocation();
+ }
+
+ public BPMNLabel getBPMNLabel() {
+ return bpmnLabel;
+ }
+
+ private void initializeLocation() {
+ Bounds bounds = bpmnLabel.getBounds();
+ if (bounds != null) {
+ super.setLayoutConstraint(BpmnNotationFactory.INSTANCE
+ .createBounds(bounds));
+ }
+ }
+
+ @Override
+ public void setLayoutConstraint(LayoutConstraint layoutConstraint) {
+ super.setLayoutConstraint(layoutConstraint);
+ if (layoutConstraint instanceof BpmnBoundsImpl) {
+ bpmnLabel.setBounds(((BpmnBoundsImpl) layoutConstraint)
+ .getBPMNBounds());
+ }
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnLabelImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnNotationFactory.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnNotationFactory.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnNotationFactory.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnNotationFactory.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,62 @@
+package org.jboss.tools.bpmn2.gmf.notation;
+
+import org.eclipse.bpmn2.di.BPMNDiagram;
+import org.eclipse.bpmn2.di.BPMNEdge;
+import org.eclipse.bpmn2.di.BPMNLabel;
+import org.eclipse.bpmn2.di.BPMNShape;
+import org.eclipse.bpmn2.di.BpmnDiFactory;
+import org.eclipse.dd.dc.Bounds;
+import org.eclipse.dd.dc.DcFactory;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+public class BpmnNotationFactory {
+
+ public static BpmnNotationFactory INSTANCE = new BpmnNotationFactory();
+
+ public BpmnEdgeImpl createEdge() {
+ BPMNEdge bpmnEdge = BpmnDiFactory.eINSTANCE.createBPMNEdge();
+ bpmnEdge.setId(EcoreUtil.generateUUID());
+ return createEdge(bpmnEdge);
+ }
+
+ public BpmnEdgeImpl createEdge(BPMNEdge bpmnEdge) {
+ return new BpmnEdgeImpl(bpmnEdge);
+ }
+
+ public BpmnShapeImpl createShape() {
+ BPMNShape bpmnShape = BpmnDiFactory.eINSTANCE.createBPMNShape();
+ bpmnShape.setId(EcoreUtil.generateUUID());
+ return createShape(bpmnShape);
+ }
+
+ public BpmnShapeImpl createShape(BPMNShape bpmnShape) {
+ return new BpmnShapeImpl(bpmnShape);
+ }
+
+ public BpmnLabelImpl createLabel() {
+ BPMNLabel bpmnLabel = BpmnDiFactory.eINSTANCE.createBPMNLabel();
+ bpmnLabel.setId(EcoreUtil.generateUUID());
+ return createLabel(bpmnLabel);
+ }
+
+ public BpmnLabelImpl createLabel(BPMNLabel label) {
+ return new BpmnLabelImpl(label);
+ }
+
+ public BpmnBoundsImpl createBounds() {
+ return createBounds(DcFactory.eINSTANCE.createBounds());
+ }
+
+ public BpmnBoundsImpl createBounds(Bounds bounds) {
+ return new BpmnBoundsImpl(bounds);
+ }
+
+ public BpmnDiagramImpl createDiagram(BPMNDiagram bpmnDiagram) {
+ return new BpmnDiagramImpl(bpmnDiagram);
+ }
+
+ public BpmnBendpointsImpl createRelativeBendpoints() {
+ return new BpmnBendpointsImpl();
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnNotationFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnShapeImpl.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/gmf/notation/BpmnShapeImpl.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnShapeImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnShapeImpl.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,124 @@
+package org.jboss.tools.bpmn2.gmf.notation;
+
+import org.eclipse.bpmn2.BaseElement;
+import org.eclipse.bpmn2.di.BPMNLabel;
+import org.eclipse.bpmn2.di.BPMNPlane;
+import org.eclipse.bpmn2.di.BPMNShape;
+import org.eclipse.dd.dc.Bounds;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.gmf.runtime.notation.DecorationNode;
+import org.eclipse.gmf.runtime.notation.LayoutConstraint;
+import org.eclipse.gmf.runtime.notation.Shape;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2VisualIDRegistry;
+
+public class BpmnShapeImpl extends ShapeImpl implements Shape {
+
+ BPMNShape bpmnShape;
+
+ public BpmnShapeImpl(BPMNShape shape) {
+ this.bpmnShape = shape;
+ }
+
+ public void initialize(View parentView) {
+ initializeElement();
+ setType(Bpmn2VisualIDRegistry.getType(
+ Bpmn2VisualIDRegistry.getNodeVisualID(
+ parentView,
+ getElement())));
+ parentView.insertChild(this);
+ initializeBounds();
+ initializeLabel(parentView);
+ }
+
+ private void initializeElement() {
+ EObject element = bpmnShape.getBpmnElement();
+ if (element != null) {
+ super.setElement(element);
+ }
+ }
+
+ private void initializeLabel(View parentView) {
+ BPMNLabel bpmnLabel = bpmnShape.getLabel();
+ if (bpmnLabel != null) {
+ DecorationNode label = BpmnNotationFactory.INSTANCE.createLabel(bpmnLabel);
+ if (getElement() != null) {
+ int id = Bpmn2VisualIDRegistry.getLabelVisualId(parentView.getElement(),
getElement());
+ if (id != -1) {
+ label.setType(Bpmn2VisualIDRegistry.getType(id));
+ }
+ }
+ super.insertChild(label);
+ }
+ }
+
+ private void initializeBounds() {
+ Bounds bounds = bpmnShape.getBounds();
+ if (bounds != null) {
+ BpmnBoundsImpl bpmnBounds =
(BpmnBoundsImpl)BpmnNotationFactory.INSTANCE.createBounds(bounds);
+ super.setLayoutConstraint(bpmnBounds);
+ bpmnBounds.initialize(this);
+ }
+ }
+
+ public BPMNShape getBPMNShape() {
+ return bpmnShape;
+ }
+
+ @Override
+ public void setElement(EObject newElement) {
+ super.setElement(newElement);
+ if (newElement instanceof BaseElement) {
+ bpmnShape.setBpmnElement((BaseElement) newElement);
+ }
+ }
+
+ @Override
+ public void setLayoutConstraint(LayoutConstraint layoutConstraint) {
+ super.setLayoutConstraint(layoutConstraint);
+ if (layoutConstraint instanceof BpmnBoundsImpl) {
+ bpmnShape.setBounds(((BpmnBoundsImpl) layoutConstraint)
+ .getBPMNBounds());
+ }
+ }
+
+ @Override
+ public void insertChild(View child) {
+ super.insertChild(child);
+ if (child instanceof BpmnLabelImpl) {
+ insertLabel((BpmnLabelImpl) child);
+ } else if (child instanceof BpmnShapeImpl) {
+ insertShape((BpmnShapeImpl)child);
+ }
+ }
+
+ protected void insertLabel(BpmnLabelImpl label) {
+ bpmnShape.setLabel(label.getBPMNLabel());
+ }
+
+ protected void insertShape(BpmnShapeImpl shape) {
+ EObject container = bpmnShape.eContainer();
+ if (container instanceof BPMNPlane) {
+ BPMNPlane bpmnPlane = (BPMNPlane)container;
+ bpmnPlane.getPlaneElement().add(shape.getBPMNShape());
+ }
+ }
+
+ public void eNotify(Notification notifier) {
+ if (notifier.getEventType() == Notification.REMOVE) {
+ Object feature = notifier.getFeature();
+ if (feature instanceof EReference) {
+ String name = ((EReference) feature).getName();
+ Object oldValue = notifier.getOldValue();
+ if ("children".equals(name) && oldValue instanceof BpmnShapeImpl)
{
+ getDiagram().eNotify(notifier);
+ }
+ }
+ }
+ super.eNotify(notifier);
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/gmf/notation/BpmnShapeImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/figures
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/figures)
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySectionBis.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySectionBis.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySectionBis.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySectionBis.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,143 @@
+package org.jboss.tools.bpmn2.process.diagram.sheet;
+
+import org.eclipse.bpmn2.FlowElement;
+import org.eclipse.bpmn2.provider.Bpmn2ItemProviderAdapterFactory;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.gef.EditPart;
+import
org.eclipse.gmf.runtime.emf.ui.properties.sections.UndoableModelPropertySheetEntry;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+public class Bpmn2PropertySectionBis extends AbstractPropertySection {
+
+ private EObject selectedObject = null;
+ private TreeViewer treeViewer;
+ private PropertySheetPage propertySheetPage;
+ private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
+ private Composite master, details;
+
+ public void createControls(Composite parent, TabbedPropertySheetPage
tabbedPropertySheetPage) {
+ super.createControls(parent, tabbedPropertySheetPage);
+ final Composite composite = getWidgetFactory().createFlatFormComposite(parent);
+ createMasterArea(composite);
+ createDetailsArea(composite);
+ }
+
+ private void createMasterArea(Composite composite) {
+ master = getWidgetFactory().createComposite(composite);
+ master.setLayoutData(createMasterAreaLayoutData());
+ master.setLayout(new FormLayout());
+ Tree eventTree = getWidgetFactory().createTree(
+ master, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ eventTree.setLayoutData(createFillLayoutData());
+ treeViewer = new TreeViewer(eventTree);
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ treeViewer.setFilters(new ViewerFilter[] { new RootFilter(), new FlowElementFilter()
});
+ }
+
+ private FormData createMasterAreaLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(0, 150);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ private FormData createFillLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ private void createDetailsArea(Composite composite) {
+ details = getWidgetFactory().createComposite(composite, SWT.BORDER);
+ details.setLayoutData(createDetailsAreaLayoutData());
+ details.setLayout(new FormLayout());
+ propertySheetPage = new PropertySheetPage();
+ UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
+ OperationHistoryFactory.getOperationHistory());
+ root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
+ propertySheetPage.setRootEntry(root);
+ propertySheetPage.createControl(details);
+ propertySheetPage.getControl().setLayoutData(createFillLayoutData());
+ }
+
+ private FormData createDetailsAreaLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(master, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ public boolean shouldUseExtraSpace() {
+ return true;
+ }
+
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ selectedObject = unwrapSelection(selection);
+ treeViewer.setInput(selectedObject.eContainer());
+ StructuredSelection sel = new StructuredSelection(selectedObject);
+ treeViewer.setSelection(sel);
+ propertySheetPage.selectionChanged(part, sel);
+ }
+
+ private EObject unwrapSelection(ISelection selection) {
+ if (!(selection instanceof StructuredSelection)) {
+ return null;
+ }
+ Object object = ((StructuredSelection)selection).getFirstElement();
+ if (object == null || !(object instanceof EditPart)) {
+ return null;
+ }
+ object = ((EditPart)object).getModel();
+ if (object == null || !(object instanceof View)) {
+ return null;
+ }
+ return ((View)object).getElement();
+ }
+
+ class RootFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (parentElement == selectedObject.eContainer() && element != selectedObject)
{
+ return false;
+ }
+ return true;
+ }
+ }
+
+ class FlowElementFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (parentElement != selectedObject.eContainer() && element instanceof
FlowElement) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySectionBis.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,388 @@
+package org.jboss.tools.bpmn2.process.diagram.sheet;
+
+import org.eclipse.bpmn2.provider.Bpmn2ItemProviderAdapterFactory;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.gef.EditPart;
+import
org.eclipse.gmf.runtime.emf.ui.properties.sections.UndoableModelPropertySheetEntry;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
+
+public class Bpmn2PropertySheetPage extends PropertySheetPage {
+
+// private EObject selectedEditorObject = null;
+// private EObject selectedObject = null;
+ private Bpmn2DiagramEditor editor;
+// private Composite mainControl, masterArea, detailsArea;
+// private TreeViewer treeViewer;
+// private PropertySheetPage propertySheetPage;
+// private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
+// private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
+ private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
+
+ public Bpmn2PropertySheetPage(Bpmn2DiagramEditor editor) {
+ this.editor = editor;
+ UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
+ OperationHistoryFactory.getOperationHistory());
+ root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
+ setRootEntry(root);
+ }
+
+// @Override
+// public void createControl(Composite parent) {
+//// propertySheetPage = new PropertySheetPage();
+//// UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
+//// OperationHistoryFactory.getOperationHistory());
+//// root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
+//// propertySheetPage.setRootEntry(root);
+//// propertySheetPage.createControl(parent);
+//// propertySheetPage.getControl().setLayoutData(createFillLayoutData());
+// mainControl = createMainControl(parent);
+// createMasterArea(mainControl);
+// createDetailsArea(mainControl);
+// }
+//
+// public Composite createMainControl(Composite parent) {
+// Composite composite = editor.getFormToolkit().createComposite(parent);
+// FormLayout layout = new FormLayout();
+// layout.marginWidth = ITabbedPropertyConstants.HSPACE + 2;
+// layout.marginHeight = ITabbedPropertyConstants.VSPACE;
+// layout.spacing = ITabbedPropertyConstants.VMARGIN + 1;
+// composite.setLayout(layout);
+// return composite;
+// }
+//
+// private void createMasterArea(Composite composite) {
+// masterArea = editor.getFormToolkit().createComposite(composite);
+// masterArea.setLayoutData(createMasterAreaLayoutData());
+// masterArea.setLayout(new FormLayout());
+// Tree eventTree = editor.getFormToolkit().createTree(
+// masterArea, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.FULL_SELECTION);
+// eventTree.setLayoutData(createFillLayoutData());
+// popupMenu = createPopupMenu(eventTree);
+// eventTree.setMenu(popupMenu);
+// treeViewer = new TreeViewer(eventTree);
+// treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+// treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+// treeViewer.setFilters(new ViewerFilter[] { new RootFilter(), new FlowElementFilter()
});
+// treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+// @Override
+// public void selectionChanged(SelectionChangedEvent event) {
+// handleTreeViewerSelectionChanged(event);
+// }
+// });
+// }
+//
+// private void handleTreeViewerSelectionChanged(SelectionChangedEvent event) {
+// propertySheetPage.selectionChanged(null, event.getSelection());
+// EObject object = unwrapSelection(event.getSelection());
+// if (object != selectedObject) {
+// selectedObject = object;
+// }
+// }
+//
+// private EObject unwrapSelection(ISelection selection) {
+// EObject result = null;
+// if (selection instanceof IStructuredSelection) {
+// Object object = ((IStructuredSelection)selection).getFirstElement();
+// if (object != null && object instanceof EditPart) {
+// object = ((EditPart)object).getModel();
+// }
+// if (object != null && object instanceof View) {
+// result = ((View)object).getElement();
+// } else if (object instanceof EObject) {
+// result = (EObject)object;
+// }
+// }
+// return result;
+// }
+//
+// private FormData createMasterAreaLayoutData() {
+// FormData data = new FormData();
+// data.left = new FormAttachment(0, 0);
+// data.right = new FormAttachment(0, 200);
+// data.top = new FormAttachment(0, 0);
+// data.bottom = new FormAttachment(100, 0);
+// return data;
+// }
+//
+// private FormData createFillLayoutData() {
+// FormData data = new FormData();
+// data.left = new FormAttachment(0, 0);
+// data.right = new FormAttachment(100, 0);
+// data.top = new FormAttachment(0, 0);
+// data.bottom = new FormAttachment(100, 0);
+// return data;
+// }
+//
+// private void createDetailsArea(Composite composite) {
+// detailsArea = editor.getFormToolkit().createComposite(composite, SWT.BORDER);
+// detailsArea.setLayoutData(createDetailsAreaLayoutData());
+// detailsArea.setLayout(new FormLayout());
+// propertySheetPage = new PropertySheetPage();
+// UndoableModelPropertySheetEntry root = new UndoableModelPropertySheetEntry(
+// OperationHistoryFactory.getOperationHistory());
+// root.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
+// propertySheetPage.setRootEntry(root);
+// propertySheetPage.createControl(detailsArea);
+// propertySheetPage.getControl().setLayoutData(createFillLayoutData());
+// }
+//
+// private FormData createDetailsAreaLayoutData() {
+// FormData data = new FormData();
+// data.left = new FormAttachment(masterArea, 0);
+// data.right = new FormAttachment(100, 0);
+// data.top = new FormAttachment(0, 0);
+// data.bottom = new FormAttachment(100, 0);
+// return data;
+// }
+//
+// private Menu createPopupMenu(Composite composite) {
+// Menu popupMenu = new Menu(composite);
+// composite.setMenu(popupMenu);
+// popupMenu.addMenuListener(new MenuAdapter() {
+// public void menuShown(MenuEvent e) {
+// depopulatePopupMenu();
+// populatePopupMenu();
+// }
+// });
+// return popupMenu;
+// }
+//
+// private Object getTreeViewerSelectionUnwrapped() {
+// ISelection selection = treeViewer.getSelection();
+// if (selection instanceof IStructuredSelection) {
+// return ((IStructuredSelection)selection).getFirstElement();
+// }
+// return null;
+// }
+//
+// private void createAddChildSubmenu() {
+// MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+// addChildMenuItem.setText("&New Child");
+// addChildSubmenu = new Menu(addChildMenuItem);
+// addChildMenuItem.setMenu(addChildSubmenu);
+// Object obj = getTreeViewerSelectionUnwrapped();
+// Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(obj, null);
+// ArrayList<IAction> actions = new ArrayList<IAction>();
+// for (Object descriptor : descriptors) {
+// if (descriptor instanceof CommandParameter) {
+// CommandParameter commandParameter = (CommandParameter)descriptor;
+// Object value = commandParameter.getValue();
+// if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+// actions.add(new CreateChildAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+// }
+// }
+// addChildMenuItem.setEnabled(!actions.isEmpty());
+// for (final IAction action : actions) {
+// MenuItem menuItem = new MenuItem(addChildSubmenu, SWT.PUSH);
+// menuItem.setText(action.getText());
+// menuItem.setImage(action.getImageDescriptor().createImage());
+// menuItem.addSelectionListener(new SelectionAdapter() {
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// action.run();
+// }
+// });
+// }
+// }
+//
+// private void createAddSiblingSubmenu() {
+// MenuItem addSiblingMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+// addSiblingMenuItem.setText("N&ew Sibling");
+// addSiblingSubmenu = new Menu(addSiblingMenuItem);
+// addSiblingMenuItem.setMenu(addSiblingSubmenu);
+// if (!canEnableAddSibling()) {
+// addSiblingMenuItem.setEnabled(false);
+// } else {
+// Object obj = getTreeViewerSelectionUnwrapped();
+// Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(null, obj);
+// ArrayList<IAction> actions = new ArrayList<IAction>();
+// for (Object descriptor : descriptors) {
+// if (descriptor instanceof CommandParameter) {
+// CommandParameter commandParameter = (CommandParameter)descriptor;
+// Object value = commandParameter.getValue();
+// if (value instanceof FlowElement || value instanceof Artifact || !(value
instanceof BaseElement)) continue;
+// actions.add(new CreateSiblingAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+// }
+// }
+// addSiblingMenuItem.setEnabled(!actions.isEmpty());
+// for (final IAction action : actions) {
+// MenuItem menuItem = new MenuItem(addSiblingSubmenu, SWT.PUSH);
+// menuItem.setText(action.getText());
+// menuItem.setImage(action.getImageDescriptor().createImage());
+// menuItem.addSelectionListener(new SelectionAdapter() {
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// action.run();
+// }
+// });
+// }
+// }
+// }
+//
+// private boolean canEnableAddSibling() {
+// ISelection selection = treeViewer.getSelection();
+// if (selection instanceof IStructuredSelection) {
+// Object object = ((IStructuredSelection)selection).getFirstElement();
+// if (object != null && object instanceof EObject) {
+// return ((EObject)object).eContainer() != treeViewer.getInput();
+// }
+// }
+// return false;
+// }
+//
+// private void depopulatePopupMenu() {
+// disposePopupMenuItems(popupMenu);
+// }
+//
+// private void disposePopupMenuItems(Menu menu) {
+// for (MenuItem menuItem : menu.getItems()) {
+// Menu nestedMenu = menuItem.getMenu();
+// if (nestedMenu != null) {
+// disposePopupMenuItems(nestedMenu);
+// }
+// menuItem.dispose();
+// }
+// }
+//
+// private void populatePopupMenu() {
+// createAddChildSubmenu();
+// createAddSiblingSubmenu();
+// }
+//
+// @Override
+// public void dispose() {
+// popupMenu.dispose();
+// detailsArea.dispose();
+// masterArea.dispose();
+// mainControl.dispose();
+// }
+//
+// @Override
+// public Control getControl() {
+// return mainControl;
+// }
+//
+// @Override
+// public void setActionBars(IActionBars actionBars) {
+// // TODO Auto-generated method stub
+//
+// }
+//
+// @Override
+// public void setFocus() {
+// // TODO Auto-generated method stub
+//
+// }
+
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (part == editor) {
+ selection = new StructuredSelection(unwrapEditorSelection(selection));
+ }
+ super.selectionChanged(part, selection);
+// if (part == editor || part instanceof Bpmn2Details) {
+// EObject object = unwrapEditorSelection(selection);
+// if (object != selectedEditorObject) {
+// if (selectedEditorObject != null) {
+// selectedEditorObject.eAdapters().remove(selectedElementObserver);
+// }
+// selectedEditorObject = object;
+// if (selectedEditorObject != null) {
+// selectedEditorObject.eAdapters().add(selectedElementObserver);
+// treeViewer.setInput(selectedEditorObject.eContainer());
+// treeViewer.setSelection(new StructuredSelection(selectedEditorObject));
+// } else {
+// treeViewer.setInput(null);
+// treeViewer.setSelection(null);
+// }
+//
+// }
+// }
+// propertySheetPage.selectionChanged(null, selection);
+// EObject object = unwrapSelection(selection);
+// if (object != selectedObject) {
+// selectedObject = object;
+// propertySheetPage.selectionChanged(null, selection);
+// }
+ }
+
+ private EObject unwrapEditorSelection(ISelection selection) {
+ if (!(selection instanceof StructuredSelection)) {
+ return null;
+ }
+ Object object = ((StructuredSelection)selection).getFirstElement();
+ if (object == null || !(object instanceof EditPart)) {
+ return null;
+ }
+ object = ((EditPart)object).getModel();
+ if (object == null || !(object instanceof View)) {
+ return null;
+ }
+ return ((View)object).getElement();
+ }
+
+// class RootFilter extends ViewerFilter {
+// public boolean select(Viewer viewer, Object parentElement, Object element) {
+// if (parentElement == selectedEditorObject.eContainer() && element !=
selectedEditorObject) {
+// return false;
+// }
+// return true;
+// }
+// }
+//
+// class FlowElementFilter extends ViewerFilter {
+// public boolean select(Viewer viewer, Object parentElement, Object element) {
+// if (parentElement != selectedEditorObject.eContainer() && (element
instanceof FlowElement || element instanceof Artifact)) {
+// return false;
+// }
+// return true;
+// }
+// }
+//
+// private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
+// class SelectedElementObserver extends EContentAdapter {
+// public void notifyChanged(Notification notification) {
+// super.notifyChanged(notification);
+// handleSelectedElementChanged(notification);
+// }
+// }
+//
+// private void handleSelectedElementChanged(Notification notification) {
+// int eventType = notification.getEventType();
+// if (eventType == Notification.ADD || eventType == Notification.SET) {
+// Object object = notification.getNewValue();
+// if (object instanceof EObject) {
+// setIdIfNotSet((EObject)object);
+// updateTreeSelection(object);
+// }
+// }
+// }
+//
+// private void updateTreeSelection(final Object object) {
+// getControl().getDisplay().asyncExec(new Runnable() {
+// @Override
+// public void run() {
+// treeViewer.setSelection(new StructuredSelection(object));
+// }
+// });
+// }
+//
+// protected void setIdIfNotSet(EObject obj) {
+// if (obj.eClass() != null) {
+// EStructuralFeature idAttr = obj.eClass().getEIDAttribute();
+// if (idAttr != null && !obj.eIsSet(idAttr)) {
+// CommandParameter commandParameter = new CommandParameter(obj, idAttr,
EcoreUtil.generateUUID(), CommandParameter.NO_INDEX);
+// Command command =
editor.getEditingDomain().createCommand(SetCommand.class, commandParameter);
+// editor.getEditingDomain().getCommandStack().execute(command);
+// }
+// }
+// }
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/process/diagram/sheet/Bpmn2PropertySheetPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/util
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/util)
Modified:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/util/Bpmn2ResourceFactoryImpl.java
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/util/Bpmn2ResourceFactoryImpl.java 2010-12-13
17:41:25 UTC (rev 27417)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/util/Bpmn2ResourceFactoryImpl.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -19,7 +19,6 @@
private ResourceHandler resourceHandler = new Bpmn2ResourceHandlerImpl();
- @Override
public Resource createResource(URI uri) {
XMLResource result = (XMLResource)super.createResource(uri);
result.getDefaultLoadOptions().put(XMLResource.OPTION_RESOURCE_HANDLER,
resourceHandler);
@@ -29,12 +28,10 @@
class Bpmn2ResourceHandlerImpl implements ResourceHandler {
- @Override
public void preLoad(XMLResource resource, InputStream inputStream,
Map<?, ?> options) {
}
- @Override
public void postLoad(XMLResource resource, InputStream inputStream,
Map<?, ?> options) {
TreeIterator<EObject> contents = resource.getAllContents();
@@ -54,23 +51,10 @@
return BpmnNotationFactory.INSTANCE.createDiagram(bpmnDiagram);
}
- @Override
public void preSave(XMLResource resource, OutputStream outputStream,
Map<?, ?> options) {
}
-// private View getParentView(View candidate, View view) {
-// for (Object child : candidate.getVisibleChildren()) {
-// if (child == view) {
-// return candidate;
-// } else {
-// return getParentView((View)child, view);
-// }
-// }
-// return null;
-// }
-
- @Override
public void postSave(XMLResource resource, OutputStream outputStream,
Map<?, ?> options) {
}
@@ -78,16 +62,4 @@
}
-
-// private void prepareSave(Resource resource) {
-// EObject cur;
-// for (Iterator<EObject> iter = resource.getAllContents(); iter.hasNext();)
{
-// cur = iter.next();
-//
-// EStructuralFeature idAttr = cur.eClass().getEIDAttribute();
-// if (idAttr != null && !cur.eIsSet(idAttr)) {
-// cur.eSet(idAttr, EcoreUtil.generateUUID());
-// }
-// }
-// }
}
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,21 @@
+package org.jboss.tools.bpmn2.view;
+
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPageBookViewPage;
+
+public class Bpmn2Definitions extends Bpmn2Details {
+
+ protected PageRec doCreatePage(IWorkbenchPart part) {
+ Object obj = part.getAdapter(IBpmn2DefinitionsPage.class);
+ if (obj instanceof IBpmn2DefinitionsPage) {
+ IBpmn2DefinitionsPage page = (IBpmn2DefinitionsPage) obj;
+ if (page instanceof IPageBookViewPage) {
+ initPage((IPageBookViewPage) page);
+ }
+ page.createControl(getPageBook());
+ return new PageRec(part, page);
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Definitions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,332 @@
+package org.jboss.tools.bpmn2.view;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.bpmn2.Artifact;
+import org.eclipse.bpmn2.BaseElement;
+import org.eclipse.bpmn2.Definitions;
+import org.eclipse.bpmn2.FlowElement;
+import org.eclipse.bpmn2.Process;
+import org.eclipse.bpmn2.provider.Bpmn2ItemProviderAdapterFactory;
+import org.eclipse.dd.di.Diagram;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.Page;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
+
+public class Bpmn2DefinitionsPageImpl extends Page implements IBpmn2DefinitionsPage {
+
+ class FlowElementFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof Process || element instanceof Diagram) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ class SelectedElementObserver extends EContentAdapter {
+ public void notifyChanged(Notification notification) {
+ super.notifyChanged(notification);
+ handleSelectedElementChanged(notification);
+ }
+ }
+
+ private EObject selectedTreeObject = null;
+ private Bpmn2DiagramEditor editor;
+ private TreeViewer treeViewer;
+ private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
+ private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
+ private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
+
+ public Bpmn2DefinitionsPageImpl(Bpmn2DiagramEditor editor) {
+ this.editor = editor;
+ }
+
+ public void createControl(Composite parent) {
+ Tree eventTree = editor.getFormToolkit().createTree(
+ parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ eventTree.setLayoutData(createFillLayoutData());
+ popupMenu = createPopupMenu(eventTree);
+ eventTree.setMenu(popupMenu);
+ treeViewer = new TreeViewer(eventTree);
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ treeViewer.setAutoExpandLevel(2);
+ treeViewer.setFilters(new ViewerFilter[] { new FlowElementFilter() });
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleTreeViewerSelectionChanged(event);
+ }
+ });
+ Definitions definitions = getDefinitions();
+ if (definitions != null) {
+ definitions.eAdapters().add(selectedElementObserver);
+ treeViewer.setInput(getDefinitions().eContainer());
+ treeViewer.setSelection(new StructuredSelection(definitions));
+ selectedTreeObject = definitions;
+ }
+ }
+
+ private Definitions getDefinitions() {
+ EObject object = editor.getDiagram().getElement();
+ if (object == null || !(object instanceof Process)) {
+ return null;
+ }
+ object = ((Process)object).eContainer();
+ if (!(object instanceof Definitions)) {
+ return null;
+ } else {
+ return (Definitions)object;
+ }
+ }
+
+ private FormData createFillLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ private Menu createPopupMenu(Composite composite) {
+ Menu popupMenu = new Menu(composite);
+ composite.setMenu(popupMenu);
+ popupMenu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ depopulatePopupMenu();
+ populatePopupMenu();
+ }
+ });
+ return popupMenu;
+ }
+
+ private void handleTreeViewerSelectionChanged(SelectionChangedEvent event) {
+ ISelectionProvider selectionProvider = getSite().getSelectionProvider();
+ if (selectionProvider != null) {
+ selectionProvider.setSelection(event.getSelection());
+ }
+ EObject object = unwrapTreeViewerSelection(event.getSelection());
+ if (object != selectedTreeObject) {
+ selectedTreeObject = object;
+ }
+ }
+
+ private EObject unwrapTreeViewerSelection(ISelection selection) {
+ EObject result = null;
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EObject) {
+ result = (EObject)object;
+ }
+ }
+ return result;
+ }
+
+ private void populatePopupMenu() {
+ createAddChildSubmenu();
+ createAddSiblingSubmenu();
+ }
+
+ private void createAddChildSubmenu() {
+ MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addChildMenuItem.setText("&New Child");
+ addChildSubmenu = new Menu(addChildMenuItem);
+ addChildMenuItem.setMenu(addChildSubmenu);
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors = editor.getEditingDomain().getNewChildDescriptors(obj,
null);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateChildAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addChildMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addChildSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+
+ private void createAddSiblingSubmenu() {
+ MenuItem addSiblingMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addSiblingMenuItem.setText("N&ew Sibling");
+ addSiblingSubmenu = new Menu(addSiblingMenuItem);
+ addSiblingMenuItem.setMenu(addSiblingSubmenu);
+ if (!canEnableAddSibling()) {
+ addSiblingMenuItem.setEnabled(false);
+ } else {
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(null, obj);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateSiblingAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addSiblingMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addSiblingSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+ }
+
+ private boolean canEnableAddSibling() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EObject) {
+ return ((EObject)object).eContainer() != treeViewer.getInput();
+ }
+ }
+ return false;
+ }
+
+ private Object getTreeViewerSelectionUnwrapped() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ return ((IStructuredSelection)selection).getFirstElement();
+ }
+ return null;
+ }
+
+ private void depopulatePopupMenu() {
+ disposePopupMenuItems(popupMenu);
+ }
+
+ private void disposePopupMenuItems(Menu menu) {
+ for (MenuItem menuItem : menu.getItems()) {
+ Menu nestedMenu = menuItem.getMenu();
+ if (nestedMenu != null) {
+ disposePopupMenuItems(nestedMenu);
+ }
+ menuItem.dispose();
+ }
+ }
+
+ public Control getControl() {
+ return treeViewer.getControl();
+ }
+
+ public void setFocus() {
+ // Nothing to do
+
+ }
+
+ public void dispose() {
+ popupMenu.dispose();
+ Definitions definitions = getDefinitions();
+ if (definitions != null) {
+ definitions.eAdapters().remove(selectedElementObserver);
+ }
+ super.dispose();
+ }
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ }
+
+ private void handleSelectedElementChanged(Notification notification) {
+ int eventType = notification.getEventType();
+ if (eventType == Notification.ADD || eventType == Notification.SET) {
+ Object object = notification.getNewValue();
+ if (object instanceof EObject) {
+ setIdIfNotSet((EObject)object);
+ updateTreeSelection(object);
+ }
+ }
+ }
+
+ private void updateTreeSelection(final Object object) {
+ getControl().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ treeViewer.setSelection(new StructuredSelection(object), true);
+ }
+ });
+ }
+
+ protected void setIdIfNotSet(EObject obj) {
+ if (obj.eClass() != null) {
+ EStructuralFeature idAttr = obj.eClass().getEIDAttribute();
+ if (idAttr != null && !obj.eIsSet(idAttr)) {
+ CommandParameter commandParameter = new CommandParameter(obj, idAttr,
EcoreUtil.generateUUID(), CommandParameter.NO_INDEX);
+ Command command = editor.getEditingDomain().createCommand(SetCommand.class,
commandParameter);
+ editor.getEditingDomain().getCommandStack().execute(command);
+ }
+ }
+ }
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ treeViewer.addSelectionChangedListener(listener);
+ }
+
+ public ISelection getSelection() {
+ return treeViewer.getSelection();
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ treeViewer.removeSelectionChangedListener(listener);
+
+ }
+
+ public void setSelection(ISelection selection) {
+ // ignore
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DefinitionsPageImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Details.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2Details.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Details.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Details.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,119 @@
+package org.jboss.tools.bpmn2.view;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.MessagePage;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.PageBookView;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
+
+public class Bpmn2Details extends PageBookView implements ISelectionProvider,
+ ISelectionChangedListener {
+
+ private ISelection bootstrapSelection;
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ getSelectionProvider().addSelectionChangedListener(listener);
+ }
+
+ protected IPage createDefaultPage(PageBook book) {
+ MessagePage page = new MessagePage();
+ initPage(page);
+ page.createControl(book);
+ page.setMessage("Details are not available");
+ return page;
+ }
+
+ protected PageRec doCreatePage(IWorkbenchPart part) {
+ Object obj = part.getAdapter(IBpmn2DetailsPage.class);
+ if (obj instanceof IBpmn2DetailsPage) {
+ IBpmn2DetailsPage page = (IBpmn2DetailsPage) obj;
+ if (page instanceof IPageBookViewPage) {
+ initPage((IPageBookViewPage) page);
+ }
+ page.createControl(getPageBook());
+ return new PageRec(part, page);
+ }
+ return null;
+ }
+
+ protected void doDestroyPage(IWorkbenchPart part, PageRec rec) {
+ IBpmn2DetailsPage page = (IBpmn2DetailsPage) rec.page;
+ page.dispose();
+ rec.dispose();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class type) {
+ IWorkbenchPart currentPart = getCurrentContributingPart();
+ if (type == IPropertySheetPage.class && currentPart != null &&
currentPart instanceof Bpmn2DiagramEditor) {
+ return ((Bpmn2DiagramEditor)currentPart).getAdapter(type);
+ }
+ return super.getAdapter(type);
+ }
+
+ @Override
+ protected IWorkbenchPart getBootstrapPart() {
+ IWorkbenchPage page = getSite().getPage();
+ if (page != null) {
+ bootstrapSelection = page.getSelection();
+ return page.getActiveEditor();
+ }
+ return null;
+ }
+
+ @Override
+ public void partActivated(IWorkbenchPart part) {
+ super.partActivated(part);
+ if (bootstrapSelection != null) {
+ IPage page = getCurrentPage();
+ if (page != null && page instanceof IBpmn2DetailsPage) {
+ ((IBpmn2DetailsPage)page).selectionChanged(part, bootstrapSelection);
+ bootstrapSelection = null;
+ }
+ }
+ }
+
+ public ISelection getSelection() {
+ return getSelectionProvider().getSelection();
+ }
+
+ protected boolean isImportant(IWorkbenchPart part) {
+ return (part instanceof IEditorPart);
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+ partActivated(part);
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ getSelectionProvider().removeSelectionChangedListener(listener);
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ getSelectionProvider().selectionChanged(event);
+ }
+
+ public void setSelection(ISelection selection) {
+ getSelectionProvider().setSelection(selection);
+ }
+
+ protected void showPageRec(PageRec pageRec) {
+ IPageSite pageSite = getPageSite(pageRec.page);
+ ISelectionProvider provider = pageSite.getSelectionProvider();
+ if (provider == null && (pageRec.page instanceof IBpmn2DetailsPage)) {
+ pageSite.setSelectionProvider((IBpmn2DetailsPage) pageRec.page);
+ }
+ super.showPageRec(pageRec);
+ }
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2Details.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,356 @@
+package org.jboss.tools.bpmn2.view;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.bpmn2.Artifact;
+import org.eclipse.bpmn2.BaseElement;
+import org.eclipse.bpmn2.FlowElement;
+import org.eclipse.bpmn2.provider.Bpmn2ItemProviderAdapterFactory;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+import org.jboss.tools.bpmn2.process.diagram.part.Bpmn2DiagramEditor;
+
+public class Bpmn2DetailsPageImpl extends Page implements IBpmn2DetailsPage {
+
+ class RootFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (parentElement == selectedEditorObject.eContainer() && element !=
selectedEditorObject) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ class FlowElementFilter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (parentElement != selectedEditorObject.eContainer() && (element instanceof
FlowElement || element instanceof Artifact)) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ class SelectedElementObserver extends EContentAdapter {
+ public void notifyChanged(Notification notification) {
+ super.notifyChanged(notification);
+ handleSelectedElementChanged(notification);
+ }
+ }
+
+ private EObject selectedEditorObject = null;
+ private EObject selectedTreeObject = null;
+ private Bpmn2DiagramEditor editor;
+ private TreeViewer treeViewer;
+ private AdapterFactory adapterFactory = new Bpmn2ItemProviderAdapterFactory();
+ private Menu popupMenu, addChildSubmenu, addSiblingSubmenu;
+ private SelectedElementObserver selectedElementObserver = new
SelectedElementObserver();
+
+ public Bpmn2DetailsPageImpl(Bpmn2DiagramEditor editor) {
+ this.editor = editor;
+ }
+
+ public void init(IPageSite site) {
+ site.getPage().addSelectionListener(this);
+ super.init(site);
+ }
+
+ public void createControl(Composite parent) {
+ Tree eventTree = editor.getFormToolkit().createTree(
+ parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ eventTree.setLayoutData(createFillLayoutData());
+ popupMenu = createPopupMenu(eventTree);
+ eventTree.setMenu(popupMenu);
+ treeViewer = new TreeViewer(eventTree);
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ treeViewer.setFilters(new ViewerFilter[] { new RootFilter(), new FlowElementFilter()
});
+ treeViewer.setAutoExpandLevel(2);
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleTreeViewerSelectionChanged(event);
+ }
+ });
+ }
+
+ private FormData createFillLayoutData() {
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, 0);
+ data.bottom = new FormAttachment(100, 0);
+ return data;
+ }
+
+ private Menu createPopupMenu(Composite composite) {
+ Menu popupMenu = new Menu(composite);
+ composite.setMenu(popupMenu);
+ popupMenu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ depopulatePopupMenu();
+ populatePopupMenu();
+ }
+ });
+ return popupMenu;
+ }
+
+ private void handleTreeViewerSelectionChanged(SelectionChangedEvent event) {
+ ISelectionProvider selectionProvider = getSite().getSelectionProvider();
+ if (selectionProvider != null) {
+ selectionProvider.setSelection(event.getSelection());
+ }
+ EObject object = unwrapTreeViewerSelection(event.getSelection());
+ if (object != selectedTreeObject) {
+ selectedTreeObject = object;
+ }
+ }
+
+ private EObject unwrapTreeViewerSelection(ISelection selection) {
+ EObject result = null;
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EObject) {
+ result = (EObject)object;
+ }
+ }
+ return result;
+ }
+
+ private void populatePopupMenu() {
+ createAddChildSubmenu();
+ createAddSiblingSubmenu();
+ }
+
+ private void createAddChildSubmenu() {
+ MenuItem addChildMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addChildMenuItem.setText("&New Child");
+ addChildSubmenu = new Menu(addChildMenuItem);
+ addChildMenuItem.setMenu(addChildSubmenu);
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors = editor.getEditingDomain().getNewChildDescriptors(obj,
null);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateChildAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addChildMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addChildSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+
+ private void createAddSiblingSubmenu() {
+ MenuItem addSiblingMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
+ addSiblingMenuItem.setText("N&ew Sibling");
+ addSiblingSubmenu = new Menu(addSiblingMenuItem);
+ addSiblingMenuItem.setMenu(addSiblingSubmenu);
+ if (!canEnableAddSibling()) {
+ addSiblingMenuItem.setEnabled(false);
+ } else {
+ Object obj = getTreeViewerSelectionUnwrapped();
+ Collection<?> descriptors =
editor.getEditingDomain().getNewChildDescriptors(null, obj);
+ ArrayList<IAction> actions = new ArrayList<IAction>();
+ for (Object descriptor : descriptors) {
+ if (descriptor instanceof CommandParameter) {
+ CommandParameter commandParameter = (CommandParameter)descriptor;
+ Object value = commandParameter.getValue();
+ if (value instanceof FlowElement || value instanceof Artifact || !(value instanceof
BaseElement)) continue;
+ actions.add(new CreateSiblingAction(editor.getEditingDomain(),
treeViewer.getSelection(), descriptor));
+ }
+ }
+ addSiblingMenuItem.setEnabled(!actions.isEmpty());
+ for (final IAction action : actions) {
+ MenuItem menuItem = new MenuItem(addSiblingSubmenu, SWT.PUSH);
+ menuItem.setText(action.getText());
+ menuItem.setImage(action.getImageDescriptor().createImage());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ action.run();
+ }
+ });
+ }
+ }
+ }
+
+ private boolean canEnableAddSibling() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+ if (object != null && object instanceof EObject) {
+ return ((EObject)object).eContainer() != treeViewer.getInput();
+ }
+ }
+ return false;
+ }
+
+ private Object getTreeViewerSelectionUnwrapped() {
+ ISelection selection = treeViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ return ((IStructuredSelection)selection).getFirstElement();
+ }
+ return null;
+ }
+
+ private void depopulatePopupMenu() {
+ disposePopupMenuItems(popupMenu);
+ }
+
+ private void disposePopupMenuItems(Menu menu) {
+ for (MenuItem menuItem : menu.getItems()) {
+ Menu nestedMenu = menuItem.getMenu();
+ if (nestedMenu != null) {
+ disposePopupMenuItems(nestedMenu);
+ }
+ menuItem.dispose();
+ }
+ }
+
+ public Control getControl() {
+ return treeViewer.getControl();
+ }
+
+ public void setFocus() {
+ // Nothing to do
+
+ }
+
+ public void dispose() {
+ super.dispose();
+ popupMenu.dispose();
+ }
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (part == editor) {
+ EObject object = unwrapEditorSelection(selection);
+ if (selectedEditorObject == null || object != selectedEditorObject) {
+ if (selectedEditorObject != null) {
+ selectedEditorObject.eAdapters().remove(selectedElementObserver);
+ }
+ selectedEditorObject = object;
+ if (selectedEditorObject != null) {
+ selectedEditorObject.eAdapters().add(selectedElementObserver);
+ treeViewer.setInput(selectedEditorObject.eContainer());
+ treeViewer.setSelection(new StructuredSelection(selectedEditorObject));
+ } else {
+ treeViewer.setInput(null);
+ treeViewer.setSelection(null);
+ }
+
+ }
+ }
+ }
+
+ private EObject unwrapEditorSelection(ISelection selection) {
+ if (!(selection instanceof StructuredSelection)) {
+ return null;
+ }
+ Object object = ((StructuredSelection)selection).getFirstElement();
+ if (object == null || !(object instanceof EditPart)) {
+ return null;
+ }
+ object = ((EditPart)object).getModel();
+ if (object == null || !(object instanceof View)) {
+ return null;
+ }
+ return ((View)object).getElement();
+ }
+
+ private void handleSelectedElementChanged(Notification notification) {
+ int eventType = notification.getEventType();
+ if (eventType == Notification.ADD || eventType == Notification.SET) {
+ Object object = notification.getNewValue();
+ if (object instanceof EObject) {
+ setIdIfNotSet((EObject)object);
+ updateTreeSelection(object);
+ }
+ }
+ }
+
+ private void updateTreeSelection(final Object object) {
+ getControl().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ treeViewer.setSelection(new StructuredSelection(object));
+ }
+ });
+ }
+
+ protected void setIdIfNotSet(EObject obj) {
+ if (obj.eClass() != null) {
+ EStructuralFeature idAttr = obj.eClass().getEIDAttribute();
+ if (idAttr != null && !obj.eIsSet(idAttr)) {
+ CommandParameter commandParameter = new CommandParameter(obj, idAttr,
EcoreUtil.generateUUID(), CommandParameter.NO_INDEX);
+ Command command = editor.getEditingDomain().createCommand(SetCommand.class,
commandParameter);
+ editor.getEditingDomain().getCommandStack().execute(command);
+ }
+ }
+ }
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ treeViewer.addSelectionChangedListener(listener);
+ }
+
+ public ISelection getSelection() {
+ return treeViewer.getSelection();
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ treeViewer.removeSelectionChangedListener(listener);
+
+ }
+
+ public void setSelection(ISelection selection) {
+ // ignore
+ }
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/Bpmn2DetailsPageImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,7 @@
+package org.jboss.tools.bpmn2.view;
+
+
+
+public interface IBpmn2DefinitionsPage extends IBpmn2DetailsPage {
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DefinitionsPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java
(from rev 27417,
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src-custom/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java)
===================================================================
---
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java
(rev 0)
+++
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java 2010-12-13
21:07:04 UTC (rev 27419)
@@ -0,0 +1,9 @@
+package org.jboss.tools.bpmn2.view;
+
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.part.IPage;
+
+public interface IBpmn2DetailsPage extends IPage, ISelectionListener, ISelectionProvider
{
+
+}
Property changes on:
trunk/bpmn/plugins/org.jboss.tools.bpmn2.process.diagram/src/org/jboss/tools/bpmn2/view/IBpmn2DetailsPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain