Bug 568098 - [Robotics, Component Diagram] A class is created instead of an Activity after a drag-n-drop

- Remove ThreadAdvice in library plugin

- Add ActivityEditHelperAdvice in core, Naming is based on NamingUtil now

- Remove Thread from library element-types, add advice to robotics element-types

- Palette points to ActivityEditHelperAdvice

- Avoid the use of RecordingCommand in advices, as it breaks undo/redo (e.g. activityInstance remains in model after undo)
	=> Also do that for Assertion, Contract and SkillDefinition advices

- Remove useless overloads in ConnectorEditHelperAdvice

Change-Id: I1069c0ac6d934f1f0e45caed4ae708a96103c661
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
diff --git a/plugins/assertions/org.eclipse.papyrus.robotics.assertions.types/src/org/eclipse/papyrus/robotics/assertions/types/advice/AssertionAdvice.java b/plugins/assertions/org.eclipse.papyrus.robotics.assertions.types/src/org/eclipse/papyrus/robotics/assertions/types/advice/AssertionAdvice.java
index a98bc94..00d4a2d 100644
--- a/plugins/assertions/org.eclipse.papyrus.robotics.assertions.types/src/org/eclipse/papyrus/robotics/assertions/types/advice/AssertionAdvice.java
+++ b/plugins/assertions/org.eclipse.papyrus.robotics.assertions.types/src/org/eclipse/papyrus/robotics/assertions/types/advice/AssertionAdvice.java
@@ -18,21 +18,22 @@
 
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.util.TransactionUtil;
 import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
 import org.eclipse.gmf.runtime.common.core.command.ICommand;
 import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
 import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
 import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
 import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
 import org.eclipse.papyrus.robotics.assertions.profile.assertions.Assertion;
 import org.eclipse.papyrus.robotics.assertions.profile.util.AssertionsResource;
 import org.eclipse.papyrus.robotics.core.types.advice.AbstractApplyStereotypeEditHelperAdvice;
 import org.eclipse.papyrus.robotics.core.utils.NamingUtil;
 import org.eclipse.uml2.uml.Class;
 import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.UMLPackage;
 
 public class AssertionAdvice extends AbstractApplyStereotypeEditHelperAdvice {
 
@@ -65,16 +66,18 @@
 			return super.getAfterConfigureCommand(request);
 		}
 		final Constraint assertion = (Constraint) newElement;
-
-		RecordingCommand defaultValue = new RecordingCommand(TransactionUtil.getEditingDomain(newElement)) {
-			@Override
-			protected void doExecute() {
-				NamingUtil.setName(assertion, ASSERTION_PREFIX);
-				assertion.getConstrainedElements().add(assertion.getContext());
-			}
-		};
-
-		compositeCommand.add(EMFtoGMFCommandWrapper.wrap(defaultValue));
+		
+		// set name element and constrained elements
+		final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(assertion);
+		SetRequest setAssertionNameReq = new SetRequest(assertion, UMLPackage.eINSTANCE.getNamedElement_Name(),
+				NamingUtil.getName(assertion, ASSERTION_PREFIX, "%04d")); //$NON-NLS-1$
+		ICommand setAssertionNameCmd = commandProvider.getEditCommand(setAssertionNameReq);
+		SetRequest setConstrainedElemReq = new SetRequest(assertion, UMLPackage.eINSTANCE.getConstraint_ConstrainedElement(),
+				assertion.getContext());
+		ICommand setConstrainedElemCmd = commandProvider.getEditCommand(setConstrainedElemReq);
+		
+		compositeCommand.add(setAssertionNameCmd);
+		compositeCommand.add(setConstrainedElemCmd);
 
 		return compositeCommand.isEmpty() ? super.getAfterConfigureCommand(request) : compositeCommand;
 	}
diff --git a/plugins/assertions/org.eclipse.papyrus.robotics.assertions.types/src/org/eclipse/papyrus/robotics/assertions/types/advice/ContractAdvice.java b/plugins/assertions/org.eclipse.papyrus.robotics.assertions.types/src/org/eclipse/papyrus/robotics/assertions/types/advice/ContractAdvice.java
index 86377c7..cd35222 100644
--- a/plugins/assertions/org.eclipse.papyrus.robotics.assertions.types/src/org/eclipse/papyrus/robotics/assertions/types/advice/ContractAdvice.java
+++ b/plugins/assertions/org.eclipse.papyrus.robotics.assertions.types/src/org/eclipse/papyrus/robotics/assertions/types/advice/ContractAdvice.java
@@ -18,21 +18,22 @@
 
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.util.TransactionUtil;
 import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
 import org.eclipse.gmf.runtime.common.core.command.ICommand;
 import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
 import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
 import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
 import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
 import org.eclipse.papyrus.robotics.assertions.profile.assertions.Contract;
 import org.eclipse.papyrus.robotics.assertions.profile.util.AssertionsResource;
 import org.eclipse.papyrus.robotics.core.types.advice.AbstractApplyStereotypeEditHelperAdvice;
 import org.eclipse.papyrus.robotics.core.utils.NamingUtil;
 import org.eclipse.uml2.uml.Class;
 import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.UMLPackage;
 
 public class ContractAdvice extends AbstractApplyStereotypeEditHelperAdvice {
 
@@ -66,14 +67,11 @@
 		}
 		final Comment contract = (Comment) newElement;
 
-		RecordingCommand setName = new RecordingCommand(TransactionUtil.getEditingDomain(newElement)) {
-			@Override
-			protected void doExecute() {
-				NamingUtil.setName(contract, CONTRACT_PREFIX);
-			}
-		};
-
-		compositeCommand.add(EMFtoGMFCommandWrapper.wrap(setName));
+		final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(contract);
+		SetRequest setContractBodyReq = new SetRequest(contract, UMLPackage.eINSTANCE.getComment_Body(),
+				NamingUtil.getName(contract, CONTRACT_PREFIX, "%04d")); //$NON-NLS-1$
+		ICommand setContractBodyCmd = commandProvider.getEditCommand(setContractBodyReq);
+		compositeCommand.add(setContractBodyCmd);
 
 		return compositeCommand.isEmpty() ? super.getAfterConfigureCommand(request) : compositeCommand;
 	}
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.core/elementtypes/robotics.elementtypesconfigurations b/plugins/customization/org.eclipse.papyrus.robotics.core/elementtypes/robotics.elementtypesconfigurations
index 480b721..d193e4e 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.core/elementtypes/robotics.elementtypesconfigurations
+++ b/plugins/customization/org.eclipse.papyrus.robotics.core/elementtypes/robotics.elementtypesconfigurations
@@ -2,11 +2,19 @@
 <elementtypesconfigurations:ElementTypeSetConfiguration xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:applystereotypeadvice="http://www.eclipse.org/papyrus/uml/types/applystereotypeadvice/1.1" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmlns:stereotypematcher="http://www.eclipse.org/papyrus/uml/types/stereotypematcher/1.1" xmi:id="org.eclipse.papyrus.robotics.elementTypes" identifier="org.eclipse.papyrus.robotics.elementTypes" name="robmosys" metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML">
   <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.robotics.Activity" identifier="org.eclipse.papyrus.robotics.Activity" name="Activity" hint="UML::Class" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
     <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_rLp94DjWEeivhYDKTmyYtg" iconPath="/icons/full/obj16/Class.gif" bundleId="org.eclipse.uml2.uml.edit"/>
+    <editHelperAdviceConfiguration xmi:type="elementtypesconfigurations:EditHelperAdviceConfiguration" xmi:id="_tbVJEBRTEeuP85G-C1t-gQ" editHelperAdviceClassName="org.eclipse.papyrus.robotics.core.types.advice.ActivityEditHelperAdvice"/>
     <matcherConfiguration xmi:type="stereotypematcher:StereotypeApplicationMatcherConfiguration" xmi:id="_rLp94TjWEeivhYDKTmyYtg">
       <stereotypesQualifiedNames>robotics::components::Activity</stereotypesQualifiedNames>
     </matcherConfiguration>
     <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.Class"/>
   </elementTypeConfigurations>
+  <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.robotics.ActivityInstance" identifier="org.eclipse.papyrus.robotics.ActivityInstance" name="ActivityInstance" hint="UML::Class" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
+    <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_rLp94DjWEeivhYDKTmyYtg" iconPath="/icons/full/obj16/Class.gif" bundleId="org.eclipse.uml2.uml.edit"/>
+    <matcherConfiguration xmi:type="stereotypematcher:StereotypeApplicationMatcherConfiguration" xmi:id="_rLp94TjWEeivhYDKTmyYtg">
+      <stereotypesQualifiedNames>robotics::components::ActivityInstance</stereotypesQualifiedNames>
+    </matcherConfiguration>
+    <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.Property"/>
+  </elementTypeConfigurations>
   <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.robotics.BehaviorArtefact" identifier="org.eclipse.papyrus.robotics.BehaviorArtefact" name="BehaviorArtefact" hint="UML::Artifact" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
     <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_rLp94jjWEeivhYDKTmyYtg" iconPath="/icons/full/obj16/Artifact.gif" bundleId="org.eclipse.uml2.uml.edit"/>
     <matcherConfiguration xmi:type="stereotypematcher:StereotypeApplicationMatcherConfiguration" xmi:id="_rLp94zjWEeivhYDKTmyYtg">
@@ -278,6 +286,11 @@
       <requiredProfiles>robotics::components</requiredProfiles>
     </stereotypesToApply>
   </adviceBindingsConfigurations>
+  <adviceBindingsConfigurations xmi:type="applystereotypeadvice:ApplyStereotypeAdviceConfiguration" xmi:id="_rLqlFjjWEeivhYDKTmyYtg" description="Activity" identifier="org.eclipse.papyrus.robotics.activityInstance" target="org.eclipse.papyrus.robotics.ActivityInstance">
+    <stereotypesToApply xmi:type="applystereotypeadvice:StereotypeToApply" xmi:id="_rLqlFzjWEeivhYDKTmyYtg" stereotypeQualifiedName="robotics::components::ActivityInstance" updateName="true">
+      <requiredProfiles>robotics::components</requiredProfiles>
+    </stereotypesToApply>
+  </adviceBindingsConfigurations>
   <adviceBindingsConfigurations xmi:type="applystereotypeadvice:ApplyStereotypeAdviceConfiguration" xmi:id="_rLqlGDjWEeivhYDKTmyYtg" description="BehaviorArtefact" identifier="org.eclipse.papyrus.robotics.behaviorArtefact" target="org.eclipse.papyrus.robotics.BehaviorArtefact">
     <stereotypesToApply xmi:type="applystereotypeadvice:StereotypeToApply" xmi:id="_rLrMADjWEeivhYDKTmyYtg" stereotypeQualifiedName="robotics::deployment::BehaviorArtefact" updateName="true">
       <requiredProfiles>robotics::deployment</requiredProfiles>
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/IRoboticElementTypes.java b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/IRoboticElementTypes.java
index ab6d89f..25df081 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/IRoboticElementTypes.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/IRoboticElementTypes.java
@@ -18,15 +18,17 @@
 /**
  * Declaration of all constants for robotic element types.
  */
+@SuppressWarnings("nls")
 public interface IRoboticElementTypes {
 
-	public static final String PREFIX = "org.eclipse.papyrus.robotics."; //$NON-NLS-1$
+	public static final String PREFIX = "org.eclipse.papyrus.robotics.";
 
-	public static final String COMPONENT_SERVICE_ID = PREFIX + "ComponentService"; //$NON-NLS-1$
+	public static final String COMPONENT_SERVICE_ID = PREFIX + "ComponentService";
 
-	public static final String IN_ATTRIBUTE_ID = PREFIX + "InAttribute"; //$NON-NLS-1$
-	public static final String OUT_ATTRIBUTE_ID = PREFIX + "OutAttribute"; //$NON-NLS-1$
-	public static final String SKILL_RESULT_ID = PREFIX + "SkillResult"; //$NON-NLS-1$
+	public static final String IN_ATTRIBUTE_ID = PREFIX + "InAttribute";
+	public static final String OUT_ATTRIBUTE_ID = PREFIX + "OutAttribute";
+	public static final String SKILL_RESULT_ID = PREFIX + "SkillResult";
 
-	public static final String PARAM_ENTRY_ID = PREFIX + "ParameterEntry"; //$NON-NLS-1$
+	public static final String PARAM_ENTRY_ID = PREFIX + "ParameterEntry";
+	public static final String ACTIVITY_INSTANCE_ID = PREFIX + "ActivityInstance";
 }
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/RoboticElementTypesEnumerator.java b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/RoboticElementTypesEnumerator.java
index f30d75a..200250a 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/RoboticElementTypesEnumerator.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/RoboticElementTypesEnumerator.java
@@ -30,4 +30,5 @@
 	public static final IHintedType SKILL_RESULT = (IHintedType) getElementType(SKILL_RESULT_ID);
 	
 	public static final IHintedType PARAM_ENTRY = (IHintedType) getElementType(PARAM_ENTRY_ID);
+	public static final IHintedType ACTIVITY_INSTANCE = (IHintedType) getElementType(ACTIVITY_INSTANCE_ID);
 }
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/advice/ActivityEditHelperAdvice.java b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/advice/ActivityEditHelperAdvice.java
new file mode 100644
index 0000000..01f3ec1
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/advice/ActivityEditHelperAdvice.java
@@ -0,0 +1,176 @@
+/*****************************************************************************
+ * Copyright (c) 2020 CEA LIST
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ *  ansgar.radermacher@cea.fr  - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.robotics.core.types.advice;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.robotics.core.types.RoboticElementTypesEnumerator;
+import org.eclipse.papyrus.robotics.core.utils.NamingUtil;
+import org.eclipse.papyrus.robotics.profile.robotics.components.ComponentDefinition;
+import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * Create additional activityInstance, when an activity get created.
+ */
+public class ActivityEditHelperAdvice extends AbstractEditHelperAdvice {
+
+	/**
+	 * Allow creation only if container is a component definition
+	 */
+	protected boolean approveCreateElementRequest(CreateElementRequest request) {
+		IElementType type = request.getElementType();
+		EObject container = request.getContainer();
+		if (type != null && container instanceof Class) {
+			if (StereotypeUtil.isApplied((Class) container, ComponentDefinition.class)) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	@Override
+	public boolean approveRequest(IEditCommandRequest request) {
+		if (request instanceof GetEditContextRequest) {
+			GetEditContextRequest context = (GetEditContextRequest) request;
+			if (context.getEditCommandRequest() instanceof CreateElementRequest) {
+				return approveCreateElementRequest((CreateElementRequest) context.getEditCommandRequest());
+			}
+		}
+		return super.approveRequest(request);
+	}
+
+	/**
+	 * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(ogrg.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)
+	 * 
+	 *      Add data-type.
+	 */
+	@Override
+	protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
+
+		// Get element from the request
+		EObject newElement = request.getElementToConfigure();
+
+		// Check it is a kind of Class
+		if (!(newElement instanceof Class)) {
+			// Activator.log.debug("");
+			return super.getAfterConfigureCommand(request);
+		}
+		Class activity = (Class) newElement;
+		// Check it is a nested Classifier of a ComponentDefinition
+		Element eClsOwner = activity.getOwner();
+		if (!(eClsOwner instanceof Class && StereotypeUtil.isApplied(eClsOwner, ComponentDefinition.class))) {
+			return super.getAfterConfigureCommand(request);
+		}
+		Class component = (Class) eClsOwner;
+
+		CompositeCommand compositeCommand = new CompositeCommand("Configure activity command"); //$NON-NLS-1$
+
+		final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(component);
+		CreateElementRequest createActInstReq = new CreateElementRequest(component, RoboticElementTypesEnumerator.ACTIVITY_INSTANCE);
+		ICommand createActInstCmd = commandProvider.getEditCommand(createActInstReq);
+		@SuppressWarnings("nls")
+		SetRequest setActivityNameReq = new SetRequest(activity, UMLPackage.eINSTANCE.getNamedElement_Name(),
+				NamingUtil.getName(activity, "Activity", "%02d"));
+		ICommand setActivityNameCmd = commandProvider.getEditCommand(setActivityNameReq);
+
+		// execute rest of command (after having obtained the command result), notably
+		// naming the activityInstance and setting its type
+		ICommand wrapper = new CompositeCommand("wrapper") { //$NON-NLS-1$
+
+			boolean first = true;
+
+			@Override
+			public boolean canExecute() {
+				if (first) {
+					return true;
+				}
+				return super.canExecute();
+			}
+
+			@Override
+			public IStatus execute(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+				if (first) {
+					Object result = createActInstCmd.getCommandResult().getReturnValue();
+					if (result instanceof Property) {
+						Property activityInst = (Property) result;
+						SetRequest setInstNameReq = new SetRequest(activityInst, UMLPackage.eINSTANCE.getNamedElement_Name(),
+								activity.getName().toLowerCase());
+						ICommand setInstNameCmd = commandProvider.getEditCommand(setInstNameReq);
+						add(setInstNameCmd);
+						SetRequest setInstTypeReq = new SetRequest(activityInst, UMLPackage.eINSTANCE.getTypedElement_Type(), activity);
+						ICommand setInstTypeCmd = commandProvider.getEditCommand(setInstTypeReq);
+						add(setInstTypeCmd);
+					}
+					first = false;
+
+				}
+				return super.execute(progressMonitor, info);
+			}
+		};
+		compositeCommand.add(createActInstCmd);
+		compositeCommand.add(setActivityNameCmd);
+		compositeCommand.add(wrapper);
+		return compositeCommand.isEmpty() ? super.getAfterConfigureCommand(request) : compositeCommand;
+	}
+
+	/**
+	 * Remove created activityInstance, if activity is destroyed
+	 */
+	@Override
+	protected ICommand getAfterDestroyDependentsCommand(DestroyDependentsRequest request) {
+		CompositeCommand compositeCommand = new CompositeCommand("activity instance destruction command"); //$NON-NLS-1$
+		EObject destroyElement = request.getElementToDestroy();
+		if (!(destroyElement instanceof Class)) {
+			return super.getAfterDestroyDependentsCommand(request);
+		}
+		final Class cls = (Class) destroyElement;
+		final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(cls);
+
+		for (Setting setting : UMLUtil.getNonNavigableInverseReferences(cls)) {
+			EObject propertyCandidate = setting.getEObject();
+			if (propertyCandidate instanceof Property) {
+				DestroyElementRequest destroyDepReq = new DestroyElementRequest(propertyCandidate, false);
+				ICommand destroyDepCmd = commandProvider.getEditCommand(destroyDepReq);
+				compositeCommand.add(destroyDepCmd);
+			}
+		}
+
+		return compositeCommand.isEmpty() ? super.getAfterDestroyDependentsCommand(request) : compositeCommand;
+	}
+}
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/advice/ConnectorEditHelperAdvice.java b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/advice/ConnectorEditHelperAdvice.java
index 282880e..e4bf12d 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/advice/ConnectorEditHelperAdvice.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/types/advice/ConnectorEditHelperAdvice.java
@@ -16,9 +16,7 @@
 package org.eclipse.papyrus.robotics.core.types.advice;
 
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
 import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
 import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
 import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
 import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
@@ -61,25 +59,6 @@
 		return false;
 	}
 
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest)
-	 */
-	@Override
-	protected ICommand getBeforeConfigureCommand(ConfigureRequest request) {
-		return super.getBeforeConfigureCommand(request);
-	}
-
-
-	/**
-	 * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)
-	 */
-	@Override
-	protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
-		return super.getAfterConfigureCommand(request);
-	}
-	
 	protected EObject source;
 	protected EObject target;
 }
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/utils/NamingUtil.java b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/utils/NamingUtil.java
index 600e994..2b1dcc8 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/utils/NamingUtil.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.core/src/org/eclipse/papyrus/robotics/core/utils/NamingUtil.java
@@ -24,37 +24,72 @@
 
 /**
  * Simple mechanism to provide a unique named (within the owning namespace) based on a prefix
- * and a 4 digit number 
+ * and a 4 digit number
  */
 public class NamingUtil {
-	public static void setName(NamedElement ne, String prefix) {
+	// max. number of distinguishable names
+	final public static int MAX_COUNT = 1000;
+
+	/**
+	 * Return a unique name for a named element
+	 * 
+	 * @param ne
+	 *            a named element
+	 * @param prefix
+	 *            the name prefix to use
+	 * @param format
+	 *            the number format to use, e.g. "%04d"
+	 */
+	public static String getName(NamedElement ne, String prefix, String format) {
 		List<String> existingNames = new ArrayList<String>();
 		for (NamedElement existingNE : ne.getNamespace().getMembers()) {
 			existingNames.add(existingNE.getName());
 		}
-		for(int index = 1; index < 1000; index++) {
-			String name = calcName(prefix, index);
+		for (int index = 1; index < MAX_COUNT; index++) {
+			String name = calcName(prefix, format, index);
 			if (!existingNames.contains(name)) {
-				ne.setName(name);
-				return;
+				return name;
 			}
 		}
+		return null;
 	}
-	
-	public static void setName(Comment comment, String prefix) {
+
+	/**
+	 * Return a unique name for a comment (largely duplicated code with setName for a named element),
+	 * 
+	 * @param comment
+	 *            a comment
+	 * @param prefix
+	 *            the name prefix to use
+	 * @param format
+	 *            the number format to use, e.g. "%04d"
+	 */
+	public static String getName(Comment comment, String prefix, String format) {
 		List<String> existingNames = new ArrayList<String>();
 		for (Comment existingComment : comment.getOwner().getOwnedComments()) {
 			existingNames.add(existingComment.getBody());
 		}
-		for(int index = 1; index < 1000; index++) {
-			String name = calcName(prefix, index);
+		for (int index = 1; index < MAX_COUNT; index++) {
+			String name = calcName(prefix, format, index);
 			if (!existingNames.contains(name)) {
-				comment.setBody(name);
-				return;
+				return name;
 			}
 		}
+		return null;
 	}
-	public static String calcName(String prefix, int index) {
-		return String.format("%s%04d", prefix, index); //$NON-NLS-1$
+
+	/**
+	 * Calculate the resulting name
+	 * 
+	 * @param prefix
+	 *            the name prefix to use
+	 * @param format
+	 *            a number format string
+	 * @param index
+	 *            the index number
+	 * @return
+	 */
+	protected static String calcName(String prefix, String format, int index) {
+		return String.format("%s" + format, prefix, index); //$NON-NLS-1$
 	}
 }
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.diagrams/resources/palettes/RoboticsComponentDiagram.paletteconfiguration b/plugins/customization/org.eclipse.papyrus.robotics.diagrams/resources/palettes/RoboticsComponentDiagram.paletteconfiguration
index fc7857c..6f64f80 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.diagrams/resources/palettes/RoboticsComponentDiagram.paletteconfiguration
+++ b/plugins/customization/org.eclipse.papyrus.robotics.diagrams/resources/palettes/RoboticsComponentDiagram.paletteconfiguration
@@ -47,7 +47,7 @@
     <ownedConfigurations xmi:type="paletteconfiguration:ToolConfiguration" id="palettemodel.org.eclipse.papyrus.robotics.diagram.rmscomponent.Activity" label="Activity" description="Create an Activity" kind="CreationTool">
       <icon xmi:type="paletteconfiguration:IconDescriptor" pluginID="org.eclipse.papyrus.robotics.profile" iconPath="/icons/Activity.png"/>
       <elementDescriptors xmi:type="paletteconfiguration:ElementDescriptor">
-        <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.robotics.library/elementtypes/library.di.elementtypesconfigurations#_PY4xIPqGEeek7fYJ-ff-Iw"/>
+        <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.robotics.diagrams/resources/elementtypes/robotics.di.elementtypesconfigurations#org.eclipse.papyrus.robotics.di.Activity_Class_Shape_CN"/>
       </elementDescriptors>
     </ownedConfigurations>
     <ownedConfigurations xmi:type="paletteconfiguration:ToolConfiguration" id="palettemodel.org.eclipse.papyrus.robotics.diagram.rmscomponent.ActivityPort" label="Activity Port" description="Create an activity port" kind="CreationTool">
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.diagrams/src/org/eclipse/papyrus/robotics/diagrams/Activator.java b/plugins/customization/org.eclipse.papyrus.robotics.diagrams/src/org/eclipse/papyrus/robotics/diagrams/Activator.java
index 916e259..84619d0 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.diagrams/src/org/eclipse/papyrus/robotics/diagrams/Activator.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.diagrams/src/org/eclipse/papyrus/robotics/diagrams/Activator.java
@@ -13,6 +13,7 @@
 package org.eclipse.papyrus.robotics.diagrams;
 
 import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
 import org.eclipse.papyrus.robotics.simplifiedui.ui.RoboticsPartListener;
 import org.eclipse.ui.IPartService;
 import org.eclipse.ui.IWorkbenchWindow;
@@ -30,6 +31,8 @@
 
 	private static Activator plugin;
 
+	public static LogHelper log;
+
 	/**
 	 * Returns an image descriptor for the image file at the given
 	 * plug-in relative path
@@ -45,6 +48,7 @@
 	@Override
 	public void start(BundleContext context) throws Exception {
 		super.start(context);
+		log = new LogHelper(this);
 		plugin = this;
 
 		IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.diagrams/src/org/eclipse/papyrus/robotics/diagrams/advices/SkillDefinitionEditHelperAdvice.java b/plugins/customization/org.eclipse.papyrus.robotics.diagrams/src/org/eclipse/papyrus/robotics/diagrams/advices/SkillDefinitionEditHelperAdvice.java
index 64af049..8b50d42 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.diagrams/src/org/eclipse/papyrus/robotics/diagrams/advices/SkillDefinitionEditHelperAdvice.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.diagrams/src/org/eclipse/papyrus/robotics/diagrams/advices/SkillDefinitionEditHelperAdvice.java
@@ -15,6 +15,7 @@
 
 package org.eclipse.papyrus.robotics.diagrams.advices;
 
+import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.emf.common.util.TreeIterator;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EStructuralFeature;
@@ -37,6 +38,7 @@
 import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
 import org.eclipse.papyrus.robotics.core.commands.CancelCommand;
 import org.eclipse.papyrus.robotics.core.utils.NamingUtil;
+import org.eclipse.papyrus.robotics.diagrams.Activator;
 import org.eclipse.papyrus.robotics.profile.robotics.skills.SkillDefinition;
 import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
 import org.eclipse.swt.widgets.Display;
@@ -93,7 +95,7 @@
 		StateMachine fsm = null;
 		if (op != null) {
 			SkillDefinition skdef =  UMLUtil.getStereotypeApplication(op, SkillDefinition.class);
-			if (skdef.getDefaultSemantic() != null) {
+			if (skdef != null && skdef.getDefaultSemantic() != null) {
 				fsm = skdef.getDefaultSemantic().getBase_StateMachine();
 			}
 		}
@@ -191,16 +193,18 @@
 		// (non-initialized class attributes to null, prepare the command, ...)
 		final Operation op = (Operation) newElement;
 		final Model umlModel = op.getModel();
-		CompositeCommand compositeCommand = new CompositeCommand("SkillDefinition configuration command");
+		CompositeCommand compositeCommand = new CompositeCommand("SkillDefinition configuration command"); //$NON-NLS-1$
 
-		// * Set a name for the skill definition
-		RecordingCommand setNameCmd = new RecordingCommand(TransactionUtil.getEditingDomain(op)){
-			@Override
-			protected void doExecute() {
-				NamingUtil.setName(op, SKILLDEF_PREFIX);
-			}
-		};
-		setNameCmd.execute();
+		final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(op);
+
+		SetRequest setSkillDefNameReq = new SetRequest(op, UMLPackage.eINSTANCE.getNamedElement_Name(),
+				NamingUtil.getName(op, SKILLDEF_PREFIX, "%04d")); //$NON-NLS-1$
+		ICommand setSkillDefNameCmd = commandProvider.getEditCommand(setSkillDefNameReq);
+		try {
+			setSkillDefNameCmd.execute(null, null);
+		} catch (ExecutionException ee) {
+			Activator.log.error(ee);
+		}
 
 		// * Copy the default semantics template to the 'defaultsemantics' package (provided by the wizard)
 		//
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.library/elementtypes/library.di.elementtypesconfigurations b/plugins/customization/org.eclipse.papyrus.robotics.library/elementtypes/library.di.elementtypesconfigurations
index 038fe6e..aaa32b8 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.library/elementtypes/library.di.elementtypesconfigurations
+++ b/plugins/customization/org.eclipse.papyrus.robotics.library/elementtypes/library.di.elementtypesconfigurations
@@ -1,9 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <elementtypesconfigurations:ElementTypeSetConfiguration xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmi:id="org.eclipse.papyrus.robotics.library.di.elementTypes" description="RobMoSys library element types" identifier="org.eclipse.papyrus.robotics.library.di.elementTypes" name="robmosys-di-library" metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML">
-  <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="_PY4xIPqGEeek7fYJ-ff-Iw" identifier="org.eclipse.papyrus.robotics.library.di.Thread" name="Thread Shape CN" hint="Class_Shape_CN" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
-    <specializedTypes xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.robotics.library/elementtypes/library.elementtypesconfigurations#org.eclipse.papyrus.robotics.library.Thread"/>
-    <specializedTypes xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.Class_Shape_CN"/>
-  </elementTypeConfigurations>
   <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.robotics.library.di.patterns.Push" identifier="org.eclipse.papyrus.robotics.library.di.patterns.Push" name="Push Shape (Comm pattern)" hint="Interface_Shape" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
     <specializedTypes xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.robotics.library/elementtypes/library.elementtypesconfigurations#org.eclipse.papyrus.robotics.library.patterns.Push"/>
     <specializedTypes xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.Interface_Shape"/>
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.library/elementtypes/library.elementtypesconfigurations b/plugins/customization/org.eclipse.papyrus.robotics.library/elementtypes/library.elementtypesconfigurations
index 852cfed..75baedb 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.library/elementtypes/library.elementtypesconfigurations
+++ b/plugins/customization/org.eclipse.papyrus.robotics.library/elementtypes/library.elementtypesconfigurations
@@ -1,10 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <elementtypesconfigurations:ElementTypeSetConfiguration xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmi:id="org.eclipse.papyrus.robotics.library.elementTypes" description="RobMoSys library element types" identifier="org.eclipse.papyrus.robotics.library.elementTypes" name="robmosys-library" metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML">
-  <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.robotics.library.Thread" identifier="org.eclipse.papyrus.robotics.library.Thread" name="Thread" hint="UML::Class" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
-    <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_SH21gLofEeeGRo_EXu8EmA" iconPath="/icons/full/obj16/Class.gif" bundleId="org.eclipse.uml2.uml.edit"/>
-    <matcherConfiguration xmi:type="elementtypesconfigurations:MatcherConfiguration" xmi:id="_SOVdEPn-Eee8c8wpObBu7w" matcherClassName="org.eclipse.papyrus.robotics.library.matcher.ThreadTypedElementMatcher"/>
-    <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.Class"/>
-  </elementTypeConfigurations>
   <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.robotics.library.patterns.Push" identifier="org.eclipse.papyrus.robotics.library.patterns.Push" name="Push (Comm pattern)" hint="" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
     <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_tvAFQPrZEeetU8XfwwzJPw" iconPath="/icons/full/obj16/Collaboration.gif" bundleId="org.eclipse.uml2.uml.edit"/>
     <matcherConfiguration xmi:type="elementtypesconfigurations:MatcherConfiguration" xmi:id="_x5XM4PrZEeetU8XfwwzJPw" matcherClassName="org.eclipse.papyrus.robotics.library.matcher.PushCommPatternMatcher"/>
@@ -30,7 +25,6 @@
     <matcherConfiguration xmi:type="elementtypesconfigurations:MatcherConfiguration" xmi:id="_pcyokj-KEkksdfJ3DBcRIw" matcherClassName="org.eclipse.papyrus.robotics.library.matcher.ActionCommPatternMatcher"/>
     <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.Interface"/>
   </elementTypeConfigurations>
-  <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="org.eclipse.papyrus.robotics.library.advice.Thread" description="Thread advice binding" identifier="org.eclipse.papyrus.robotics.library.advice.ThreadAdvice" target="org.eclipse.papyrus.robotics.library.Thread" editHelperAdviceClassName="org.eclipse.papyrus.robotics.library.advice.ThreadAdvice"/>
   <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_6d2WcPrZEeetU8XfwwzJPw" description="PushCommPattern advice binding" identifier="org.eclipse.papyrus.robotics.library.advice.PushCommPatternAdvice" target="org.eclipse.papyrus.robotics.library.patterns.Push" editHelperAdviceClassName="org.eclipse.papyrus.robotics.library.advice.PushCommPatternAdvice"/>
   <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_6o1ecPrZEeetU8XfwwzJPw" description="EventCommPattern advice binding" identifier="org.eclipse.papyrus.robotics.library.advice.EventCommPatternAdvice" target="org.eclipse.papyrus.robotics.library.patterns.Event" editHelperAdviceClassName="org.eclipse.papyrus.robotics.library.advice.EventCommPatternAdvice"/>
   <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_W4J3cD-EEeiGfvfxm_yE3A" description="QueryCommPattern advice binding" identifier="org.eclipse.papyrus.robotics.library.advice.QueryCommPatternAdvice" target="_OE__wD-EEeiGfvfxm_yE3A" editHelperAdviceClassName="org.eclipse.papyrus.robotics.library.advice.QueryCommPatternAdvice"/>
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/advice/ThreadAdvice.java b/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/advice/ThreadAdvice.java
deleted file mode 100644
index 772695c..0000000
--- a/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/advice/ThreadAdvice.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.eclipse.papyrus.robotics.library.advice;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.papyrus.designer.languages.common.base.ElementUtils;
-import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Property;
-
-public class ThreadAdvice extends AbstractEditHelperAdvice {
-
-	/**
-     * Allow creation only if container is a component definition
-     */
-    protected boolean approveCreateElementRequest(CreateElementRequest request) {
-        IElementType type = request.getElementType();
-        EObject container = request.getContainer();
-        if (type != null && container instanceof Class) {
-            if (StereotypeUtil.isApplied((Class) container, "robotics::components::ComponentDefinition")) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-	 * qualified name of the thread element within the RobMoSys library
-	 */
-	public static final String RMS_THREAD_QN = "robotics::execcontainer::Thread";
-
-    @Override
-    public boolean approveRequest(IEditCommandRequest request) {
-        if (request instanceof GetEditContextRequest) {
-            GetEditContextRequest context = (GetEditContextRequest) request;
-            if (context.getEditCommandRequest() instanceof CreateElementRequest) {
-                return approveCreateElementRequest((CreateElementRequest) context.getEditCommandRequest());
-            }
-        }
-        return super.approveRequest(request);
-    }
-
-	/**
-	 * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(ogrg.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)
-	 * 
-	 * Add data-type.
-	 */
-	@Override
-	protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
-
-		// Get element from the request
-		EObject newElement = request.getElementToConfigure();
-		
-		// Check it is a kind of Class
-		if (!(newElement instanceof Class)) {
-			//Activator.log.debug("");
-			return super.getAfterConfigureCommand(request);
-		}
-		Class cls = (Class) newElement;
-		// Check it is a nested Classifier of a ComponentDefinition
-		Element eClsOwner = cls.getOwner();
-		if (!(eClsOwner instanceof Class && StereotypeUtil.isApplied((Class) eClsOwner, "robotics::components::ComponentDefinition"))) {
-			//Activator.log.debug("");
-			return super.getAfterConfigureCommand(request);
-		}
-		Class clsOwner = (Class) eClsOwner;
-		// Check the associated RS element that corresponds to a Thread is a Classifier
-		NamedElement threadType = ElementUtils.getQualifiedElementFromRS(cls, RMS_THREAD_QN);
-		if (!(threadType instanceof Classifier)) {
-			//Activator.log.debug("");
-			return super.getAfterConfigureCommand(request);
-		}
-
-		// build commands
-		CompositeCommand compositeCommand = new CompositeCommand("Activity creation command");
-		RecordingCommand typeElement = new RecordingCommand(TransactionUtil.getEditingDomain(newElement)) {
-			@Override
-			protected void doExecute() {
-				// create generalization relationship so that the cls specializes Thread
-				cls.createGeneralization((Classifier) threadType);
-				// apply Activity stereotype to cls
-				StereotypeUtil.apply(cls, "robotics::components::Activity");
-				// give cls a name
-				int idx = 1;
-				List<String> allNamesOfExistingActivities = new ArrayList<String>();
-				for (Classifier c : clsOwner.getNestedClassifiers())
-					if (c instanceof Class && StereotypeUtil.isApplied(c,"robotics::components::Activity"))
-						allNamesOfExistingActivities.add(c.getName());
-				while(allNamesOfExistingActivities.contains("Activity"+idx))
-					idx = idx+1;
-				cls.setName("Activity"+idx);
-				// create a part that instantiates the nested classifier
-				Property clsPart = clsOwner.createOwnedAttribute("activity"+idx, cls);
-				// apply ActivityInstance stereotype to the part
-				StereotypeUtil.apply(clsPart, "robotics::components::ActivityInstance");
-			}
-		};
-		compositeCommand.add(EMFtoGMFCommandWrapper.wrap(typeElement));
-		return compositeCommand.isEmpty() ? super.getAfterConfigureCommand(request) : compositeCommand;
-	}
-	
-}
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/matcher/ThreadTypedElementMatcher.java b/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/matcher/ThreadTypedElementMatcher.java
deleted file mode 100644
index 23a042a..0000000
--- a/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/matcher/ThreadTypedElementMatcher.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.eclipse.papyrus.robotics.library.matcher;
-
-import org.eclipse.papyrus.robotics.library.advice.ThreadAdvice;
-
-public class ThreadTypedElementMatcher extends AbstractTypedElementMatcher {
-
-	protected boolean checkType(String qName) {
-		return (qName.equals(ThreadAdvice.RMS_THREAD_QN));
-	}
-}