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-2007 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:
042: package org.netbeans.modules.visualweb.gravy.debugger;
043:
044: import org.netbeans.modules.visualweb.gravy.TopComponentOperator;
045: import org.netbeans.modules.visualweb.gravy.Util;
046:
047: import java.awt.Component;
048:
049: import javax.swing.JDesktopPane;
050:
051: import org.netbeans.jemmy.ComponentChooser;
052: import org.netbeans.jemmy.JemmyException;
053:
054: import org.netbeans.jemmy.operators.ComponentOperator;
055: import org.netbeans.jemmy.operators.ContainerOperator;
056: import org.netbeans.jemmy.operators.JButtonOperator;
057: import org.netbeans.jemmy.operators.JDialogOperator;
058: import org.netbeans.jemmy.operators.JInternalFrameOperator;
059: import org.netbeans.jemmy.operators.JListOperator;
060: import org.netbeans.jemmy.operators.JPopupMenuOperator;
061: import org.netbeans.jemmy.operators.JTableOperator;
062: import org.netbeans.jemmy.operators.JToggleButtonOperator;
063: import org.netbeans.jemmy.operators.JTextComponentOperator;
064: import org.netbeans.jemmy.operators.Operator;
065:
066: /**
067: * DebuggerWindowOperator class
068: */
069: public class DebuggerWindowOperator extends TopComponentOperator {
070: ComponentOperator desktop = null;
071: JTextComponentOperator query = null;
072:
073: private JToggleButtonOperator _tbSessions;
074: private JToggleButtonOperator _tbThreads;
075: private JToggleButtonOperator _tbCallStack;
076: private JToggleButtonOperator _tbLocalVariables;
077: private JToggleButtonOperator _tbAllInOne;
078: private JToggleButtonOperator _tbWatches;
079: private JToggleButtonOperator _tbClasses;
080: private JToggleButtonOperator _tbBreakpoints;
081: private JToggleButtonOperator _tbProperties;
082: private JToggleButtonOperator _tbPublic;
083: private JToggleButtonOperator _tbProtected;
084: private JToggleButtonOperator _tbPrivate;
085: private JToggleButtonOperator _tbPackagePrivate;
086: private JToggleButtonOperator _tbStatic;
087: private JToggleButtonOperator _tbInherited;
088:
089: private JTableOperator _tabTreeTable;
090:
091: private String[] views = { "Sessions", "Threads", "CallStack",
092: "LocalVariables", "AllInOne", "Watches", "Classes",
093: "Breakpoints", "Properties" };
094:
095: public DebuggerWindowOperator(ContainerOperator parent) {
096: super (parent, new DebuggerWindowChooser("Debugger"));
097: }
098:
099: public DebuggerWindowOperator() {
100: this (Util.getMainWindow());
101: }
102:
103: /** Show debugger window
104: */
105: public DebuggerWindowOperator show() {
106: this .setComparator(new Operator.DefaultStringComparator(false,
107: true));
108: Util.getMainTab().setSelectedIndex(
109: Util.getMainTab().findPage("Debugger"));
110: return (new DebuggerWindowOperator(Util.getMainWindow()));
111: }
112:
113: /** Tries to find "" ToolbarToggleButton in this dialog.
114: * @return JToggleButtonOperator
115: */
116: public JToggleButtonOperator tbSessions() {
117: _tbSessions = new JToggleButtonOperator(this , "", 0);
118: return _tbSessions;
119: }
120:
121: /** Tries to find "" ToolbarToggleButton in this dialog.
122: * @return JToggleButtonOperator
123: */
124: public JToggleButtonOperator tbThreads() {
125: _tbThreads = new JToggleButtonOperator(this , "", 1);
126: return _tbThreads;
127: }
128:
129: /** Tries to find "" ToolbarToggleButton in this dialog.
130: * @return JToggleButtonOperator
131: */
132: public JToggleButtonOperator tbCallStack() {
133: _tbCallStack = new JToggleButtonOperator(this , "", 2);
134: return _tbCallStack;
135: }
136:
137: /** Tries to find "" ToolbarToggleButton in this dialog.
138: * @return JToggleButtonOperator
139: */
140: public JToggleButtonOperator tbLocalVariables() {
141: _tbLocalVariables = new JToggleButtonOperator(this , "", 3);
142: return _tbLocalVariables;
143: }
144:
145: /** Tries to find "" ToolbarToggleButton in this dialog.
146: * @return JToggleButtonOperator
147: */
148: public JToggleButtonOperator tbAllInOne() {
149: _tbAllInOne = new JToggleButtonOperator(this , "", 4);
150: return _tbAllInOne;
151: }
152:
153: /** Tries to find "" ToolbarToggleButton in this dialog.
154: * @return JToggleButtonOperator
155: */
156: public JToggleButtonOperator tbWatches() {
157: _tbWatches = new JToggleButtonOperator(this , "", 5);
158: return _tbWatches;
159: }
160:
161: /** Tries to find "" ToolbarToggleButton in this dialog.
162: * @return JToggleButtonOperator
163: */
164: public JToggleButtonOperator tbClasses() {
165: _tbClasses = new JToggleButtonOperator(this , "", 6);
166: return _tbClasses;
167: }
168:
169: /** Tries to find "" ToolbarToggleButton in this dialog.
170: * @return JToggleButtonOperator
171: */
172: public JToggleButtonOperator tbBreakpoints() {
173: _tbBreakpoints = new JToggleButtonOperator(this , "", 7);
174: return _tbBreakpoints;
175: }
176:
177: /** Tries to find "" ToolbarToggleButton in this dialog.
178: * @return JToggleButtonOperator
179: */
180: public JToggleButtonOperator tbProperties() {
181: _tbProperties = new JToggleButtonOperator(this , "", 8);
182: return _tbProperties;
183: }
184:
185: /** Tries to find "" ToolbarToggleButton in this dialog.
186: * @return JToggleButtonOperator
187: */
188: public JToggleButtonOperator tbPublic() {
189: _tbPublic = new JToggleButtonOperator(this , "", 9);
190: return _tbPublic;
191: }
192:
193: /** Tries to find "" ToolbarToggleButton in this dialog.
194: * @return JToggleButtonOperator
195: */
196: public JToggleButtonOperator tbProtected() {
197: _tbProtected = new JToggleButtonOperator(this , "", 10);
198: return _tbProtected;
199: }
200:
201: /** Tries to find "" ToolbarToggleButton in this dialog.
202: * @return JToggleButtonOperator
203: */
204: public JToggleButtonOperator tbPrivate() {
205: _tbPrivate = new JToggleButtonOperator(this , "", 11);
206: return _tbPrivate;
207: }
208:
209: /** Tries to find "" ToolbarToggleButton in this dialog.
210: * @return JToggleButtonOperator
211: */
212: public JToggleButtonOperator tbPackagePrivate() {
213: _tbPackagePrivate = new JToggleButtonOperator(this , "", 12);
214: return _tbPackagePrivate;
215: }
216:
217: /** Tries to find "" ToolbarToggleButton in this dialog.
218: * @return JToggleButtonOperator
219: */
220: public JToggleButtonOperator tbStatic() {
221: _tbStatic = new JToggleButtonOperator(this , "", 13);
222: return _tbStatic;
223: }
224:
225: /** Tries to find "" ToolbarToggleButton in this dialog.
226: * @return JToggleButtonOperator
227: */
228: public JToggleButtonOperator tbInherited() {
229: _tbInherited = new JToggleButtonOperator(this , "", 14);
230: return _tbInherited;
231: }
232:
233: /** checks or unchecks given ToolbarToggleButton
234: * @param state boolean requested state
235: */
236: public void checkBreakpoints(boolean state) {
237: if (tbBreakpoints().isSelected() != state) {
238: tbBreakpoints().push();
239: }
240: }
241:
242: /** Get state of the given ToolbarToggleButton
243: */
244: public boolean getBreakpointsState() {
245: return tbBreakpoints().isSelected();
246: }
247:
248: /** checks or unchecks given ToolbarToggleButton
249: * @param state boolean requested state
250: */
251: public void checkSessions(boolean state) {
252: if (tbSessions().isSelected() != state) {
253: tbSessions().push();
254: }
255: }
256:
257: /** Get state of the given ToolbarToggleButton
258: */
259: public boolean getSessionsState() {
260: return tbSessions().isSelected();
261: }
262:
263: /** checks or unchecks given ToolbarToggleButton
264: * @param state boolean requested state
265: */
266: public void checkThreads(boolean state) {
267: if (tbThreads().isSelected() != state) {
268: tbThreads().push();
269: }
270: }
271:
272: /** Get state of the given ToolbarToggleButton
273: */
274: public boolean getThreadsState() {
275: return tbThreads().isSelected();
276: }
277:
278: /** checks or unchecks given ToolbarToggleButton
279: * @param state boolean requested state
280: */
281: public void checkCallStack(boolean state) {
282: if (tbCallStack().isSelected() != state) {
283: tbCallStack().push();
284: }
285: }
286:
287: /** Get state of the given ToolbarToggleButton
288: */
289: public boolean getCallStackState() {
290: return tbCallStack().isSelected();
291: }
292:
293: /** checks or unchecks given ToolbarToggleButton
294: * @param state boolean requested state
295: */
296: public void checkLocalVariables(boolean state) {
297: if (tbLocalVariables().isSelected() != state) {
298: tbLocalVariables().push();
299: }
300: }
301:
302: /** Get state of the given ToolbarToggleButton
303: */
304: public boolean getLocalVariablesState() {
305: return tbLocalVariables().isSelected();
306: }
307:
308: /** checks or unchecks given ToolbarToggleButton
309: * @param state boolean requested state
310: */
311: public void checkAllInOne(boolean state) {
312: if (tbAllInOne().isSelected() != state) {
313: tbAllInOne().push();
314: }
315: }
316:
317: /** Get state of the given ToolbarToggleButton
318: */
319: public boolean getAllInOneState() {
320: return tbAllInOne().isSelected();
321: }
322:
323: /** checks or unchecks given ToolbarToggleButton
324: * @param state boolean requested state
325: */
326: public void checkWatches(boolean state) {
327: if (tbWatches().isSelected() != state) {
328: tbWatches().push();
329: }
330: }
331:
332: /** Get state of the given ToolbarToggleButton
333: */
334: public boolean getWatchesState() {
335: return tbWatches().isSelected();
336: }
337:
338: /** checks or unchecks given ToolbarToggleButton
339: * @param state boolean requested state
340: */
341: public void checkClasses(boolean state) {
342: if (tbClasses().isSelected() != state) {
343: tbClasses().push();
344: }
345: }
346:
347: /** Get state of the given ToolbarToggleButton
348: */
349: public boolean getClassesState() {
350: return tbClasses().isSelected();
351: }
352:
353: /** checks or unchecks given ToolbarToggleButton
354: * @param state boolean requested state
355: */
356: public void checkProperties(boolean state) {
357: if (tbProperties().isSelected() != state) {
358: tbProperties().push();
359: }
360: }
361:
362: /** Get state of the given ToolbarToggleButton
363: */
364: public boolean getPropertiesState() {
365: return tbProperties().isSelected();
366: }
367:
368: /** Tries to find null TreeTable in this dialog.
369: * @return JTableOperator
370: */
371: public JTableOperator getJTableOperator(String view) {
372: int viewNumber = -1;
373: int displayedViews = -1;
374: do {
375: viewNumber++;
376: switch (viewNumber) {
377: case 0: {
378: if (views[viewNumber].equals(view)) {
379: checkSessions(true);
380: displayedViews++;
381: } else if (getSessionsState()) {
382: displayedViews++;
383: }
384: break;
385: }
386: case 1: {
387: if (views[viewNumber].equals(view)) {
388: checkThreads(true);
389: displayedViews++;
390: } else if (getThreadsState()) {
391: displayedViews++;
392: }
393: break;
394: }
395: case 2: {
396: if (views[viewNumber].equals(view)) {
397: checkCallStack(true);
398: displayedViews++;
399: } else if (getCallStackState()) {
400: displayedViews++;
401: }
402: break;
403: }
404: case 3: {
405: if (views[viewNumber].equals(view)) {
406: checkLocalVariables(true);
407: displayedViews++;
408: } else if (getLocalVariablesState()) {
409: displayedViews++;
410: }
411: break;
412: }
413: case 4: {
414: if (views[viewNumber].equals(view)) {
415: checkAllInOne(true);
416: displayedViews++;
417: } else if (getAllInOneState()) {
418: displayedViews++;
419: }
420: break;
421: }
422: case 5: {
423: if (views[viewNumber].equals(view)) {
424: checkWatches(true);
425: displayedViews++;
426: } else if (getWatchesState()) {
427: displayedViews++;
428: }
429: break;
430: }
431: case 6: {
432: if (views[viewNumber].equals(view)) {
433: checkClasses(true);
434: displayedViews++;
435: } else if (getClassesState()) {
436: displayedViews++;
437: }
438: break;
439: }
440: case 7: {
441: if (views[viewNumber].equals(view)) {
442: checkBreakpoints(true);
443: displayedViews++;
444: } else if (getBreakpointsState()) {
445: displayedViews++;
446: }
447: break;
448: }
449: case 8: {
450: if (views[viewNumber].equals(view)) {
451: checkProperties(true);
452: displayedViews++;
453: } else if (getPropertiesState()) {
454: displayedViews++;
455: }
456: break;
457: }
458: }
459:
460: } while (!views[viewNumber].equals(view));
461: _tabTreeTable = new JTableOperator(this , displayedViews);
462: return _tabTreeTable;
463: }
464:
465: public static class DebuggerWindowChooser implements
466: ComponentChooser {
467: String ID;
468: private Operator.StringComparator comparator;
469:
470: public DebuggerWindowChooser(String ID) {
471: this (ID, new Operator.DefaultStringComparator(false, false));
472: }
473:
474: public DebuggerWindowChooser(String ID,
475: Operator.StringComparator comparator) {
476: this .ID = ID;
477: this .comparator = comparator;
478: }
479:
480: public boolean checkComponent(Component comp) {
481: if (comp != null && ((Component) comp).getName() != null)
482: return (comp instanceof Component && ((Component) comp)
483: .getName().equals(ID));
484: else
485: return false;
486: }
487:
488: public String getDescription() {
489: return ("A Component with \"" + ID + "\" ID");
490: }
491: }
492:
493: }
|