From 8702e07b1ef23818e0ae40e787434c3f890c1971 Mon Sep 17 00:00:00 2001 From: Laurent Wouters Date: Thu, 27 Mar 2014 13:49:48 +0100 Subject: #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 --- ...tractPapyrusGmfCreateDiagramCommandHandler.java | 30 ++-------- .../provider/ModelAutoCreateItemProvider.java | 23 ++++--- .../META-INF/MANIFEST.MF | 4 +- .../ComplexTypePropertyDescriptor.java | 62 +++++++++++++++++++ .../model/configuration.ecore | 4 +- .../configuration/ConfigurationPackage.java | 12 ++-- .../viewpoints/configuration/ModelAutoCreate.java | 14 ++--- .../impl/ConfigurationPackageImpl.java | 8 +-- .../configuration/impl/ModelAutoCreateImpl.java | 70 +++++++++++++--------- .../builtin/default.configuration | 60 ++++++++----------- .../InternalBlockDiagramCreateCommand.java | 47 ++------------- 11 files changed, 177 insertions(+), 157 deletions(-) create mode 100755 plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.configuration/custom-src/org/eclipse/papyrus/infra/viewpoints/configuration/ComplexTypePropertyDescriptor.java (limited to 'plugins') 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 d78e6f1df0a..d00760e1448 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; @@ -234,15 +223,6 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst resource.getContents().add(root); } - /** - * 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 * 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 9fd76e42daa..e56e923826b 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 c08080d9874..77657ef5d3d 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 00000000000..856d1e9b1f4 --- /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 empty = new ArrayList(); + private List result; + + public ComplexTypePropertyDescriptor(IItemPropertyDescriptor inner) { + super(inner); + result = new ArrayList(); + 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 68809247223..566c4c72817 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 @@ - + 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 6a415ddccd7..0b9647e2f56 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 'Creation Type' reference. + * The feature id for the 'Creation Type' attribute. * * * @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 Creation Type}'. + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.viewpoints.configuration.ModelAutoCreate#getCreationType Creation Type}'. * * - * @return the meta object for the reference 'Creation Type'. + * @return the meta object for the attribute 'Creation Type'. * @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 'Creation Type' reference feature. + * The meta object literal for the 'Creation Type' attribute feature. * * * @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 6880563fbe1..5554224f4c9 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 'Creation Type' reference. + * Returns the value of the 'Creation Type' attribute. * *

* If the meaning of the 'Creation Type' reference isn't clear, * there really should be more of a description here... *

* - * @return the value of the 'Creation Type' reference. - * @see #setCreationType(EClass) + * @return the value of the 'Creation Type' 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 Creation Type}' reference. + * Sets the value of the '{@link org.eclipse.papyrus.infra.viewpoints.configuration.ModelAutoCreate#getCreationType Creation Type}' attribute. * * - * @param value the new value of the 'Creation Type' reference. + * @param value the new value of the 'Creation Type' 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 9eb2cf46154..f71442a11aa 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 * * @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 4f404b4ba70..d3c4ab5f01f 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() Creation Type}' reference. + * The default value of the '{@link #getCreationType() Creation Type}' attribute. * * * @see #getCreationType() * @generated * @ordered */ - protected EClass creationType; + protected static final String CREATION_TYPE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getCreationType() Creation Type}' attribute. + * + * + * @see #getCreationType() + * @generated + * @ordered + */ + protected String creationType = CREATION_TYPE_EDEFAULT; /** * @@ -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(); - } - - /** - * - * - * @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 * * @generated */ - public EClass basicGetCreationType() { + public String getCreationType() { return creationType; } @@ -171,8 +170,8 @@ public class ModelAutoCreateImpl extends MinimalEObjectImpl.Container implements * * @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); } + /** + * + * + * @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 4751bf58f5f..818cc30d113 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 @@ - + - - + - - + - @@ -103,23 +100,20 @@ - + - - + - - + - @@ -237,23 +231,20 @@ - + - - + - - + - @@ -267,23 +258,20 @@ - + - - + - - + - @@ -315,23 +303,20 @@ - + - - + - - + - @@ -353,13 +338,16 @@ - - - + + + + + + @@ -381,13 +369,13 @@ - - - + + + 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 a92567f3942..c19ef904233 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; -- cgit v1.2.3