Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfaure2011-09-23 09:17:16 -0400
committertfaure2011-09-23 09:17:16 -0400
commit27baf9e9898115963fefdcc49b32cc3559c9ff39 (patch)
treeefeb994822196cc428e95eb34b41d567531ddf55 /plugins/core/org.eclipse.papyrus.navigation
parentac6dbdf61230c157322df57041a1e6d9565fa867 (diff)
downloadorg.eclipse.papyrus-27baf9e9898115963fefdcc49b32cc3559c9ff39.tar.gz
org.eclipse.papyrus-27baf9e9898115963fefdcc49b32cc3559c9ff39.tar.xz
org.eclipse.papyrus-27baf9e9898115963fefdcc49b32cc3559c9ff39.zip
REOPENED - bug 273413: [Usability][Navigation] Papyrus shall enable diagram navigation history with back and next buttons
https://bugs.eclipse.org/bugs/show_bug.cgi?id=273413 Patch provided by Anass Radouani, modifications in page manger perspective extension for displaying buttons commands implementation
Diffstat (limited to 'plugins/core/org.eclipse.papyrus.navigation')
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/META-INF/MANIFEST.MF40
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/icons/BACK.pngbin0 -> 655 bytes
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/icons/NEXT.pngbin0 -> 676 bytes
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/icons/TOP.pngbin0 -> 636 bytes
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/icons/UP.pngbin0 -> 652 bytes
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/plugin.xml213
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/Activator.java39
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreateDiagramWithNavigationHandler.java15
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreatedNavigableElement.java10
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/ExistingNavigableElement.java3
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/IBaseNameSetter.java6
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigableElement.java4
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigationHelper.java19
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecorator.java29
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecoratorProvider.java24
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/BackNavigateHandler.java54
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/NextNavigateHandler.java53
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/TopNavigateHandler.java105
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/UpNavigateHandler.java93
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/INavigationPreferenceConstant.java20
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferenceInitializer.java4
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferencePage.java37
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/Messages.java27
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/MultiDiagramDialog.java176
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/PropertyTester.java77
-rw-r--r--plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/messages.properties6
26 files changed, 943 insertions, 111 deletions
diff --git a/plugins/core/org.eclipse.papyrus.navigation/META-INF/MANIFEST.MF b/plugins/core/org.eclipse.papyrus.navigation/META-INF/MANIFEST.MF
index c6cf78529ab..13787829129 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/META-INF/MANIFEST.MF
+++ b/plugins/core/org.eclipse.papyrus.navigation/META-INF/MANIFEST.MF
@@ -1,17 +1,23 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.papyrus.navigation;singleton:=true
-Bundle-Version: 0.9.0.qualifier
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.papyrus.core;bundle-version="0.8.0";visibility:=reexport,
- org.eclipse.papyrus.preferences;bundle-version="0.8.0",
- org.eclipse.papyrus.core.adaptor.gmf;bundle-version="0.8.0",
- org.eclipse.papyrus.ui.toolbox;bundle-version="0.8.0"
-Export-Package: org.eclipse.papyrus.navigation,
- org.eclipse.papyrus.navigation.decorator,
- org.eclipse.papyrus.navigation.preference
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Bundle-ActivationPolicy: lazy
-Bundle-Activator: org.eclipse.papyrus.navigation.Activator
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.navigation;singleton:=true
+Bundle-Version: 0.8.1.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.papyrus.core;bundle-version="0.8.0";visibility:=reexport,
+ org.eclipse.papyrus.commands,
+ org.eclipse.papyrus.preferences;bundle-version="0.8.0",
+ org.eclipse.papyrus.core.adaptor.gmf;bundle-version="0.8.0",
+ org.eclipse.papyrus.ui.toolbox;bundle-version="0.8.0",
+ org.eclipse.core.expressions;bundle-version="3.4.300",
+ org.eclipse.papyrus.modelexplorer;bundle-version="0.8.1",
+ org.eclipse.ui.navigator;bundle-version="3.5.100",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.1.0",
+ org.eclipse.papyrus.ui.perspectiveconfiguration
+Export-Package: org.eclipse.papyrus.navigation,
+ org.eclipse.papyrus.navigation.decorator,
+ org.eclipse.papyrus.navigation.preference
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.eclipse.papyrus.navigation.Activator
diff --git a/plugins/core/org.eclipse.papyrus.navigation/icons/BACK.png b/plugins/core/org.eclipse.papyrus.navigation/icons/BACK.png
new file mode 100644
index 00000000000..659cd90d7f8
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/icons/BACK.png
Binary files differ
diff --git a/plugins/core/org.eclipse.papyrus.navigation/icons/NEXT.png b/plugins/core/org.eclipse.papyrus.navigation/icons/NEXT.png
new file mode 100644
index 00000000000..6ef8de76e0f
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/icons/NEXT.png
Binary files differ
diff --git a/plugins/core/org.eclipse.papyrus.navigation/icons/TOP.png b/plugins/core/org.eclipse.papyrus.navigation/icons/TOP.png
new file mode 100644
index 00000000000..70f2c996cd7
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/icons/TOP.png
Binary files differ
diff --git a/plugins/core/org.eclipse.papyrus.navigation/icons/UP.png b/plugins/core/org.eclipse.papyrus.navigation/icons/UP.png
new file mode 100644
index 00000000000..fa9a7d71b56
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/icons/UP.png
Binary files differ
diff --git a/plugins/core/org.eclipse.papyrus.navigation/plugin.xml b/plugins/core/org.eclipse.papyrus.navigation/plugin.xml
index 21227caf819..75f4a22b0ed 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/plugin.xml
+++ b/plugins/core/org.eclipse.papyrus.navigation/plugin.xml
@@ -29,5 +29,216 @@
</decoratorProvider>
</extension>
-
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ name="Navigation Command"
+ id="org.eclipse.papyrus.navigation.commands.category">
+ </category>
+ <command
+ name="Back Navigation Command"
+ categoryId="org.eclipse.papyrus.navigation.commands.category"
+ id="org.eclipse.papyrus.navigation.commands.backNavigationCommand">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.navigation.commands.category"
+ id="org.eclipse.papyrus.navigation.commands.upNavigationCommand"
+ name="Up Navigation Command">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.navigation.commands.category"
+ id="org.eclipse.papyrus.navigation.commands.topNavigationCommand"
+ name="Top Navigation Command">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.navigation.commands.category"
+ id="org.eclipse.papyrus.navigation.commands.nextNavigationCommand"
+ name="Next Navigation Command">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ commandId="org.eclipse.papyrus.navigation.commands.backNavigationCommand"
+ class="org.eclipse.papyrus.navigation.handlers.BackNavigateHandler">
+ <enabledWhen>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.navigation.isBackCommandPossible">
+ </test>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.navigation.handlers.NextNavigateHandler"
+ commandId="org.eclipse.papyrus.navigation.commands.nextNavigationCommand">
+ <enabledWhen>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.navigation.isNextCommandPossible">
+ </test>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.navigation.handlers.UpNavigateHandler"
+ commandId="org.eclipse.papyrus.navigation.commands.upNavigationCommand">
+ <enabledWhen>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.navigation.isUpCommandPossible">
+ </test>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.navigation.handlers.TopNavigateHandler"
+ commandId="org.eclipse.papyrus.navigation.commands.topNavigationCommand">
+ <enabledWhen>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.navigation.isTopCommandPossible">
+ </test>
+ </with>
+ </enabledWhen>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
+ <toolbar
+ id="org.eclipse.papyrus.navigation.toolbars.navigationToolbar"
+ label="Navigation Papyrus Diagram">
+ <command
+ commandId="org.eclipse.papyrus.navigation.commands.backNavigationCommand"
+ icon="icons/BACK.png"
+ id="org.eclipse.papyrus.navigation.toolbars.BackCommand"
+ style="push"
+ tooltip="BACK">
+ <visibleWhen>
+ <or>
+ <reference
+ definitionId="org.eclipse.papyrus.diagram.common.IsPapyrusActiveWithUMLModel">
+ </reference>
+ <reference
+ definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML">
+ </reference>
+ </or>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.navigation.commands.nextNavigationCommand"
+ icon="icons/NEXT.png"
+ id="org.eclipse.papyrus.navigation.toolbars.NextCommand"
+ style="push"
+ tooltip="NEXT">
+ <visibleWhen>
+ <or>
+ <reference
+ definitionId="org.eclipse.papyrus.diagram.common.IsPapyrusActiveWithUMLModel">
+ </reference>
+ <reference
+ definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML">
+ </reference>
+ </or>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.navigation.commands.upNavigationCommand"
+ icon="icons/UP.png"
+ id="org.eclipse.papyrus.navigation.toolbars.UpCommand"
+ style="push"
+ tooltip="UP">
+ <visibleWhen>
+ <or>
+ <reference
+ definitionId="org.eclipse.papyrus.diagram.common.IsPapyrusActiveWithUMLModel">
+ </reference>
+ <reference
+ definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML">
+ </reference>
+ </or>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.navigation.commands.topNavigationCommand"
+ icon="icons/TOP.png"
+ id="org.eclipse.papyrus.navigation.toolbars.TopCommand"
+ style="push"
+ tooltip="TOP">
+ <visibleWhen>
+ <or>
+ <reference
+ definitionId="org.eclipse.papyrus.diagram.common.IsPapyrusActiveWithUMLModel">
+ </reference>
+ <reference
+ definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML">
+ </reference>
+ </or>
+ </visibleWhen>
+ </command>
+ </toolbar>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.navigation.utils.PropertyTester"
+ id="org.eclipse.papyrus.navigation.PropertyTester"
+ namespace="org.eclipse.papyrus.navigation"
+ properties="isNextCommandPossible"
+ type="org.eclipse.jface.viewers.ISelection">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.navigation.utils.PropertyTester"
+ id="org.eclipse.papyrus.navigation.PropertyTester"
+ namespace="org.eclipse.papyrus.navigation"
+ properties="isBackCommandPossible"
+ type="org.eclipse.jface.viewers.ISelection">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.navigation.utils.PropertyTester"
+ id="org.eclipse.papyrus.navigation.PropertyTester"
+ namespace="org.eclipse.papyrus.navigation"
+ properties="isUpCommandPossible"
+ type="org.eclipse.jface.viewers.ISelection">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.navigation.utils.PropertyTester"
+ id="org.eclipse.papyrus.navigation.PropertyTester"
+ namespace="org.eclipse.papyrus.navigation"
+ properties="isTopCommandPossible"
+ type="org.eclipse.jface.viewers.ISelection">
+ </propertyTester>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.ui.perspectiveconfiguration">
+ <configuration
+ perspectiveID="org.eclipse.papyrus.core.perspective">
+ <toolbar
+ toolbarID="org.eclipse.papyrus.navigation.toolbars.navigationToolbar">
+ </toolbar>
+ <command
+ commandID="org.eclipse.papyrus.navigation.commands.backNavigationCommand">
+ </command>
+ <command
+ commandID="org.eclipse.papyrus.navigation.commands.nextNavigationCommand">
+ </command>
+ <command
+ commandID="org.eclipse.papyrus.navigation.commands.topNavigationCommand">
+ </command>
+ <command
+ commandID="org.eclipse.papyrus.navigation.commands.upNavigationCommand">
+ </command>
+ </configuration>
+ </extension>
</plugin>
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/Activator.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/Activator.java
index 709769ac16a..08a476750a8 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/Activator.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/Activator.java
@@ -13,11 +13,12 @@
package org.eclipse.papyrus.navigation;
import org.eclipse.papyrus.navigation.preference.NavigationPreferenceInitializer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
-
-
public class Activator extends AbstractUIPlugin {
// The plug-in ID
@@ -35,7 +36,8 @@ public class Activator extends AbstractUIPlugin {
/*
* (non-Javadoc)
*
- * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ * @see
+ * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
@@ -47,7 +49,8 @@ public class Activator extends AbstractUIPlugin {
/*
* (non-Javadoc)
*
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ * @see
+ * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
@@ -63,5 +66,33 @@ public class Activator extends AbstractUIPlugin {
return plugin;
}
+ /**
+ * Returns the active workbench shell
+ *
+ * @return the active workbench shell
+ */
+ public static Shell getActiveWorkbenchShell() {
+ IWorkbenchWindow workBenchWindow = getActiveWorkbenchWindow();
+ if(workBenchWindow == null) {
+ return null;
+ }
+ return workBenchWindow.getShell();
+ }
+
+ /**
+ * Returns the active workbench window
+ *
+ * @return the active workbench window
+ */
+ public static IWorkbenchWindow getActiveWorkbenchWindow() {
+ if(getDefault() == null) {
+ return null;
+ }
+ IWorkbench workBench = getDefault().getWorkbench();
+ if(workBench == null) {
+ return null;
+ }
+ return workBench.getActiveWorkbenchWindow();
+ }
}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreateDiagramWithNavigationHandler.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreateDiagramWithNavigationHandler.java
index 802b2f40be9..4843b43c427 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreateDiagramWithNavigationHandler.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreateDiagramWithNavigationHandler.java
@@ -37,10 +37,10 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
/**
- * This command handler will try to create a diagram on the currently selected element,
- * using navigation if necessary.
- * The action is always available and the check is done in the run
- * to avoid heavy navigation computation on each selection change.
+ * This command handler will try to create a diagram on the currently selected
+ * element, using navigation if necessary. The action is always available and
+ * the check is done in the run to avoid heavy navigation computation on each
+ * selection change.
*
* @author mvelten
*
@@ -65,8 +65,8 @@ public abstract class CreateDiagramWithNavigationHandler extends AbstractHandler
public Object execute(ExecutionEvent event) throws ExecutionException {
NavigableElement navElement = getNavigableElementWhereToCreateDiagram();
- if (navElement == null) {
- InformationDialog dialog = new InformationDialog(Display.getCurrent().getActiveShell(), "Impossible diagram creation", "It is not possible to create this diagram on the selected element.", null, null, SWT.OK, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL });
+ if(navElement == null) {
+ InformationDialog dialog = new InformationDialog(Display.getCurrent().getActiveShell(), "Impossible diagram creation", "It is not possible to create this diagram on the selected element.", null, null, SWT.OK, MessageDialog.WARNING, new String[]{ IDialogConstants.OK_LABEL });
dialog.open();
} else {
createDiagram(navElement);
@@ -87,7 +87,8 @@ public abstract class CreateDiagramWithNavigationHandler extends AbstractHandler
Collections.sort(navElements);
for(NavigableElement navElement : navElements) {
- // ignore existing elements because we want a hierarchy to be created if it is not on the current element
+ // ignore existing elements because we want a hierarchy to
+ // be created if it is not on the current element
if(navElement instanceof CreatedNavigableElement && creationCondition.create(navElement.getElement())) {
return navElement;
}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreatedNavigableElement.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreatedNavigableElement.java
index 0c7ad6373f6..907f0436f25 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreatedNavigableElement.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/CreatedNavigableElement.java
@@ -18,9 +18,9 @@ import org.eclipse.emf.ecore.EStructuralFeature;
/**
* This class represents an element that have been created by the navigation.
- * This element is not currently linked to the model, but it can be
- * by using linkToModel if the user decides to navigate to it,
- * to create a diagram on it for example.
+ * This element is not currently linked to the model, but it can be by using
+ * linkToModel if the user decides to navigate to it, to create a diagram on it
+ * for example.
*
* @author mvelten
*
@@ -34,8 +34,8 @@ public class CreatedNavigableElement extends NavigableElement {
private IBaseNameSetter baseNameSetter = null;
/**
- * This constructor initiates a navigable element from a newly created element.
- * This element is not directly linked to its container.
+ * This constructor initiates a navigable element from a newly created
+ * element. This element is not directly linked to its container.
* linkToModel() needs to be defined and call when you want to link it.
*
* @param element
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/ExistingNavigableElement.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/ExistingNavigableElement.java
index 8fee9ecf790..729569f9947 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/ExistingNavigableElement.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/ExistingNavigableElement.java
@@ -25,7 +25,8 @@ import org.eclipse.emf.ecore.EStructuralFeature;
public class ExistingNavigableElement extends NavigableElement {
/**
- * This constructor initiates a navigable element from an existing model element.
+ * This constructor initiates a navigable element from an existing model
+ * element.
*
* @param element
*/
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/IBaseNameSetter.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/IBaseNameSetter.java
index 0fc0a136eea..6b03450c0b5 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/IBaseNameSetter.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/IBaseNameSetter.java
@@ -16,9 +16,9 @@ package org.eclipse.papyrus.navigation;
import org.eclipse.emf.ecore.EObject;
/**
- * This interface allows to set the base name of an element.
- * The base can then be used to derive a more useful name,
- * containing the name of the element type for example.
+ * This interface allows to set the base name of an element. The base can then
+ * be used to derive a more useful name, containing the name of the element type
+ * for example.
*
* @author mvelten
*
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigableElement.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigableElement.java
index 837374b2052..a776559f333 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigableElement.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigableElement.java
@@ -17,8 +17,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
/**
- * This class represents an element which can be accessed
- * from an other element throught a feature using defined navigation rules.
+ * This class represents an element which can be accessed from an other element
+ * throught a feature using defined navigation rules.
*
* @author mvelten
*
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigationHelper.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigationHelper.java
index 7f27fe6fe2c..5b5d5f0f705 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigationHelper.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/NavigationHelper.java
@@ -32,7 +32,6 @@ import org.eclipse.papyrus.core.extension.commands.ICreationCommand;
import org.eclipse.papyrus.core.utils.DiResourceSet;
import org.eclipse.papyrus.core.utils.OpenDiagramCommand;
-
public class NavigationHelper {
private static class NavigationHelperHolder {
@@ -45,7 +44,7 @@ public class NavigationHelper {
}
private static final String EXTENSION_ID = "org.eclipse.papyrus.navigation.navigationRules";
-
+
private static final String NAVIGATIONRULE_ID = "navigationRule";
private static final String RULE_ID = "rule";
@@ -56,7 +55,7 @@ public class NavigationHelper {
// Reading data from plugins
IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
for(IConfigurationElement configElement : configElements) {
- if (NAVIGATIONRULE_ID.equals(configElement.getName())) {
+ if(NAVIGATIONRULE_ID.equals(configElement.getName())) {
try {
Object obj = configElement.createExecutableExtension(RULE_ID);
if(obj instanceof INavigationRule) {
@@ -83,7 +82,8 @@ public class NavigationHelper {
}
/**
- * get all navigation possibilities (existing or "to create" elements) from the specified element.
+ * get all navigation possibilities (existing or "to create" elements) from
+ * the specified element.
*
* @param element
* the element
@@ -98,10 +98,10 @@ public class NavigationHelper {
}
/**
- * This method link the created element with its parent
- * and browse the hierarchy to link the parents between them.
- * Ultimately the hierarchy will be attached to an {@link ExistingNavigableElement},
- * so to the original model.
+ * This method link the created element with its parent and browse the
+ * hierarchy to link the parents between them. Ultimately the hierarchy will
+ * be attached to an {@link ExistingNavigableElement}, so to the original
+ * model.
*
* @param createdNavElement
*/
@@ -115,7 +115,8 @@ public class NavigationHelper {
}
/**
- * Same behavior as {@link NavigationHelper#linkToModel(CreatedNavigableElement)} but set the base name of the elements.
+ * Same behavior as {@link NavigationHelper#linkToModel(CreatedNavigableElement)} but set the
+ * base name of the elements.
*
* @param createdNavElement
* @param base
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecorator.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecorator.java
index 52fe8e7390d..27ab0aa2d42 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecorator.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecorator.java
@@ -46,9 +46,8 @@ import org.eclipse.papyrus.preferences.Activator;
import org.eclipse.papyrus.ui.toolbox.draw2d.ManuallyDrawnShortcutDecorationFigure;
import org.eclipse.swt.graphics.Color;
-
public class NavigationDecorator extends AbstractDecorator implements Adapter {
-
+
private static final String EXTENSION_ID = "org.eclipse.papyrus.navigation.navigationColorProviders";
private static final String COLORPROVIDER_ID = "navigationColorProvider";
@@ -56,12 +55,12 @@ public class NavigationDecorator extends AbstractDecorator implements Adapter {
private static final String PROVIDER_ID = "provider";
private static List<IColorProvider> navigationColorProviders = new LinkedList<IColorProvider>();
-
+
static {
// Reading data from plugins
IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
for(IConfigurationElement configElement : configElements) {
- if (COLORPROVIDER_ID.equals(configElement.getName())) {
+ if(COLORPROVIDER_ID.equals(configElement.getName())) {
try {
Object obj = configElement.createExecutableExtension(PROVIDER_ID);
if(obj instanceof IColorProvider) {
@@ -78,7 +77,7 @@ public class NavigationDecorator extends AbstractDecorator implements Adapter {
private ManuallyDrawnShortcutDecorationFigure shortcutFigure = new ManuallyDrawnShortcutDecorationFigure();
private IGraphicalEditPart gep = null;
-
+
private boolean displayOnly;
public NavigationDecorator(IDecoratorTarget decoratorTarget) {
@@ -101,7 +100,6 @@ public class NavigationDecorator extends AbstractDecorator implements Adapter {
if(editPart instanceof IGraphicalEditPart) {
gep = (IGraphicalEditPart)editPart;
-
if(editPart instanceof ShapeEditPart) {
setDecoration(getDecoratorTarget().addShapeDecoration(shortcutFigure, IDecoratorTarget.Direction.NORTH_EAST, -5, displayOnly));
} else if(editPart instanceof ConnectionEditPart) {
@@ -123,12 +121,12 @@ public class NavigationDecorator extends AbstractDecorator implements Adapter {
currentDiagram = view.getDiagram();
}
- if (currentDiagram != null) {
+ if(currentDiagram != null) {
addResourceListener(currentDiagram.eResource());
}
List<NavigableElement> navElements = NavigationHelper.getInstance().getAllNavigableElements(element);
-
+
Color shortcutColor = null;
for(NavigableElement navElement : navElements) {
@@ -146,13 +144,14 @@ public class NavigationDecorator extends AbstractDecorator implements Adapter {
for(Diagram diag : associatedDiagrams) {
addResourceListener(diag.eResource());
if(!diag.equals(currentDiagram)) {
- for (IColorProvider provider : navigationColorProviders) {
+ for(IColorProvider provider : navigationColorProviders) {
Color color = provider.getBackground(navElement);
- if (color != null) {
- if (shortcutColor == null) {
+ if(color != null) {
+ if(shortcutColor == null) {
shortcutColor = color;
- } else if (!shortcutColor.equals(color)) {
- // more than one color for this element :
+ } else if(!shortcutColor.equals(color)) {
+ // more than one color for this
+ // element :
// just use white in this case
shortcutColor = ColorConstants.white;
}
@@ -165,8 +164,8 @@ public class NavigationDecorator extends AbstractDecorator implements Adapter {
}
}
}
-
- if (shortcutColor == null) {
+
+ if(shortcutColor == null) {
shortcutFigure.setVisible(false);
} else {
shortcutFigure.setVisible(true);
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecoratorProvider.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecoratorProvider.java
index 94dc52d9c84..4812a674be5 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecoratorProvider.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/decorator/NavigationDecoratorProvider.java
@@ -33,11 +33,13 @@ import org.eclipse.papyrus.preferences.Activator;
public class NavigationDecoratorProvider extends AbstractProvider implements IDecoratorProvider {
private static Set<Class<?>> forbiddenClasses = new HashSet<Class<?>>();
+
private static Set<Class<?>> decoratedClasses = new HashSet<Class<?>>();
private static final String EXTENSION_ID = "org.eclipse.papyrus.navigation.navigationDecoratorRules";
private static final String FORBIDDENCLASS_ID = "forbiddenClass";
+
private static final String DECORATEDCLASS_ID = "decoratedClass";
private static final String CLASS_ID = "class";
@@ -50,12 +52,13 @@ public class NavigationDecoratorProvider extends AbstractProvider implements IDe
Class<?> class_ = null;
try {
class_ = Platform.getBundle(configElement.getContributor().getName()).loadClass(className);
- } catch(Exception e) {}
+ } catch (Exception e) {
+ }
if(class_ != null) {
- if (FORBIDDENCLASS_ID.equals(configElement.getName())) {
+ if(FORBIDDENCLASS_ID.equals(configElement.getName())) {
forbiddenClasses.add(class_);
- } else if (DECORATEDCLASS_ID.equals(configElement.getName())) {
+ } else if(DECORATEDCLASS_ID.equals(configElement.getName())) {
decoratedClasses.add(class_);
}
}
@@ -64,20 +67,20 @@ public class NavigationDecoratorProvider extends AbstractProvider implements IDe
public boolean provides(IOperation operation) {
String decoratorVisibility = Activator.getDefault().getPreferenceStore().getString(INavigationPreferenceConstant.PAPYRUS_NAVIGATION_DECORATOR_VISIBILITY);
- if (operation instanceof CreateDecoratorsOperation && !INavigationPreferenceConstant.DISABLED.equals(decoratorVisibility)) {
- IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation) operation).getDecoratorTarget();
+ if(operation instanceof CreateDecoratorsOperation && !INavigationPreferenceConstant.DISABLED.equals(decoratorVisibility)) {
+ IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation)operation).getDecoratorTarget();
EditPart editPart = (EditPart)decoratorTarget.getAdapter(EditPart.class);
if(editPart instanceof IPrimaryEditPart) {
- EObject element = ((IGraphicalEditPart) editPart).resolveSemanticElement();
+ EObject element = ((IGraphicalEditPart)editPart).resolveSemanticElement();
boolean decorate = false;
- for (Class<?> class_ : decoratedClasses) {
- if (class_.isInstance(element)) {
+ for(Class<?> class_ : decoratedClasses) {
+ if(class_.isInstance(element)) {
decorate = true;
break;
}
}
- for (Class<?> class_ : forbiddenClasses) {
- if (class_.isInstance(element)) {
+ for(Class<?> class_ : forbiddenClasses) {
+ if(class_.isInstance(element)) {
decorate = false;
break;
}
@@ -92,5 +95,4 @@ public class NavigationDecoratorProvider extends AbstractProvider implements IDe
new NavigationDecorator(decoratorTarget);
}
-
}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/BackNavigateHandler.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/BackNavigateHandler.java
new file mode 100644
index 00000000000..eb3f3df020f
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/BackNavigateHandler.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2011 AtoS
+ * 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:
+ * Anass RADOUANI (AtoS)
+ *******************************************************************************/
+
+package org.eclipse.papyrus.navigation.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * handler for Up command
+ *
+ */
+public class BackNavigateHandler extends AbstractHandler {
+
+ private IEditorPart editor;
+
+ private IPageMngr pageMngr;
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ editor = HandlerUtil.getActiveEditor(event);
+
+ if(editor instanceof CoreMultiDiagramEditor) {
+ CoreMultiDiagramEditor papyrusEditor = (CoreMultiDiagramEditor)editor;
+ EditingDomain editingDomain = papyrusEditor.getEditingDomain();
+ if(editingDomain instanceof TransactionalEditingDomain) {
+ try {
+ pageMngr = papyrusEditor.getServicesRegistry().getService(IPageMngr.class);
+ pageMngr.openPrevious();
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/NextNavigateHandler.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/NextNavigateHandler.java
new file mode 100644
index 00000000000..4a3d3bb8f7d
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/NextNavigateHandler.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2011 AtoS
+ * 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:
+ * Anass RADOUANI (AtoS)
+ *******************************************************************************/
+
+package org.eclipse.papyrus.navigation.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * handler for Next command
+ *
+ */
+public class NextNavigateHandler extends AbstractHandler {
+
+ private IEditorPart editor;
+
+ private IPageMngr pageMngr;
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ editor = HandlerUtil.getActiveEditor(event);
+ if(editor instanceof CoreMultiDiagramEditor) {
+ CoreMultiDiagramEditor papyrusEditor = (CoreMultiDiagramEditor)editor;
+ EditingDomain editingDomain = papyrusEditor.getEditingDomain();
+ if(editingDomain instanceof TransactionalEditingDomain) {
+ try {
+ pageMngr = papyrusEditor.getServicesRegistry().getService(IPageMngr.class);
+ pageMngr.openNext();
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/TopNavigateHandler.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/TopNavigateHandler.java
new file mode 100644
index 00000000000..50fc5fbe1f4
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/TopNavigateHandler.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2011 AtoS
+ * 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:
+ * Anass RADOUANI (AtoS)
+ *******************************************************************************/
+
+package org.eclipse.papyrus.navigation.handlers;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.core.adaptor.gmf.DiagramsUtil;
+import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.core.utils.OpenDiagramCommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.navigation.Activator;
+import org.eclipse.papyrus.navigation.utils.MultiDiagramDialog;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.window.Window;
+
+/**
+ * handler for Up command
+ *
+ */
+public class TopNavigateHandler extends AbstractHandler {
+
+ private IEditorPart editor;
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ editor = HandlerUtil.getActiveEditor(event);
+ if(editor instanceof CoreMultiDiagramEditor) {
+ CoreMultiDiagramEditor papyrusEditor = (CoreMultiDiagramEditor)editor;
+ EObject parent = papyrusEditor.getDiagram().getElement().eContainer();
+ List<List<Diagram>> diagramsTemp = new Vector<List<Diagram>>();
+ List<Diagram> diagrams = Collections.emptyList();
+ List<Diagram> associatedDiag = Collections.emptyList();
+ if(parent != null) {
+ while(parent != null) {
+ associatedDiag = DiagramsUtil.getAssociatedDiagrams(parent, null);
+ if(!associatedDiag.isEmpty()) {
+ diagramsTemp.add(associatedDiag);
+ }
+ parent = parent.eContainer();
+ }
+
+ while(diagrams.size() == 0 && diagramsTemp.size() != 0) {
+ diagrams = diagramsTemp.get(diagramsTemp.size() - 1);
+ diagramsTemp.remove(diagramsTemp.size() - 1);
+
+ }
+ openDialog(papyrusEditor, diagrams);
+
+ }
+ }
+ return null;
+ }
+
+ /**
+ * open the diagram if there is just one or open a dialog to choose the
+ * diagram to open if there is more than one
+ *
+ * @param papyrusEditor
+ * @param diagrams
+ */
+ private void openDialog(CoreMultiDiagramEditor papyrusEditor, List<Diagram> diagrams) {
+ if(diagrams != null) {
+ if(diagrams.size() == 1) {
+ openDiagram(papyrusEditor, diagrams.get(0));
+ } else if(diagrams.size() > 1) {
+ MultiDiagramDialog multiDiagramDialog = new MultiDiagramDialog(Activator.getActiveWorkbenchShell(), diagrams);
+ if(multiDiagramDialog.open() == Window.OK) {
+ openDiagram(papyrusEditor, diagrams.get(multiDiagramDialog.getSelectedDiagram()));
+ }
+ }
+ }
+ }
+
+ /**
+ * open a dialog to choose which diagram have to be opened
+ *
+ * @param papyrusEditor
+ * @param diagram
+ */
+ private void openDiagram(CoreMultiDiagramEditor papyrusEditor, Diagram diagram) {
+ if(papyrusEditor.getEditingDomain() instanceof TransactionalEditingDomain) {
+ TransactionalEditingDomain domain = (TransactionalEditingDomain)papyrusEditor.getEditingDomain();
+ OpenDiagramCommand openDiagramCommand = new OpenDiagramCommand(domain, diagram);
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(openDiagramCommand));
+ }
+ }
+
+}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/UpNavigateHandler.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/UpNavigateHandler.java
new file mode 100644
index 00000000000..2e595addb94
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/handlers/UpNavigateHandler.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2011 AtoS
+ * 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:
+ * Anass RADOUANI (AtoS)
+ *******************************************************************************/
+
+package org.eclipse.papyrus.navigation.handlers;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.core.adaptor.gmf.DiagramsUtil;
+import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.core.utils.OpenDiagramCommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.navigation.Activator;
+import org.eclipse.papyrus.navigation.utils.MultiDiagramDialog;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.window.Window;
+
+/**
+ * handler for Up command
+ *
+ */
+public class UpNavigateHandler extends AbstractHandler {
+
+ private IEditorPart editor;
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ editor = HandlerUtil.getActiveEditor(event);
+ if(editor instanceof CoreMultiDiagramEditor) {
+ CoreMultiDiagramEditor papyrusEditor = (CoreMultiDiagramEditor)editor;
+ EObject parent = papyrusEditor.getDiagram().getElement().eContainer();
+ List<Diagram> diagrams = Collections.emptyList();
+ if(parent != null) {
+ while(parent != null && diagrams.size() == 0) {
+ diagrams = DiagramsUtil.getAssociatedDiagrams(parent, null);
+ parent = parent.eContainer();
+ }
+ openDialog(papyrusEditor, diagrams);
+
+ }
+ }
+ return null;
+ }
+
+ /**
+ * open the diagram if there is just one or open a dialog to choose the
+ * diagram to open if there is more than one
+ *
+ * @param papyrusEditor
+ * @param diagrams
+ */
+ private void openDialog(CoreMultiDiagramEditor papyrusEditor, List<Diagram> diagrams) {
+ if(diagrams != null) {
+ if(diagrams.size() == 1) {
+ openDiagram(papyrusEditor, diagrams.get(0));
+ } else if(diagrams.size() > 1) {
+ MultiDiagramDialog multiDiagramDialog = new MultiDiagramDialog(Activator.getActiveWorkbenchShell(), diagrams);
+ if(multiDiagramDialog.open() == Window.OK) {
+ openDiagram(papyrusEditor, diagrams.get(multiDiagramDialog.getSelectedDiagram()));
+ }
+ }
+ }
+ }
+
+ /**
+ * open a dialog to choose which diagram have to be opened
+ *
+ * @param papyrusEditor
+ * @param diagram
+ */
+ private void openDiagram(CoreMultiDiagramEditor papyrusEditor, Diagram diagram) {
+ if(papyrusEditor.getEditingDomain() instanceof TransactionalEditingDomain) {
+ TransactionalEditingDomain domain = (TransactionalEditingDomain)papyrusEditor.getEditingDomain();
+ OpenDiagramCommand openDiagramCommand = new OpenDiagramCommand(domain, diagram);
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(openDiagramCommand));
+ }
+ }
+
+}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/INavigationPreferenceConstant.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/INavigationPreferenceConstant.java
index 4a226f35fd7..bdaba3dc752 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/INavigationPreferenceConstant.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/INavigationPreferenceConstant.java
@@ -17,15 +17,21 @@ package org.eclipse.papyrus.navigation.preference;
*/
public interface INavigationPreferenceConstant {
-
- public String PAPYRUS_NAVIGATION_DOUBLECLICK_KIND ="PAPYRUS_NAVIGATION_DOUBLECLICK_KIND";
- public String NO_NAVIGATION="NO_NAVIGATION";
- public String EXPLICIT_NAVIGATION="EXPLICIT_NAVIGATION";
- public String EXPLICIT_IMPLICIT_NAVIGATION="EXPLICIT_IMPLICIT_NAVIGATION";
+
+ public String PAPYRUS_NAVIGATION_DOUBLECLICK_KIND = "PAPYRUS_NAVIGATION_DOUBLECLICK_KIND";
+
+ public String NO_NAVIGATION = "NO_NAVIGATION";
+
+ public String EXPLICIT_NAVIGATION = "EXPLICIT_NAVIGATION";
+
+ public String EXPLICIT_IMPLICIT_NAVIGATION = "EXPLICIT_IMPLICIT_NAVIGATION";
public String PAPYRUS_NAVIGATION_DECORATOR_VISIBILITY = "PAPYRUS_NAVIGATION_DECORATOR_VISIBILITY";
+
public String DISABLED = "DISABLED";
- public String DISPLAY_ONLY="DISPLAY_ONLY";
- public String EVERYWHERE="EVERYWHERE";
+
+ public String DISPLAY_ONLY = "DISPLAY_ONLY";
+
+ public String EVERYWHERE = "EVERYWHERE";
}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferenceInitializer.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferenceInitializer.java
index 76434387149..e6755c35572 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferenceInitializer.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferenceInitializer.java
@@ -27,8 +27,8 @@ public class NavigationPreferenceInitializer extends AbstractPreferenceInitializ
*/
public void initializeDefaultPreferences() {
IPreferenceStore store = getPreferenceStore();
- store.setDefault(INavigationPreferenceConstant.PAPYRUS_NAVIGATION_DOUBLECLICK_KIND,INavigationPreferenceConstant.EXPLICIT_IMPLICIT_NAVIGATION);
- store.setDefault(INavigationPreferenceConstant.PAPYRUS_NAVIGATION_DECORATOR_VISIBILITY,INavigationPreferenceConstant.DISPLAY_ONLY);
+ store.setDefault(INavigationPreferenceConstant.PAPYRUS_NAVIGATION_DOUBLECLICK_KIND, INavigationPreferenceConstant.EXPLICIT_IMPLICIT_NAVIGATION);
+ store.setDefault(INavigationPreferenceConstant.PAPYRUS_NAVIGATION_DECORATOR_VISIBILITY, INavigationPreferenceConstant.DISPLAY_ONLY);
}
/**
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferencePage.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferencePage.java
index ce440e5b37d..8071f5e8884 100644
--- a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferencePage.java
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/preference/NavigationPreferencePage.java
@@ -19,15 +19,16 @@ import org.eclipse.papyrus.preferences.Activator;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-
/**
- * preference page for the navigation
- * It proposes to choose among 3 possibilities: no navigation, explicit navigation, or explicit + implicit naviagation
- *
+ * preference page for the navigation It proposes to choose among 3
+ * possibilities: no navigation, explicit navigation, or explicit + implicit
+ * naviagation
+ *
*/
public class NavigationPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
protected RadioGroupFieldEditor dblClkFieldEditor;
+
protected RadioGroupFieldEditor decoratorVisibilityFieldEditor;
public void init(IWorkbench workbench) {
@@ -36,31 +37,13 @@ public class NavigationPreferencePage extends FieldEditorPreferencePage implemen
@Override
protected void createFieldEditors() {
- dblClkFieldEditor = new RadioGroupFieldEditor(
- INavigationPreferenceConstant.PAPYRUS_NAVIGATION_DOUBLECLICK_KIND,
- Messages.DoubleClickNavigationText,
- 1,
- new String[][] {
- {Messages.No_Navigation_Text,INavigationPreferenceConstant.NO_NAVIGATION},
- {Messages.ExplicitNavigation_Text,INavigationPreferenceConstant.EXPLICIT_NAVIGATION},
- {Messages.Explicit_ImplicitNavigation_Text,INavigationPreferenceConstant.EXPLICIT_IMPLICIT_NAVIGATION}
- },
- getFieldEditorParent());
+ dblClkFieldEditor = new RadioGroupFieldEditor(INavigationPreferenceConstant.PAPYRUS_NAVIGATION_DOUBLECLICK_KIND, Messages.DoubleClickNavigationText, 1, new String[][]{ { Messages.No_Navigation_Text, INavigationPreferenceConstant.NO_NAVIGATION }, { Messages.ExplicitNavigation_Text, INavigationPreferenceConstant.EXPLICIT_NAVIGATION }, { Messages.Explicit_ImplicitNavigation_Text, INavigationPreferenceConstant.EXPLICIT_IMPLICIT_NAVIGATION } }, getFieldEditorParent());
addField(dblClkFieldEditor);
dblClkFieldEditor.setPreferenceStore(Activator.getDefault().getPreferenceStore());
-
- decoratorVisibilityFieldEditor = new RadioGroupFieldEditor(
- INavigationPreferenceConstant.PAPYRUS_NAVIGATION_DECORATOR_VISIBILITY,
- Messages.DecoratorVisibilityText,
- 1,
- new String[][] {
- {Messages.DecoratorDisabled_Text,INavigationPreferenceConstant.DISABLED},
- {Messages.DisplayOnly_Text,INavigationPreferenceConstant.DISPLAY_ONLY},
- {Messages.Everywhere_Text,INavigationPreferenceConstant.EVERYWHERE}
- },
- getFieldEditorParent());
- addField(decoratorVisibilityFieldEditor);
- decoratorVisibilityFieldEditor.setPreferenceStore(Activator.getDefault().getPreferenceStore());
+
+ decoratorVisibilityFieldEditor = new RadioGroupFieldEditor(INavigationPreferenceConstant.PAPYRUS_NAVIGATION_DECORATOR_VISIBILITY, Messages.DecoratorVisibilityText, 1, new String[][]{ { Messages.DecoratorDisabled_Text, INavigationPreferenceConstant.DISABLED }, { Messages.DisplayOnly_Text, INavigationPreferenceConstant.DISPLAY_ONLY }, { Messages.Everywhere_Text, INavigationPreferenceConstant.EVERYWHERE } }, getFieldEditorParent());
+ addField(decoratorVisibilityFieldEditor);
+ decoratorVisibilityFieldEditor.setPreferenceStore(Activator.getDefault().getPreferenceStore());
}
}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/Messages.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/Messages.java
new file mode 100644
index 00000000000..a521f925a9f
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/Messages.java
@@ -0,0 +1,27 @@
+package org.eclipse.papyrus.navigation.utils;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.navigation.utils.messages"; //$NON-NLS-1$
+
+ public static String MultiDiagramDialog_0;
+
+ public static String MultiDiagramDialog_1;
+
+ public static String IS_BACK_POSSIBLE;
+
+ public static String IS_NEXT_POSSIBLE;
+
+ public static String IS_UP_POSSIBLE;
+
+ public static String IS_TOP_POSSIBLE;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/MultiDiagramDialog.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/MultiDiagramDialog.java
new file mode 100644
index 00000000000..2f3cdef1f61
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/MultiDiagramDialog.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * Copyright (c) 2011 AtoS
+ * 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:
+ * Anass RADOUANI (AtoS)
+ *******************************************************************************/
+
+package org.eclipse.papyrus.navigation.utils;
+
+import java.util.List;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.papyrus.modelexplorer.MoDiscoLabelProvider;
+import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.jface.viewers.TableViewer;
+
+/**
+ * This class Provide a dialog filled with a list of reachable diagrams
+ *
+ * @author aradouan
+ *
+ */
+public class MultiDiagramDialog extends Dialog {
+
+ private List<Diagram> diagrams;
+
+ private Composite dialogComposite;
+
+ protected int selectedDiagram;
+
+ private Table table;
+
+ private TableViewer list;
+
+ public int getSelectedDiagram() {
+ return selectedDiagram;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.MultiDiagramDialog_0);
+ }
+
+ public MultiDiagramDialog(Shell parentShell, List<Diagram> diagrams) {
+ super(parentShell);
+ this.diagrams = diagrams;
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ dialogComposite = (Composite)super.createDialogArea(parent);
+ parent.setLayout(new GridLayout());
+ dialogComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ createDialogComposite();
+ createDialogContents(dialogComposite);
+ hookListeners();
+ loadData();
+ defaultSelection();
+
+ return dialogComposite;
+ }
+
+ private void createDialogContents(Composite parent) {
+ dialogComposite.setLayout(new GridLayout(1, false));
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new FillLayout(SWT.HORIZONTAL));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+
+ Label lblDiagrams = new Label(composite, SWT.NONE);
+ lblDiagrams.setText(Messages.MultiDiagramDialog_1);
+
+ Composite composite_1 = new Composite(parent, SWT.NONE);
+ composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ composite_1.setLayout(new GridLayout(1, false));
+
+ list = new TableViewer(composite_1, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
+ list.setUseHashlookup(true);
+ table = list.getTable();
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ list.setLabelProvider(new MoDiscoLabelProvider());
+ list.setContentProvider(new IStructuredContentProvider() {
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof List) {
+ return ((List)inputElement).toArray();
+ } else {
+ return new Object[]{ inputElement };
+ }
+ }
+ });
+ }
+
+ private void createDialogComposite() {
+ GridData dialogLayoutData = new GridData(GridData.FILL_BOTH);
+ dialogComposite.setLayoutData(dialogLayoutData);
+
+ }
+
+ private void hookListeners() {
+ table.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ MultiDiagramDialog.this.selectedDiagram = table.getSelectionIndex();
+ }
+
+ });
+ }
+
+ private void loadData() {
+ list.setInput(diagrams);
+ }
+
+ private void defaultSelection() {
+ boolean found = false;
+ IPageMngr pageMngr;
+ try {
+ pageMngr = EditorUtils.getServiceRegistry().getService(IPageMngr.class);
+
+ for(Diagram diagram : diagrams) {
+ if(pageMngr.isOpen(diagram)) {
+ table.select(diagrams.indexOf(diagram));
+ found = true;
+ break;
+ }
+ }
+
+ if(!found) {
+ int diagFound = 0;
+ int diagFoundTemp = 0;
+ for(Diagram diagram : diagrams) {
+ diagFoundTemp = pageMngr.isInHsitory(diagram);
+ if(diagFoundTemp > diagFound) {
+ diagFound = diagFoundTemp;
+ table.select(diagrams.indexOf(diagram));
+ found = true;
+ }
+ }
+ }
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ }
+
+ if(!found) {
+ table.select(0);
+ }
+ }
+}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/PropertyTester.java b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/PropertyTester.java
new file mode 100644
index 00000000000..46d3d41a57d
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/PropertyTester.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2011 AtoS
+ * 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:
+ * Anass RADOUANI (AtoS) - test property to enable or disable Navigation Icons
+ *******************************************************************************/
+package org.eclipse.papyrus.navigation.utils;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.core.adaptor.gmf.DiagramsUtil;
+import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.core.services.ServicesRegistry;
+import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.papyrus.navigation.Activator;
+import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+
+public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
+
+ @SuppressWarnings("deprecation")
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ boolean result = false;
+
+ ServicesRegistry serviceRegistry = EditorUtils.getServiceRegistry();
+ if(serviceRegistry != null && Messages.IS_BACK_POSSIBLE.equals(property)) {
+ try {
+ IPageMngr pageMngr = serviceRegistry.getService(IPageMngr.class);
+ result = pageMngr.hasPreviousHistory();
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ }
+
+ } else if(serviceRegistry != null && Messages.IS_NEXT_POSSIBLE.equals(property)) {
+ try {
+ IPageMngr pageMngr = serviceRegistry.getService(IPageMngr.class);
+ result = pageMngr.hasNextHistory();
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ }
+
+ } else if(Messages.IS_UP_POSSIBLE.equals(property) || Messages.IS_TOP_POSSIBLE.equals(property)) {
+ IWorkbenchWindow activeWorkbenchWindow = Activator.getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow != null)
+ {
+ IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
+ if (activePage != null)
+ {
+ IEditorPart editor = activePage.getActiveEditor();
+ if(editor instanceof CoreMultiDiagramEditor) {
+ CoreMultiDiagramEditor papyrusEditor = (CoreMultiDiagramEditor)editor;
+ EObject parent = null;
+ if(papyrusEditor.getDiagram() != null && papyrusEditor.getDiagram().getElement() != null) {
+ parent = papyrusEditor.getDiagram().getElement().eContainer();
+ }
+
+ if(parent != null) {
+ while(parent != null && !result) {
+ result = !DiagramsUtil.getAssociatedDiagrams(parent, null).isEmpty();
+ parent = parent.eContainer();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+}
diff --git a/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/messages.properties b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/messages.properties
new file mode 100644
index 00000000000..c230b60594c
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.navigation/src/org/eclipse/papyrus/navigation/utils/messages.properties
@@ -0,0 +1,6 @@
+MultiDiagramDialog_0=Diagrams
+MultiDiagramDialog_1=Select a diagram :
+IS_BACK_POSSIBLE=isBackCommandPossible
+IS_NEXT_POSSIBLE=isNextCommandPossible
+IS_UP_POSSIBLE=isUpCommandPossible
+IS_TOP_POSSIBLE=isTopCommandPossible

Back to the top