diff options
author | Christian W. Damus | 2013-12-05 22:53:00 +0000 |
---|---|---|
committer | Christian W. Damus | 2013-12-05 22:53:00 +0000 |
commit | 37092bc6e7a9e1e1d6adae9912da0776ffb25780 (patch) | |
tree | 4bd0c2e0bf04bb661fe79e3644b14abcf28de540 | |
parent | d5d3ebcf445d83aa6f28d9130fb04f96fe8bd322 (diff) | |
download | org.eclipse.uml2-37092bc6e7a9e1e1d6adae9912da0776ffb25780.tar.gz org.eclipse.uml2-37092bc6e7a9e1e1d6adae9912da0776ffb25780.tar.xz org.eclipse.uml2-37092bc6e7a9e1e1d6adae9912da0776ffb25780.zip |
[412912] Editor creates LiteralString for Enumeration Property default
https://bugs.eclipse.org/bugs/show_bug.cgi?id=412912
Re-use an existing InstanceValue (if any) for enumeration property/parameter.
Also update the InstanceValue item-provider to notify when its instance changes, because the label string depends on it.
4 files changed, 45 insertions, 14 deletions
diff --git a/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/InstanceValueItemProvider.java b/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/InstanceValueItemProvider.java index 8f4042fec..599e9b99c 100644 --- a/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/InstanceValueItemProvider.java +++ b/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/InstanceValueItemProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010 IBM Corporation, Embarcadero Technologies, and others. + * Copyright (c) 2005, 2013 IBM Corporation, Embarcadero Technologies, CEA, and others. * 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 @@ -9,8 +9,8 @@ * IBM - initial API and implementation * Kenn Hussey (Embarcadero Technologies) - 215418, 204200 * Kenn Hussey - 323181 + * Christian W. Damus (CEA) - 412912 * - * $Id: InstanceValueItemProvider.java,v 1.13 2010/09/28 21:00:19 khussey Exp $ */ package org.eclipse.uml2.uml.edit.providers; @@ -30,6 +30,7 @@ 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.ViewerNotification; import org.eclipse.uml2.common.util.UML2Util; import org.eclipse.uml2.uml.InstanceValue; import org.eclipse.uml2.uml.UMLPackage; @@ -145,6 +146,13 @@ public class InstanceValueItemProvider @Override public void notifyChanged(Notification notification) { updateChildren(notification); + + switch (notification.getFeatureID(InstanceValue.class)) { + case UMLPackage.INSTANCE_VALUE__INSTANCE : + fireNotifyChanged(new ViewerNotification(notification, + notification.getNotifier(), false, true)); + return; + } super.notifyChanged(notification); } diff --git a/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/ParameterItemProvider.java b/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/ParameterItemProvider.java index 34e70bc4a..ac6727afe 100644 --- a/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/ParameterItemProvider.java +++ b/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/ParameterItemProvider.java @@ -277,7 +277,7 @@ public class ParameterItemProvider * This adds a property descriptor for the Default feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated + * @generated NOT */ protected void addDefaultPropertyDescriptor(Object object) { itemPropertyDescriptors diff --git a/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/TypedElementDefaultPropertyDescriptor.java b/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/TypedElementDefaultPropertyDescriptor.java index 0cde4228f..c486f6097 100644 --- a/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/TypedElementDefaultPropertyDescriptor.java +++ b/plugins/org.eclipse.uml2.uml.edit/src/org/eclipse/uml2/uml/edit/providers/TypedElementDefaultPropertyDescriptor.java @@ -210,16 +210,39 @@ public class TypedElementDefaultPropertyDescriptor if (literal == null) { super.setPropertyValue(object, value); } else { - InstanceValue instance = UMLFactory.eINSTANCE - .createInstanceValue(); - instance.setInstance(literal); - if (editingDomain == null) { - setDefaultValue(element, instance); + EStructuralFeature defaultValueFeature = getDefaultValueFeature(element); + ValueSpecification existing = (ValueSpecification) element + .eGet(defaultValueFeature); + + if (existing instanceof InstanceValue) { + InstanceValue instance = (InstanceValue) existing; + + if (editingDomain == null) { + instance.setInstance(literal); + } else { + editingDomain + .getCommandStack() + .execute( + SetCommand + .create( + editingDomain, + instance, + UMLPackage.Literals.INSTANCE_VALUE__INSTANCE, + literal)); + } } else { - editingDomain.getCommandStack().execute( - SetCommand.create(editingDomain, element, - getDefaultValueFeature(element), - instance)); + InstanceValue instance = UMLFactory.eINSTANCE + .createInstanceValue(); + instance.setInstance(literal); + + if (editingDomain == null) { + setDefaultValue(element, instance); + } else { + editingDomain.getCommandStack().execute( + SetCommand.create(editingDomain, + element, defaultValueFeature, + instance)); + } } } break; diff --git a/plugins/org.eclipse.uml2.uml/model/UML.genmodel b/plugins/org.eclipse.uml2.uml/model/UML.genmodel index 89152e9ca..8d92a3113 100644 --- a/plugins/org.eclipse.uml2.uml/model/UML.genmodel +++ b/plugins/org.eclipse.uml2.uml/model/UML.genmodel @@ -3973,8 +3973,8 @@ </genOperations> </genClasses> <genClasses xsi:type="genmodel:GenClass" ecoreClass="UML.ecore#//InstanceValue"> - <genFeatures xsi:type="genmodel:GenFeature" notify="false" createChild="false" - propertySortChoices="true" ecoreFeature="ecore:EReference UML.ecore#//InstanceValue/instance"/> + <genFeatures xsi:type="genmodel:GenFeature" createChild="false" propertySortChoices="true" + ecoreFeature="ecore:EReference UML.ecore#//InstanceValue/instance"/> </genClasses> <genClasses xsi:type="genmodel:GenClass" ecoreClass="UML.ecore#//JoinNode"> <genFeatures xsi:type="genmodel:GenFeature" createChild="false" ecoreFeature="ecore:EAttribute UML.ecore#//JoinNode/isCombineDuplicate"/> |