Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2015-02-11 22:43:03 +0000
committerLars Vogel2015-02-16 12:02:32 +0000
commitca6d410cf1d3749c9a3727ea17620f5b9ef39db2 (patch)
treee1078d3d50abfe9f5e4ebe4ec19f07d75cedb1ae
parent60eeca78e4ac811794818181edb5a1fcc2af1c5b (diff)
downloadeclipse.platform.ui-ca6d410cf1d3749c9a3727ea17620f5b9ef39db2.tar.gz
eclipse.platform.ui-ca6d410cf1d3749c9a3727ea17620f5b9ef39db2.tar.xz
eclipse.platform.ui-ca6d410cf1d3749c9a3727ea17620f5b9ef39db2.zip
Bug 337588 - [EditorMgmt] Editor should have "Close Tabs To The Right"
Added "Close Tabs To The Left" and "Close Tabs To The Right" menus to the tab area below "Close Others" and above "Close All". The menus appear only if there is at least one tab on the appropriate side from the current tab. Added extra separator before "Close All" to have visual highliht between close "some" and close "all" menus. Change-Id: I7cb8618c779ed5ced380bd07cdd562c3a8c46bc6 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/SWTRenderersMessages.java4
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/messages.properties4
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java80
3 files changed, 78 insertions, 10 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/SWTRenderersMessages.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/SWTRenderersMessages.java
index bcd22bfef2b..ed97ab07ff0 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/SWTRenderersMessages.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/SWTRenderersMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 IBM Corporation 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
@@ -25,6 +25,8 @@ public class SWTRenderersMessages extends NLS {
public static String menuClose;
public static String menuCloseOthers;
public static String menuCloseAll;
+ public static String menuCloseRight;
+ public static String menuCloseLeft;
public static String viewMenu;
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/messages.properties b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/messages.properties
index c7112c6d320..69d10626cba 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/messages.properties
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/internal/workbench/renderers/swt/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2010, 2014 IBM Corporation and others.
+# Copyright (c) 2010, 2015 IBM Corporation 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
@@ -16,6 +16,8 @@ choosePartsToSave=Select the parts to save:
menuClose = &Close
menuCloseOthers = Close &Others
menuCloseAll = Close &All
+menuCloseRight = Close Tabs To The &Right
+menuCloseLeft = Close Tabs To The &Left
viewMenu = View Menu
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
index 31ecffe9470..6683d724cc6 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Lars Vogel <Lars.Vogel@vogella.com> - Bug 429728, 430166, 441150, 442285
+ * Andrey Loskutov <loskutov@gmx.de> - Bug 337588
*******************************************************************************/
package org.eclipse.e4.ui.workbench.renderers.swt;
@@ -1391,6 +1392,34 @@ public class StackRenderer extends LazyStackRenderer {
}
});
+ int leftFrom = getCloseableSideParts(part, true).size();
+ if (leftFrom > 0) {
+ MenuItem menuItemLeft = new MenuItem(menu, SWT.NONE);
+ menuItemLeft.setText(SWTRenderersMessages.menuCloseLeft);
+ menuItemLeft.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ MPart part = (MPart) menu.getData(STACK_SELECTED_PART);
+ closeSideParts(part, true);
+ }
+ });
+ }
+
+ int rightFrom = getCloseableSideParts(part, false).size();
+ if (rightFrom > 0) {
+ MenuItem menuItemRight = new MenuItem(menu, SWT.NONE);
+ menuItemRight.setText(SWTRenderersMessages.menuCloseRight);
+ menuItemRight.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ MPart part = (MPart) menu.getData(STACK_SELECTED_PART);
+ closeSideParts(part, false);
+ }
+ });
+ }
+
+ new MenuItem(menu, SWT.SEPARATOR);
+
MenuItem menuItemAll = new MenuItem(menu, SWT.NONE);
menuItemAll.setText(SWTRenderersMessages.menuCloseAll);
menuItemAll.addSelectionListener(new SelectionAdapter() {
@@ -1415,16 +1444,37 @@ public class StackRenderer extends LazyStackRenderer {
return parent;
}
+ private List<MPart> getCloseableSideParts(MPart part, boolean left) {
+ MElementContainer<MUIElement> container = getParent(part);
+ if (container == null) {
+ return new ArrayList<MPart>();
+ }
+
+ List<MUIElement> children = container.getChildren();
+ int thisPartIdx = children.indexOf(part);
+ final int start = left ? 0 : thisPartIdx + 1;
+ final int end = left ? thisPartIdx : children.size();
+
+ return getCloseableSiblingParts(part, children, start, end);
+ }
+
private List<MPart> getCloseableSiblingParts(MPart part) {
- // broken out from closeSiblingParts so it can be used to determine how
- // many closeable siblings are available
MElementContainer<MUIElement> container = getParent(part);
- List<MPart> closeableSiblings = new ArrayList<MPart>();
- if (container == null)
- return closeableSiblings;
+ if (container == null) {
+ return new ArrayList<MPart>();
+ }
List<MUIElement> children = container.getChildren();
- for (MUIElement child : children) {
+ return getCloseableSiblingParts(part, children, 0, children.size());
+ }
+
+ private List<MPart> getCloseableSiblingParts(MPart part, List<MUIElement> children,
+ final int start, final int end) {
+ // broken out from closeSiblingParts so it can be used to determine how
+ // many closeable siblings are available
+ List<MPart> closeableSiblings = new ArrayList<MPart>();
+ for (int i = start; i < end; i++) {
+ MUIElement child = children.get(i);
// If the element isn't showing skip it
if (!child.isToBeRendered())
continue;
@@ -1448,12 +1498,26 @@ public class StackRenderer extends LazyStackRenderer {
return closeableSiblings;
}
- private void closeSiblingParts(MPart part, boolean skipThisPart) {
+ private void closeSideParts(MPart part, boolean left) {
MElementContainer<MUIElement> container = getParent(part);
- if (container == null)
+ if (container == null) {
return;
+ }
+ List<MPart> others = getCloseableSideParts(part, left);
+ closeSiblingParts(part, others, true);
+ }
+ private void closeSiblingParts(MPart part, boolean skipThisPart) {
+ MElementContainer<MUIElement> container = getParent(part);
+ if (container == null) {
+ return;
+ }
List<MPart> others = getCloseableSiblingParts(part);
+ closeSiblingParts(part, others, skipThisPart);
+ }
+
+ private void closeSiblingParts(MPart part, List<MPart> others, boolean skipThisPart) {
+ MElementContainer<MUIElement> container = getParent(part);
// add the current part last so that we unrender obscured items first
if (!skipThisPart && part.isToBeRendered() && isClosable(part)) {

Back to the top