diff options
author | Christian W. Damus | 2017-02-17 22:15:27 +0000 |
---|---|---|
committer | Christian W. Damus | 2017-02-17 22:15:27 +0000 |
commit | 63877606e3175acca5bbcb42ba850b5cae1f32c1 (patch) | |
tree | aaa2d2bba6abf1740484cf3fedc338b7158da928 | |
parent | dac6aa8f4523467a7837154bb6d9c240c423f6ef (diff) | |
download | org.eclipse.papyrus-63877606e3175acca5bbcb42ba850b5cae1f32c1.tar.gz org.eclipse.papyrus-63877606e3175acca5bbcb42ba850b5cae1f32c1.tar.xz org.eclipse.papyrus-63877606e3175acca5bbcb42ba850b5cae1f32c1.zip |
Bug 512387: [Properties] UML Advanced Properties assumes too much about adaptables
Ensure that adaptables are leveraged to their full potential for
extraction of the semantic element.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=512387
Change-Id: I5c813286711ea22352afaa4f2d5858399c02f23b
3 files changed, 31 insertions, 31 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF index 545959910fb..2a9113c2e7a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF @@ -79,7 +79,7 @@ Require-Bundle: org.eclipse.papyrus.extensionpoints.editors;bundle-version="[1.2 org.eclipse.papyrus.infra.hyperlink;bundle-version="[2.0.0,3.0.0)", org.eclipse.nebula.widgets.richtext;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.1.qualifier Eclipse-BuddyPolicy: dependent Bundle-Activator: org.eclipse.papyrus.uml.diagram.common.Activator Bundle-ManifestVersion: 2 diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/pom.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/pom.xml index c14b9fc6bd6..15630dd3614 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/pom.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/pom.xml @@ -7,6 +7,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.diagram.common</artifactId> - <version>2.0.0-SNAPSHOT</version> + <version>2.0.1-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/sheet/UMLPropertySection.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/sheet/UMLPropertySection.java index f67ab315db1..514bda13bee 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/sheet/UMLPropertySection.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/sheet/UMLPropertySection.java @@ -1,6 +1,5 @@ /***************************************************************************** - * Copyright (c) 2009, 2014 ATOS ORIGIN, CEA, and others. - * + * Copyright (c) 2009, 2017 ATOS ORIGIN, CEA, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -9,8 +8,10 @@ * * Atos Origin - Initial API and implementation * Christian W. Damus (CEA) - bug 386118 + * Christian W. Damus - bug 512387 * *****************************************************************************/ + package org.eclipse.papyrus.uml.diagram.common.sheet; import java.util.ArrayList; @@ -24,6 +25,7 @@ import org.eclipse.emf.edit.provider.IItemPropertySource; import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.emf.transaction.util.TransactionUtil; import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; import org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.jface.viewers.ISelection; @@ -38,13 +40,6 @@ import org.eclipse.ui.views.properties.IPropertySourceProvider; */ public class UMLPropertySection extends AdvancedPropertySection implements IPropertySourceProvider { - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.views.properties.IPropertySourceProvider#getPropertySource - * (java.lang.Object) - */ @Override public IPropertySource getPropertySource(Object object) { if (object instanceof IPropertySource) { @@ -58,7 +53,7 @@ public class UMLPropertySection extends AdvancedPropertySection implements IProp } } if (object instanceof IAdaptable) { - return (IPropertySource) ((IAdaptable) object).getAdapter(IPropertySource.class); + return ((IAdaptable) object).getAdapter(IPropertySource.class); } return null; } @@ -82,21 +77,33 @@ public class UMLPropertySection extends AdvancedPropertySection implements IProp if (selected == null) { return null; } - if (selected instanceof IAdaptable && ((IAdaptable) selected).getAdapter(IPropertySource.class) != null) { - return ((IAdaptable) selected).getAdapter(IPropertySource.class); + if (selected instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) selected; + + Object adapter = adaptable.getAdapter(IPropertySource.class); + if (adapter != null) { + // This is a terminal transformation + return adapter; + } + adapter = adaptable.getAdapter(EObject.class); + if (adapter != null) { + // This is a terminal transformation + return adapter; + } + adapter = adaptable.getAdapter(View.class); + if (adapter instanceof View) { + // This is an intermediate transformation + return transformSelection(adapter); + } } if (selected instanceof EditPart) { + // This is an intermediate transformation Object model = ((EditPart) selected).getModel(); - return model instanceof View ? ((View) model).getElement() : null; + return transformSelection(model); } if (selected instanceof View) { - return ((View) selected).getElement(); - } - if (selected instanceof IAdaptable) { - View view = (View) ((IAdaptable) selected).getAdapter(View.class); - if (view != null) { - return view.getElement(); - } + // This is a terminal transformation + return ViewUtil.resolveSemanticElement((View) selected); } EObject elem = EMFHelper.getEObject(selected); @@ -107,13 +114,6 @@ public class UMLPropertySection extends AdvancedPropertySection implements IProp return selected; } - /* - * (non-Javadoc) - * - * @see org.eclipse.gmf.runtime.diagram.ui.properties.sections. - * AdvancedPropertySection#setInput(org .eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ @Override public void setInput(IWorkbenchPart part, ISelection selection) { if (selection.isEmpty() || false == selection instanceof StructuredSelection) { @@ -121,8 +121,8 @@ public class UMLPropertySection extends AdvancedPropertySection implements IProp return; } final StructuredSelection structuredSelection = ((StructuredSelection) selection); - ArrayList transformedSelection = new ArrayList(structuredSelection.size()); - for (Iterator it = structuredSelection.iterator(); it.hasNext();) { + ArrayList<Object> transformedSelection = new ArrayList<>(structuredSelection.size()); + for (Iterator<?> it = structuredSelection.iterator(); it.hasNext();) { Object r = transformSelection(it.next()); if (r != null) { transformedSelection.add(r); |