Skip to main content
summaryrefslogtreecommitdiffstats
blob: f5329e2f41d7315fb8e1819dbe719cc437b70720 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
 * Copyright (c) 2004 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.wst.ws.internal.explorer;

import org.eclipse.swt.SWTException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;

public class LaunchWizardTask {
	// singleton
	private static LaunchWizardTask task_;

	// the shell for the wizard to be launched
	private Shell shell_;

	// the LaunchWizardRunnable that is currently running
	private LaunchWizardRunnable runnable_;

	private LaunchWizardTask(Shell shell) {
		shell_ = shell;
		runnable_ = null;
	}

	public static LaunchWizardTask getInstance() {
		if (task_ == null)
			task_ = new LaunchWizardTask(PlatformUI.getWorkbench()
					.getActiveWorkbenchWindow().getShell());
		return task_;
	}

	public void asyncExec(Runnable runnable) throws SWTException {
		shell_.getDisplay().asyncExec(runnable);
	}

	public boolean checkAndAsyncExec(LaunchWizardRunnable runnable) {
		try {
			if (!getIsExecuting()) {
				asyncExec(runnable);
				runnable_ = runnable;
				return true;
			} else
				return false;
		} catch (Exception e) {
			return false;
		}
	}

	public boolean getIsExecuting() {
		if (runnable_ != null) {
			boolean isFinish = runnable_.isFinish();
			if (isFinish)
				runnable_ = null;
			return !isFinish;
		} else
			return false;
	}
}

Back to the top