|
25 | 25 | import org.eclipse.emf.ecore.util.EcoreUtil;
|
26 | 26 | import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
|
27 | 27 | import org.eclipse.sirius.diagram.DDiagramElement;
|
| 28 | +import org.obeonetwork.dsl.bpmn2.Association; |
28 | 29 | import org.obeonetwork.dsl.bpmn2.BoundaryEvent;
|
29 | 30 | import org.obeonetwork.dsl.bpmn2.Bpmn2Factory;
|
30 | 31 | import org.obeonetwork.dsl.bpmn2.Bpmn2Package;
|
31 | 32 | import org.obeonetwork.dsl.bpmn2.ChoreographyTask;
|
32 | 33 | import org.obeonetwork.dsl.bpmn2.Collaboration;
|
33 | 34 | 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; |
34 | 39 | import org.obeonetwork.dsl.bpmn2.Definitions;
|
35 | 40 | import org.obeonetwork.dsl.bpmn2.EndEvent;
|
36 | 41 | import org.obeonetwork.dsl.bpmn2.EventBasedGateway;
|
37 | 42 | import org.obeonetwork.dsl.bpmn2.ExclusiveGateway;
|
| 43 | +import org.obeonetwork.dsl.bpmn2.ExtensionAttributeValue; |
38 | 44 | import org.obeonetwork.dsl.bpmn2.FlowElement;
|
39 | 45 | import org.obeonetwork.dsl.bpmn2.FlowElementsContainer;
|
40 | 46 | import org.obeonetwork.dsl.bpmn2.FlowNode;
|
41 | 47 | import org.obeonetwork.dsl.bpmn2.ImplicitThrowEvent;
|
42 | 48 | import org.obeonetwork.dsl.bpmn2.InclusiveGateway;
|
| 49 | +import org.obeonetwork.dsl.bpmn2.InputOutputSpecification; |
43 | 50 | import org.obeonetwork.dsl.bpmn2.InteractionNode;
|
44 | 51 | import org.obeonetwork.dsl.bpmn2.IntermediateCatchEvent;
|
45 | 52 | import org.obeonetwork.dsl.bpmn2.Lane;
|
@@ -130,13 +137,66 @@ public static void paste(EObject newContainer, DDiagramElement containerView, EO
|
130 | 137 | lane.getFlowNodeRefs().add((FlowNode) newElement);
|
131 | 138 | }
|
132 | 139 | }
|
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 | + } |
135 | 152 |
|
136 | 153 | // Copy Sirius and GMF styles
|
137 | 154 | CopySiriusGMFStylesHelper.copyStyles(newElement, containerView, oldId, newId);
|
138 | 155 | }
|
139 | 156 |
|
| 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 | + |
140 | 200 | public EList<FlowElement> getSubElements(EObject eo) {
|
141 | 201 | if (eo instanceof SubProcess) {
|
142 | 202 | return ((SubProcess) eo).getFlowElements();
|
|
0 commit comments