summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorEric Moffatt2013-05-06 11:23:23 (EDT)
committer Gerrit Code Review @ Eclipse.org2013-05-14 10:19:39 (EDT)
commit96b7c38e40aff3d1e3ea3fa3941a159d0ceea206 (patch)
tree15e0dc0c7255af53eb0bc310d3f50b03aef945ac
parenta34cd181dc0b2c65c64e504e1409dffd075e9ac9 (diff)
downloadeclipse.platform.ui-96b7c38e40aff3d1e3ea3fa3941a159d0ceea206.zip
eclipse.platform.ui-96b7c38e40aff3d1e3ea3fa3941a159d0ceea206.tar.gz
eclipse.platform.ui-96b7c38e40aff3d1e3ea3fa3941a159d0ceea206.tar.bz2
Fix for Bug 404016 - Regression to 4.x: Workbench window as runnablerefs/changes/61/12361/6
context does not work/block ...adds code to disable the BindingService Change-Id: I775c75ec2a19d5f89f0e0dec50b49b0634e5389f
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java64
1 files changed, 64 insertions, 0 deletions
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 bea34f9..c9be57c 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
@@ -75,6 +75,7 @@ import org.eclipse.e4.ui.workbench.modeling.IWindowCloseHandler;
import org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer;
import org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRendererFilter;
import org.eclipse.e4.ui.workbench.renderers.swt.TrimBarLayout;
+import org.eclipse.e4.ui.workbench.renderers.swt.TrimmedPartLayout;
import org.eclipse.e4.ui.workbench.swt.factories.IRendererFactory;
import org.eclipse.jface.action.AbstractGroupMarker;
import org.eclipse.jface.action.CoolBarManager;
@@ -107,6 +108,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
@@ -167,6 +169,7 @@ import org.eclipse.ui.internal.services.IWorkbenchLocationService;
import org.eclipse.ui.internal.services.ServiceLocator;
import org.eclipse.ui.internal.services.WorkbenchLocationService;
import org.eclipse.ui.internal.util.PrefUtil;
+import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.IMenuService;
import org.eclipse.ui.presentations.AbstractPresentationFactory;
@@ -1690,6 +1693,13 @@ public class WorkbenchWindow implements IWorkbenchWindow {
perspectiveListeners.removePerspectiveListener(l);
}
+ private void disableControl(Control ctrl, List<Control> toEnable) {
+ if (ctrl != null && !ctrl.isDisposed() && ctrl.isEnabled()) {
+ ctrl.setEnabled(false);
+ toEnable.add(ctrl);
+ }
+ }
+
/*
* (non-Javadoc) Method declared on IRunnableContext.
*/
@@ -1703,7 +1713,46 @@ public class WorkbenchWindow implements IWorkbenchWindow {
runnable.run(new NullProgressMonitor());
} else {
boolean wasCancelEnabled = manager.isCancelEnabled();
+ boolean enableMainMenu = false;
+
+ IBindingService bs = model.getContext().get(IBindingService.class);
+ boolean keyFilterEnabled = bs.isKeyFilterEnabled();
+ List<Control> toEnable = new ArrayList<Control>();
try {
+ Menu mainMenu = (Menu) model.getMainMenu().getWidget();
+ if (mainMenu != null && !mainMenu.isDisposed() && mainMenu.isEnabled()) {
+ mainMenu.setEnabled(false);
+ enableMainMenu = true;
+ }
+
+ if (keyFilterEnabled)
+ bs.setKeyFilterEnabled(false);
+
+ // disable child shells
+ Shell theShell = getShell();
+ for (Shell childShell : theShell.getShells()) {
+ disableControl(childShell, toEnable);
+ }
+
+ //Disable the presentation (except the bottom trim)
+ TrimmedPartLayout tpl = (TrimmedPartLayout) getShell().getLayout();
+ disableControl(tpl.clientArea, toEnable);
+ disableControl(tpl.top, toEnable);
+ disableControl(tpl.left, toEnable);
+ disableControl(tpl.right, toEnable);
+
+ // Disable everything in the bottom trim except the status line
+ if (tpl.bottom != null && !tpl.bottom.isDisposed() && tpl.bottom.isEnabled()) {
+ MUIElement statusLine = modelService.find("StatusLine", model); //$NON-NLS-1$
+ if (statusLine != null && statusLine.getWidget() instanceof Control) {
+ Control slCtrl = (Control) statusLine.getWidget();
+ for (Control bottomCtrl : tpl.bottom.getChildren()) {
+ if (bottomCtrl != slCtrl)
+ disableControl(bottomCtrl, toEnable);
+ }
+ }
+ }
+
manager.setCancelEnabled(cancelable);
final InvocationTargetException[] ite = new InvocationTargetException[1];
@@ -1731,6 +1780,21 @@ public class WorkbenchWindow implements IWorkbenchWindow {
}
} finally {
manager.setCancelEnabled(wasCancelEnabled);
+
+ // re-enable the main menu if necessary
+ if (enableMainMenu) {
+ Menu mainMenu = (Menu) model.getMainMenu().getWidget();
+ mainMenu.setEnabled(true);
+ }
+
+ if (keyFilterEnabled)
+ bs.setKeyFilterEnabled(true);
+
+ // Re-enable any disabled controls
+ for (Control ctrl : toEnable) {
+ if (!ctrl.isDisposed())
+ ctrl.setEnabled(true);
+ }
}
}
}