001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.api.debugger.jpda;
042:
043: import java.beans.PropertyChangeListener;
044: import java.beans.PropertyChangeSupport;
045:
046: import com.sun.jdi.request.StepRequest;
047:
048: /**
049: * Represents one JPDA step.
050: *
051: * @author Roman Ondruska
052: */
053: public abstract class JPDAStep {
054: private int size;
055: private int depth;
056: private boolean hidden;
057: /** Associated JPDA debugger */
058: protected JPDADebugger debugger;
059: private PropertyChangeSupport pcs;
060:
061: /** Step into any newly pushed frames */
062: public static final int STEP_INTO = StepRequest.STEP_INTO;
063: /** Step over any newly pushed frames */
064: public static final int STEP_OVER = StepRequest.STEP_OVER;
065: /** Step out of the current frame */
066: public static final int STEP_OUT = StepRequest.STEP_OUT;
067: /** Step to the next location on a different line */
068: public static final int STEP_LINE = StepRequest.STEP_LINE;
069: /** Step to the next available operation */
070: public static final int STEP_OPERATION = 10;
071: /** Step to the next available location */
072: public static final int STEP_MIN = StepRequest.STEP_MIN;
073: /** Property fired when the step is executed */
074: public static final String PROP_STATE_EXEC = "exec";
075:
076: /** Constructs a JPDAStep for given {@link org.netbeans.api.debugger.jpda.JPDADebugger},
077: * size {@link #STEP_LINE}, {@link #STEP_MIN}
078: * and depth {@link #STEP_OUT}, {@link #STEP_INTO}.
079: *
080: * @param debugger an associated JPDADebuger
081: * @param size step size
082: * @param depth step depth
083: */
084: public JPDAStep(JPDADebugger debugger, int size, int depth) {
085: this .size = size;
086: this .depth = depth;
087: this .debugger = debugger;
088: this .hidden = false;
089: pcs = new PropertyChangeSupport(this );
090: }
091:
092: /** Sets the hidden property. */
093: public void setHidden(boolean hidden) {
094: this .hidden = hidden;
095: }
096:
097: /**
098: * Returns hidden property of the step.
099: *
100: * @return hidden property
101: */
102: public boolean getHidden() {
103: return hidden;
104: }
105:
106: /** Sets size of the step.
107: * @param size step size
108: */
109: public void setSize(int size) {
110: this .size = size;
111: }
112:
113: /**
114: * Returns size of the step.
115: *
116: * @return step size
117: */
118: public int getSize() {
119: return size;
120: }
121:
122: /** Sets depth of the step.
123: * @param depth step depth
124: */
125: public void setDepth(int depth) {
126: this .depth = depth;
127: }
128:
129: /**
130: * Returns depth of the step.
131: *
132: * @return step depth
133: */
134: public int getDepth() {
135: return depth;
136: }
137:
138: /** Adds the step request to the associated
139: * {@link org.netbeans.api.debugger.jpda.JPDADebugger}.
140: * Method is not synchronized.
141: *
142: * @param tr associated thread
143: */
144: public abstract void addStep(JPDAThread tr);
145:
146: /**
147: * Adds property change listener.
148: *
149: * @param l new listener.
150: */
151: public void addPropertyChangeListener(PropertyChangeListener l) {
152: pcs.addPropertyChangeListener(l);
153: }
154:
155: /**
156: * Removes property change listener.
157: *
158: * @param l removed listener.
159: */
160: public void removePropertyChangeListener(PropertyChangeListener l) {
161: pcs.removePropertyChangeListener(l);
162: }
163:
164: /**
165: * Adds property change listener.
166: *
167: * @param l new listener.
168: */
169: public void addPropertyChangeListener(String propertyName,
170: PropertyChangeListener l) {
171: pcs.addPropertyChangeListener(propertyName, l);
172: }
173:
174: /**
175: * Removes property change listener.
176: *
177: * @param l removed listener.
178: */
179: public void removePropertyChangeListener(String propertyName,
180: PropertyChangeListener l) {
181: pcs.removePropertyChangeListener(propertyName, l);
182: }
183:
184: /**
185: * Fires property change.
186: */
187: protected void firePropertyChange(String name, Object o, Object n) {
188: pcs.firePropertyChange(name, o, n);
189: }
190:
191: }
|