Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrik Suzzi2017-04-10 16:30:26 +0000
committerPatrik Suzzi2017-04-10 16:30:26 +0000
commit8f2f668a3ca69828368913a9b5308be677e6981e (patch)
tree824a544a67805539522a02e5fa2a22712907f147
parent7b7b8d0571eea8f135fff170adbbcbba61f59818 (diff)
downloadeclipse.platform.ui-8f2f668a3ca69828368913a9b5308be677e6981e.tar.gz
eclipse.platform.ui-8f2f668a3ca69828368913a9b5308be677e6981e.tar.xz
eclipse.platform.ui-8f2f668a3ca69828368913a9b5308be677e6981e.zip
Bug 409633 - Lock the toolbars command not working
Re-implemented the LockToolBarHandler, by setting the values of IPresentationEngine.NO_MOVE and IPresentationEngine.DRAGGABLE, and then forcing the call of ToolBarManagerRenderer#createWidgeg(), followed by the call of CSSRenderingUtils#frameMeIfPossible. See the proposed solution in action: https://bugs.eclipse.org/bugs/attachment.cgi?id=267733 Change-Id: Ic0a44f0eb8b0519802cc317623d0d5593a1a778a Signed-off-by: Patrik Suzzi <psuzzi@gmail.com>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java4
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/LockToolBarHandler.java48
2 files changed, 44 insertions, 8 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 5a9e90a0dc6..7664a65acfe 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 IBM Corporation and others.
+ * Copyright (c) 2011, 2017 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
@@ -10,6 +10,7 @@
* Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 430116
* Lars Vogel <Lars.Vogel@vogella.com> - Bug 457237, 472654
* Andrey Loskutov <loskutov@gmx.de> - Bugs 383569, 420956, 457198, 395601, 445538
+ * Patrik Suzzi <psuzzi@gmail.com> - Bug 409633
******************************************************************************/
package org.eclipse.ui.internal;
@@ -525,6 +526,7 @@ public class CoolBarToTrimManager extends ContributionManager implements ICoolBa
@Override
public void setLockLayout(boolean value) {
+ // 409633 Not implemented, see LockToolBarHandler
}
@Override
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/LockToolBarHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/LockToolBarHandler.java
index 3b3b946205d..fb174cae09b 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/LockToolBarHandler.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/LockToolBarHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 2017 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
@@ -7,12 +7,18 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Patrik Suzzi <psuzzi@gmail.com> - Bug 409633
*******************************************************************************/
package org.eclipse.ui.internal.handlers;
+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.e4.ui.model.application.ui.basic.MTrimmedWindow;
+import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
+import org.eclipse.e4.ui.workbench.IPresentationEngine;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.internal.WorkbenchWindow;
@@ -26,16 +32,44 @@ import org.eclipse.ui.internal.WorkbenchWindow;
*/
public class LockToolBarHandler extends AbstractHandler {
+ private static final String TOOLBAR_SEPARATOR = "toolbarSeparator"; //$NON-NLS-1$
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- WorkbenchWindow workbenchWindow = (WorkbenchWindow) HandlerUtil
- .getActiveWorkbenchWindow(event);
- if (workbenchWindow != null) {
- ICoolBarManager coolBarManager = workbenchWindow.getCoolBarManager2();
+ WorkbenchWindow window = (WorkbenchWindow) HandlerUtil.getActiveWorkbenchWindowChecked(event);
+ MTrimmedWindow winModel = window.getService(MTrimmedWindow.class);
+ EModelService modelService = window.getService(EModelService.class);
+
+ if (window != null) {
+ ICoolBarManager coolBarManager = window.getCoolBarManager2();
if (coolBarManager != null) {
- boolean oldValue = HandlerUtil.toggleCommandState(event.getCommand());
- coolBarManager.setLockLayout(!oldValue);
+ // lock is the opposite of the original value before toggle
+ boolean lock = !HandlerUtil.toggleCommandState(event.getCommand());
+ final List<MToolBar> children = modelService.findElements(winModel, null, MToolBar.class, null);
+ for (MToolBar el : children) {
+ if (!el.getTags().contains(TOOLBAR_SEPARATOR)) {
+ if (lock) {
+ // locks the toolbars
+ if (!el.getTags().contains(IPresentationEngine.NO_MOVE)) {
+ el.getTags().add(IPresentationEngine.NO_MOVE);
+ }
+ if (el.getTags().contains(IPresentationEngine.DRAGGABLE)) {
+ el.getTags().remove(IPresentationEngine.DRAGGABLE);
+ }
+ } else {
+ // unlocks the toolbars
+ if (el.getTags().contains(IPresentationEngine.NO_MOVE)) {
+ el.getTags().remove(IPresentationEngine.NO_MOVE);
+ }
+ if (!el.getTags().contains(IPresentationEngine.DRAGGABLE)) {
+ el.getTags().add(IPresentationEngine.DRAGGABLE);
+ }
+ }
+ // Force the render, and then the call of frameMeIfPossible.
+ el.setToBeRendered(false);
+ el.setToBeRendered(true);
+ }
+ }
}
}
return null;

Back to the top