Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuai Li2015-04-21 15:32:33 +0000
committerBenoit Maggi2015-04-23 12:17:17 +0000
commitae78b91ba6005ae70b725a1e967541bad2f6e839 (patch)
tree245fcb4b4966e4cfcb3f4ffa262aac589beb8d3d /plugins/editor/org.eclipse.papyrus.editor
parentf5f6d51ec1623f91ef584af4b6684171cdb0c28e (diff)
downloadorg.eclipse.papyrus-ae78b91ba6005ae70b725a1e967541bad2f6e839.tar.gz
org.eclipse.papyrus-ae78b91ba6005ae70b725a1e967541bad2f6e839.tar.xz
org.eclipse.papyrus-ae78b91ba6005ae70b725a1e967541bad2f6e839.zip
Bug 465122 - [Navigation] Keys to travers opened tabs in editor
- Remove unnecessary execute methods - Log errors - Fix wrong javadoc - Modifications after review. Most noticeable change is that multi-tabfolders are now supported, i.e. traverse tabs in the current active tabfolder. - Add getNextPage and getPreviousPage methods in ISashWindowsContainer and SashWindowsContainer (implementation) - Add CollectNextPageVisitor in SashWindowsContainer to collect the next/previous page - Extend org.eclipse.ui.bindings with 2 key sequences: CTRL+TAB and CTRL+M2+TAB triggering commands below - Extend org.eclipse.ui.category.navigate with Next Tab and Previous Tab commands - NextTabHandler and PreviousTabHandler (extend TraversTabHandler) for the commands Change-Id: I56f0ac57dcb62540a3b5ddf9bb2e21568f20b9f3 Signed-off-by: Shuai Li <shuai.li@cea.fr> Reviewed-on: https://git.eclipse.org/r/46192 Tested-by: Hudson CI Reviewed-by: Christian W. Damus <give.a.damus@gmail.com> Tested-by: Christian W. Damus <give.a.damus@gmail.com> Reviewed-by: Benoit Maggi <benoit.maggi@cea.fr>
Diffstat (limited to 'plugins/editor/org.eclipse.papyrus.editor')
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/plugin.xml100
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/NextTabHandler.java29
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/PreviousTabHandler.java29
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/TraverseTabHandler.java69
4 files changed, 202 insertions, 25 deletions
diff --git a/plugins/editor/org.eclipse.papyrus.editor/plugin.xml b/plugins/editor/org.eclipse.papyrus.editor/plugin.xml
index e93975eabfb..656c9b7a877 100644
--- a/plugins/editor/org.eclipse.papyrus.editor/plugin.xml
+++ b/plugins/editor/org.eclipse.papyrus.editor/plugin.xml
@@ -1,25 +1,75 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<plugin>
- <extension point="org.eclipse.ui.editors">
- <editor
- class="org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor"
- contributorClass="org.eclipse.papyrus.editor.PapyrusActionBarContributor"
- default="true"
- extensions="di"
- icon="icons/papyrus/Papyrus_16x16.gif"
- id="org.eclipse.papyrus.infra.core.papyrusEditor"
- matchingStrategy="org.eclipse.papyrus.editor.PapyrusMatchingStrategy"
- name="Papyrus Editor Core">
- </editor>
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <category
- description="this a category of papyrus commands"
- id="org.eclipse.papyrus.editor.category"
- name="Papyrus Category">
- </category>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension point="org.eclipse.ui.editors">
+ <editor
+ class="org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor"
+ contributorClass="org.eclipse.papyrus.editor.PapyrusActionBarContributor"
+ default="true"
+ extensions="di"
+ icon="icons/papyrus/Papyrus_16x16.gif"
+ id="org.eclipse.papyrus.infra.core.papyrusEditor"
+ matchingStrategy="org.eclipse.papyrus.editor.PapyrusMatchingStrategy"
+ name="Papyrus Editor Core">
+ </editor>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ description="this a category of papyrus commands"
+ id="org.eclipse.papyrus.editor.category"
+ name="Papyrus Category">
+ </category>
+
+ <command
+ categoryId="org.eclipse.ui.category.navigate"
+ id="org.eclipse.papyrus.editor.nextTabCommand"
+ name="Next Tab">
+ </command>
+ <command
+ categoryId="org.eclipse.ui.category.navigate"
+ id="org.eclipse.papyrus.editor.previousTabCommand"
+ name="Previous Tab">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.bindings">
+ <key
+ commandId="org.eclipse.papyrus.editor.nextTabCommand"
+ contextId="org.eclipse.ui.contexts.window"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="CTRL+TAB">
+ </key>
+ <key
+ commandId="org.eclipse.papyrus.editor.previousTabCommand"
+ contextId="org.eclipse.ui.contexts.window"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="CTRL+M2+TAB">
+ </key>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.editor.handlers.NextTabHandler"
+ commandId="org.eclipse.papyrus.editor.nextTabCommand">
+ <activeWhen>
+ <with variable="activeEditorId">
+ <equals value="org.eclipse.papyrus.infra.core.papyrusEditor"/>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.editor.handlers.PreviousTabHandler"
+ commandId="org.eclipse.papyrus.editor.previousTabCommand">
+ <activeWhen>
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.infra.core.papyrusEditor">
+ </equals>
+ </with>
+ </activeWhen>
+ </handler>
+ </extension>
+
+</plugin>
diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/NextTabHandler.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/NextTabHandler.java
new file mode 100644
index 00000000000..99f02589ba2
--- /dev/null
+++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/NextTabHandler.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * 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.editor.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/**
+ * The handler for the next tab command that lets the user navigate to
+ * the next page of the active tab-folder with Ctrl+Tab
+ *
+ * @author Shuai Li
+ */
+public class NextTabHandler extends TraverseTabHandler {
+ public NextTabHandler() {
+ super(false);
+ }
+}
diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/PreviousTabHandler.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/PreviousTabHandler.java
new file mode 100644
index 00000000000..ae42ef0170c
--- /dev/null
+++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/PreviousTabHandler.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * 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.editor.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/**
+ * The handler for the previous tab command that lets the user navigate to
+ * the previous page of the active tab-folder with Ctrl+Shift+Tab
+ *
+ * @author Shuai Li
+ */
+public class PreviousTabHandler extends TraverseTabHandler {
+ public PreviousTabHandler() {
+ super(true);
+ }
+}
diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/TraverseTabHandler.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/TraverseTabHandler.java
new file mode 100644
index 00000000000..dba5f87e2e9
--- /dev/null
+++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/handlers/TraverseTabHandler.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * 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.editor.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.editor.Activator;
+import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * The handler for the next/previous tab commands that let the user navigate to
+ * the next/previous page of the active tab-folder with Ctrl+Shift/Ctrl+Shift+Tab
+ *
+ * @author Shuai Li
+ */
+public abstract class TraverseTabHandler extends AbstractHandler {
+ private final boolean isPrevious;
+
+ public TraverseTabHandler() {
+ isPrevious = false;
+ }
+
+ public TraverseTabHandler(boolean isPrevious) {
+ this.isPrevious = isPrevious;
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if (activeWorkbenchWindow != null) {
+ IWorkbenchPart activePart = activeWorkbenchWindow.getActivePage().getActivePart();
+
+ if (activePart instanceof PapyrusMultiDiagramEditor) {
+ PapyrusMultiDiagramEditor papyrusEditor = (PapyrusMultiDiagramEditor) activePart;
+ try {
+ IPage nextPage = null;
+ if (isPrevious) {
+ nextPage = papyrusEditor.getISashWindowsContainer().getPreviousPage();
+ } else {
+ nextPage = papyrusEditor.getISashWindowsContainer().getNextPage();
+ }
+
+ papyrusEditor.getISashWindowsContainer().selectPage(nextPage);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+
+ return null;
+ }
+}

Back to the top