Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 247818 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java (-1 / +18 lines)
Lines 222-227 Link Here
222
	 */
222
	 */
223
	private class InternalDialog extends TrayDialog {
223
	private class InternalDialog extends TrayDialog {
224
224
225
		/* (non-Javadoc)
226
		 * @see org.eclipse.jface.dialogs.TrayDialog#close()
227
		 */
228
		public boolean close() {
229
			boolean result = super.close();
230
			if (listener != null && !modalitySwitch) {
231
				listener.statusDialogClosed();
232
			}
233
			return result;
234
		}
235
225
		private WorkbenchStatusDialogManager statusDialog;
236
		private WorkbenchStatusDialogManager statusDialog;
226
237
227
		/**
238
		/**
Lines 1006-1011 Link Here
1006
	 */
1017
	 */
1007
	private Composite titleArea;
1018
	private Composite titleArea;
1008
1019
1020
	private IStatusDialogListener listener;
1021
1009
	/**
1022
	/**
1010
	 * Creates workbench status dialog.
1023
	 * Creates workbench status dialog.
1011
	 * 
1024
	 * 
Lines 1659-1665 Link Here
1659
	/**
1672
	/**
1660
	 * Returns the shell of the dialog.
1673
	 * Returns the shell of the dialog.
1661
	 */
1674
	 */
1662
	Shell getShell() {
1675
	private Shell getShell() {
1663
		if (this.dialog == null) return null;
1676
		if (this.dialog == null) return null;
1664
		return this.dialog.getShell();
1677
		return this.dialog.getShell();
1665
	}
1678
	}
Lines 2196-2199 Link Here
2196
		}
2209
		}
2197
		titleArea.layout();
2210
		titleArea.layout();
2198
	}
2211
	}
2212
	
2213
	void setStatusDialogListener(IStatusDialogListener listener){
2214
		this.listener = listener;
2215
	}
2199
}
2216
}
(-)Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchErrorHandler.java (-7 / +18 lines)
Lines 14-20 Link Here
14
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Status;
15
import org.eclipse.core.runtime.Status;
16
import org.eclipse.swt.widgets.Display;
16
import org.eclipse.swt.widgets.Display;
17
import org.eclipse.swt.widgets.Shell;
18
import org.eclipse.ui.PlatformUI;
17
import org.eclipse.ui.PlatformUI;
19
import org.eclipse.ui.application.WorkbenchAdvisor;
18
import org.eclipse.ui.application.WorkbenchAdvisor;
20
import org.eclipse.ui.internal.WorkbenchPlugin;
19
import org.eclipse.ui.internal.WorkbenchPlugin;
Lines 26-31 Link Here
26
 * @since 3.3
25
 * @since 3.3
27
 */
26
 */
28
public class WorkbenchErrorHandler extends AbstractStatusHandler {
27
public class WorkbenchErrorHandler extends AbstractStatusHandler {
28
	
29
	private boolean dialogClosed = false;
30
	private IStatusDialogListener listener = new IStatusDialogListener(){
31
32
		public void statusDialogClosed() {
33
			dialogClosed = true;
34
		}
35
		
36
	};
29
37
30
	private WorkbenchStatusDialogManager statusDialog;
38
	private WorkbenchStatusDialogManager statusDialog;
31
39
Lines 110-120 Link Here
110
		getStatusDialogManager().addStatusAdapter(statusAdapter, block);
118
		getStatusDialogManager().addStatusAdapter(statusAdapter, block);
111
119
112
		if (block) {
120
		if (block) {
113
			Shell shell;
121
			// this variable will be set to true if and only if user closes the
114
			while ((shell = getStatusDialogManager().getShell()) != null
122
			// dialog
115
					&& !getStatusDialogManager().getShell().isDisposed()) {
123
			dialogClosed = false;
116
				if (!shell.getDisplay().readAndDispatch()) {
124
			while (!dialogClosed) {
117
					Thread.yield();
125
				if (!Display.getDefault().readAndDispatch()) {
126
					Display.getDefault().sleep();
118
				}
127
				}
119
			}
128
			}
120
		}
129
		}
Lines 124-131 Link Here
124
	 * This method returns current {@link WorkbenchStatusDialogManager}.
133
	 * This method returns current {@link WorkbenchStatusDialogManager}.
125
	 * 
134
	 * 
126
	 * @return current {@link WorkbenchStatusDialogManager}
135
	 * @return current {@link WorkbenchStatusDialogManager}
136
	 * @noreference This method is not intended to be referenced by clients.
127
	 */
137
	 */
128
	private WorkbenchStatusDialogManager getStatusDialogManager() {
138
	public WorkbenchStatusDialogManager getStatusDialogManager() {
129
		if (statusDialog == null) {
139
		if (statusDialog == null) {
130
			initStatusDialogManager();
140
			initStatusDialogManager();
131
		}
141
		}
Lines 158-163 Link Here
158
	 */
168
	 */
159
	private void initStatusDialogManager() {
169
	private void initStatusDialogManager() {
160
		statusDialog = new WorkbenchStatusDialogManager(null);
170
		statusDialog = new WorkbenchStatusDialogManager(null);
171
		statusDialog.setStatusDialogListener(listener);
161
		configureStatusDialog(statusDialog);
172
		configureStatusDialog(statusDialog);
162
	}
173
	}
163
}
174
}
(-)Eclipse (+20 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.statushandlers;
13
14
/**
15
 * @since 3.4
16
 *
17
 */
18
interface IStatusDialogListener {
19
	public void statusDialogClosed();
20
}
(-)Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java (+35 lines)
Lines 31-36 Link Here
31
import org.eclipse.swt.widgets.Button;
31
import org.eclipse.swt.widgets.Button;
32
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.swt.widgets.Display;
34
import org.eclipse.swt.widgets.Event;
35
import org.eclipse.swt.widgets.Event;
35
import org.eclipse.swt.widgets.Label;
36
import org.eclipse.swt.widgets.Label;
36
import org.eclipse.swt.widgets.Shell;
37
import org.eclipse.swt.widgets.Shell;
Lines 42-47 Link Here
42
import org.eclipse.ui.statushandlers.AbstractStatusAreaProvider;
43
import org.eclipse.ui.statushandlers.AbstractStatusAreaProvider;
43
import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
44
import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
44
import org.eclipse.ui.statushandlers.StatusAdapter;
45
import org.eclipse.ui.statushandlers.StatusAdapter;
46
import org.eclipse.ui.statushandlers.StatusManager;
47
import org.eclipse.ui.statushandlers.WorkbenchErrorHandler;
45
import org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager;
48
import org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager;
46
49
47
public class StatusDialogManagerTest extends TestCase {
50
public class StatusDialogManagerTest extends TestCase {
Lines 73-78 Link Here
73
		assertNotNull(shell);
76
		assertNotNull(shell);
74
		assertTrue((shell.getStyle() & SWT.APPLICATION_MODAL) == SWT.APPLICATION_MODAL);
77
		assertTrue((shell.getStyle() & SWT.APPLICATION_MODAL) == SWT.APPLICATION_MODAL);
75
	}
78
	}
79
	
80
	//checks if the calling thread is really blocked
81
	public void testBlockingBehavior(){
82
		WorkbenchErrorHandler weh = new WorkbenchErrorHandler();
83
		wsdm = weh.getStatusDialogManager();
84
		Thread thread = new Thread(new Runnable(){
85
			public void run() {
86
				int count = 50;
87
				final boolean opened[] = new boolean[]{false};
88
				while (!opened[0] && count-- != 0) {
89
					try {
90
						Thread.sleep(50);
91
					} catch (InterruptedException e) {
92
						e.printStackTrace();
93
					}
94
					Display.getDefault().syncExec(new Runnable() {
95
						public void run() {
96
							opened[0] = StatusDialogUtil.getStatusShell() != null;
97
							if(opened[0]){
98
								selectWidget(StatusDialogUtil.getOkButton());
99
							}
100
						}
101
					});
102
				}
103
				assertTrue(count > 0);
104
				
105
			}
106
		});
107
		thread.start();
108
		weh.handle(createStatusAdapter(MESSAGE_1), StatusManager.BLOCK);
109
		assertNull(StatusDialogUtil.getStatusShell());
110
	}
76
111
77
	public void testNonBlockingAppearance() {
112
	public void testNonBlockingAppearance() {
78
		wsdm.addStatusAdapter(createStatusAdapter(MESSAGE_1), false);
113
		wsdm.addStatusAdapter(createStatusAdapter(MESSAGE_1), false);

Return to bug 247818