KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > monitors > MonitorTraceAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.ui.monitors;
12
13
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.core.runtime.jobs.Job;
18 import org.eclipse.jdt.debug.core.IJavaDebugTarget;
19 import org.eclipse.jface.action.IAction;
20 import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
21
22 /**
23  * Suspend all non-system threads and updates the data in MonitorManager
24  */

25 public class MonitorTraceAction extends MonitorAction {
26     
27     /**
28      * @see IActionDelegate#run(IAction)
29      */

30     public void run(IAction action) {
31             
32         final IJavaDebugTarget target= getDebugTarget();
33         if (target == null) {
34             return;
35         }
36         Job job = new Job(MonitorMessages.getString("MonitorsView.4")) { //$NON-NLS-1$
37
protected IStatus run(IProgressMonitor monitor) {
38                 MonitorManager.getDefault().update(target);
39                 Runnable JavaDoc r = new Runnable JavaDoc() {
40                     public void run() {
41                         fView.refreshCurrentViewer(target.supportsMonitorInformation(), false);
42                     }
43                 };
44                 fView.asyncExec(r);
45                 return Status.OK_STATUS;
46             }
47         };
48         job.setSystem(true);
49         IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) fView.getAdapter(IWorkbenchSiteProgressService.class);
50         if (service == null) {
51             job.schedule();
52         } else {
53             service.schedule(job);
54         }
55     }
56     
57     /* (non-Javadoc)
58      * @see org.eclipse.ui.texteditor.IUpdate#update()
59      */

60     public void update() {
61         boolean enable= false;
62         if (fAction != null) {
63             IJavaDebugTarget target= getDebugTarget();
64             if (target != null) {
65                 enable= target.supportsMonitorInformation();
66             }
67             fAction.setEnabled(enable);
68         }
69     }
70 }
71
Popular Tags