01: package org.eclipse.ui.examples.jobs.actions;
02:
03: import org.eclipse.core.runtime.OperationCanceledException;
04: import org.eclipse.core.runtime.Platform;
05: import org.eclipse.jface.action.IAction;
06: import org.eclipse.jface.viewers.ISelection;
07: import org.eclipse.ui.IWorkbenchWindow;
08: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
09:
10: /**
11: * Toggles the suspend/resume state of the job manager.
12: */
13: public class SuspendJobManagerAction implements
14: IWorkbenchWindowActionDelegate {
15:
16: /* (non-Javadoc)
17: * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
18: */
19: public void run(IAction action) {
20: try {
21: if (action.isChecked())
22: Platform.getJobManager().suspend();
23: else
24: Platform.getJobManager().resume();
25: } catch (OperationCanceledException e) {
26: //thrown if the user cancels the attempt to suspend
27: e.printStackTrace();
28: }
29: }
30:
31: /* (non-Javadoc)
32: * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
33: */
34: public void selectionChanged(IAction action, ISelection selection) {
35: //do nothing
36: }
37:
38: /* (non-Javadoc)
39: * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
40: */
41: public void dispose() {
42: //do nothing
43: }
44:
45: /* (non-Javadoc)
46: * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
47: */
48: public void init(IWorkbenchWindow window) {
49: //do nothing
50: }
51: }
|