KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > dialogs > WorkbenchDialogBlockedHandler


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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 package org.eclipse.ui.internal.dialogs;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.jface.dialogs.IDialogBlockedHandler;
16 import org.eclipse.swt.widgets.Shell;
17 import org.eclipse.ui.internal.progress.BlockedJobsDialog;
18
19 /**
20  * The WorkbenchWizardBlockedHandler is the class that implements the blocked
21  * handler for the workbench.
22  */

23 public class WorkbenchDialogBlockedHandler implements 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 JavaDoc 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, blockingMonitor,
74                     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, IStatus blockingStatus,
86             String JavaDoc blockedName) {
87         showBlocked(null, blocking, blockingStatus, blockedName);
88     }
89 }
90
Popular Tags