aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWojciech Sudol2014-04-03 08:46:54 (EDT)
committerPaul Webster2014-04-09 14:08:08 (EDT)
commit78d5f3de253dd16a205d0ebeb6b0a024084c74bc (patch)
treee2208366f2c0a3151a6b716ad76b91e4a69e9b27
parent2978fff7ac5aa802f45a15ecf9b8283ae35a393a (diff)
downloadeclipse.platform.ui-78d5f3de253dd16a205d0ebeb6b0a024084c74bc.zip
eclipse.platform.ui-78d5f3de253dd16a205d0ebeb6b0a024084c74bc.tar.gz
eclipse.platform.ui-78d5f3de253dd16a205d0ebeb6b0a024084c74bc.tar.bz2
Bug 422651 - [Trim] Toolbar right aligned in RCP applicationrefs/changes/12/23612/11
Change-Id: I6a806529d46e14c360de3a9dbd5346a102e24944 Signed-off-by: Wojciech Sudol <wojciech.sudol@pl.ibm.com>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java8
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java14
2 files changed, 19 insertions, 3 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java
index c04737e..97b0c9a 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java
@@ -105,6 +105,14 @@ public class CoolBarToTrimManager extends ContributionManager implements ICoolBa
}
private void add(MTrimBar trimBar, int idx, IContributionItem item) {
+ // Special check to make sure that new additions are *before* the SPACER
+ if (idx == -1) {
+ MUIElement spacer = modelService.find(WorkbenchWindow.PERSPECTIVE_SPACER_ID, trimBar);
+ if (spacer != null) {
+ idx = trimBar.getChildren().indexOf(spacer);
+ }
+ }
+
if (item instanceof IToolBarContributionItem) {
IToolBarManager mgr = ((IToolBarContributionItem) item).getToolBarManager();
if (!(mgr instanceof ToolBarManager)) {
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
index aae2785..99d305b 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
@@ -202,6 +202,11 @@ import org.osgi.service.event.EventHandler;
*/
public class WorkbenchWindow implements IWorkbenchWindow {
+ /**
+ * The 'elementId' of the spacer used to right-align it in the trim
+ */
+ public static final String PERSPECTIVE_SPACER_ID = "PerspectiveSpacer"; //$NON-NLS-1$
+
private static final String MAIN_TOOLBAR_ID = "org.eclipse.ui.main.toolbar"; //$NON-NLS-1$
private static final String COMMAND_ID_TOGGLE_COOLBAR = "org.eclipse.ui.ToggleCoolbarAction"; //$NON-NLS-1$
@@ -806,6 +811,7 @@ public class WorkbenchWindow implements IWorkbenchWindow {
void populateTopTrimContributions() {
getCoolBarManager2().update(true);
+ getCoolBarManager2().add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
final MTrimBar trimBar = getTopTrim();
// TODO why aren't these added as trim contributions
@@ -821,10 +827,10 @@ public class WorkbenchWindow implements IWorkbenchWindow {
* and so on, buttons which are normally placed at the beginning of the
* trimbar (left) would be moved to the end of it (right).)
*/
- MToolControl spacerControl = (MToolControl) modelService.find("PerspectiveSpacer", model); //$NON-NLS-1$
+ MToolControl spacerControl = (MToolControl) modelService.find(PERSPECTIVE_SPACER_ID, model);
if (spacerControl == null) {
spacerControl = modelService.createModelElement(MToolControl.class);
- spacerControl.setElementId("PerspectiveSpacer"); //$NON-NLS-1$
+ spacerControl.setElementId(PERSPECTIVE_SPACER_ID);
spacerControl
.setContributionURI("bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.LayoutModifierToolControl"); //$NON-NLS-1$
spacerControl.getTags().add(TrimBarLayout.SPACER);
@@ -833,7 +839,7 @@ public class WorkbenchWindow implements IWorkbenchWindow {
MToolControl switcherControl = (MToolControl) modelService.find(
"PerspectiveSwitcher", model); //$NON-NLS-1$
- if (switcherControl == null) {
+ if (switcherControl == null && getWindowConfigurer().getShowPerspectiveBar()) {
switcherControl = modelService.createModelElement(MToolControl.class);
switcherControl.setToBeRendered(getWindowConfigurer().getShowPerspectiveBar());
switcherControl.setElementId("PerspectiveSwitcher"); //$NON-NLS-1$
@@ -841,6 +847,8 @@ public class WorkbenchWindow implements IWorkbenchWindow {
switcherControl
.setContributionURI("bundleclass://org.eclipse.ui.workbench/org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher"); //$NON-NLS-1$
trimBar.getChildren().add(switcherControl);
+ } else if (switcherControl != null && !getWindowConfigurer().getShowPerspectiveBar()) {
+ trimBar.getChildren().remove(switcherControl);
}
// render now after everything has been added so contributions can be