Skip to content

Commit 4e9285b

Browse files
Stephane DrapeauStephane Drapeau
Stephane Drapeau
authored and
Stephane Drapeau
committed
Add copy/paste of Association and Data(Store|Object|Input|Output)
Change-Id: Id74e2f1b23133b3598008e44024fc205f1778b9a
1 parent 32158b9 commit 4e9285b

File tree

2 files changed

+76
-11
lines changed

2 files changed

+76
-11
lines changed

plugins/org.obeonetwork.dsl.bpmn2.design/src/org/obeonetwork/bpmn2/design/CopySiriusGMFStylesHelper.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,29 @@
4848
import org.obeonetwork.bpmn2.design.util.GMFStyleCopier;
4949
import org.obeonetwork.bpmn2.design.util.SiriusHelper;
5050
import org.obeonetwork.bpmn2.design.util.SiriusStyleCopier;
51+
import org.obeonetwork.dsl.bpmn2.Association;
5152
import org.obeonetwork.dsl.bpmn2.BoundaryEvent;
53+
import org.obeonetwork.dsl.bpmn2.DataInput;
54+
import org.obeonetwork.dsl.bpmn2.DataObject;
55+
import org.obeonetwork.dsl.bpmn2.DataOutput;
56+
import org.obeonetwork.dsl.bpmn2.DataStore;
5257
import org.obeonetwork.dsl.bpmn2.FlowNode;
5358
import org.obeonetwork.dsl.bpmn2.SequenceFlow;
5459

5560
public class CopySiriusGMFStylesHelper {
5661

5762
public static void copyStyles(EObject newElement, DDiagramElement containerView, String oldId, String newId) {
5863
if (newElement instanceof BoundaryEvent) {
59-
copyBoundaryEvent((BoundaryEvent) newElement, containerView, oldId, newId);
60-
} else if (newElement instanceof FlowNode) {
61-
copyFlowNode((FlowNode) newElement, containerView, oldId, newId);
62-
} else if (newElement instanceof SequenceFlow) {
63-
copySequenceFlow((SequenceFlow) newElement, containerView, oldId, newId);
64+
copyBoundaryNode(newElement, containerView, oldId, newId);
65+
} else if (newElement instanceof FlowNode || newElement instanceof DataStore || newElement instanceof DataObject
66+
|| newElement instanceof DataInput || newElement instanceof DataOutput) {
67+
copyNode(newElement, containerView, oldId, newId);
68+
} else if (newElement instanceof SequenceFlow || newElement instanceof Association) {
69+
copyEdge(newElement, containerView, oldId, newId);
6470
}
6571
}
6672

67-
private static void copyBoundaryEvent(BoundaryEvent newElement, DDiagramElement containerView, String oldId,
73+
private static void copyBoundaryNode(EObject newElement, DDiagramElement containerView, String oldId,
6874
String newId) {
6975
IWorkbench workbench = PlatformUI.getWorkbench();
7076
IWorkbenchPage[] pages = workbench.getActiveWorkbenchWindow().getPages();
@@ -104,7 +110,7 @@ protected void doExecute() {
104110
}
105111
}
106112

107-
private static void copyFlowNode(FlowNode newElement, DDiagramElement containerView, String oldId, String newId) {
113+
private static void copyNode(EObject newElement, DDiagramElement containerView, String oldId, String newId) {
108114
IWorkbench workbench = PlatformUI.getWorkbench();
109115
IWorkbenchPage[] pages = workbench.getActiveWorkbenchWindow().getPages();
110116
AbstractDNode oldAbstractDNode = SiriusHelper.getAbstractDNode(oldId, pages);
@@ -119,8 +125,7 @@ private static void copyFlowNode(FlowNode newElement, DDiagramElement containerV
119125
}
120126
}
121127

122-
private static void copySequenceFlow(SequenceFlow newElement, DDiagramElement containerView, String oldId,
123-
String newId) {
128+
private static void copyEdge(EObject newElement, DDiagramElement containerView, String oldId, String newId) {
124129
IWorkbench workbench = PlatformUI.getWorkbench();
125130
IWorkbenchPage[] pages = workbench.getActiveWorkbenchWindow().getPages();
126131
// Update edges asynchronously.

plugins/org.obeonetwork.dsl.bpmn2.design/src/org/obeonetwork/bpmn2/design/ProcessService.java

+62-2
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,28 @@
2525
import org.eclipse.emf.ecore.util.EcoreUtil;
2626
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
2727
import org.eclipse.sirius.diagram.DDiagramElement;
28+
import org.obeonetwork.dsl.bpmn2.Association;
2829
import org.obeonetwork.dsl.bpmn2.BoundaryEvent;
2930
import org.obeonetwork.dsl.bpmn2.Bpmn2Factory;
3031
import org.obeonetwork.dsl.bpmn2.Bpmn2Package;
3132
import org.obeonetwork.dsl.bpmn2.ChoreographyTask;
3233
import org.obeonetwork.dsl.bpmn2.Collaboration;
3334
import org.obeonetwork.dsl.bpmn2.ComplexGateway;
35+
import org.obeonetwork.dsl.bpmn2.DataInput;
36+
import org.obeonetwork.dsl.bpmn2.DataObject;
37+
import org.obeonetwork.dsl.bpmn2.DataOutput;
38+
import org.obeonetwork.dsl.bpmn2.DataStore;
3439
import org.obeonetwork.dsl.bpmn2.Definitions;
3540
import org.obeonetwork.dsl.bpmn2.EndEvent;
3641
import org.obeonetwork.dsl.bpmn2.EventBasedGateway;
3742
import org.obeonetwork.dsl.bpmn2.ExclusiveGateway;
43+
import org.obeonetwork.dsl.bpmn2.ExtensionAttributeValue;
3844
import org.obeonetwork.dsl.bpmn2.FlowElement;
3945
import org.obeonetwork.dsl.bpmn2.FlowElementsContainer;
4046
import org.obeonetwork.dsl.bpmn2.FlowNode;
4147
import org.obeonetwork.dsl.bpmn2.ImplicitThrowEvent;
4248
import org.obeonetwork.dsl.bpmn2.InclusiveGateway;
49+
import org.obeonetwork.dsl.bpmn2.InputOutputSpecification;
4350
import org.obeonetwork.dsl.bpmn2.InteractionNode;
4451
import org.obeonetwork.dsl.bpmn2.IntermediateCatchEvent;
4552
import org.obeonetwork.dsl.bpmn2.Lane;
@@ -130,13 +137,66 @@ public static void paste(EObject newContainer, DDiagramElement containerView, EO
130137
lane.getFlowNodeRefs().add((FlowNode) newElement);
131138
}
132139
}
133-
FlowElementsContainer flowElementsContainer = getFlowElementsContainer(newContainer);
134-
flowElementsContainer.getFlowElements().add((FlowElement) newElement);
140+
if (newElement instanceof FlowElement) {
141+
FlowElementsContainer flowElementsContainer = getFlowElementsContainer(newContainer);
142+
flowElementsContainer.getFlowElements().add((FlowElement) newElement);
143+
} else if (newElement instanceof DataStore || newElement instanceof DataObject
144+
|| newElement instanceof DataInput || newElement instanceof DataOutput) {
145+
setDataInContainer(newContainer, newElement);
146+
} else if (newElement instanceof Association) {
147+
Process process = ServiceHelper.getProcess(newContainer);
148+
if (process != null) {
149+
process.getArtifacts().add((Association) newElement);
150+
}
151+
}
135152

136153
// Copy Sirius and GMF styles
137154
CopySiriusGMFStylesHelper.copyStyles(newElement, containerView, oldId, newId);
138155
}
139156

157+
private static void setDataInContainer(EObject newContainer, EObject newElement) {
158+
if (newContainer instanceof Lane) {
159+
Lane lane = (Lane) newContainer;
160+
if (newElement instanceof DataStore || newElement instanceof DataObject) {
161+
ExtensionAttributeValue extensionAttributeValue = Bpmn2Factory.eINSTANCE
162+
.createExtensionAttributeValue();
163+
lane.getExtensionValues().add(extensionAttributeValue);
164+
extensionAttributeValue.setValue(newElement);
165+
} else if (newElement instanceof DataInput || newElement instanceof DataOutput) {
166+
if (lane.getPartitionElement() == null) {
167+
InputOutputSpecification ioSpec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
168+
lane.setPartitionElement(ioSpec);
169+
}
170+
if (newElement instanceof DataInput) {
171+
((InputOutputSpecification) lane.getPartitionElement()).getDataInputs().add((DataInput) newElement);
172+
} else if (newElement instanceof DataOutput) {
173+
((InputOutputSpecification) lane.getPartitionElement()).getDataOutputs()
174+
.add((DataOutput) newElement);
175+
}
176+
}
177+
} else if (newContainer instanceof SubProcess) {
178+
SubProcess process = (SubProcess) newContainer;
179+
if (newElement instanceof DataStore || newElement instanceof DataObject) {
180+
ExtensionAttributeValue extensionAttributeValue = Bpmn2Factory.eINSTANCE
181+
.createExtensionAttributeValue();
182+
process.getExtensionValues().add(extensionAttributeValue);
183+
extensionAttributeValue.setValue(newElement);
184+
} else if (newElement instanceof DataInput || newElement instanceof DataOutput) {
185+
if (process.getIoSpecification() == null) {
186+
InputOutputSpecification ioSpec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
187+
process.setIoSpecification(ioSpec);
188+
}
189+
if (newElement instanceof DataInput) {
190+
((InputOutputSpecification) process.getIoSpecification()).getDataInputs()
191+
.add((DataInput) newElement);
192+
} else if (newElement instanceof DataOutput) {
193+
((InputOutputSpecification) process.getIoSpecification()).getDataOutputs()
194+
.add((DataOutput) newElement);
195+
}
196+
}
197+
}
198+
}
199+
140200
public EList<FlowElement> getSubElements(EObject eo) {
141201
if (eo instanceof SubProcess) {
142202
return ((SubProcess) eo).getFlowElements();

0 commit comments

Comments
 (0)