Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-03-11 17:13:59 +0000
committercletavernie2013-03-11 17:13:59 +0000
commitaaac7917520e1f5c56b4fd3dcaa4fae45d4fdbfa (patch)
treec262c597eec3852aba6c5b36455064d916726c77
parent01ef83ad82f5783f079bb923ddf77362ab66e5cd (diff)
downloadorg.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
-rw-r--r--incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/OperationTypeNavigableElement.java37
-rw-r--r--incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedElementNavigationContributor.java5
-rw-r--r--incoming/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedNavigableElement.java30
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/SelectionMenu.java5
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java30
5 files changed, 89 insertions, 18 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;
}
-
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/SelectionMenu.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/SelectionMenu.java
index ed57820cdd8..445d445e1c6 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/SelectionMenu.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/SelectionMenu.java
@@ -60,6 +60,11 @@ public class SelectionMenu {
}
public SelectionMenu(Shell parentShell, Point location) {
+ //Move the shell so that it doesn't open under the mouse
+ //The hovered element can still be selected
+ location.x += 5;
+ location.y += 5;
+
this.parentShell = parentShell;
this.location = location;
labelProvider = new LabelProvider();
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
index 5464f2ec8e0..b87c312c35f 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
@@ -78,6 +78,7 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IEditorPart;
@@ -394,7 +395,26 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
}
public void keyPressed(KeyEvent e) {
- //Nothing
+ if(e.keyCode != SWT.CTRL) {
+ return;
+ }
+
+ Tree tree = getCommonViewer().getTree();
+
+ //Generate a basic mouse event
+ Event event = new Event();
+ event.widget = tree;
+ event.stateMask = SWT.CTRL;
+
+ Point absoluteTreeLocation = tree.toDisplay(new Point(0, 0));
+
+ event.x = tree.getDisplay().getCursorLocation().x - absoluteTreeLocation.x;
+ event.y = tree.getDisplay().getCursorLocation().y - absoluteTreeLocation.y;
+
+ MouseEvent mouseEvent = new MouseEvent(event);
+ if(isEnterState(mouseEvent)) {
+ enterItem(currentItem);
+ }
}
});
@@ -402,6 +422,10 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
@Override
public void mouseUp(MouseEvent e) {
+ if((e.stateMask & SWT.CTRL) == 0) {
+ return;
+ }
+
TreeItem currentItem = getTreeItem(e);
if(currentItem != null) {
Object data = currentItem.getData();
@@ -431,7 +455,7 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
}
if(isEnterState(e)) {
- enterItem(currentItem, e);
+ enterItem(currentItem);
}
}
@@ -497,7 +521,7 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
disposeCurrentMenu();
}
- private void enterItem(TreeItem item, MouseEvent e) {
+ private void enterItem(TreeItem item) {
try {
NavigationService navigation = serviceRegistry.getService(NavigationService.class);
disposeCurrentMenu();

Back to the top