summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Wouters2014-03-27 08:49:48 (EDT)
committerLaurent Wouters2014-03-27 09:18:34 (EDT)
commit8702e07b1ef23818e0ae40e787434c3f890c1971 (patch)
tree08f46a0a466c7979f852751f414e867d596b1476
parent6594cae513986631c6c4744678d8c90ac6b19c70 (diff)
downloadorg.eclipse.papyrus-8702e07b1ef23818e0ae40e787434c3f890c1971.zip
org.eclipse.papyrus-8702e07b1ef23818e0ae40e787434c3f890c1971.tar.gz
org.eclipse.papyrus-8702e07b1ef23818e0ae40e787434c3f890c1971.tar.bz2
#431139: [Diagram Creation] Issues with the Viewpoint-based Diagram Creation commands
Fixing the auto-creation of diagram root https://bugs.eclipse.org/bugs/show_bug.cgi?id=431139 Signed-off-by: Laurent Wouters <laurent.wouters@cea.fr>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java30
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration.edit/src/org/eclipse/papyrus/infra/viewpoints/configuration/provider/ModelAutoCreateItemProvider.java23
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/META-INF/MANIFEST.MF4
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/custom-src/org/eclipse/papyrus/infra/viewpoints/configuration/ComplexTypePropertyDescriptor.java62
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/model/configuration.ecore4
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ConfigurationPackage.java12
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ModelAutoCreate.java14
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ConfigurationPackageImpl.java8
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ModelAutoCreateImpl.java70
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration60
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src-gen/org/eclipse/papyrus/sysml/diagram/internalblock/InternalBlockDiagramCreateCommand.java47
11 files changed, 177 insertions, 157 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java
index d78e6f1..d00760e 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java
@@ -16,7 +16,6 @@
package org.eclipse.papyrus.infra.gmfdiag.common;
import java.util.ArrayList;
-import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
@@ -28,7 +27,6 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.resource.Resource;
@@ -49,7 +47,6 @@ import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.commands.OpenDiagramCommand;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
@@ -67,9 +64,6 @@ import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
import org.eclipse.papyrus.uml.tools.model.UmlUtils;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
/**
* Command creating a new GMF diagram in Papyrus. This command is intended to be used in eclipse
@@ -155,20 +149,15 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
// We have a path for the root auto-creation
for (ModelAutoCreate auto : rule.getNewModelPath()) {
EReference ref = auto.getFeature();
- EClass type = auto.getCreationType();
+ String type = auto.getCreationType();
if (ref.isMany()) {
- EObject temp = create(element, ref, type);
- List list = (List) element.eGet(ref);
- list.add(temp);
- element = temp;
+ element = create(element, ref, type);
} else {
EObject temp = (EObject) element.eGet(ref);
if (temp != null) {
element = temp;
} else {
- temp = create(element, ref, type);
- element.eSet(ref, temp);
- element = temp;
+ element = create(element, ref, type);
}
}
}
@@ -192,8 +181,8 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
return diagram;
}
- private EObject create(EObject origin, EReference reference, EClass type) {
- IElementType itype = ElementTypeRegistry.getInstance().getElementType(type, clientContext);
+ private EObject create(EObject origin, EReference reference, String typeID) {
+ IElementType itype = ElementTypeRegistry.getInstance().getType(typeID);
CreateElementRequest request = new CreateElementRequest(origin, itype, reference);
ICommand command = service.getEditCommand(request);
IStatus status = null;
@@ -235,15 +224,6 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
}
/**
- * Get the current MultiDiagramEditor.
- */
- private IMultiDiagramEditor getMultiDiagramEditor() {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IEditorPart editorPart = page.getActiveEditor();
- return (IMultiDiagramEditor)editorPart;
- }
-
- /**
* Open popup to enter the new diagram name
*
* @param defaultValue
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration.edit/src/org/eclipse/papyrus/infra/viewpoints/configuration/provider/ModelAutoCreateItemProvider.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration.edit/src/org/eclipse/papyrus/infra/viewpoints/configuration/provider/ModelAutoCreateItemProvider.java
index 9fd76e4..e56e923 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration.edit/src/org/eclipse/papyrus/infra/viewpoints/configuration/provider/ModelAutoCreateItemProvider.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration.edit/src/org/eclipse/papyrus/infra/viewpoints/configuration/provider/ModelAutoCreateItemProvider.java
@@ -29,7 +29,10 @@ import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+import org.eclipse.papyrus.infra.viewpoints.configuration.ComplexTypePropertyDescriptor;
import org.eclipse.papyrus.infra.viewpoints.configuration.ConfigurationPackage;
import org.eclipse.papyrus.infra.viewpoints.configuration.EReferencePropertyDescriptor;
import org.eclipse.papyrus.infra.viewpoints.configuration.ModelAutoCreate;
@@ -128,7 +131,7 @@ public class ModelAutoCreateItemProvider
*/
protected void addCreationTypePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
- (createItemPropertyDescriptor
+ (new ComplexTypePropertyDescriptor(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ModelAutoCreate_creationType_feature"),
@@ -136,10 +139,10 @@ public class ModelAutoCreateItemProvider
ConfigurationPackage.Literals.MODEL_AUTO_CREATE__CREATION_TYPE,
true,
false,
- true,
- null,
+ false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
- null));
+ null)));
}
/**
@@ -164,12 +167,12 @@ public class ModelAutoCreateItemProvider
StringBuilder builder = new StringBuilder();
EClass origin = path.getOrigin();
EReference feature = path.getFeature();
- EClass target = path.getCreationType();
+ String target = path.getCreationType();
builder.append(origin != null ? origin.getName() : "?");
builder.append(".");
builder.append(feature != null ? feature.getName() : "?");
- builder.append(" => new ");
- builder.append(target != null ? target.getName() : "?");
+ builder.append(" = new ");
+ builder.append(target != null ? target : "?");
return builder.toString();
}
@@ -184,6 +187,12 @@ public class ModelAutoCreateItemProvider
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);
+
+ switch (notification.getFeatureID(ModelAutoCreate.class)) {
+ case ConfigurationPackage.MODEL_AUTO_CREATE__CREATION_TYPE:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
+ return;
+ }
super.notifyChanged(notification);
}
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/META-INF/MANIFEST.MF b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/META-INF/MANIFEST.MF
index c08080d..77657ef 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/META-INF/MANIFEST.MF
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/META-INF/MANIFEST.MF
@@ -7,9 +7,11 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jface,
org.eclipse.emf.ecore,
org.eclipse.emf.edit,
+ org.eclipse.gmf.runtime.emf.type.core,
org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.viewpoints.iso42010;bundle-version="1.0.0"
+ org.eclipse.papyrus.infra.viewpoints.iso42010;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.services.edit
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/custom-src/org/eclipse/papyrus/infra/viewpoints/configuration/ComplexTypePropertyDescriptor.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/custom-src/org/eclipse/papyrus/infra/viewpoints/configuration/ComplexTypePropertyDescriptor.java
new file mode 100755
index 0000000..856d1e9
--- /dev/null
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/custom-src/org/eclipse/papyrus/infra/viewpoints/configuration/ComplexTypePropertyDescriptor.java
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * 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:
+ * Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.viewpoints.configuration;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.services.edit.internal.context.TypeContext;
+
+/**
+ * Represents a descriptor for properties of type EClass
+ * This is used for the ModelAutoCreate.target property because we may want to create stereotyped elements
+ *
+ * @author Laurent Wouters
+ */
+public class ComplexTypePropertyDescriptor extends SurrogateItemPropertyDescriptor {
+ private static final Collection<EObject> empty = new ArrayList<EObject>();
+ private List<String> result;
+
+ public ComplexTypePropertyDescriptor(IItemPropertyDescriptor inner) {
+ super(inner);
+ result = new ArrayList<String>();
+ try {
+ IClientContext context = TypeContext.getContext();
+ IElementType[] types = ElementTypeRegistry.getInstance().getElementTypes(context);
+ if (types != null) {
+ for (IElementType type : types) {
+ result.add(type.getId());
+ }
+ }
+ Collections.sort(result);
+ } catch (ServiceException e) {
+ }
+ }
+
+ @Override
+ public Collection<?> getChoiceOfValues(Object object) {
+ EObject current = (EObject) object;
+ if (current == null)
+ return empty;
+ return result;
+ }
+}
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/model/configuration.ecore b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/model/configuration.ecore
index 6880924..566c4c7 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/model/configuration.ecore
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/model/configuration.ecore
@@ -106,7 +106,7 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="origin" lowerBound="1"
eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EClass" changeable="false"
volatile="true" transient="true" derived="true"/>
- <eStructuralFeatures xsi:type="ecore:EReference" name="creationType" lowerBound="1"
- eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EClass"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="creationType" lowerBound="1"
+ eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ConfigurationPackage.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ConfigurationPackage.java
index 6a415dd..0b9647e 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ConfigurationPackage.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ConfigurationPackage.java
@@ -1211,7 +1211,7 @@ public interface ConfigurationPackage extends EPackage {
int MODEL_AUTO_CREATE__ORIGIN = 1;
/**
- * The feature id for the '<em><b>Creation Type</b></em>' reference.
+ * The feature id for the '<em><b>Creation Type</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -1763,15 +1763,15 @@ public interface ConfigurationPackage extends EPackage {
EReference getModelAutoCreate_Origin();
/**
- * Returns the meta object for the reference '{@link org.eclipse.papyrus.infra.viewpoints.configuration.ModelAutoCreate#getCreationType <em>Creation Type</em>}'.
+ * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.viewpoints.configuration.ModelAutoCreate#getCreationType <em>Creation Type</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for the reference '<em>Creation Type</em>'.
+ * @return the meta object for the attribute '<em>Creation Type</em>'.
* @see org.eclipse.papyrus.infra.viewpoints.configuration.ModelAutoCreate#getCreationType()
* @see #getModelAutoCreate()
* @generated
*/
- EReference getModelAutoCreate_CreationType();
+ EAttribute getModelAutoCreate_CreationType();
/**
* Returns the factory that creates the instances of the model.
@@ -2217,12 +2217,12 @@ public interface ConfigurationPackage extends EPackage {
EReference MODEL_AUTO_CREATE__ORIGIN = eINSTANCE.getModelAutoCreate_Origin();
/**
- * The meta object literal for the '<em><b>Creation Type</b></em>' reference feature.
+ * The meta object literal for the '<em><b>Creation Type</b></em>' attribute feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- EReference MODEL_AUTO_CREATE__CREATION_TYPE = eINSTANCE.getModelAutoCreate_CreationType();
+ EAttribute MODEL_AUTO_CREATE__CREATION_TYPE = eINSTANCE.getModelAutoCreate_CreationType();
}
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ModelAutoCreate.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ModelAutoCreate.java
index 6880563..5554224 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ModelAutoCreate.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/ModelAutoCreate.java
@@ -78,29 +78,29 @@ public interface ModelAutoCreate extends EObject {
EClass getOrigin();
/**
- * Returns the value of the '<em><b>Creation Type</b></em>' reference.
+ * Returns the value of the '<em><b>Creation Type</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Creation Type</em>' reference isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
- * @return the value of the '<em>Creation Type</em>' reference.
- * @see #setCreationType(EClass)
+ * @return the value of the '<em>Creation Type</em>' attribute.
+ * @see #setCreationType(String)
* @see org.eclipse.papyrus.infra.viewpoints.configuration.ConfigurationPackage#getModelAutoCreate_CreationType()
* @model required="true"
* @generated
*/
- EClass getCreationType();
+ String getCreationType();
/**
- * Sets the value of the '{@link org.eclipse.papyrus.infra.viewpoints.configuration.ModelAutoCreate#getCreationType <em>Creation Type</em>}' reference.
+ * Sets the value of the '{@link org.eclipse.papyrus.infra.viewpoints.configuration.ModelAutoCreate#getCreationType <em>Creation Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @param value the new value of the '<em>Creation Type</em>' reference.
+ * @param value the new value of the '<em>Creation Type</em>' attribute.
* @see #getCreationType()
* @generated
*/
- void setCreationType(EClass value);
+ void setCreationType(String value);
} // ModelAutoCreate
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ConfigurationPackageImpl.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ConfigurationPackageImpl.java
index 9eb2cf4..f71442a 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ConfigurationPackageImpl.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ConfigurationPackageImpl.java
@@ -653,8 +653,8 @@ public class ConfigurationPackageImpl extends EPackageImpl implements Configurat
* <!-- end-user-doc -->
* @generated
*/
- public EReference getModelAutoCreate_CreationType() {
- return (EReference)modelAutoCreateEClass.getEStructuralFeatures().get(2);
+ public EAttribute getModelAutoCreate_CreationType() {
+ return (EAttribute)modelAutoCreateEClass.getEStructuralFeatures().get(2);
}
/**
@@ -747,7 +747,7 @@ public class ConfigurationPackageImpl extends EPackageImpl implements Configurat
modelAutoCreateEClass = createEClass(MODEL_AUTO_CREATE);
createEReference(modelAutoCreateEClass, MODEL_AUTO_CREATE__FEATURE);
createEReference(modelAutoCreateEClass, MODEL_AUTO_CREATE__ORIGIN);
- createEReference(modelAutoCreateEClass, MODEL_AUTO_CREATE__CREATION_TYPE);
+ createEAttribute(modelAutoCreateEClass, MODEL_AUTO_CREATE__CREATION_TYPE);
}
/**
@@ -855,7 +855,7 @@ public class ConfigurationPackageImpl extends EPackageImpl implements Configurat
initEClass(modelAutoCreateEClass, ModelAutoCreate.class, "ModelAutoCreate", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getModelAutoCreate_Feature(), ecorePackage.getEReference(), null, "feature", null, 1, 1, ModelAutoCreate.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getModelAutoCreate_Origin(), ecorePackage.getEClass(), null, "origin", null, 1, 1, ModelAutoCreate.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
- initEReference(getModelAutoCreate_CreationType(), ecorePackage.getEClass(), null, "creationType", null, 1, 1, ModelAutoCreate.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getModelAutoCreate_CreationType(), ecorePackage.getEString(), "creationType", null, 1, 1, ModelAutoCreate.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// Create resource
createResource(eNS_URI);
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ModelAutoCreateImpl.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ModelAutoCreateImpl.java
index 4f404b4..d3c4ab5 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ModelAutoCreateImpl.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/src/org/eclipse/papyrus/infra/viewpoints/configuration/impl/ModelAutoCreateImpl.java
@@ -20,6 +20,8 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.papyrus.infra.viewpoints.configuration.ConfigurationPackage;
import org.eclipse.papyrus.infra.viewpoints.configuration.ModelAutoCreate;
import org.eclipse.papyrus.infra.viewpoints.configuration.OwningRule;
@@ -51,14 +53,24 @@ public class ModelAutoCreateImpl extends MinimalEObjectImpl.Container implements
protected EReference feature;
/**
- * The cached value of the '{@link #getCreationType() <em>Creation Type</em>}' reference.
+ * The default value of the '{@link #getCreationType() <em>Creation Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCreationType()
* @generated
* @ordered
*/
- protected EClass creationType;
+ protected static final String CREATION_TYPE_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getCreationType() <em>Creation Type</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getCreationType()
+ * @generated
+ * @ordered
+ */
+ protected String creationType = CREATION_TYPE_EDEFAULT;
/**
* <!-- begin-user-doc -->
@@ -137,24 +149,11 @@ public class ModelAutoCreateImpl extends MinimalEObjectImpl.Container implements
int index = list.indexOf(this);
if (index == 0)
return rule.getElement();
- return list.get(index - 1).getCreationType();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public EClass getCreationType() {
- if (creationType != null && creationType.eIsProxy()) {
- InternalEObject oldCreationType = (InternalEObject)creationType;
- creationType = (EClass)eResolveProxy(oldCreationType);
- if (creationType != oldCreationType) {
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.RESOLVE, ConfigurationPackage.MODEL_AUTO_CREATE__CREATION_TYPE, oldCreationType, creationType));
- }
- }
- return creationType;
+ String id = list.get(index - 1).getCreationType();
+ IElementType etype = ElementTypeRegistry.getInstance().getType(id);
+ if (etype == null)
+ return null;
+ return etype.getEClass();
}
/**
@@ -162,7 +161,7 @@ public class ModelAutoCreateImpl extends MinimalEObjectImpl.Container implements
* <!-- end-user-doc -->
* @generated
*/
- public EClass basicGetCreationType() {
+ public String getCreationType() {
return creationType;
}
@@ -171,8 +170,8 @@ public class ModelAutoCreateImpl extends MinimalEObjectImpl.Container implements
* <!-- end-user-doc -->
* @generated
*/
- public void setCreationType(EClass newCreationType) {
- EClass oldCreationType = creationType;
+ public void setCreationType(String newCreationType) {
+ String oldCreationType = creationType;
creationType = newCreationType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackage.MODEL_AUTO_CREATE__CREATION_TYPE, oldCreationType, creationType));
@@ -193,8 +192,7 @@ public class ModelAutoCreateImpl extends MinimalEObjectImpl.Container implements
if (resolve) return getOrigin();
return basicGetOrigin();
case ConfigurationPackage.MODEL_AUTO_CREATE__CREATION_TYPE:
- if (resolve) return getCreationType();
- return basicGetCreationType();
+ return getCreationType();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -211,7 +209,7 @@ public class ModelAutoCreateImpl extends MinimalEObjectImpl.Container implements
setFeature((EReference)newValue);
return;
case ConfigurationPackage.MODEL_AUTO_CREATE__CREATION_TYPE:
- setCreationType((EClass)newValue);
+ setCreationType((String)newValue);
return;
}
super.eSet(featureID, newValue);
@@ -229,7 +227,7 @@ public class ModelAutoCreateImpl extends MinimalEObjectImpl.Container implements
setFeature((EReference)null);
return;
case ConfigurationPackage.MODEL_AUTO_CREATE__CREATION_TYPE:
- setCreationType((EClass)null);
+ setCreationType(CREATION_TYPE_EDEFAULT);
return;
}
super.eUnset(featureID);
@@ -248,9 +246,25 @@ public class ModelAutoCreateImpl extends MinimalEObjectImpl.Container implements
case ConfigurationPackage.MODEL_AUTO_CREATE__ORIGIN:
return basicGetOrigin() != null;
case ConfigurationPackage.MODEL_AUTO_CREATE__CREATION_TYPE:
- return creationType != null;
+ return CREATION_TYPE_EDEFAULT == null ? creationType != null : !CREATION_TYPE_EDEFAULT.equals(creationType);
}
return super.eIsSet(featureID);
}
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (creationType: ");
+ result.append(creationType);
+ result.append(')');
+ return result.toString();
+ }
+
} //ModelAutoCreateImpl
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration
index 4751bf5..818cc30 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration
@@ -64,23 +64,20 @@
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Activity">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/classifierBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Activity"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Activity">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/ownedBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Activity"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Activity">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//Package/packagedElement"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Activity"/>
</newModelPath>
</owningRules>
<childRules/>
@@ -103,23 +100,20 @@
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Interaction">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/classifierBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Interaction"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Interaction">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/ownedBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Interaction"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Interaction">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//Package/packagedElement"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Interaction"/>
</newModelPath>
</owningRules>
<childRules/>
@@ -237,23 +231,20 @@
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Interaction">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/classifierBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Interaction"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Interaction">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/ownedBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Interaction"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Interaction">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//Package/packagedElement"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Interaction"/>
</newModelPath>
</owningRules>
<childRules/>
@@ -267,23 +258,20 @@
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.StateMachine">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/classifierBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//StateMachine"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.StateMachine">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/ownedBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//StateMachine"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.StateMachine">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//Package/packagedElement"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//StateMachine"/>
</newModelPath>
</owningRules>
<childRules/>
@@ -315,23 +303,20 @@
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Activity">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/classifierBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Activity"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Activity">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//BehavioredClassifier/ownedBehavior"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Activity"/>
</newModelPath>
</owningRules>
<owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
- <newModelPath>
+ <newModelPath creationType="org.eclipse.papyrus.uml.Activity">
<feature href="http://www.eclipse.org/uml2/5.0.0/UML#//Package/packagedElement"/>
- <creationType href="http://www.eclipse.org/uml2/5.0.0/UML#//Activity"/>
</newModelPath>
</owningRules>
<childRules/>
@@ -354,12 +339,15 @@
<stereotypes href="http://www.eclipse.org/papyrus/0.7.0/SysML#//blocks/Block"/>
</modelRules>
<owningRules>
- <element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
- </owningRules>
- <owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
<stereotypes href="http://www.eclipse.org/papyrus/0.7.0/SysML#//blocks/Block"/>
</owningRules>
+ <owningRules>
+ <element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
+ <newModelPath creationType="org.eclipse.papyrus.sysml.Block">
+ <feature href="http://www.eclipse.org/uml2/5.0.0/UML#//Package/packagedElement"/>
+ </newModelPath>
+ </owningRules>
<childRules/>
</modelKinds>
<modelKinds xsi:type="configuration:PapyrusDiagram" implementationID="Parametric" categories="//@categories.1">
@@ -382,12 +370,12 @@
<stereotypes href="http://www.eclipse.org/papyrus/0.7.0/SysML#//constraints/ConstraintBlock"/>
</modelRules>
<owningRules>
- <element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
- </owningRules>
- <owningRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Class"/>
<stereotypes href="http://www.eclipse.org/papyrus/0.7.0/SysML#//constraints/ConstraintBlock"/>
</owningRules>
+ <owningRules>
+ <element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
+ </owningRules>
<childRules/>
<paletteRules permit="false" element="parametric.tool.blockpropertycomposite"/>
<paletteRules permit="false" element="parametric.tool.reference"/>
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src-gen/org/eclipse/papyrus/sysml/diagram/internalblock/InternalBlockDiagramCreateCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src-gen/org/eclipse/papyrus/sysml/diagram/internalblock/InternalBlockDiagramCreateCommand.java
index a92567f..c19ef90 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src-gen/org/eclipse/papyrus/sysml/diagram/internalblock/InternalBlockDiagramCreateCommand.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src-gen/org/eclipse/papyrus/sysml/diagram/internalblock/InternalBlockDiagramCreateCommand.java
@@ -13,29 +13,20 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml.diagram.internalblock;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.infra.services.edit.utils.GMFCommandUtils;
import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
import org.eclipse.papyrus.sysml.blocks.Block;
import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes;
import org.eclipse.papyrus.sysml.diagram.internalblock.provider.ElementTypes;
-import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
import org.eclipse.papyrus.uml.diagram.common.commands.SemanticAdapter;
import org.eclipse.papyrus.uml.diagram.composite.part.UMLDiagramEditorPlugin;
import org.eclipse.uml2.uml.Element;
@@ -80,39 +71,13 @@ public class InternalBlockDiagramCreateCommand extends AbstractPapyrusGmfCreateD
// Start of user code Custom diagram creation
Diagram diagram = null;
- if (element instanceof org.eclipse.uml2.uml.Class) {
- org.eclipse.uml2.uml.Class cOwner = (org.eclipse.uml2.uml.Class)element;
- Block block = UMLUtil.getStereotypeApplication(cOwner, Block.class);
-
- if(block != null) {
- canvasDomainElement = (EObject)element;
- Package owningPackage = ((Element)element).getNearestPackage();
- diagram = super.doCreateDiagram(diagramResource, owner, owningPackage, prototype, name);
- }
-
- } else if (element instanceof Package) {
-
- try {
- canvasDomainElement = null;
-
- IEditCommandRequest request = new CreateElementRequest((Package)element, SysMLElementTypes.BLOCK);
- IElementEditService commandService = ElementEditServiceUtils.getCommandProvider(element);
- if(commandService == null) {
- return null;
- }
-
- ICommand createElementCommand = commandService.getEditCommand(request);
- if((createElementCommand != null) && (createElementCommand.canExecute())) {
- createElementCommand.execute(new NullProgressMonitor(), null);
- EObject block = GMFCommandUtils.getCommandEObjectResult(createElementCommand);
- canvasDomainElement = block;
- diagram = super.doCreateDiagram(diagramResource, owner, (Package)element, prototype, name);
- }
-
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
+ org.eclipse.uml2.uml.Class cOwner = (org.eclipse.uml2.uml.Class) element;
+ Block block = UMLUtil.getStereotypeApplication(cOwner, Block.class);
+ if (block != null) {
+ canvasDomainElement = (EObject) element;
+ Package owningPackage = ((Element) element).getNearestPackage();
+ diagram = super.doCreateDiagram(diagramResource, owner, owningPackage, prototype, name);
}
return diagram;