Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-07-12 13:56:39 +0000
committercletavernie2011-07-12 13:56:39 +0000
commit438f5213cc000e7e1034637be7fa18a2a5759cf1 (patch)
treeeaa54dfbb488ef91258349672eb012e3af153300 /plugins
parent12b0836df0864010e2b485ef263ad420301b7712 (diff)
downloadorg.eclipse.papyrus-438f5213cc000e7e1034637be7fa18a2a5759cf1.tar.gz
org.eclipse.papyrus-438f5213cc000e7e1034637be7fa18a2a5759cf1.tar.xz
org.eclipse.papyrus-438f5213cc000e7e1034637be7fa18a2a5759cf1.zip
350682: [Sequence Diagram] Improve the Property Views for different kind of Messages
https://bugs.eclipse.org/bugs/show_bug.cgi?id=350682
Diffstat (limited to 'plugins')
-rw-r--r--plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/creation/EcorePropertyEditorFactory.java18
-rw-r--r--plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleReferenceEditor.java16
-rw-r--r--plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleValueEditor.java15
-rw-r--r--plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/ReferenceDialog.java13
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/creation/MessageValueSpecificationFactory.java152
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java48
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/InstanceValueContentProvider.java28
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/InstanceValueViewerFilter.java56
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/SignatureContentProvider.java5
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/SelectOrCreateDialogPropertyEditor.java9
10 files changed, 339 insertions, 21 deletions
diff --git a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/creation/EcorePropertyEditorFactory.java b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/creation/EcorePropertyEditorFactory.java
index 08ebb7144e8..43873af8215 100644
--- a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/creation/EcorePropertyEditorFactory.java
+++ b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/creation/EcorePropertyEditorFactory.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2010 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
@@ -40,13 +40,13 @@ import org.eclipse.swt.widgets.MenuItem;
*/
public class EcorePropertyEditorFactory extends PropertyEditorFactory {
- private EClass type;
+ protected EClass type;
- private EClass eClass;
+ protected EClass eClass;
- private String nsUri;
+ protected String nsUri;
- private String className;
+ protected String className;
/**
*
@@ -151,12 +151,12 @@ public class EcorePropertyEditorFactory extends PropertyEditorFactory {
return super.createObject(widget, instance);
}
- private EClass chooseEClass(Control widget) {
+ protected EClass chooseEClass(Control widget) {
if(eClass != null) {
return eClass;
}
- List<EClass> availableClasses = EMFHelper.getSubclassesOf(type, true);
+ List<EClass> availableClasses = getAvailableEClasses();
if(availableClasses.isEmpty()) {
return null;
}
@@ -206,6 +206,10 @@ public class EcorePropertyEditorFactory extends PropertyEditorFactory {
return eClass;
}
+ protected List<EClass> getAvailableEClasses() {
+ return EMFHelper.getSubclassesOf(type, true);
+ }
+
@Override
public Collection<Object> validateObjects(Collection<Object> objectsToValidate) {
return objectsToValidate;
diff --git a/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleReferenceEditor.java b/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleReferenceEditor.java
index 5cbb1c8fca3..bc8397ee4ff 100644
--- a/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleReferenceEditor.java
+++ b/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleReferenceEditor.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2010 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
@@ -14,6 +14,7 @@ package org.eclipse.papyrus.widgets.editors;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.widgets.providers.EmptyContentProvider;
+import org.eclipse.papyrus.widgets.providers.IAdaptableContentProvider;
import org.eclipse.papyrus.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.widgets.providers.WrappedLabelProvider;
import org.eclipse.papyrus.widgets.selectors.ReferenceSelector;
@@ -34,6 +35,8 @@ public class MultipleReferenceEditor extends MultipleValueEditor {
*/
protected ReferenceSelector selector;
+ protected IStaticContentProvider contentProvider;
+
/**
*
* Constructor.
@@ -93,9 +96,10 @@ public class MultipleReferenceEditor extends MultipleValueEditor {
* The label provider for the elements
*/
public void setProviders(IStaticContentProvider contentProvider, ILabelProvider labelProvider) {
-
Assert.isNotNull(contentProvider, "The content provider should be defined"); //$NON-NLS-1$
+ this.contentProvider = contentProvider;
+
selector.setContentProvider(contentProvider);
if(labelProvider != null) {
@@ -109,4 +113,12 @@ public class MultipleReferenceEditor extends MultipleValueEditor {
selector.setUnique(unique);
super.setUnique(unique);
}
+
+ @Override
+ protected Object adaptResult(Object result) {
+ if(contentProvider instanceof IAdaptableContentProvider) {
+ return ((IAdaptableContentProvider)contentProvider).getAdaptedValue(result);
+ }
+ return result;
+ }
}
diff --git a/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleValueEditor.java b/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleValueEditor.java
index 797f23fe7dc..0f17fc6e62c 100644
--- a/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleValueEditor.java
+++ b/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/MultipleValueEditor.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2010 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
@@ -371,7 +371,7 @@ public class MultipleValueEditor extends AbstractListEditor implements Selection
java.util.List<Object> resultElements = new LinkedList<Object>();
for(Object r : result) {
- resultElements.add(r);
+ resultElements.add(adaptResult(r));
}
modelProperty.addAll(resultElements);
@@ -379,6 +379,17 @@ public class MultipleValueEditor extends AbstractListEditor implements Selection
commit();
}
+ /**
+ * Transforms the selected result object to the actual
+ * semantic object, if needed
+ *
+ * @param result
+ * @return
+ */
+ protected Object adaptResult(Object result) {
+ return result;
+ }
+
@Override
protected void commit() {
super.commit();
diff --git a/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/ReferenceDialog.java b/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/ReferenceDialog.java
index e170e287891..0ad7672d7aa 100644
--- a/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/ReferenceDialog.java
+++ b/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/editors/ReferenceDialog.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2010 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
@@ -23,6 +23,7 @@ import org.eclipse.papyrus.widgets.Activator;
import org.eclipse.papyrus.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.widgets.messages.Messages;
import org.eclipse.papyrus.widgets.providers.EncapsulatedContentProvider;
+import org.eclipse.papyrus.widgets.providers.IAdaptableContentProvider;
import org.eclipse.papyrus.widgets.providers.IStaticContentProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
@@ -123,8 +124,8 @@ public class ReferenceDialog extends AbstractValueEditor implements IChangeListe
public void mouseDoubleClick(MouseEvent e) {
editAction(); // TODO : Try to determine whether the double
- // click should call the edit, create or browse
- // action
+ // click should call the edit, create or browse
+ // action
// e.g. if the value is null, try to browse. If we cannot
// browse, try to create an instance.
}
@@ -183,7 +184,11 @@ public class ReferenceDialog extends AbstractValueEditor implements IChangeListe
if(newValue.length == 0) {
modelProperty.setValue(null);
} else {
- modelProperty.setValue(newValue[0]);
+ Object value = newValue[0];
+ if(contentProvider instanceof IAdaptableContentProvider) {
+ value = ((IAdaptableContentProvider)contentProvider).getAdaptedValue(value);
+ }
+ modelProperty.setValue(value);
}
updateLabel();
}
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/creation/MessageValueSpecificationFactory.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/creation/MessageValueSpecificationFactory.java
new file mode 100644
index 00000000000..33b593f2dbf
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/creation/MessageValueSpecificationFactory.java
@@ -0,0 +1,152 @@
+package org.eclipse.papyrus.properties.uml.creation;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.properties.creation.EcorePropertyEditorFactory;
+import org.eclipse.papyrus.properties.util.EMFHelper;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.InstanceValue;
+import org.eclipse.uml2.uml.Message;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+public class MessageValueSpecificationFactory extends EcorePropertyEditorFactory {
+
+ /**
+ * The message in which the arguments will be created
+ */
+ protected Message parent;
+
+ /**
+ * Indicates the liberty we let to the user.
+ * If set to true, he won't be able to instantiate invalid elements,
+ * ie. he cannot instantiate arguments which don't correspond to an
+ * operation's parameter.
+ */
+ protected boolean restrictedInstantiation = false;
+
+ protected Set<ParameterDirectionKind> directions;
+
+ public MessageValueSpecificationFactory(EClass type, Message parent, Set<ParameterDirectionKind> directions) {
+ super(type);
+ this.parent = parent;
+ this.directions = directions;
+ }
+
+ @Override
+ protected List<EClass> getAvailableEClasses() {
+ List<EClass> allClasses = EMFHelper.getSubclassesOf(type, true);
+ List<EClass> result = new LinkedList<EClass>();
+ for(EClass eClass : allClasses) {
+ if(isValid(eClass)) {
+ result.add(eClass);
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object createObject(Control widget) {
+ EClass eClass = chooseEClass(widget);
+ if(eClass == null) {
+ return null;
+ }
+
+ EObject instance = eClass.getEPackage().getEFactoryInstance().create(eClass);
+ if(instance != null && instance instanceof NamedElement) {
+ Parameter parameter = getParameter();
+ if(parameter != null) {
+ ((NamedElement)instance).setName(parameter.getName());
+ }
+
+ if(instance instanceof InstanceValue) {
+ ((InstanceValue)instance).setType(parameter.getType());
+ }
+ }
+
+ return super.createObject(widget, instance);
+ }
+
+ protected boolean isValid(EClass eClass) {
+ Parameter parameter = getParameter();
+ if(parameter == null) {
+ return !restrictedInstantiation;
+ }
+
+ Type parameterType = parameter.getType();
+ if(parameterType instanceof PrimitiveType) {
+ return isValidType(eClass, (PrimitiveType)parameterType);
+ }
+
+ if(parameterType instanceof Classifier) {
+ return eClass == UMLPackage.eINSTANCE.getInstanceValue();
+ }
+
+ return !restrictedInstantiation; //The operation has no signature
+ }
+
+ protected Operation getOperation() {
+ NamedElement namedElement = parent.getSignature();
+
+ if(namedElement instanceof Operation) {
+ return (Operation)namedElement;
+ }
+
+ return null;
+ }
+
+ protected Parameter getParameter() {
+ Operation operation = getOperation();
+ if(operation == null) {
+ return null;
+ }
+
+ int index = parent.getArguments().size();
+
+ int i = 0;
+ for(Parameter parameter : operation.getOwnedParameters()) {
+ ParameterDirectionKind direction = parameter.getDirection();
+ if(directions.contains(direction)) {
+ if(i++ == index) {
+ return parameter;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ protected boolean isValidType(EClass eClass, PrimitiveType parameterType) {
+ String typeName = parameterType.getName();
+
+ if(eClass == UMLPackage.eINSTANCE.getLiteralInteger() || eClass == UMLPackage.eINSTANCE.getLiteralUnlimitedNatural()) {
+ return typeName.equals("Integer") || typeName.equals("int");
+ }
+
+ if(eClass == UMLPackage.eINSTANCE.getLiteralString()) {
+ return !(typeName.equals("Integer") || typeName.equals("int") || typeName.equals("Boolean") || typeName.equals("boolean"));
+ }
+
+ if(eClass == UMLPackage.eINSTANCE.getInstanceValue()) {
+ return !(typeName.equals("Integer") || typeName.equals("int") || typeName.equals("Boolean") || typeName.equals("boolean") || typeName.equals("String"));
+ }
+
+ if(eClass == UMLPackage.eINSTANCE.getLiteralBoolean()) {
+ return typeName.equals("Boolean") || typeName.equals("boolean");
+ }
+
+ return false;
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java
index b17acaf994f..345ef95d260 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java
@@ -11,7 +11,14 @@
*****************************************************************************/
package org.eclipse.papyrus.properties.uml.modelelement;
+import static org.eclipse.uml2.uml.ParameterDirectionKind.INOUT_LITERAL;
+import static org.eclipse.uml2.uml.ParameterDirectionKind.IN_LITERAL;
+import static org.eclipse.uml2.uml.ParameterDirectionKind.OUT_LITERAL;
+import static org.eclipse.uml2.uml.ParameterDirectionKind.RETURN_LITERAL;
+
import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.list.IObservableList;
@@ -25,16 +32,22 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.properties.modelelement.EMFModelElement;
+import org.eclipse.papyrus.properties.uml.creation.MessageValueSpecificationFactory;
import org.eclipse.papyrus.properties.uml.databinding.PapyrusObservableList;
import org.eclipse.papyrus.properties.uml.databinding.PapyrusObservableValue;
import org.eclipse.papyrus.properties.uml.databinding.SignatureObservableValue;
+import org.eclipse.papyrus.properties.uml.providers.InstanceValueContentProvider;
import org.eclipse.papyrus.properties.uml.providers.SignatureContentProvider;
import org.eclipse.papyrus.properties.uml.providers.UMLLabelProvider;
import org.eclipse.papyrus.uml.modelexplorer.widgets.ServiceEditFilteredUMLContentProvider;
import org.eclipse.papyrus.umlutils.PackageUtil;
+import org.eclipse.papyrus.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.widgets.providers.IStaticContentProvider;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.InstanceValue;
+import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
import org.eclipse.uml2.uml.UMLPackage;
@@ -92,8 +105,14 @@ public class UMLModelElement extends EMFModelElement {
root = PackageUtil.getRootPackage((Element)source);
}
- ServiceEditFilteredUMLContentProvider contentProvider = new ServiceEditFilteredUMLContentProvider(source, feature, root);
- // contentProvider = new UMLElementMEBContentProvider(root);
+ ServiceEditFilteredUMLContentProvider contentProvider;
+
+ if(feature == UMLPackage.eINSTANCE.getInstanceValue_Instance()) {
+ contentProvider = new InstanceValueContentProvider((InstanceValue)source, feature, root);
+ } else {
+ contentProvider = new ServiceEditFilteredUMLContentProvider(source, feature, root);
+ }
+
contentProvider.setMetaClassWanted(feature.getEType());
contentProvider.setMetaClassNotWanted(Collections.EMPTY_LIST);
@@ -121,4 +140,29 @@ public class UMLModelElement extends EMFModelElement {
return super.isOrdered(propertyPath);
}
+ @Override
+ public ReferenceValueFactory getValueFactory(String propertyPath) {
+ EStructuralFeature feature = getFeature(propertyPath);
+ if(feature == UMLPackage.eINSTANCE.getMessage_Argument()) {
+ if(source instanceof Message) {
+ Set<ParameterDirectionKind> directions = new HashSet<ParameterDirectionKind>();
+ switch(((Message)source).getMessageSort()) {
+ case REPLY_LITERAL:
+ directions.add(OUT_LITERAL);
+ directions.add(INOUT_LITERAL);
+ directions.add(RETURN_LITERAL);
+ return new MessageValueSpecificationFactory(((EReference)feature).getEReferenceType(), (Message)source, directions);
+ case SYNCH_CALL_LITERAL:
+ case ASYNCH_CALL_LITERAL:
+ case ASYNCH_SIGNAL_LITERAL:
+ directions.add(IN_LITERAL);
+ directions.add(INOUT_LITERAL);
+ return new MessageValueSpecificationFactory(((EReference)feature).getEReferenceType(), (Message)source, directions);
+ }
+ }
+ }
+
+ return super.getValueFactory(propertyPath);
+ }
+
}
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/InstanceValueContentProvider.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/InstanceValueContentProvider.java
new file mode 100644
index 00000000000..5992961fa47
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/InstanceValueContentProvider.java
@@ -0,0 +1,28 @@
+package org.eclipse.papyrus.properties.uml.providers;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.uml.modelexplorer.widgets.ServiceEditFilteredUMLContentProvider;
+import org.eclipse.uml2.uml.InstanceValue;
+
+
+public class InstanceValueContentProvider extends ServiceEditFilteredUMLContentProvider {
+
+ private InstanceValue source;
+
+ public InstanceValueContentProvider(InstanceValue source, EStructuralFeature feature, EObject semanticRoot) {
+ super(source, feature, semanticRoot);
+ this.source = source;
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ if(this.viewer != null) {
+ this.viewer.setFilters(new ViewerFilter[]{ new InstanceValueViewerFilter(this, source) });
+ }
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/InstanceValueViewerFilter.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/InstanceValueViewerFilter.java
new file mode 100644
index 00000000000..84e58a18a21
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/InstanceValueViewerFilter.java
@@ -0,0 +1,56 @@
+package org.eclipse.papyrus.properties.uml.providers;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.properties.uml.util.UMLUtil;
+import org.eclipse.papyrus.uml.modelexplorer.widgets.UMLHierarchicViewerFilter;
+import org.eclipse.papyrus.widgets.providers.IHierarchicContentProvider;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.InstanceValue;
+import org.eclipse.uml2.uml.Type;
+
+
+public class InstanceValueViewerFilter extends UMLHierarchicViewerFilter {
+
+ private InstanceValue source;
+
+ public InstanceValueViewerFilter(IHierarchicContentProvider contentProvider, InstanceValue source) {
+ super(contentProvider);
+ this.source = source;
+ }
+
+ @Override
+ public boolean isVisible(Viewer viewer, Object parentElement, Object element) {
+ if(!super.isVisible(viewer, parentElement, element)) {
+ return false;
+ }
+
+ if(source.getType() == null) {
+ return true;
+ }
+
+ Type type = source.getType();
+
+ InstanceSpecification instance = (InstanceSpecification)UMLUtil.resolveUMLElement(element);
+
+ if(type instanceof Enumeration) {
+ return ((Enumeration)type).getOwnedLiterals().contains(instance);
+ } else if (type instanceof Classifier){
+ Classifier classifier = (Classifier)type;
+ if(instance.getClassifiers().contains(classifier)) {
+ return true;
+ }
+
+ for(Classifier implementedClassifier : instance.getClassifiers()) {
+ if(implementedClassifier.conformsTo(classifier)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/SignatureContentProvider.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/SignatureContentProvider.java
index dd013a43401..4a9daca3e15 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/SignatureContentProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/providers/SignatureContentProvider.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2011 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
@@ -76,6 +76,9 @@ public class SignatureContentProvider extends AbstractStaticContentProvider {
}
protected Object[] getElementsFromContext(org.eclipse.uml2.uml.Class clazz) {
+ if(clazz == null) {
+ return new Object[0];
+ }
List<EObject> result = new LinkedList<EObject>();
result.addAll(clazz.getOwnedOperations());
if(message != null && (message.getMessageSort() == MessageSort.ASYNCH_CALL_LITERAL || message.getMessageSort() == MessageSort.ASYNCH_SIGNAL_LITERAL)) {
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/SelectOrCreateDialogPropertyEditor.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/SelectOrCreateDialogPropertyEditor.java
index d49cc68219d..6119441fb94 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/SelectOrCreateDialogPropertyEditor.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/SelectOrCreateDialogPropertyEditor.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2011 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
@@ -79,8 +79,11 @@ public class SelectOrCreateDialogPropertyEditor extends AbstractPropertyEditor {
Class parentClass = findParentClass(sourceElement);
- editor.setCreateAs(UMLPackage.eINSTANCE.getOperation(), parentClass, UMLPackage.eINSTANCE.getClass_OwnedOperation());
- editor.setCreateAs(UMLPackage.eINSTANCE.getSignal(), parentClass.getNearestPackage(), UMLPackage.eINSTANCE.getPackage_PackagedElement());
+ if(parentClass != null) {
+ editor.setCreateAs(UMLPackage.eINSTANCE.getOperation(), parentClass, UMLPackage.eINSTANCE.getClass_OwnedOperation());
+ editor.setCreateAs(UMLPackage.eINSTANCE.getSignal(), parentClass.getNearestPackage(), UMLPackage.eINSTANCE.getPackage_PackagedElement());
+ }
+
editor.setEditingDomain(umlModelElement.getDomain());
}
}

Back to the top