diff options
author | Shuai Li | 2016-04-19 15:32:29 +0000 |
---|---|---|
committer | Shuai Li | 2016-04-20 12:16:19 +0000 |
commit | 44d69cbc26a57d625d3e8a64b7bf2468fa8b3d92 (patch) | |
tree | 1adc9051ab6bdf0537621eaed91f952ebd1717f1 | |
parent | 74277e4e464813a72120e2f3e1c320eca04a51f2 (diff) | |
download | org.eclipse.papyrus-44d69cbc26a57d625d3e8a64b7bf2468fa8b3d92.tar.gz org.eclipse.papyrus-44d69cbc26a57d625d3e8a64b7bf2468fa8b3d92.tar.xz org.eclipse.papyrus-44d69cbc26a57d625d3e8a64b7bf2468fa8b3d92.zip |
Bug 463687 - Not possible to see and click-to-navigate to opposite
elements across links in Model Explorer
Update navigation contributor for associations:
* Member end (property)
Add navigation contributor for property:
* Association
Change-Id: I761938737e1a4d158d448b4291a5f09d86fa32d7
Signed-off-by: Shuai Li <shuai.li@cea.fr>
6 files changed, 124 insertions, 5 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml b/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml index a0812c56716..3fe0a30c837 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml +++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml @@ -22,6 +22,12 @@ label="UML Call Behavior Action navigation"> </contributor> <contributor + contributor="org.eclipse.papyrus.uml.navigation.navigableElement.PropertyNavigationContributor" + description="Navigates from a property" + id="org.eclipse.papyrus.uml.navigation.property" + label="UML Property navigation"> + </contributor> + <contributor contributor="org.eclipse.papyrus.uml.navigation.navigableElement.RelationshipNavigationContributor" description="Navigates from a relationship" id="org.eclipse.papyrus.uml.navigation.relationship" diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/AssociationNavigableElement.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/AssociationNavigableElement.java new file mode 100644 index 00000000000..5d157771ee0 --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/AssociationNavigableElement.java @@ -0,0 +1,35 @@ +/***************************************************************************** + * Copyright (c) 2016 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: + * Shuai Li (CEA LIST) shuai.li@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.uml.navigation.navigableElement; + +import org.eclipse.uml2.uml.Property; + +/** + * Navigable element representing an association + * + */ +public class AssociationNavigableElement extends GenericNavigableElement { + + public AssociationNavigableElement(Property property) { + super(property.getAssociation()); + } + + @Override + public String getLabel() { + return "Go to association" + getElementLabel() + "..."; + } + + @Override + public String getDescription() { + return "Go to the association of this property:" + getElementLabel(); + } +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/MemberEndNavigableElement.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/MemberEndNavigableElement.java index 67a3a911afb..1bf7fbab74a 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/MemberEndNavigableElement.java +++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/MemberEndNavigableElement.java @@ -14,22 +14,22 @@ package org.eclipse.papyrus.uml.navigation.navigableElement; import org.eclipse.uml2.uml.Property; /** - * Navigable element representing the target of a directed relationship + * Navigable element representing the member end (property) of an association * */ public class MemberEndNavigableElement extends GenericNavigableElement { public MemberEndNavigableElement(Property property) { - super(property.getType()); + super(property); } @Override public String getLabel() { - return "Go to member end type" + getElementLabel() + "..."; + return "Go to member end" + getElementLabel() + "..."; } @Override public String getDescription() { - return "Go to the member end type of this association:" + getElementLabel(); + return "Go to the member end of this association:" + getElementLabel(); } } diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/MemberEndTypeNavigableElement.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/MemberEndTypeNavigableElement.java new file mode 100644 index 00000000000..20b4e3cc94c --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/MemberEndTypeNavigableElement.java @@ -0,0 +1,35 @@ +/***************************************************************************** + * Copyright (c) 2016 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: + * Shuai Li (CEA LIST) shuai.li@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.uml.navigation.navigableElement; + +import org.eclipse.uml2.uml.Property; + +/** + * Navigable element representing the type of a member end of an association + * + */ +public class MemberEndTypeNavigableElement extends GenericNavigableElement { + + public MemberEndTypeNavigableElement(Property property) { + super(property.getType()); + } + + @Override + public String getLabel() { + return "Go to member end type" + getElementLabel() + "..."; + } + + @Override + public String getDescription() { + return "Go to the member end type of this association:" + getElementLabel(); + } +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/PropertyNavigationContributor.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/PropertyNavigationContributor.java new file mode 100644 index 00000000000..6271996340d --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/PropertyNavigationContributor.java @@ -0,0 +1,42 @@ +/***************************************************************************** + * Copyright (c) 2016 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: + * Shuai Li (CEA LIST) shuai.li@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.uml.navigation.navigableElement; + +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement; +import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor; +import org.eclipse.papyrus.uml.tools.utils.UMLUtil; +import org.eclipse.uml2.uml.Connector; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.TypedElement; + +/** + * NavigationContributor to navigate from a Property to its Association + * + */ +public class PropertyNavigationContributor implements NavigationContributor { + + public List<NavigableElement> getNavigableElements(Object fromElement) { + List<NavigableElement> result = new LinkedList<NavigableElement>(); + + Element element = UMLUtil.resolveUMLElement(fromElement); + if (element instanceof Property && ((Property) element).getAssociation() != null) { + result.add(new AssociationNavigableElement(((Property) element))); + } + + return result; + } +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/RelationshipNavigationContributor.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/RelationshipNavigationContributor.java index 6a3854b56d5..4002f3c4545 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/RelationshipNavigationContributor.java +++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/RelationshipNavigationContributor.java @@ -47,8 +47,9 @@ public class RelationshipNavigationContributor implements NavigationContributor Association association = (Association) element; if (association.getMemberEnds().size() > 0) { for (Property end : association.getMemberEnds()) { + result.add(new MemberEndNavigableElement(end)); if (end.getType() != null) { - result.add(new MemberEndNavigableElement(end)); + result.add(new MemberEndTypeNavigableElement(end)); } } } |