summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/BSPProgressDialog.java
blob: 8d5864ce50119457618122f0ea1bfbc90718046e (plain)
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
package org.yocto.sdk.remotetools.wizards.bsp;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Shell;

/**
 * Creates a progress monitor dialog that will run in the background a BSPThread and display a custom message
 * @author ioana.grigoropol
 *
 */
public class BSPProgressDialog extends ProgressMonitorDialog{
	String displayMessage;
	BSPThread getterThread;
	Shell shell;


	public BSPProgressDialog(Shell parent, BSPThread getterThread, String displayMessage) {
		super(parent);
		this.shell = parent;
		this.getterThread = getterThread;
		this.displayMessage = displayMessage;
	}

	public void run(boolean showProgressDialog){
		try {
			if (showProgressDialog)
				super.run(true, true, new IRunnableWithProgress(){
					@Override
					public void run(IProgressMonitor monitor) {
						monitor.beginTask(displayMessage + " ...", 100);
						getterThread.run();
						monitor.done();
					}
				});
			else
				getterThread.run();
		} catch (Exception e) {
			getterThread.getBspAction().setMessage(e.getMessage());
		}
	}

	public BSPAction getBspAction() {
		return getterThread.getBspAction();
	}
}