Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuai Li2015-05-06 12:03:34 +0000
committerGerrit Code Review @ Eclipse.org2015-11-18 10:01:35 +0000
commit5c6b9f2134605509211bcf3ef271799e1554d5f2 (patch)
treecc7b4e8625597e82c1a1d02f3a77b2b7dc06ddd0 /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink
parent7dbaf8867e0b3e43d606caa8f2d342dbf479d3d6 (diff)
downloadorg.eclipse.papyrus-5c6b9f2134605509211bcf3ef271799e1554d5f2.tar.gz
org.eclipse.papyrus-5c6b9f2134605509211bcf3ef271799e1554d5f2.tar.xz
org.eclipse.papyrus-5c6b9f2134605509211bcf3ef271799e1554d5f2.zip
Bug 463589 - [Navigation] Alt Menu
- Add navigation menu on alt+hover over a navigable element (in diagram or model explorer) - Move hyperlinks to this navigation menu - First version of navigation extension framework to contribute navigation menu buttons to the menu. These contributors are handled by the navigation service. - Current contributors are: parents, children, types, views, targets, sources - Add NamedElement navigable element - Add method to chose navigation target provider in navigation service - Add method to get semantic element from navigable element - Change some navigable element labels - Rm DiagramNavigationProvider because views where the element appears are already shown. - Add PopupBarEditPolicyProvider to edit policy extensions Patch set 20: Architecture changes: - oep.views.navigation is deleted and its content moved to oep.infra.gmfdiag.navigation. Several changes were made beforehand: - Remove dependency on oep.uml.tools - Remove useless import of org.eclipse.uml.uml2 - Remove dependencies on uml and nattable - Move oep.views.navigation.contributor oep.uml.navigation.menuContributor - Remove useless imports of navigation menu button package elsewhere - Delete oep.views.navigation[.feature] and remove from main pom Feature changes: - In oep.infra.gmfdiag.navigation, added OwnedDiagramButton menu contributor, which will show diagrams owned by the hovered element Other changes: - Contribute DiagramOfViewLabelProvider extension in context of "oep.infra.services.navigation.menu.labelprovider" - Add ViewerSearchService to DefaultNavigationMenu. This replaces getViewsToSelect and getClosedViewsToSelect methods. - Rename oep.uml.navigation.contributor to navigableElement - Remove old navigation contributors from oep.infra.gmfdiag.navigation (not contributed through extensions anyway) Change-Id: I895ea3923b1e5612b3bba4d3296a91176b7c2b94 Signed-off-by: Shuai Li <shuai.li@cea.fr>
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml63
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperlinkNavigationMenuEditPolicy.java252
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigableElement.java80
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigationProvider.java82
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java147
7 files changed, 351 insertions, 278 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml
index c2e965c397e..91cc4e06ce7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml
@@ -1,36 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders">
- <editpolicyProvider
- class="org.eclipse.papyrus.infra.gmfdiag.hyperlink.providers.HyperlinkEditPolicyProvider">
- <Priority
- name="Lowest">
- </Priority>
- </editpolicyProvider>
- </extension>
- <extension
- point="org.eclipse.papyrus.infra.gmfdiag.dnd.dropStrategy">
- <strategy
- strategy="org.eclipse.papyrus.infra.gmfdiag.hyperlink.dnd.HyperlinkDropStrategy">
- </strategy>
- </extension>
- <extension
- point="org.eclipse.papyrus.infra.hyperlink.specificHyperLinks">
- <specificHyperLink
- contentProvider="org.eclipse.papyrus.infra.gmfdiag.hyperlink.providers.SpecificViewContentProvider">
- </specificHyperLink>
-
- </extension>
- <extension
- point="org.eclipse.papyrus.infra.services.navigation.navigationContributor">
- <contributor
- contributor="org.eclipse.papyrus.infra.gmfdiag.hyperlink.navigation.DiagramNavigationProvider"
- description="Navigates to the current element&apos;s diagram(s)"
- id="org.eclipse.papyrus.infra.gmfdiag.hyperlink.diagram"
- label="Automatic Diagram Navigation">
- </contributor>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders">
+ <editpolicyProvider
+ class="org.eclipse.papyrus.infra.gmfdiag.hyperlink.providers.HyperlinkEditPolicyProvider">
+ <Priority
+ name="Lowest">
+ </Priority>
+ </editpolicyProvider>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.gmfdiag.dnd.dropStrategy">
+ <strategy
+ strategy="org.eclipse.papyrus.infra.gmfdiag.hyperlink.dnd.HyperlinkDropStrategy">
+ </strategy>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.hyperlink.specificHyperLinks">
+ <specificHyperLink
+ contentProvider="org.eclipse.papyrus.infra.gmfdiag.hyperlink.providers.SpecificViewContentProvider">
+ </specificHyperLink>
+
+ </extension>
+
+</plugin>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java
index 543cefd253f..83753f6b0fd 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java
@@ -33,8 +33,7 @@ import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusPopupBarEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.hyperlink.ui.AdvancedHLManager;
-import org.eclipse.papyrus.infra.hyperlink.Activator;
+import org.eclipse.papyrus.infra.gmfdiag.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.helper.AbstractHyperLinkHelper;
import org.eclipse.papyrus.infra.hyperlink.helper.HyperLinkHelperFactory;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperlinkNavigationMenuEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperlinkNavigationMenuEditPolicy.java
new file mode 100644
index 00000000000..03cf2f11cde
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperlinkNavigationMenuEditPolicy.java
@@ -0,0 +1,252 @@
+/*****************************************************************************
+ * Copyright (c) 2009, 2014 CEA LIST, 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 451230
+ * Shuai Li - Modifications for navigation menu integration
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.tools.AbstractPopupBarTool;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
+import org.eclipse.papyrus.infra.core.editorsfactory.PageIconsRegistry;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.hyperlink.Activator;
+import org.eclipse.papyrus.infra.gmfdiag.navigation.editpolicy.NavigationEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.navigation.menu.button.HyperlinkButton;
+import org.eclipse.papyrus.infra.hyperlink.helper.AbstractHyperLinkHelper;
+import org.eclipse.papyrus.infra.hyperlink.helper.HyperLinkHelperFactory;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkDocument;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkWeb;
+import org.eclipse.papyrus.infra.hyperlink.ui.HyperLinkManagerShell;
+import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkException;
+import org.eclipse.papyrus.infra.hyperlink.util.HyperLinkHelpersRegistrationUtil;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * The Class HyperlinkNavigationMenuEditPolicy can be applied on edit part to display
+ * shortcuts on sub-diagrams or to associate hyper-link of files, in addition to the
+ * tools provided by the Navigation menu.
+ */
+public class HyperlinkNavigationMenuEditPolicy extends NavigationEditPolicy {
+
+ /** The editor registry. */
+ private IPageIconsRegistry editorRegistry;
+
+ /** The hyper link manager shell. */
+ private HyperLinkManagerShell hyperLinkManagerShell;
+
+ protected LinkedList<HyperLinkObject> hyperLinkObjectList;
+
+ protected HyperLinkHelperFactory hyperlinkHelperFactory;
+
+ public HyperlinkNavigationMenuEditPolicy() {
+ super();
+
+ ArrayList<AbstractHyperLinkHelper> hyperLinkHelpers = new ArrayList<AbstractHyperLinkHelper>();
+ // TODO
+ // hyperLinkHelpers.add(new DiagramHyperLinkHelper());
+ // hyperLinkHelpers.add(new DocumentHyperLinkHelper());
+ // hyperLinkHelpers.add(new WebHyperLinkHelper());
+ hyperLinkHelpers.addAll(HyperLinkHelpersRegistrationUtil.INSTANCE.getAllRegisteredHyperLinkHelper());
+ hyperlinkHelperFactory = new HyperLinkHelperFactory(hyperLinkHelpers);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void appendNavigationMenuItem() {
+ clearAppendObjects();
+
+ // add all subdiagrams
+ try {
+ hyperLinkObjectList = new LinkedList<HyperLinkObject>();
+ ArrayList<HyperLinkObject> unfilteredHyperlinkObjects = (ArrayList<HyperLinkObject>) hyperlinkHelperFactory.getAllreferenced(((IGraphicalEditPart) getHost()).getNotationView());
+
+ for (AbstractHyperLinkHelper hyperlinkHelper : hyperlinkHelperFactory.getHyperLinkHelpers()) {
+ hyperLinkObjectList.addAll(hyperlinkHelper.getFilteredObject(unfilteredHyperlinkObjects));
+ }
+
+ if (hyperLinkObjectList.isEmpty()) {
+ hyperLinkObjectList.addAll(unfilteredHyperlinkObjects);
+ } else if (hyperLinkObjectList.size() != unfilteredHyperlinkObjects.size()) {
+ hyperLinkObjectList.clear();
+ hyperLinkObjectList.addAll(unfilteredHyperlinkObjects);
+ }
+
+ addHyperlinks();
+ } catch (HyperLinkException e) {
+ Activator.log.error(e);
+ }
+
+ // Add the New Hyperlink tool
+ addNavigationMenuHyperlinkDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.papyrus.uml.diagram.common", "/icons/obj16/Plus.gif").createImage(), new AddHyperlinkAction(), "Open hyperlinks menu", "Modify hyperlinks");
+ }
+
+ private void addHyperlinks() {
+ ILabelProvider labelProvider = null;
+ boolean localLabelProvider = false;
+ try {
+ EObject contextElement = EMFHelper.getEObject(getHost());
+ labelProvider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, contextElement).getLabelProvider();
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
+
+ if (labelProvider == null) {
+ labelProvider = new LabelProvider();
+ localLabelProvider = true;
+ }
+
+ for (HyperLinkObject hyperlink : hyperLinkObjectList) {
+ String tooltip;
+ String text;
+ if (labelProvider instanceof CellLabelProvider) {
+ tooltip = ((CellLabelProvider) labelProvider).getToolTipText(hyperlink);
+ text = tooltip;
+ } else {
+ if (hyperlink instanceof HyperLinkDocument || hyperlink instanceof HyperLinkWeb) {
+ text = hyperlink.getTooltipText();
+ tooltip = labelProvider.getText(hyperlink);
+ } else {
+ text = labelProvider.getText(hyperlink);
+ tooltip = hyperlink.getTooltipText();
+ }
+
+ if (tooltip == null) {
+ tooltip = text;
+ }
+
+ if (text == null) {
+ text = tooltip;
+ }
+ }
+
+ addNavigationMenuHyperlinkDescriptor(labelProvider.getImage(hyperlink), new NavigateHyperlinkAction(hyperlink), tooltip, text);
+ }
+
+ if (localLabelProvider) {
+ labelProvider.dispose();
+ }
+ }
+
+ protected void addNavigationMenuHyperlinkDescriptor(Image theImage, IAction theAction, String theTip, String theText) {
+ if (!(theAction instanceof AbstractPopupBarTool) || ((AbstractPopupBarTool) theAction).isCommandEnabled()) {
+ // We only add pop-up bar tools whose commands are actually executable in this context
+ HyperlinkButton desc = new HyperlinkButton(theText, theTip, theImage, theAction);
+ this.navigationMenu.getAppendObjects().add(desc);
+ }
+ }
+
+ //
+ // Nested types
+ //
+
+ //protected abstract class AbstractHyperlinkTool extends AbstractTool implements DragTracker {
+ protected abstract class AbstractHyperlinkAction extends Action {
+
+ }
+
+ public class AddHyperlinkAction extends AbstractHyperlinkAction {
+ @Override
+ public void run() {
+ hyperLinkManagerShell = new HyperLinkManagerShell(getEditorRegistry(), ((IGraphicalEditPart) getHost()).getEditingDomain(), (EModelElement) ((IGraphicalEditPart) getHost()).getNotationView().getElement(),
+ ((IGraphicalEditPart) getHost()).getNotationView(), hyperlinkHelperFactory);
+ hyperLinkManagerShell.setInput(hyperLinkObjectList);
+
+ // Hide the navigation menu now because the shell is modal
+ //destroyViewerContext();
+
+ hyperLinkManagerShell.open();
+ }
+ }
+
+ protected class NavigateHyperlinkAction extends AbstractHyperlinkAction {
+ private final HyperLinkObject hyperlink;
+
+ public NavigateHyperlinkAction(HyperLinkObject hyperlink) {
+ super();
+
+ this.hyperlink = hyperlink;
+ }
+
+ @Override
+ public void run() {
+ if (hyperlink.needsOpenCommand()) {
+ try {
+ TransactionalEditingDomain editingDomain = ServiceUtilsForEditPart.getInstance().getTransactionalEditingDomain(getHost());
+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain, hyperlink.getTooltipText()) {
+
+ @Override
+ protected void doExecute() {
+ hyperlink.openLink();
+ }
+ });
+ } catch (ServiceException ex) {
+
+ }
+ } else {
+ hyperlink.openLink();
+ }
+ }
+ }
+
+ /**
+ * Return the EditorRegistry for nested editor descriptors. Subclass should
+ * implements this method in order to return the registry associated to the
+ * extension point namespace.
+ *
+ * @return the EditorRegistry for nested editor descriptors
+ *
+ * @generated NOT
+ */
+ protected IPageIconsRegistry createEditorRegistry() {
+ try {
+ return ServiceUtilsForEditPart.getInstance().getService(IPageIconsRegistry.class, getHost());
+ } catch (ServiceException e) {
+ // Return an empty registry always providing null;
+ return new PageIconsRegistry();
+ }
+ }
+
+ /**
+ * Gets the editor registry.
+ *
+ * @return the singleton eINSTANCE of editor registry
+ *
+ * @generated NOT Get the EditorRegistry used to create editor instances.
+ * This default implementation return the singleton eINSTANCE.
+ * This method can be subclassed to return another registry.
+ */
+ protected IPageIconsRegistry getEditorRegistry() {
+ if (editorRegistry == null) {
+ editorRegistry = createEditorRegistry();
+ }
+ return editorRegistry;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java
index ce46788598b..27fe0bc19a4 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java
@@ -437,7 +437,7 @@ public class NavigationEditPolicy extends OpenEditPolicy {
/**
* Get the open command previously defined by ShortCutEditPolicy
- *
+ *
* @param request
* @return
*/
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigableElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigableElement.java
deleted file mode 100644
index 017312dd0e8..00000000000
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigableElement.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*****************************************************************************
- * 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.infra.gmfdiag.hyperlink.navigation;
-
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.papyrus.infra.gmfdiag.hyperlink.Activator;
-import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
-import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
-import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
-import org.eclipse.swt.graphics.Image;
-
-
-public class DiagramNavigableElement implements NavigableElement {
-
- protected Diagram targetDiagram;
-
- public DiagramNavigableElement(Diagram target) {
- this.targetDiagram = target;
- }
-
- public String getLabel() {
- return "Navigate to diagram " + targetDiagram.getName();
- }
-
- public String getDescription() {
- return String.format("Navigates to the %s %s", targetDiagram.getType(), targetDiagram.getName());
- }
-
- public boolean navigate(NavigationTarget navigationContext) {
- try {
- final IPageManager pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(targetDiagram);
- if (pageManager.isOpen(targetDiagram)) {
- pageManager.selectPage(targetDiagram);
- } else {
- pageManager.openPage(targetDiagram);
- }
-
- return true;
- } catch (ServiceException ex) {
- Activator.log.error(ex);
- }
-
- return false;
- }
-
- @Deprecated
- public void navigate(IRevealSemanticElement revealSemanticElement) {
- }
-
- public Image getImage() {
- if (targetDiagram != null) {
- try {
- ILabelProvider labelProvider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, targetDiagram).getLabelProvider();
- return labelProvider.getImage(targetDiagram);
- } catch (ServiceException ex) {
- return null;
- }
- }
- return null;
- }
-
- public boolean isEnabled() {
- return targetDiagram != null;
- }
-
-}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigationProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigationProvider.java
deleted file mode 100644
index 6c0e00e2ad9..00000000000
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigationProvider.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2013, 2014 CEA LIST and others.
- *
- * 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
- * Christian W. Damus (CEA) - bug 430726
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.hyperlink.navigation;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
-import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
-import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor;
-
-
-public class DiagramNavigationProvider implements NavigationContributor {
-
- public List<NavigableElement> getNavigableElements(Object fromElement) {
- if (fromElement != null) {
- // Find pages under the element (isPageContainer)
- // Alt1: Find diagrams under the element (+ all Tables in a separate provider)
-
- List<NavigableElement> navigableElements = new LinkedList<NavigableElement>();
-
-
- for (Diagram diagram : getOwnedDiagrams(fromElement)) {
- navigableElements.add(new DiagramNavigableElement(diagram));
- }
- return navigableElements;
- }
- return Collections.emptyList();
- }
-
- protected List<Diagram> getOwnedDiagrams(Object fromElement) {
- EObject eObject = EMFHelper.getEObject(fromElement); // Should not be null (Otherwise, return=)
- View currentView = NotationHelper.findView(fromElement); // May be null (e.g. Selection from the ModelExplorer)
- if (eObject instanceof View || eObject == null) {
- return Collections.emptyList();
- }
-
- try {
- List<Diagram> ownedDiagrams = new LinkedList<Diagram>();
-
- IPageManager pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(eObject);
- for (Object pageObject : pageManager.allPages()) {
- if (pageObject instanceof Diagram) {
- Diagram diagram = (Diagram) pageObject;
-
- // Avoid navigation to the current diagram
- if (currentView != null && currentView.getDiagram() == diagram) {
- continue;
- }
-
- if (diagram.getElement() == eObject) {
- ownedDiagrams.add(diagram);
- }
- }
- }
-
- return ownedDiagrams;
- } catch (ServiceException ex) {
- return Collections.emptyList();
- }
- }
-
-}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java
index eb71d7edd18..10fab80d91b 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java
@@ -1,77 +1,70 @@
-/*****************************************************************************
- * Copyright (c) 2012, 2014 CEA LIST, 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
- * 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
- * Christian W. Damus - bug 451230
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.hyperlink.providers;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies.HyperLinkPopupBarEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies.NavigationEditPolicy;
-
-/**
- * An EditPolicyProvider for Navigation and Hyperlinks
- *
- * @author Camille Letavernier
- *
- */
-public class HyperlinkEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
-
- /**
- * {@inheritDoc}
- *
- * This provider can handle GraphicalEditParts
- */
- public boolean provides(IOperation operation) {
- if (operation instanceof CreateEditPoliciesOperation) {
- CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
- EditPart editPart = epOperation.getEditPart();
- try {
- ServicesRegistry registry = ServiceUtilsForEditPart.getInstance().getServiceRegistry(editPart);
- if (registry == null) {
- // We're not in the Papyrus context
- return false;
- }
- } catch (ServiceException ex) {
- // We're not in the Papyrus context
- // Ignore the exception and do not provide the EditPolicy
- return false;
- }
- return editPart instanceof IGraphicalEditPart;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * Installs the Hyperlink and Navigation edit policies
- */
- public void createEditPolicies(EditPart editPart) {
- if (editPart instanceof IPrimaryEditPart) {
- editPart.removeEditPolicy(EditPolicyRoles.POPUPBAR_ROLE);
- editPart.installEditPolicy(EditPolicyRoles.POPUPBAR_ROLE, new HyperLinkPopupBarEditPolicy());
- }
- editPart.installEditPolicy(NavigationEditPolicy.NAVIGATION_POLICY, new NavigationEditPolicy());
-
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2012, 2014 CEA LIST, 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
+ * 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
+ * Christian W. Damus - bug 451230
+ * Shuai Li
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.hyperlink.providers;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies.HyperlinkNavigationMenuEditPolicy;
+
+/**
+ * An EditPolicyProvider for Navigation and Hyperlinks
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class HyperlinkEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
+
+ /**
+ * {@inheritDoc}
+ *
+ * This provider can handle GraphicalEditParts
+ */
+ public boolean provides(IOperation operation) {
+ if (operation instanceof CreateEditPoliciesOperation) {
+ CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
+ EditPart editPart = epOperation.getEditPart();
+ try {
+ ServicesRegistry registry = ServiceUtilsForEditPart.getInstance().getServiceRegistry(editPart);
+ if (registry == null) {
+ // We're not in the Papyrus context
+ return false;
+ }
+ } catch (ServiceException ex) {
+ // We're not in the Papyrus context
+ // Ignore the exception and do not provide the EditPolicy
+ return false;
+ }
+ return editPart instanceof IGraphicalEditPart;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Installs the Hyperlink and Navigation edit policies
+ */
+ public void createEditPolicies(EditPart editPart) {
+ editPart.installEditPolicy(org.eclipse.papyrus.infra.gmfdiag.navigation.editpolicy.NavigationEditPolicy.EDIT_POLICY_ID, new HyperlinkNavigationMenuEditPolicy());
+ editPart.installEditPolicy(org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies.NavigationEditPolicy.NAVIGATION_POLICY, new org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies.NavigationEditPolicy());
+ }
+}

Back to the top