diff options
author | cletavernie | 2013-03-11 17:13:59 +0000 |
---|---|---|
committer | cletavernie | 2013-03-11 17:13:59 +0000 |
commit | aaac7917520e1f5c56b4fd3dcaa4fae45d4fdbfa (patch) | |
tree | c262c597eec3852aba6c5b36455064d916726c77 /incoming | |
parent | 01ef83ad82f5783f079bb923ddf77362ab66e5cd (diff) | |
download | org.eclipse.papyrus-aaac7917520e1f5c56b4fd3dcaa4fae45d4fdbfa.tar.gz org.eclipse.papyrus-aaac7917520e1f5c56b4fd3dcaa4fae45d4fdbfa.tar.xz org.eclipse.papyrus-aaac7917520e1f5c56b4fd3dcaa4fae45d4fdbfa.zip |
399882: [ModelExplorer] Papyrus shall enable navigation between typed model elements shown in views and the model explorer
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399882
- Add support for Operations
- Bug fixes
Diffstat (limited to 'incoming')
3 files changed, 57 insertions, 15 deletions
diff --git a/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/OperationTypeNavigableElement.java b/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/OperationTypeNavigableElement.java new file mode 100644 index 00000000000..588bad63b53 --- /dev/null +++ b/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/OperationTypeNavigableElement.java @@ -0,0 +1,37 @@ +/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.navigation.contributor;
+
+import org.eclipse.uml2.uml.Operation;
+
+/**
+ * Navigates from an Operation to it's return type declaration
+ *
+ * @author CL228098
+ *
+ */
+public class OperationTypeNavigableElement extends TypedNavigableElement {
+
+ public OperationTypeNavigableElement(Operation operation) {
+ super(operation.getType());
+ }
+
+ @Override
+ public String getLabel() {
+ return "Go to return Type" + getTypeLabel();
+ }
+
+ @Override
+ public String getDescription() {
+ return "Go to the return type declaration of this Operation" + getTypeLabel();
+ }
+}
diff --git a/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedElementNavigationContributor.java b/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedElementNavigationContributor.java index 884e7078611..c72ac955732 100644 --- a/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedElementNavigationContributor.java +++ b/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedElementNavigationContributor.java @@ -18,6 +18,7 @@ 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.Element;
+import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.TypedElement;
/**
@@ -33,7 +34,9 @@ public class TypedElementNavigationContributor implements NavigationContributor Element element = UMLUtil.resolveUMLElement(fromElement);
if(element instanceof TypedElement) {
- result.add(new TypedNavigableElement((TypedElement)element));
+ result.add(new TypedNavigableElement(((TypedElement)element).getType()));
+ } else if(element instanceof Operation) {
+ result.add(new OperationTypeNavigableElement((Operation)element));
}
return result;
diff --git a/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedNavigableElement.java b/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedNavigableElement.java index ab1795f572a..9c73309739e 100644 --- a/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedNavigableElement.java +++ b/incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedNavigableElement.java @@ -19,7 +19,6 @@ import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement; import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
import org.eclipse.swt.graphics.Image;
import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.TypedElement;
/**
* Navigates from a TypedElement to its Type declaration
@@ -28,26 +27,31 @@ import org.eclipse.uml2.uml.TypedElement; */
public class TypedNavigableElement implements NavigableElement {
- private final TypedElement typedElement;
+ protected final Type type;
- public TypedNavigableElement(TypedElement typedElement) {
- this.typedElement = typedElement;
+ /**
+ *
+ * @param type
+ * The Type to navigate to. May be null.
+ */
+ public TypedNavigableElement(Type type) {
+ this.type = type;
}
public String getLabel() {
- String label = "Open type declaration" + getTypeLabel();
+ String label = "Go to type" + getTypeLabel();
return label;
}
public String getDescription() {
- return "Opens the type declaration of this TypedElement" + getTypeLabel();
+ return "Go to the type declaration of this TypedElement" + getTypeLabel();
}
- private String getTypeLabel() {
- if(typedElement.getType() == null) {
+ protected String getTypeLabel() {
+ if(type == null) {
return " (Undefined)";
} else {
- return " (" + typedElement.getType().getName() + ")";
+ return " (" + type.getName() + ")";
}
}
@@ -56,17 +60,16 @@ public class TypedNavigableElement implements NavigableElement { return;
}
- Type type = typedElement.getType();
navigationContext.revealSemanticElement(Collections.singletonList(type));
}
public Image getImage() {
- if(typedElement.getType() == null) {
+ if(type == null) {
return null;
}
try {
- return ServiceUtilsForEObject.getInstance().getServiceRegistry(typedElement).getService(LabelProviderService.class).getLabelProvider().getImage(typedElement.getType());
+ return ServiceUtilsForEObject.getInstance().getServiceRegistry(type).getService(LabelProviderService.class).getLabelProvider().getImage(type);
} catch (Exception ex) {
return null;
}
@@ -76,7 +79,6 @@ public class TypedNavigableElement implements NavigableElement { * Enabled when the type is defined
*/
public boolean isEnabled() {
- return typedElement.getType() != null;
+ return type != null;
}
-
}
|