Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuai Li2015-05-07 14:40:12 +0000
committerGerrit Code Review @ Eclipse.org2015-10-30 14:33:02 +0000
commit7bce7a1129ccdff55e1104bc2ecd63fbd22e2142 (patch)
tree649b0b5477d6d792fd8192cfb14eb193a6c4cad6 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src
parent4ef7439e07e4bfcfa03b07d690afaabbe7361689 (diff)
downloadorg.eclipse.papyrus-7bce7a1129ccdff55e1104bc2ecd63fbd22e2142.tar.gz
org.eclipse.papyrus-7bce7a1129ccdff55e1104bc2ecd63fbd22e2142.tar.xz
org.eclipse.papyrus-7bce7a1129ccdff55e1104bc2ecd63fbd22e2142.zip
Bug 465886 - [Navigation, Hyperlink] Double-click default action
- Double-click now creates hyperlinks if there are no default hyperlinks. This is done with hyperlinkContributor extensions. If there are none, then the hyperlinks menu opens. - Add HyperlinkService and its preferences page for hyperlink contributors. (The navigation service is not used for hyperlink contributors because otherwise there is a cyclic dependency issue.) - Hyperlink contributors for nested/nesting package, target/source of element in a directed relationship, owned behavior and inner class of a class - Specific hyperlinks icon for web and document - For nested and nesting contributors, diagrams must be of type class or composite - Add inner composite structure hyperlink contributor - Remove heuristic tab from hyperlink manager (remove extension from uml.diagram.common) - Open normal hyperlink manager instead of advanced one (with the heuristic tab) Patch set 16: - Remove oep.uml.hyperlink plugin (including feature and pom) - Move hyperlink contributors to oep.uml.diagram.X plugins accordingly - Views search is done with ViewerSearchService and DiagramViewerSearcher extends AbstractViewerSearcher implements IExtendedViewerSearcher; IExtendedViewerSearch is a new interface that extends IViewerSearcher - oep.uml.diagram.X depends on oep.infra.hyperlink and oep.infra.services.viewersearch - Remove table hyperlinks since all tables are trees now; will re-integrate in tree table navigation patch Change-Id: I071767591243819205b35f4965383a43ce48cd2a Signed-off-by: Shuai Li <shuai.li@cea.fr>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/InnerCompositeStructureHyperlinkContributor.java94
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/NestedPackageHyperlinkContributor.java124
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/NestingPackageHyperlinkContributor.java121
3 files changed, 339 insertions, 0 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/InnerCompositeStructureHyperlinkContributor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/InnerCompositeStructureHyperlinkContributor.java
new file mode 100644
index 00000000000..4958813b7ac
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/InnerCompositeStructureHyperlinkContributor.java
@@ -0,0 +1,94 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Shuai Li (CEA LIST) <shuai.li@cea.fr> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.composite.custom.hyperlink;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.infra.core.services.BadStateException;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkEditor;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
+import org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor;
+import org.eclipse.papyrus.infra.services.viewersearch.impl.ViewerSearchService;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart;
+
+/**
+ * Returns a list of HyperLinkEditors referencing
+ * inner composite structure diagrams
+ *
+ * @author Shuai Li
+ *
+ */
+public class InnerCompositeStructureHyperlinkContributor implements HyperlinkContributor {
+
+ /**
+ * @see org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor#getHyperlinks(java.lang.Object)
+ *
+ * @param fromElement
+ * @return
+ */
+ public List<HyperLinkObject> getHyperlinks(Object fromElement) {
+ ArrayList<HyperLinkObject> hyperlinks = new ArrayList<HyperLinkObject>();
+
+ if (fromElement instanceof org.eclipse.uml2.uml.Class) {
+ List<Object> objectsInViews = new ArrayList<Object>();
+
+ ViewerSearchService viewerSearchService = null;
+ try {
+ viewerSearchService = ServiceUtilsForEObject.getInstance().getService(ViewerSearchService.class, (EObject) fromElement);
+ } catch (ServiceException e) {
+ if (e instanceof ServiceNotFoundException) {
+ viewerSearchService = new ViewerSearchService();
+ try {
+ viewerSearchService.startService();
+ ServiceUtilsForEObject.getInstance().getServiceRegistry((EObject) fromElement).add(ViewerSearchService.class, 1, viewerSearchService);
+ } catch (ServiceException e1) {
+ Activator.log.error(e1);
+ }
+ } else if (e instanceof BadStateException) {
+ try {
+ ServiceUtilsForEObject.getInstance().getServiceRegistry((EObject) fromElement).startRegistry();
+ viewerSearchService = ServiceUtilsForEObject.getInstance().getService(ViewerSearchService.class, (EObject) fromElement);
+ } catch (Exception e1) {
+ Activator.log.error(e1);
+ }
+ }
+ }
+
+ if (viewerSearchService != null) {
+ List<Object> viewerSearchResults = viewerSearchService.getViewersInCurrentModel((org.eclipse.uml2.uml.Class) fromElement, (org.eclipse.uml2.uml.Class) fromElement, true, false);
+ objectsInViews.addAll(viewerSearchResults);
+ }
+
+ for (Object object : objectsInViews) {
+ if (object instanceof Diagram) {
+ if (((Diagram) object).getType().equals(CompositeStructureDiagramEditPart.MODEL_ID)) {
+ HyperLinkEditor hyperlink = new HyperLinkEditor();
+ hyperlink.setObject(object);
+ hyperlinks.add(hyperlink);
+ }
+ }
+ }
+ }
+
+ return hyperlinks;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/NestedPackageHyperlinkContributor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/NestedPackageHyperlinkContributor.java
new file mode 100644
index 00000000000..0750025442a
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/NestedPackageHyperlinkContributor.java
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Shuai Li (CEA LIST) <shuai.li@cea.fr> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.composite.custom.hyperlink;
+
+import java.util.ArrayList;
+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.editor.IPage;
+import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
+import org.eclipse.papyrus.infra.core.services.BadStateException;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.hyperlink.Activator;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkEditor;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
+import org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor;
+import org.eclipse.papyrus.infra.services.viewersearch.impl.ViewerSearchService;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart;
+
+/**
+ * Returns a list of HyperLinkEditor objects referencing views directly owned by
+ * the nested packages of the double-clicked package.
+ *
+ * @author Shuai Li
+ *
+ */
+public class NestedPackageHyperlinkContributor implements HyperlinkContributor {
+
+ /**
+ * @see org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor#getHyperlinks(java.lang.Object)
+ *
+ * @param fromElement
+ * @return
+ */
+ public List<HyperLinkObject> getHyperlinks(Object fromElement) {
+ ArrayList<HyperLinkObject> hyperlinks = new ArrayList<HyperLinkObject>();
+
+ if (fromElement instanceof org.eclipse.uml2.uml.Package) {
+ List<org.eclipse.uml2.uml.Package> nestedPackages = ((org.eclipse.uml2.uml.Package) fromElement).getNestedPackages();
+ List<Object> pages = new ArrayList<Object>();
+
+ for (org.eclipse.uml2.uml.Package nestedPackage : nestedPackages) {
+ ViewerSearchService viewerSearchService = null;
+ try {
+ viewerSearchService = ServiceUtilsForEObject.getInstance().getService(ViewerSearchService.class, (EObject) fromElement);
+ } catch (ServiceException e) {
+ if (e instanceof ServiceNotFoundException) {
+ viewerSearchService = new ViewerSearchService();
+ try {
+ viewerSearchService.startService();
+ ServiceUtilsForEObject.getInstance().getServiceRegistry((EObject) fromElement).add(ViewerSearchService.class, 1, viewerSearchService);
+ } catch (ServiceException e1) {
+ Activator.log.error(e1);
+ }
+ } else if (e instanceof BadStateException) {
+ try {
+ ServiceUtilsForEObject.getInstance().getServiceRegistry((EObject) fromElement).startRegistry();
+ viewerSearchService = ServiceUtilsForEObject.getInstance().getService(ViewerSearchService.class, (EObject) fromElement);
+ } catch (Exception e1) {
+ Activator.log.error(e1);
+ }
+ }
+ }
+
+ if (viewerSearchService != null) {
+ List<Object> viewerSearchResults = viewerSearchService.getViewersInCurrentModel(null, nestedPackage, true, false);
+ pages.addAll(viewerSearchResults);
+ }
+ }
+
+ for (Object page : pages) {
+
+ if (page instanceof Diagram
+ && ((Diagram) page).getType().equals(CompositeStructureDiagramEditPart.MODEL_ID)) {
+ try {
+ // Page must not be active page
+ IPage activeSashPage = ServiceUtilsForEObject.getInstance().getISashWindowsContainer((org.eclipse.uml2.uml.Package) fromElement).getActiveSashWindowsPage();
+ Object activePage = null;
+
+ if (activeSashPage != null) {
+ Object pageId = activeSashPage.getRawModel();
+
+ if (pageId instanceof PageRef) {
+ Object emfPageId = ((PageRef) pageId).getEmfPageIdentifier();
+
+ if (emfPageId instanceof View) {
+ activePage = emfPageId;
+ }
+ }
+ }
+
+ if (activePage == null || !activePage.equals(page)) {
+ HyperLinkEditor hyperlink = new HyperLinkEditor();
+ hyperlink.setObject(page);
+ hyperlinks.add(hyperlink);
+ }
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+
+
+ }
+ }
+
+ return hyperlinks;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/NestingPackageHyperlinkContributor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/NestingPackageHyperlinkContributor.java
new file mode 100644
index 00000000000..272c0630c6d
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/hyperlink/NestingPackageHyperlinkContributor.java
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Shuai Li (CEA LIST) <shuai.li@cea.fr> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.composite.custom.hyperlink;
+
+import java.util.ArrayList;
+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.editor.IPage;
+import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
+import org.eclipse.papyrus.infra.core.services.BadStateException;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.hyperlink.Activator;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkEditor;
+import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject;
+import org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor;
+import org.eclipse.papyrus.infra.services.viewersearch.impl.ViewerSearchService;
+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart;
+
+/**
+ * Returns a list of HyperLinkEditor objects referencing views directly owned by
+ * the nesting package of the double-clicked package.
+ *
+ * @author Shuai Li
+ *
+ */
+public class NestingPackageHyperlinkContributor implements HyperlinkContributor {
+
+ /**
+ * @see org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor#getHyperlinks(java.lang.Object)
+ *
+ * @param fromElement
+ * @return
+ */
+ public List<HyperLinkObject> getHyperlinks(Object fromElement) {
+ ArrayList<HyperLinkObject> hyperlinks = new ArrayList<HyperLinkObject>();
+
+ if (fromElement instanceof org.eclipse.uml2.uml.Package) {
+ org.eclipse.uml2.uml.Package nestingPackage = ((org.eclipse.uml2.uml.Package) fromElement).getNestingPackage();
+ List<Object> pages = new ArrayList<Object>();
+
+ if (nestingPackage != null) {
+ ViewerSearchService viewerSearchService = null;
+ try {
+ viewerSearchService = ServiceUtilsForEObject.getInstance().getService(ViewerSearchService.class, (EObject) fromElement);
+ } catch (ServiceException e) {
+ if (e instanceof ServiceNotFoundException) {
+ viewerSearchService = new ViewerSearchService();
+ try {
+ viewerSearchService.startService();
+ ServiceUtilsForEObject.getInstance().getServiceRegistry((EObject) fromElement).add(ViewerSearchService.class, 1, viewerSearchService);
+ } catch (ServiceException e1) {
+ Activator.log.error(e1);
+ }
+ } else if (e instanceof BadStateException) {
+ try {
+ ServiceUtilsForEObject.getInstance().getServiceRegistry((EObject) fromElement).startRegistry();
+ viewerSearchService = ServiceUtilsForEObject.getInstance().getService(ViewerSearchService.class, (EObject) fromElement);
+ } catch (Exception e1) {
+ Activator.log.error(e1);
+ }
+ }
+ }
+
+ if (viewerSearchService != null) {
+ List<Object> viewerSearchResults = viewerSearchService.getViewersInCurrentModel(null, nestingPackage, true, false);
+ pages.addAll(viewerSearchResults);
+ }
+ }
+
+ for (Object page : pages) {
+ if (page instanceof Diagram
+ && ((Diagram) page).getType().equals(CompositeStructureDiagramEditPart.MODEL_ID)) {
+ try {
+ // Page must not be active page
+ IPage activeSashPage = ServiceUtilsForEObject.getInstance().getISashWindowsContainer((org.eclipse.uml2.uml.Package) fromElement).getActiveSashWindowsPage();
+ Object activePage = null;
+
+ if (activeSashPage != null) {
+ Object pageId = activeSashPage.getRawModel();
+
+ if (pageId instanceof PageRef) {
+ Object emfPageId = ((PageRef) pageId).getEmfPageIdentifier();
+
+ if (emfPageId instanceof View) {
+ activePage = emfPageId;
+ }
+ }
+ }
+
+ if (activePage == null || !activePage.equals(page)) {
+ HyperLinkEditor hyperlink = new HyperLinkEditor();
+ hyperlink.setObject(page);
+ hyperlinks.add(hyperlink);
+ }
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+ }
+
+ return hyperlinks;
+ }
+
+}

Back to the top