1 19 20 package org.netbeans.modules.debugger.jpda.actions; 21 22 import com.sun.jdi.ThreadReference; 23 import com.sun.jdi.VMDisconnectedException; 24 import com.sun.jdi.VirtualMachine; 25 import java.util.Collections ; 26 import java.util.List ; 27 import java.util.Map ; 28 import java.util.Set ; 29 import org.netbeans.api.debugger.ActionsManager; 30 31 32 import org.netbeans.spi.debugger.ContextProvider; 33 import org.netbeans.api.debugger.jpda.JPDADebugger; 34 import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl; 35 import org.openide.util.RequestProcessor; 36 37 38 44 public class PauseActionProvider extends JPDADebuggerActionProvider { 45 46 private volatile boolean doingAction; 47 48 49 public PauseActionProvider (ContextProvider contextProvider) { 50 super ( 51 (JPDADebuggerImpl) contextProvider.lookupFirst 52 (null, JPDADebugger.class) 53 ); 54 setProviderToDisableOnLazyAction(this); 55 } 56 57 public Set getActions () { 58 return Collections.singleton (ActionsManager.ACTION_PAUSE); 59 } 60 61 public void doAction (Object action) { 62 doingAction = true; 63 try { 64 ((JPDADebuggerImpl) getDebuggerImpl ()).suspend (); 65 } finally { 66 doingAction = false; 67 } 68 } 69 70 public void postAction(Object action, final Runnable actionPerformedNotifier) { 71 doingAction = true; 72 doLazyAction(new Runnable () { 73 public void run() { 74 try { 75 ((JPDADebuggerImpl) getDebuggerImpl ()).suspend (); 76 } finally { 77 try { 78 actionPerformedNotifier.run(); 79 } finally { 80 doingAction = false; 81 } 82 } 83 } 84 }); 85 } 86 87 protected void checkEnabled (int debuggerState) { 88 setEnabled ( 89 ActionsManager.ACTION_PAUSE, 90 debuggerState == JPDADebugger.STATE_RUNNING 91 ); 92 } 93 94 } 95 | Popular Tags |