KickJava   Java API By Example, From Geeks To Geeks.

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


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.debug.core.DebugException;
15 import org.eclipse.debug.core.model.IThread;
16 import org.eclipse.jdt.debug.core.IJavaDebugTarget;
17 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
18 import org.eclipse.jface.action.IAction;
19
20
21 /**
22  * Resumes all the threads
23  */

24 public class MonitorQuitAction extends MonitorAction {
25     
26     /* (non-Javadoc)
27      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
28      */

29     public void run(IAction action) {
30         IJavaDebugTarget target= getDebugTarget();
31         if (target == null) {
32             return;
33         }
34         try {
35             IThread[] threads= target.getThreads();
36             for (int i = 0; i < threads.length; i++) {
37                 IThread thread= threads[i];
38                 if (thread.isSuspended()) {
39                     thread.resume();
40                     while (thread.isSuspended()) {
41                         Thread.sleep(100);
42                     }
43                 }
44             }
45         }
46         catch (DebugException e) {
47             JDIDebugUIPlugin.log(e);
48         }
49         catch (InterruptedException JavaDoc e){
50             JDIDebugUIPlugin.log(e);
51         }
52     }
53     
54     /* (non-Javadoc)
55      * @see org.eclipse.ui.texteditor.IUpdate#update()
56      */

57     public void update() {
58         boolean enable= false;
59         if (fAction != null) {
60             IJavaDebugTarget target= getDebugTarget();
61             if (target != null) {
62                 if (target.supportsMonitorInformation()) {
63                     try {
64                         IThread[] threads= target.getThreads();
65                         for (int i = 0; i < threads.length; i++) {
66                             IThread thread= threads[i];
67                             if (thread.isSuspended()) {
68                                 enable= true;
69                                 break;
70                             }
71                         }
72                     }catch (DebugException e) {
73                     }
74                 }
75             }
76             fAction.setEnabled(enable);
77         }
78     }
79 }
80
Popular Tags