Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 113730 Details for
Bug 247818
[StatusHandling] WorkbenchStatusDialogManager should inform of dialog closure
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Work in progress
dialogListener.txt (text/plain), 7.69 KB, created by
Krzysztof Daniel
on 2008-09-29 08:41:39 EDT
(
hide
)
Description:
Work in progress
Filename:
MIME Type:
Creator:
Krzysztof Daniel
Created:
2008-09-29 08:41:39 EDT
Size:
7.69 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java,v >retrieving revision 1.16 >diff -u -r1.16 WorkbenchStatusDialogManager.java >--- Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java 22 Sep 2008 10:26:37 -0000 1.16 >+++ Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java 29 Sep 2008 12:35:25 -0000 >@@ -222,6 +222,17 @@ > */ > private class InternalDialog extends TrayDialog { > >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.TrayDialog#close() >+ */ >+ public boolean close() { >+ boolean result = super.close(); >+ if (listener != null && !modalitySwitch) { >+ listener.statusDialogClosed(); >+ } >+ return result; >+ } >+ > private WorkbenchStatusDialogManager statusDialog; > > /** >@@ -1006,6 +1017,8 @@ > */ > private Composite titleArea; > >+ private IStatusDialogListener listener; >+ > /** > * Creates workbench status dialog. > * >@@ -1659,7 +1672,7 @@ > /** > * Returns the shell of the dialog. > */ >- Shell getShell() { >+ private Shell getShell() { > if (this.dialog == null) return null; > return this.dialog.getShell(); > } >@@ -2196,4 +2209,8 @@ > } > titleArea.layout(); > } >+ >+ void setStatusDialogListener(IStatusDialogListener listener){ >+ this.listener = listener; >+ } > } >Index: Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchErrorHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchErrorHandler.java,v >retrieving revision 1.22 >diff -u -r1.22 WorkbenchErrorHandler.java >--- Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchErrorHandler.java 26 Sep 2008 15:48:09 -0000 1.22 >+++ Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchErrorHandler.java 29 Sep 2008 12:35:24 -0000 >@@ -14,7 +14,6 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; > import org.eclipse.swt.widgets.Display; >-import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.application.WorkbenchAdvisor; > import org.eclipse.ui.internal.WorkbenchPlugin; >@@ -26,6 +25,15 @@ > * @since 3.3 > */ > public class WorkbenchErrorHandler extends AbstractStatusHandler { >+ >+ private boolean dialogClosed = false; >+ private IStatusDialogListener listener = new IStatusDialogListener(){ >+ >+ public void statusDialogClosed() { >+ dialogClosed = true; >+ } >+ >+ }; > > private WorkbenchStatusDialogManager statusDialog; > >@@ -110,11 +118,12 @@ > getStatusDialogManager().addStatusAdapter(statusAdapter, block); > > if (block) { >- Shell shell; >- while ((shell = getStatusDialogManager().getShell()) != null >- && !getStatusDialogManager().getShell().isDisposed()) { >- if (!shell.getDisplay().readAndDispatch()) { >- Thread.yield(); >+ // this variable will be set to true if and only if user closes the >+ // dialog >+ dialogClosed = false; >+ while (!dialogClosed) { >+ if (!Display.getDefault().readAndDispatch()) { >+ Display.getDefault().sleep(); > } > } > } >@@ -124,8 +133,9 @@ > * This method returns current {@link WorkbenchStatusDialogManager}. > * > * @return current {@link WorkbenchStatusDialogManager} >+ * @noreference This method is not intended to be referenced by clients. > */ >- private WorkbenchStatusDialogManager getStatusDialogManager() { >+ public WorkbenchStatusDialogManager getStatusDialogManager() { > if (statusDialog == null) { > initStatusDialogManager(); > } >@@ -158,6 +168,7 @@ > */ > private void initStatusDialogManager() { > statusDialog = new WorkbenchStatusDialogManager(null); >+ statusDialog.setStatusDialogListener(listener); > configureStatusDialog(statusDialog); > } > } >Index: Eclipse UI/org/eclipse/ui/statushandlers/IStatusDialogListener.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/statushandlers/IStatusDialogListener.java >diff -N Eclipse UI/org/eclipse/ui/statushandlers/IStatusDialogListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/statushandlers/IStatusDialogListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.statushandlers; >+ >+/** >+ * @since 3.4 >+ * >+ */ >+interface IStatusDialogListener { >+ public void statusDialogClosed(); >+} >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java,v >retrieving revision 1.5 >diff -u -r1.5 StatusDialogManagerTest.java >--- Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java 22 Sep 2008 10:26:39 -0000 1.5 >+++ Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java 29 Sep 2008 12:35:27 -0000 >@@ -31,6 +31,7 @@ > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Shell; >@@ -42,6 +43,8 @@ > import org.eclipse.ui.statushandlers.AbstractStatusAreaProvider; > import org.eclipse.ui.statushandlers.IStatusAdapterConstants; > import org.eclipse.ui.statushandlers.StatusAdapter; >+import org.eclipse.ui.statushandlers.StatusManager; >+import org.eclipse.ui.statushandlers.WorkbenchErrorHandler; > import org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager; > > public class StatusDialogManagerTest extends TestCase { >@@ -73,6 +76,38 @@ > assertNotNull(shell); > assertTrue((shell.getStyle() & SWT.APPLICATION_MODAL) == SWT.APPLICATION_MODAL); > } >+ >+ //checks if the calling thread is really blocked >+ public void testBlockingBehavior(){ >+ WorkbenchErrorHandler weh = new WorkbenchErrorHandler(); >+ wsdm = weh.getStatusDialogManager(); >+ Thread thread = new Thread(new Runnable(){ >+ public void run() { >+ int count = 50; >+ final boolean opened[] = new boolean[]{false}; >+ while (!opened[0] && count-- != 0) { >+ try { >+ Thread.sleep(50); >+ } catch (InterruptedException e) { >+ e.printStackTrace(); >+ } >+ Display.getDefault().syncExec(new Runnable() { >+ public void run() { >+ opened[0] = StatusDialogUtil.getStatusShell() != null; >+ if(opened[0]){ >+ selectWidget(StatusDialogUtil.getOkButton()); >+ } >+ } >+ }); >+ } >+ assertTrue(count > 0); >+ >+ } >+ }); >+ thread.start(); >+ weh.handle(createStatusAdapter(MESSAGE_1), StatusManager.BLOCK); >+ assertNull(StatusDialogUtil.getStatusShell()); >+ } > > public void testNonBlockingAppearance() { > wsdm.addStatusAdapter(createStatusAdapter(MESSAGE_1), false);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247818
:
113730
|
113856
|
113857
|
113964
|
114310
|
114311
|
114933
|
115700
|
115714