Bug 516607

fixed creation of rootElement Process

Change-Id: I22e29ab9eda524aa7369d9fbc91a486fa17a386d
Signed-off-by: Ralph Soika <ralph.soika@imixs.com>
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/RootElementPropertiesAdapter.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/RootElementPropertiesAdapter.java
index 6bf3b58..978ba01 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/RootElementPropertiesAdapter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/adapters/properties/RootElementPropertiesAdapter.java
@@ -69,6 +69,7 @@
 		setObjectDescriptor(new RootElementObjectDescriptor<T>(this, object));
 	}
 	
+	@SuppressWarnings("hiding")
 	public class RootElementObjectDescriptor<T extends RootElement> extends ObjectDescriptor<T> {
 
 		public RootElementObjectDescriptor(ExtendedPropertiesAdapter<T> owner, T object) {
@@ -109,13 +110,21 @@
 			        		}
 			        	}
 					}
-					else if (rootElement instanceof Process) {
+					// If we are creating a process than 
+					// see issue #516607 
+					else if (rootElement instanceof Process  ) {
 						// The new object is a Process: if this is a Collaboration diagram
-						// make the new Process a Participant.
+						// we have to lookup for the Collaboration definition.
+						// If available, then we set the DefinitionalCollaborationRef for the new Process!
 						Process process = (Process) rootElement;
-						
+						// lookup for collaboration definition containers...
 						List<Collaboration> collaborations = ModelUtil.getAllRootElements(definitions, Collaboration.class);
 						for (Collaboration collaboration : collaborations) {
+							// take the first one
+							process.setDefinitionalCollaborationRef(collaboration);
+							break; 
+							// skip the next block - we don't want another participant... (see issue #516607)
+							/*
 							BPMNDiagram bpmnDiagram = DIUtils.findBPMNDiagram(collaboration);
 							if (bpmnDiagram!=null) {
 								bpmnDiagram.getPlane().setBpmnElement(process);
@@ -135,6 +144,7 @@
 					        	collaboration.getParticipants().add(defaultParticipant);
 			        			break;
 							}
+							*/
 						}
 					}