01: /*******************************************************************************
02: * Copyright (c) 2004, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.dialogs;
11:
12: import org.eclipse.core.runtime.IProgressMonitor;
13: import org.eclipse.core.runtime.IStatus;
14: import org.eclipse.jface.dialogs.IDialogBlockedHandler;
15: import org.eclipse.swt.widgets.Shell;
16: import org.eclipse.ui.internal.progress.BlockedJobsDialog;
17:
18: /**
19: * The WorkbenchWizardBlockedHandler is the class that implements the blocked
20: * handler for the workbench.
21: */
22: public class WorkbenchDialogBlockedHandler implements
23: IDialogBlockedHandler {
24: IProgressMonitor outerMonitor;
25:
26: int nestingDepth = 0;
27:
28: /**
29: * Create a new instance of the receiver.
30: */
31: public WorkbenchDialogBlockedHandler() {
32: //No default behavior
33: }
34:
35: /*
36: * (non-Javadoc)
37: *
38: * @see org.eclipse.jface.dialogs.IDialogBlockedHandler#clearBlocked()
39: */
40: public void clearBlocked() {
41: if (nestingDepth == 0) {
42: return;
43: }
44:
45: nestingDepth--;
46:
47: if (nestingDepth <= 0) {
48: BlockedJobsDialog.clear(outerMonitor);
49: outerMonitor = null;
50: nestingDepth = 0;
51: }
52:
53: }
54:
55: /*
56: * (non-Javadoc)
57: *
58: * @see org.eclipse.jface.dialogs.IDialogBlockedHandler#showBlocked(org.eclipse.swt.widgets.Shell,
59: * org.eclipse.core.runtime.IProgressMonitor,
60: * org.eclipse.core.runtime.IStatus, java.lang.String)
61: */
62: public void showBlocked(Shell parentShell,
63: IProgressMonitor blockingMonitor, IStatus blockingStatus,
64: String blockedName) {
65:
66: nestingDepth++;
67: if (outerMonitor == null) {
68: outerMonitor = blockingMonitor;
69: //Try to get a name as best as possible
70: if (blockedName == null && parentShell != null) {
71: blockedName = parentShell.getText();
72: }
73: BlockedJobsDialog.createBlockedDialog(parentShell,
74: blockingMonitor, blockingStatus, blockedName);
75: }
76:
77: }
78:
79: /*
80: * (non-Javadoc)
81: *
82: * @see org.eclipse.jface.dialogs.IDialogBlockedHandler#showBlocked(org.eclipse.core.runtime.IProgressMonitor,
83: * org.eclipse.core.runtime.IStatus, java.lang.String)
84: */
85: public void showBlocked(IProgressMonitor blocking,
86: IStatus blockingStatus, String blockedName) {
87: showBlocked(null, blocking, blockingStatus, blockedName);
88: }
89: }
|