diff options
author | Shuai Li | 2015-05-07 14:40:12 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2015-10-30 14:33:02 +0000 |
commit | 7bce7a1129ccdff55e1104bc2ecd63fbd22e2142 (patch) | |
tree | 649b0b5477d6d792fd8192cfb14eb193a6c4cad6 /plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch | |
parent | 4ef7439e07e4bfcfa03b07d690afaabbe7361689 (diff) | |
download | org.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/infra/services/org.eclipse.papyrus.infra.services.viewersearch')
3 files changed, 323 insertions, 232 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/IExtendedViewerSearcher.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/IExtendedViewerSearcher.java new file mode 100644 index 00000000000..78fe22ad0d8 --- /dev/null +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/IExtendedViewerSearcher.java @@ -0,0 +1,40 @@ +/***************************************************************************** + * 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.infra.services.viewersearch; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; + +/** + * @author Shuai Li (CEA LIST) <shuai.li@cea.fr> + * + */ +public interface IExtendedViewerSearcher extends IViewerSearcher { + /** + * Get viewers of an element in the currently loaded model, according to some parameters. + * + * @param element + * Find views of this element (may be null if container is not null) + * @param container + * Find view contained by this container (may be null if element is not null) + * @param pagesOnly + * Return pages containing found views + * @param openPagesOnly + * Find views in open pages only + * @return + * A list of objects that are related to found views (e.g. the views themselves) + */ + public List<Object> getViewersInCurrentModel(EObject element, EObject container, boolean pagesOnly, boolean openPagesOnly); +} diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/impl/AbstractViewerSearcher.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/impl/AbstractViewerSearcher.java index 496e3a8f193..c12c40a9995 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/impl/AbstractViewerSearcher.java +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/impl/AbstractViewerSearcher.java @@ -1,76 +1,90 @@ -/*****************************************************************************
- * 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.services.viewersearch.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher;
-
-/**
- * Abstract implementation of a ViewerSearcher.
- */
-public abstract class AbstractViewerSearcher implements IViewerSearcher {
-
- /**
- * Generic implementation of this method that shouldn't be overridden
- *
- * @see org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher#getViewers(java.util.Collection, org.eclipse.papyrus.infra.core.resource.ModelSet)
- *
- * @param modelElements
- * @param modelSet
- * @return
- */
-
- public Map<Object, Map<Object, Object>> getViewers(Collection<Object> modelElements, ModelSet modelSet) {
- List<ModelSet> listModelSet = new ArrayList<ModelSet>();
- listModelSet.add(modelSet);
-
- return getViewers(modelElements, listModelSet);
-
- }
-
- /**
- * Generic implementation of this method that shouldn't be overridden
- *
- * @see org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher#getViewers(java.lang.Object, org.eclipse.papyrus.infra.core.resource.ModelSet)
- *
- * @param modelElement
- * @param modelSet
- * @return
- */
-
- public Map<Object, Map<Object, Object>> getViewers(Object modelElement, ModelSet modelSet) {
- List<ModelSet> listModelSet = new ArrayList<ModelSet>();
- listModelSet.add(modelSet);
-
- List<Object> listModelElement = new ArrayList<Object>();
- listModelElement.add(modelElement);
-
- return getViewers(listModelElement, listModelSet);
- }
-
- /**
- * @see org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher#getViewers(java.util.Collection, java.util.Collection)
- *
- * @param modelElements
- * @param models
- * @return
- */
-
- public abstract Map<Object, Map<Object, Object>> getViewers(Collection<Object> modelElements, Collection<ModelSet> models);
-}
+/***************************************************************************** + * 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: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.viewersearch.impl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.services.viewersearch.IExtendedViewerSearcher; +import org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher; + +/** + * Abstract implementation of a ViewerSearcher. + */ +public abstract class AbstractViewerSearcher implements IExtendedViewerSearcher { + + /** + * Generic implementation of this method that shouldn't be overridden + * + * @see org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher#getViewers(java.util.Collection, org.eclipse.papyrus.infra.core.resource.ModelSet) + * + * @param modelElements + * @param modelSet + * @return + */ + + public Map<Object, Map<Object, Object>> getViewers(Collection<Object> modelElements, ModelSet modelSet) { + List<ModelSet> listModelSet = new ArrayList<ModelSet>(); + listModelSet.add(modelSet); + + return getViewers(modelElements, listModelSet); + + } + + /** + * Generic implementation of this method that shouldn't be overridden + * + * @see org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher#getViewers(java.lang.Object, org.eclipse.papyrus.infra.core.resource.ModelSet) + * + * @param modelElement + * @param modelSet + * @return + */ + + public Map<Object, Map<Object, Object>> getViewers(Object modelElement, ModelSet modelSet) { + List<ModelSet> listModelSet = new ArrayList<ModelSet>(); + listModelSet.add(modelSet); + + List<Object> listModelElement = new ArrayList<Object>(); + listModelElement.add(modelElement); + + return getViewers(listModelElement, listModelSet); + } + + /** + * @see org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher#getViewers(java.util.Collection, java.util.Collection) + * + * @param modelElements + * @param models + * @return + */ + + public abstract Map<Object, Map<Object, Object>> getViewers(Collection<Object> modelElements, Collection<ModelSet> models); + + /** + * + * @see org.eclipse.papyrus.infra.services.viewersearch.IExtendedViewerSearcher#getViewersInCurrentModel(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject, boolean, boolean) + * + * @param element + * @param container + * @param pagesOnly + * @param openPagesOnly + * @return + */ + public abstract List<Object> getViewersInCurrentModel(EObject element, EObject container, boolean pagesOnly, boolean openPagesOnly); +} diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/impl/ViewerSearchService.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/impl/ViewerSearchService.java index f31f4068b91..7dd317400f5 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/impl/ViewerSearchService.java +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.viewersearch/src/org/eclipse/papyrus/infra/services/viewersearch/impl/ViewerSearchService.java @@ -1,156 +1,193 @@ -/*****************************************************************************
- * 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.services.viewersearch.impl;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.services.IService;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.services.viewersearch.Activator;
-import org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher;
-import org.eclipse.papyrus.infra.services.viewersearch.Messages;
-
-/**
- * The actual implementation of the ViewerSearcherService.
- */
-public class ViewerSearchService extends AbstractViewerSearcher implements IService {
-
- public final static String EXTENSION_ID = Activator.PLUGIN_ID + ".viewerSearcher"; //$NON-NLS-1$
-
- public final static String VIEWER_SEARCHER_ID = "id"; //$NON-NLS-1$
-
- public final static String VIEWER_SEARCHER_CLASS = "class"; //$NON-NLS-1$
-
- /** The viewerSearchers that contribute to the service. */
- private final Map<String, IViewerSearcher> viewerSearchers = new HashMap<String, IViewerSearcher>();
-
- public ViewerSearchService() {
-
- }
-
- /**
- * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry)
- *
- * @param servicesRegistry
- * @throws ServiceException
- */
-
- public void init(ServicesRegistry servicesRegistry) throws ServiceException {
-
- }
-
- /**
- * @see org.eclipse.papyrus.infra.core.services.IService#startService()
- *
- * @throws ServiceException
- */
-
- public void startService() throws ServiceException {
- IConfigurationElement[] configurations = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
-
- readViewerSearchers(configurations);
- }
-
- /**
- * Parses the available viewerSearcher from the extension point.
- *
- * @param configurations
- * The extension point IConfigurationElements
- */
- private void readViewerSearchers(IConfigurationElement[] configurations) {
- viewerSearchers.clear();
-
- for (IConfigurationElement config : configurations) {
- try {
- if ("viewerSearcher".equals(config.getName())) { //$NON-NLS-1$
- String viewerSearcherId = config.getAttribute(VIEWER_SEARCHER_ID);
- if (viewerSearcherId == null) {
- Activator.log.warn(Messages.ViewerSearcherService_2 + config.getContributor() + Messages.ViewerSearcherService_3 + EXTENSION_ID + Messages.ViewerSearcherService_4 + VIEWER_SEARCHER_ID + Messages.ViewerSearcherService_5);
- continue;
- }
-
- IViewerSearcher viewerSearcherClass = (IViewerSearcher) config.createExecutableExtension(VIEWER_SEARCHER_CLASS);
- if (viewerSearcherClass == null) {
- Activator.log.warn(Messages.ViewerSearcherService_6 + config.getContributor() + Messages.ViewerSearcherService_7 + EXTENSION_ID + Messages.ViewerSearcherService_8 + VIEWER_SEARCHER_CLASS + Messages.ViewerSearcherService_9);
- continue;
- }
-
- if (viewerSearchers.containsKey(viewerSearcherId)) {
- Activator.log.warn(Messages.ViewerSearcherService_10 + viewerSearcherId + Messages.ViewerSearcherService_11);
- continue;
- }
-
- /** Associates an empty viewerSearchers to the context */
- viewerSearchers.put(viewerSearcherId, viewerSearcherClass);
- }
- } catch (Exception ex) {
- Activator.log.error("The plugin " + config.getContributor() + " contributed an invalid extension for " + EXTENSION_ID, ex); //$NON-NLS-1$//$NON-NLS-2$
- }
- }
- }
-
- /**
- * @see org.eclipse.papyrus.infra.core.services.IService#disposeService()
- *
- * @throws ServiceException
- */
-
- public void disposeService() throws ServiceException {
- viewerSearchers.clear();
-
- }
-
- /**
- * Collects viewers from the difference viewerSearcher contributors
- *
- * @see org.eclipse.papyrus.infra.services.viewersearch.impl.AbstractViewerSearcher#getViewers(java.util.Collection, java.util.Collection)
- *
- * @param modelElements
- * @param models
- * @return
- */
-
- @Override
- public Map<Object, Map<Object, Object>> getViewers(Collection<Object> modelElements, Collection<ModelSet> models) {
- Map<Object, Map<Object, Object>> results = new HashMap<Object, Map<Object, Object>>();
-
- for (String key : viewerSearchers.keySet()) {
- IViewerSearcher viewerSearcher = viewerSearchers.get(key);
-
- Map<Object, Map<Object, Object>> subResults = viewerSearcher.getViewers(modelElements, models);
- if (subResults != null) {
- for (Object viewer : subResults.keySet()) {
-
- if (results.containsKey(viewer)) {
- Map<Object, Object> viewMappings = subResults.get(viewer);
- Map<Object, Object> resultViewMappings = results.get(viewer);
- resultViewMappings.putAll(viewMappings);
-
- } else {
- results.put(viewer, subResults.get(viewer));
- }
- }
- }
- }
-
- return results;
- }
-
-}
+/***************************************************************************** + * 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: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.viewersearch.impl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.IService; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.services.viewersearch.Activator; +import org.eclipse.papyrus.infra.services.viewersearch.IExtendedViewerSearcher; +import org.eclipse.papyrus.infra.services.viewersearch.IViewerSearcher; +import org.eclipse.papyrus.infra.services.viewersearch.Messages; + +/** + * The actual implementation of the ViewerSearcherService. + */ +public class ViewerSearchService extends AbstractViewerSearcher implements IService { + + public final static String EXTENSION_ID = Activator.PLUGIN_ID + ".viewerSearcher"; //$NON-NLS-1$ + + public final static String VIEWER_SEARCHER_ID = "id"; //$NON-NLS-1$ + + public final static String VIEWER_SEARCHER_CLASS = "class"; //$NON-NLS-1$ + + /** The viewerSearchers that contribute to the service. */ + private final Map<String, IViewerSearcher> viewerSearchers = new HashMap<String, IViewerSearcher>(); + + public ViewerSearchService() { + + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + + public void startService() throws ServiceException { + IConfigurationElement[] configurations = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID); + + readViewerSearchers(configurations); + } + + /** + * Parses the available viewerSearcher from the extension point. + * + * @param configurations + * The extension point IConfigurationElements + */ + private void readViewerSearchers(IConfigurationElement[] configurations) { + viewerSearchers.clear(); + + for (IConfigurationElement config : configurations) { + try { + if ("viewerSearcher".equals(config.getName())) { //$NON-NLS-1$ + String viewerSearcherId = config.getAttribute(VIEWER_SEARCHER_ID); + if (viewerSearcherId == null) { + Activator.log.warn(Messages.ViewerSearcherService_2 + config.getContributor() + Messages.ViewerSearcherService_3 + EXTENSION_ID + Messages.ViewerSearcherService_4 + VIEWER_SEARCHER_ID + Messages.ViewerSearcherService_5); + continue; + } + + IViewerSearcher viewerSearcherClass = (IViewerSearcher) config.createExecutableExtension(VIEWER_SEARCHER_CLASS); + if (viewerSearcherClass == null) { + Activator.log.warn(Messages.ViewerSearcherService_6 + config.getContributor() + Messages.ViewerSearcherService_7 + EXTENSION_ID + Messages.ViewerSearcherService_8 + VIEWER_SEARCHER_CLASS + Messages.ViewerSearcherService_9); + continue; + } + + if (viewerSearchers.containsKey(viewerSearcherId)) { + Activator.log.warn(Messages.ViewerSearcherService_10 + viewerSearcherId + Messages.ViewerSearcherService_11); + continue; + } + + /** Associates an empty viewerSearchers to the context */ + viewerSearchers.put(viewerSearcherId, viewerSearcherClass); + } + } catch (Exception ex) { + Activator.log.error("The plugin " + config.getContributor() + " contributed an invalid extension for " + EXTENSION_ID, ex); //$NON-NLS-1$//$NON-NLS-2$ + } + } + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + + public void disposeService() throws ServiceException { + viewerSearchers.clear(); + + } + + /** + * Collects viewers from the difference viewerSearcher contributors + * + * @see org.eclipse.papyrus.infra.services.viewersearch.impl.AbstractViewerSearcher#getViewers(java.util.Collection, java.util.Collection) + * + * @param modelElements + * @param models + * @return + */ + + @Override + public Map<Object, Map<Object, Object>> getViewers(Collection<Object> modelElements, Collection<ModelSet> models) { + Map<Object, Map<Object, Object>> results = new HashMap<Object, Map<Object, Object>>(); + + for (String key : viewerSearchers.keySet()) { + IViewerSearcher viewerSearcher = viewerSearchers.get(key); + + Map<Object, Map<Object, Object>> subResults = viewerSearcher.getViewers(modelElements, models); + if (subResults != null) { + for (Object viewer : subResults.keySet()) { + + if (results.containsKey(viewer)) { + Map<Object, Object> viewMappings = subResults.get(viewer); + Map<Object, Object> resultViewMappings = results.get(viewer); + resultViewMappings.putAll(viewMappings); + + } else { + results.put(viewer, subResults.get(viewer)); + } + } + } + } + + return results; + } + + /** + * @see org.eclipse.papyrus.infra.services.viewersearch.impl.AbstractViewerSearcher#getViewersInCurrentModel(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject, boolean, boolean) + * + * @param element + * @param container + * @param pagesOnly + * @param openPagesOnly + * @return + */ + @Override + public List<Object> getViewersInCurrentModel(EObject element, EObject container, boolean pagesOnly, boolean openPagesOnly) { + List<Object> results = new ArrayList<Object>(); + + for (String key : viewerSearchers.keySet()) { + IViewerSearcher viewerSearcher = viewerSearchers.get(key); + + if (viewerSearcher instanceof IExtendedViewerSearcher) { + List<Object> subResults = ((IExtendedViewerSearcher) viewerSearcher).getViewersInCurrentModel(element, container, pagesOnly, openPagesOnly); + + if (subResults != null) { + for (Object object : subResults) { + if (!results.contains(object)) { + results.add(object); + } + } + } + } + + } + + return results; + } + +} |