Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-04-30 11:57:34 +0000
committercletavernie2013-04-30 11:57:34 +0000
commitf7380e7301fcd7d2c48b8d013c62214ec82b0ef3 (patch)
tree3d713e0f0dec386857404b993a6c758a4a0ff651 /plugins/infra/services/org.eclipse.papyrus.infra.services.navigation
parentf9a3d88a88909845fd6c0bf85c513057ff02b342 (diff)
downloadorg.eclipse.papyrus-f7380e7301fcd7d2c48b8d013c62214ec82b0ef3.tar.gz
org.eclipse.papyrus-f7380e7301fcd7d2c48b8d013c62214ec82b0ef3.tar.xz
org.eclipse.papyrus-f7380e7301fcd7d2c48b8d013c62214ec82b0ef3.zip
404919: [Navigation Service] Improve the target of the Navigation Service
https://bugs.eclipse.org/bugs/show_bug.cgi?id=404919
Diffstat (limited to 'plugins/infra/services/org.eclipse.papyrus.infra.services.navigation')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/plugin.xml10
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/schema/navigationContributor.exsd50
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/preferences/NavigationServicePreferencesPage.java28
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/provider/NavigationTargetProvider.java39
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/provider/impl/ActiveEditorNavigationTargetProvider.java61
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigableElement.java14
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigationService.java2
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/impl/NavigationServiceImpl.java163
9 files changed, 341 insertions, 27 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/META-INF/MANIFEST.MF
index 1dd9c637a54..fd2a0e306c8 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/META-INF/MANIFEST.MF
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/META-INF/MANIFEST.MF
@@ -14,4 +14,5 @@ Require-Bundle: org.eclipse.ui,
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.infra.services.navigation,
+ org.eclipse.papyrus.infra.services.navigation.provider,
org.eclipse.papyrus.infra.services.navigation.service
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/plugin.xml
index 7f254917e4d..175d5758d53 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/plugin.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/plugin.xml
@@ -20,5 +20,15 @@
name="Navigation Service">
</page>
</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.navigation.navigationContributor">
+ <target
+ description="Display elements in the current active editor"
+ id="org.eclipse.papyrus.infra.services.navigation.target.activeEditor"
+ label="Show in the active editor"
+ navigationTargetProvider="org.eclipse.papyrus.infra.services.navigation.provider.impl.ActiveEditorNavigationTargetProvider"
+ order="10">
+ </target>
+ </extension>
</plugin>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/schema/navigationContributor.exsd b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/schema/navigationContributor.exsd
index 3cd82f134c7..6aceabdd22b 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/schema/navigationContributor.exsd
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/schema/navigationContributor.exsd
@@ -17,8 +17,11 @@
</appinfo>
</annotation>
<complexType>
- <sequence>
- <element ref="contributor" minOccurs="1" maxOccurs="unbounded"/>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <choice>
+ <element ref="target"/>
+ <element ref="contributor"/>
+ </choice>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
@@ -83,6 +86,49 @@
</complexType>
</element>
+ <element name="target">
+ <complexType>
+ <attribute name="navigationTargetProvider" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.services.navigation.provider.NavigationTargetProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="order" type="string" use="default" value="50">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<annotation>
<appinfo>
<meta.section type="since"/>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/preferences/NavigationServicePreferencesPage.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/preferences/NavigationServicePreferencesPage.java
index e6ba915f4c2..ac80cb3e623 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/preferences/NavigationServicePreferencesPage.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/preferences/NavigationServicePreferencesPage.java
@@ -29,7 +29,7 @@ import org.eclipse.jface.window.ToolTip;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.navigation.Activator;
import org.eclipse.papyrus.infra.services.navigation.service.impl.NavigationServiceImpl;
-import org.eclipse.papyrus.infra.services.navigation.service.impl.NavigationServiceImpl.NavigationContributorWrapper;
+import org.eclipse.papyrus.infra.services.navigation.service.impl.NavigationServiceImpl.NavigationContributorDescriptor;
import org.eclipse.papyrus.infra.widgets.providers.CollectionContentProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
@@ -49,7 +49,7 @@ public class NavigationServicePreferencesPage extends PreferencePage implements
public static final int ACTIVATION_COLUMN = 0;
- private Map<NavigationContributorWrapper, Button> checkboxes;
+ private Map<NavigationContributorDescriptor, Button> checkboxes;
private NavigationServiceImpl navigation = new NavigationServiceImpl();
@@ -101,15 +101,15 @@ public class NavigationServicePreferencesPage extends PreferencePage implements
@Override
public String getToolTipText(Object element) {
- if(element instanceof NavigationContributorWrapper) {
- return ((NavigationContributorWrapper)element).getDescription();
+ if(element instanceof NavigationContributorDescriptor) {
+ return ((NavigationContributorDescriptor)element).getDescription();
}
return super.getToolTipText(element);
}
@Override
public Image getImage(Object element) {
- if(element instanceof NavigationContributorWrapper) {
+ if(element instanceof NavigationContributorDescriptor) {
return null;
}
@@ -118,8 +118,8 @@ public class NavigationServicePreferencesPage extends PreferencePage implements
@Override
public String getText(Object element) {
- if(element instanceof NavigationContributorWrapper) {
- return ((NavigationContributorWrapper)element).getLabel();
+ if(element instanceof NavigationContributorDescriptor) {
+ return ((NavigationContributorDescriptor)element).getLabel();
}
return super.getText(element);
}
@@ -139,16 +139,16 @@ public class NavigationServicePreferencesPage extends PreferencePage implements
tableViewer.setInput(navigation.getNavigationContributors());
// Adds a checkbox for each service navigation, to toggle it
- checkboxes = new HashMap<NavigationContributorWrapper, Button>();
+ checkboxes = new HashMap<NavigationContributorDescriptor, Button>();
for(TableItem item : tableViewer.getTable().getItems()) {
- if(item.getData() instanceof NavigationContributorWrapper) {
+ if(item.getData() instanceof NavigationContributorDescriptor) {
TableEditor editor = new TableEditor(tableViewer.getTable());
final Button button = new Button(tableViewer.getTable(), SWT.CHECK);
final TableItem currentItem = item;
- final NavigationContributorWrapper strategy = (NavigationContributorWrapper)currentItem.getData();
+ final NavigationContributorDescriptor strategy = (NavigationContributorDescriptor)currentItem.getData();
checkboxes.put(strategy, button);
@@ -174,9 +174,9 @@ public class NavigationServicePreferencesPage extends PreferencePage implements
protected void performApply() {
IPreferenceStore preferences = Activator.getDefault().getPreferenceStore();
- for(Map.Entry<NavigationContributorWrapper, Button> entry : checkboxes.entrySet()) {
+ for(Map.Entry<NavigationContributorDescriptor, Button> entry : checkboxes.entrySet()) {
boolean checked = entry.getValue().getSelection();
- String isActiveKey = NavigationContributorWrapper.getIsActiveKey(entry.getKey());
+ String isActiveKey = NavigationContributorDescriptor.getIsActiveKey(entry.getKey());
preferences.setValue(isActiveKey, checked);
}
@@ -201,8 +201,8 @@ public class NavigationServicePreferencesPage extends PreferencePage implements
public void restoreDefaults() {
IPreferenceStore preferences = Activator.getDefault().getPreferenceStore();
- for(Map.Entry<NavigationContributorWrapper, Button> entry : checkboxes.entrySet()) {
- String isActiveKey = NavigationContributorWrapper.getIsActiveKey(entry.getKey());
+ for(Map.Entry<NavigationContributorDescriptor, Button> entry : checkboxes.entrySet()) {
+ String isActiveKey = NavigationContributorDescriptor.getIsActiveKey(entry.getKey());
boolean selected = preferences.getDefaultBoolean(isActiveKey);
entry.getValue().setSelection(selected);
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/provider/NavigationTargetProvider.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/provider/NavigationTargetProvider.java
new file mode 100644
index 00000000000..9b673859b2b
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/provider/NavigationTargetProvider.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * 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 (camille.letavernier@cea.fr) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.navigation.provider;
+
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
+
+
+/**
+ *
+ * A Provider to retrieve an implementation of a NavigationTarget from a ServicesRegistry.
+ * Implementations can retrieve e.g. the current ModelExplorer view, the Nested active editor, etc.
+ *
+ * @author Camille Letavernier
+ *
+ */
+public interface NavigationTargetProvider {
+
+ /**
+ *
+ * Returns an implementation of a NavigationTarget from the given context
+ *
+ * @param registry
+ * @return
+ * A NavigationTarget, or null if it is not available
+ */
+ public NavigationTarget getNavigationTarget(ServicesRegistry registry);
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/provider/impl/ActiveEditorNavigationTargetProvider.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/provider/impl/ActiveEditorNavigationTargetProvider.java
new file mode 100644
index 00000000000..d9bac24e722
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/provider/impl/ActiveEditorNavigationTargetProvider.java
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * 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 (camille.letavernier@cea.fr) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.navigation.provider.impl;
+
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.services.navigation.provider.NavigationTargetProvider;
+import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
+import org.eclipse.papyrus.infra.widgets.util.RevealSemanticElementWrapper;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * A NavigationTargetProvider to navigate in the current nested active editor
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class ActiveEditorNavigationTargetProvider implements NavigationTargetProvider {
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns the current active nestedEditor
+ */
+ public NavigationTarget getNavigationTarget(ServicesRegistry registry) {
+ IMultiDiagramEditor editor;
+ try {
+ editor = registry.getService(IMultiDiagramEditor.class);
+ if(editor == null) {
+ return null;
+ }
+ } catch (ServiceException ex) {
+ //We're not in the context of the multi diagram editor. We have nothing to contribute.
+ //Ignore the exception and do not do anything.
+ return null;
+ }
+
+ IEditorPart activeEditor = editor.getActiveEditor();
+ if(activeEditor instanceof NavigationTarget) {
+ return (NavigationTarget)activeEditor;
+ } else if(activeEditor instanceof IRevealSemanticElement) {
+ return new RevealSemanticElementWrapper((IRevealSemanticElement)activeEditor);
+ }
+
+ return null;
+ }
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigableElement.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigableElement.java
index 71f5b599174..544e2a9a327 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigableElement.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigableElement.java
@@ -12,6 +12,7 @@
package org.eclipse.papyrus.infra.services.navigation.service;
import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
import org.eclipse.swt.graphics.Image;
/**
@@ -40,10 +41,21 @@ public interface NavigableElement {
* Executes the navigation action
*
* @param navigationContext
+ * The NavigationTarget that can be used to select the navigation target
+ * @return true if the navigation context could select and reveal this element
+ */
+ public boolean navigate(NavigationTarget navigationContext);
+
+ /**
+ * Executes the navigation action
+ *
+ * @param navigationContext
* The IRevealSemanticElement that can be used to select the navigation target
*
+ * @deprecated Use {@link #navigate(NavigationTarget)} instead
*/
- public void navigate(IRevealSemanticElement navigationContext);
+ @Deprecated
+ public void navigate(IRevealSemanticElement revealSemanticElement);
/**
* The Image of this navigable element
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigationService.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigationService.java
index 23ef2db37ae..28270407290 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigationService.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/NavigationService.java
@@ -30,4 +30,6 @@ import org.eclipse.swt.widgets.Control;
public interface NavigationService extends IService, NavigationContributor {
public SelectionMenu createNavigationList(Object data, Control parent);
+
+ public void navigate(NavigableElement navigableElement);
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/impl/NavigationServiceImpl.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/impl/NavigationServiceImpl.java
index 39c5065ac76..b01eb1865ad 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/impl/NavigationServiceImpl.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.navigation/src/org/eclipse/papyrus/infra/services/navigation/service/impl/NavigationServiceImpl.java
@@ -11,9 +11,11 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.services.navigation.service.impl;
+import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import java.util.TreeSet;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
@@ -22,11 +24,13 @@ import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.services.navigation.Activator;
+import org.eclipse.papyrus.infra.services.navigation.provider.NavigationTargetProvider;
import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor;
import org.eclipse.papyrus.infra.services.navigation.service.NavigationService;
import org.eclipse.papyrus.infra.widgets.editors.SelectionMenu;
import org.eclipse.papyrus.infra.widgets.providers.CollectionContentProvider;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
@@ -47,25 +51,37 @@ public class NavigationServiceImpl implements NavigationService {
*/
public static final String IS_ACTIVE_KEY = "isActive"; //$NON-NLS-1$
+ protected ServicesRegistry registry;
+
+ /**
+ * {@inheritDoc}
+ */
public void init(ServicesRegistry servicesRegistry) throws ServiceException {
// Nothing
+ this.registry = servicesRegistry;
}
+ /**
+ * {@inheritDoc}
+ */
public void startService() throws ServiceException {
createNavigationContributors();
-
+ createNavigationTargetProviders();
}
protected void createNavigationContributors() {
- navigationContributors = new LinkedList<NavigationContributorWrapper>();
+ navigationContributors = new LinkedList<NavigationContributorDescriptor>();
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
for(IConfigurationElement e : config) {
+ if(!"contributor".equals(e.getName())) {
+ continue;
+ }
try {
Object instance = e.createExecutableExtension("contributor");
if(instance instanceof NavigationContributor) {
- NavigationContributorWrapper wrapper = new NavigationContributorWrapper((NavigationContributor)instance);
+ NavigationContributorDescriptor wrapper = new NavigationContributorDescriptor((NavigationContributor)instance);
wrapper.setId(e.getAttribute("id"));
wrapper.setLabel(e.getAttribute("label"));
wrapper.setDescription(e.getAttribute("description"));
@@ -78,14 +94,45 @@ public class NavigationServiceImpl implements NavigationService {
}
}
+ protected void createNavigationTargetProviders() {
+ navigationTargetProviders = new TreeSet<NavigationTargetProvider>();
+
+ IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+
+ for(IConfigurationElement e : config) {
+ if(!"target".equals(e.getName())) {
+ continue;
+ }
+ try {
+ Object instance = e.createExecutableExtension("navigationTargetProvider");
+ if(instance instanceof NavigationTargetProvider) {
+ NavigationTargetProviderDescriptor descriptor = new NavigationTargetProviderDescriptor((NavigationTargetProvider)instance);
+ descriptor.setId(e.getAttribute("id"));
+ descriptor.setLabel(e.getAttribute("label"));
+ descriptor.setDescription(e.getAttribute("description"));
+ descriptor.setOrder(Integer.parseInt(e.getAttribute("order")));
+ navigationTargetProviders.add(descriptor);
+ }
+ } catch (Exception ex) {
+ Activator.log.warn("Invalid navigation target contribution from: " + e.getContributor());
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void disposeService() throws ServiceException {
- // Nothing
+ this.registry = null;
}
+ /**
+ * {@inheritDoc}
+ */
public List<NavigableElement> getNavigableElements(Object fromElement) {
List<NavigableElement> navigableElements = new LinkedList<NavigableElement>();
- for(NavigationContributorWrapper contributor : navigationContributors) {
+ for(NavigationContributorDescriptor contributor : navigationContributors) {
if(contributor.isActive()) {
navigableElements.addAll(contributor.getNavigableElements(fromElement));
}
@@ -94,7 +141,73 @@ public class NavigationServiceImpl implements NavigationService {
return navigableElements;
}
- public static class NavigationContributorWrapper implements NavigationContributor {
+ public static class NavigationTargetProviderDescriptor implements NavigationTargetProvider, Comparable<NavigationTargetProviderDescriptor> {
+
+ private NavigationTargetProvider provider;
+
+ private int order;
+
+ private String label;
+
+ private String description;
+
+ private String id;
+
+ public NavigationTargetProviderDescriptor(NavigationTargetProvider provider) {
+ this.provider = provider;
+ }
+
+ public NavigationTarget getNavigationTarget(ServicesRegistry registry) {
+ return provider.getNavigationTarget(registry);
+ }
+
+ public int getOrder() {
+ return order;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setOrder(int order) {
+ this.order = order;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int compareTo(NavigationTargetProviderDescriptor o) {
+ if(o == null) {
+ return -1;
+ }
+
+ if(o.order == order) {
+ return 0;
+ }
+
+ return o.order < order ? 1 : -1;
+ }
+
+ }
+
+ public static class NavigationContributorDescriptor implements NavigationContributor {
private final NavigationContributor contributor;
@@ -106,7 +219,7 @@ public class NavigationServiceImpl implements NavigationService {
private final IPreferenceStore preferences;
- public NavigationContributorWrapper(NavigationContributor contributor) {
+ public NavigationContributorDescriptor(NavigationContributor contributor) {
this.contributor = contributor;
preferences = Activator.getDefault().getPreferenceStore();
@@ -154,18 +267,27 @@ public class NavigationServiceImpl implements NavigationService {
return preferences.getBoolean(preferenceKey);
}
- public static String getIsActiveKey(NavigationContributorWrapper strategy) {
+ public static String getIsActiveKey(NavigationContributorDescriptor strategy) {
return strategy.getId() + "." + IS_ACTIVE_KEY;
}
}
- private List<NavigationContributorWrapper> navigationContributors;
+ private List<NavigationContributorDescriptor> navigationContributors;
- public List<NavigationContributorWrapper> getNavigationContributors() {
+ private Collection<NavigationTargetProvider> navigationTargetProviders;
+
+ public List<NavigationContributorDescriptor> getNavigationContributors() {
return navigationContributors;
}
+ public Collection<NavigationTargetProvider> getNavigationTargetProviders() {
+ return navigationTargetProviders;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public SelectionMenu createNavigationList(Object fromElement, final Control parent) {
List<NavigableElement> navigableElements = getNavigableElements(fromElement);
if(navigableElements.isEmpty()) {
@@ -218,4 +340,25 @@ public class NavigationServiceImpl implements NavigationService {
return selectionMenu;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public void navigate(NavigableElement navigableElement) {
+ if(registry == null) {
+ throw new IllegalStateException("The navigation service is not initialized");
+ }
+
+ for(NavigationTargetProvider provider : getNavigationTargetProviders()) {
+ NavigationTarget target = provider.getNavigationTarget(registry);
+
+ if(target == null) {
+ continue;
+ }
+
+ if(navigableElement.navigate(target)) {
+ return;
+ }
+ }
+ }
}

Back to the top