Fix for Bug 417929 - [Perspectives] Resetting a perspective with an open minimized stack leaves cheese
diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/minmax/TrimStack.java b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/minmax/TrimStack.java index 7689714..c3d6def 100644 --- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/minmax/TrimStack.java +++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/minmax/TrimStack.java
@@ -102,6 +102,7 @@ private boolean isShowing = false; private MUIElement minimizedElement; + private Composite clientAreaComposite; private Composite hostPane; @Inject @@ -507,9 +508,19 @@ public void widgetDisposed(DisposeEvent e) { trimStackTB = null; trimStackMenu = null; + + if (isShowing && hostPane != null && !hostPane.isDisposed()) + showStack(false); } }); + // Get the shell's client area composite + Shell theShell = trimStackTB.getShell(); + if (theShell.getLayout() instanceof TrimmedPartLayout) { + TrimmedPartLayout tpl = (TrimmedPartLayout) theShell.getLayout(); + clientAreaComposite = tpl.clientArea; + } + trimStackTB.addListener(SWT.MenuDetect, new Listener() { public void handleEvent(Event event) { // Clear any existing menus @@ -821,14 +832,13 @@ */ public void showStack(boolean show) { Control ctrl = (Control) minimizedElement.getWidget(); - Composite clientArea = getShellClientComposite(); - if (clientArea == null) + if (clientAreaComposite == null || clientAreaComposite.isDisposed()) return; if (show && !isShowing) { hostPane = getHostPane(); ctrl.setParent(hostPane); - clientArea.addControlListener(caResizeListener); + clientAreaComposite.addControlListener(caResizeListener); // Set the initial location setPaneLocation(hostPane); @@ -892,8 +902,8 @@ } else if (!show && isShowing) { // Check to ensure that the client area is non-null since the // trimstack may be currently hosted in the limbo shell - if (clientArea != null) { - clientArea.removeControlListener(caResizeListener); + if (clientAreaComposite != null) { + clientAreaComposite.removeControlListener(caResizeListener); } if (hostPane != null && hostPane.isVisible()) { @@ -905,24 +915,11 @@ } } - Composite getShellClientComposite() { - if (trimStackTB == null || trimStackTB.isDisposed()) { - return null; - } - Shell theShell = trimStackTB.getShell(); - if (!(theShell.getLayout() instanceof TrimmedPartLayout)) - return null; - - TrimmedPartLayout tpl = (TrimmedPartLayout) theShell.getLayout(); - return tpl.clientArea; - } - private void setPaneLocation(Composite someShell) { - Composite clientComp = getShellClientComposite(); - if (clientComp == null || clientComp.isDisposed()) + if (clientAreaComposite == null || clientAreaComposite.isDisposed()) return; - Rectangle caRect = getShellClientComposite().getBounds(); + Rectangle caRect = clientAreaComposite.getBounds(); // NOTE: always starts in the persisted (or default) size Point paneSize = getHostPane().getSize();