1 33 34 package edu.rice.cs.drjava.model.debug; 35 36 import com.sun.jdi.request.*; 37 import java.util.Vector ; 38 39 42 public abstract class DebugAction<T extends EventRequest> { 43 public static final int ANY_LINE = -1; 44 45 protected final JPDADebugger _manager; 46 47 49 52 protected final Vector <T> _requests; 53 protected volatile int _suspendPolicy = EventRequest.SUSPEND_NONE; 54 protected volatile boolean _isEnabled = true; 55 protected volatile int _countFilter = -1; 56 protected volatile int _lineNumber = ANY_LINE; 57 58 63 public DebugAction(JPDADebugger manager) { 64 _manager = manager; 65 _requests = new Vector <T>(); 66 } 67 68 69 public Vector <T> getRequests() { return _requests; } 70 71 72 public int getLineNumber() { return _lineNumber; } 73 74 79 81 public boolean createRequests() throws DebugException { 82 _createRequests(); 83 if (_requests.size() > 0) { 84 _prepareRequests(_requests); 85 return true; 86 } 87 else return false; 88 } 89 90 93 protected void _initializeRequests() throws DebugException { 94 createRequests(); 95 if (_requests.size() == 0) { 96 throw new DebugException("Could not create EventRequests for this action!"); 97 } 98 } 99 100 103 protected void _createRequests() throws DebugException { } 104 105 108 protected void _prepareRequests(Vector <T> requests) { 109 for (int i=0; i < requests.size(); i++) { 110 _prepareRequest(requests.get(i)); 111 } 112 } 113 114 117 protected void _prepareRequest(T request) { 118 request.setEnabled(false); 120 121 if (_countFilter != -1) { 122 request.addCountFilter(_countFilter); 123 } 124 request.setSuspendPolicy(_suspendPolicy); 125 request.setEnabled(_isEnabled); 126 127 request.putProperty("debugAction", this); 129 } 130 131 132 public boolean isEnabled() { return _isEnabled; } 133 134 135 136 public void setEnabled(boolean isEnabled) { _isEnabled = isEnabled; } 137 } 138 | Popular Tags |