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: package org.netbeans.jellytools.modules.debugger;
042:
043: import javax.swing.JComboBox;
044: import javax.swing.JTextField;
045: import org.netbeans.jellytools.Bundle;
046: import org.netbeans.jellytools.NbDialogOperator;
047: import org.netbeans.jellytools.modules.debugger.actions.AttachDebuggerAction;
048: import org.netbeans.jemmy.operators.JComboBoxOperator;
049: import org.netbeans.jemmy.operators.JLabelOperator;
050: import org.netbeans.jemmy.operators.JTextFieldOperator;
051: import org.netbeans.jemmy.operators.Operator;
052:
053: /** Class implementing all necessary methods for handling "Attach" Dialog.
054: *
055: * @author Jiri.Skrivanek@sun.com
056: */
057: public class AttachDialogOperator extends NbDialogOperator {
058:
059: private JLabelOperator _lblDebugger;
060: private JComboBoxOperator _cboDebugger;
061: private JLabelOperator _lblConnector;
062: private JComboBoxOperator _cboConnector;
063: /** SocketAttach (Attaches by socket to other VMs) item. */
064: public static final String ITEM_SOCKET_ATTACH = "SocketAttach (Attaches by socket to other VMs)"; //NOI18N
065: /** SharedMemoryAttach (Attaches by shared memory to other VMs) item. */
066: public static final String ITEM_SHARED_MEMORY_ATTACH = "SharedMemoryAttach (Attaches by shared memory to other VMs)"; //NOI18N
067: /** SocketListen (Accepts socket connections initiated by other VMs) item. */
068: public static final String ITEM_SOCKET_LISTEN = "SocketListen (Accepts socket connections initiated by other VMs)"; //NOI18N
069: /** SharedMemoryListen (Accepts shared memory connections initiated by other VMs) item. */
070: public static final String ITEM_SHARED_MEMORY_LISTEN = "SharedMemoryListen (Accepts shared memory connections initiated by other VMs)"; //NOI18N
071: private JLabelOperator _lblTransport;
072: private JTextFieldOperator _txtTransport;
073: private JLabelOperator _lblName;
074: private JTextFieldOperator _txtName;
075: private JLabelOperator _lblTimeoutMs;
076: private JTextFieldOperator _txtTimeoutMs;
077: private JLabelOperator _lblPort;
078: private JTextFieldOperator _txtPort;
079: private JLabelOperator _lblHost;
080: private JTextFieldOperator _txtHost;
081:
082: /** Waits for dialog with Attach title and creates AttachDialogOperator. */
083: public AttachDialogOperator() {
084: super (Bundle.getString(
085: "org.netbeans.modules.debugger.ui.actions.Bundle",
086: "CTL_Connect_to_running_process"));
087: }
088:
089: /** Opens Attach dialog and returns instance of AttachDialogOperator.
090: * @return AttachDialogOperator instance
091: */
092: public static AttachDialogOperator invoke() {
093: new AttachDebuggerAction().perform();
094: return new AttachDialogOperator();
095: }
096:
097: //******************************
098: // Subcomponents definition part
099: //******************************
100:
101: /** Tries to find "Debugger:" JLabel in this dialog.
102: * @return JLabelOperator
103: */
104: public JLabelOperator lblDebugger() {
105: if (_lblDebugger == null) {
106: _lblDebugger = new JLabelOperator(
107: this ,
108: Bundle
109: .getStringTrimmed(
110: "org.netbeans.modules.debugger.ui.actions.Bundle",
111: "CTL_Connect_through"));
112: }
113: return _lblDebugger;
114: }
115:
116: /** Tries to find Debugger JComboBox in this dialog.
117: * @return JComboBoxOperator
118: */
119: public JComboBoxOperator cboDebugger() {
120: if (_cboDebugger == null) {
121: _cboDebugger = new JComboBoxOperator(
122: (JComboBox) lblDebugger().getLabelFor());
123: }
124: return _cboDebugger;
125: }
126:
127: /** Tries to find "Connector:" JLabel in this dialog.
128: * @return JLabelOperator
129: */
130: public JLabelOperator lblConnector() {
131: if (_lblConnector == null) {
132: _lblConnector = new JLabelOperator(
133: this ,
134: Bundle
135: .getStringTrimmed(
136: "org.netbeans.modules.debugger.jpda.ui.Bundle",
137: "CTL_Connector"));
138: }
139: return _lblConnector;
140: }
141:
142: /** Tries to find Connector JComboBox in this dialog.
143: * @return JComboBoxOperator
144: */
145: public JComboBoxOperator cboConnector() {
146: if (_cboConnector == null) {
147: _cboConnector = new JComboBoxOperator(
148: (JComboBox) lblConnector().getLabelFor());
149: }
150: return _cboConnector;
151: }
152:
153: /** Tries to find "Transport:" JLabel in this dialog.
154: * @return JLabelOperator
155: */
156: public JLabelOperator lblTransport() {
157: if (_lblTransport == null) {
158: _lblTransport = new JLabelOperator(
159: this ,
160: Bundle
161: .getStringTrimmed(
162: "org.netbeans.modules.debugger.jpda.ui.Bundle",
163: "CTL_Transport"));
164: }
165: return _lblTransport;
166: }
167:
168: /** Tries to find Transport JTextField in this dialog.
169: * @return JTextFieldOperator
170: */
171: public JTextFieldOperator txtTransport() {
172: if (_txtTransport == null) {
173: _txtTransport = new JTextFieldOperator(
174: (JTextField) lblTransport().getLabelFor());
175: }
176: return _txtTransport;
177: }
178:
179: /** Tries to find "Name:" JLabel in this dialog.
180: * @return JLabelOperator
181: */
182: public JLabelOperator lblName() {
183: if (_lblName == null) {
184: _lblName = new JLabelOperator(
185: this ,
186: Bundle
187: .getStringTrimmed(
188: "org.netbeans.modules.debugger.jpda.ui.Bundle",
189: "CTL_CA_name"));
190: }
191: return _lblName;
192: }
193:
194: /** Tries to find Name JTextField in this dialog.
195: * @return JTextFieldOperator
196: */
197: public JTextFieldOperator txtName() {
198: if (_txtName == null) {
199: _txtName = new JTextFieldOperator((JTextField) lblName()
200: .getLabelFor());
201: }
202: return _txtName;
203: }
204:
205: /** Tries to find "Timeout [ms]:" JLabel in this dialog.
206: * @return JLabelOperator
207: */
208: public JLabelOperator lblTimeout() {
209: if (_lblTimeoutMs == null) {
210: _lblTimeoutMs = new JLabelOperator(
211: this ,
212: Bundle
213: .getStringTrimmed(
214: "org.netbeans.modules.debugger.jpda.ui.Bundle",
215: "CTL_CA_timeout"));
216: }
217: return _lblTimeoutMs;
218: }
219:
220: /** Tries to find Timeout JTextField in this dialog.
221: * @return JTextFieldOperator
222: */
223: public JTextFieldOperator txtTimeout() {
224: if (_txtTimeoutMs == null) {
225: _txtTimeoutMs = new JTextFieldOperator(
226: (JTextField) lblTimeout().getLabelFor());
227: }
228: return _txtTimeoutMs;
229: }
230:
231: /** Tries to find "Host:" JLabel in this dialog.
232: * @return JLabelOperator
233: */
234: public JLabelOperator lblHost() {
235: if (_lblHost == null) {
236: _lblHost = new JLabelOperator(
237: this ,
238: Bundle
239: .getStringTrimmed(
240: "org.netbeans.modules.debugger.jpda.ui.Bundle",
241: "CTL_CA_hostname"));
242: }
243: return _lblHost;
244: }
245:
246: /** Tries to find Host JTextField in this dialog.
247: * @return JTextFieldOperator
248: */
249: public JTextFieldOperator txtHost() {
250: if (_txtHost == null) {
251: _txtHost = new JTextFieldOperator((JTextField) lblHost()
252: .getLabelFor());
253: }
254: return _txtHost;
255: }
256:
257: /** Tries to find "Port:" JLabel in this dialog.
258: * @return JLabelOperator
259: */
260: public JLabelOperator lblPort() {
261: if (_lblPort == null) {
262: Operator.StringComparator old = getComparator();
263: try {
264: // set exact comparator because port vs. trasport clash
265: setComparator(new DefaultStringComparator(true, true));
266: _lblPort = new JLabelOperator(
267: this ,
268: Bundle
269: .getStringTrimmed(
270: "org.netbeans.modules.debugger.jpda.ui.Bundle",
271: "CTL_CA_port"));
272: } finally {
273: setComparator(old);
274: }
275: }
276: return _lblPort;
277: }
278:
279: /** Tries to find Port JTextField in this dialog.
280: * @return JTextFieldOperator
281: */
282: public JTextFieldOperator txtPort() {
283: if (_txtPort == null) {
284: _txtPort = new JTextFieldOperator((JTextField) lblPort()
285: .getLabelFor());
286: }
287: return _txtPort;
288: }
289:
290: //****************************************
291: // Low-level functionality definition part
292: //****************************************
293:
294: /** returns selected item for cboDebugger
295: * @return String item
296: */
297: public String getSelectedDebugger() {
298: return cboDebugger().getSelectedItem().toString();
299: }
300:
301: /** selects item for cboDebugger
302: * @param item String item
303: */
304: public void selectDebugger(String item) {
305: cboDebugger().selectItem(item);
306: }
307:
308: /** returns selected item for cboConnector
309: * @return String item
310: */
311: public String getSelectedConnector() {
312: return cboConnector().getSelectedItem().toString();
313: }
314:
315: /** selects item for cboConnector
316: * @param item String item
317: */
318: public void selectConnector(String item) {
319: cboConnector().selectItem(item);
320: }
321:
322: /** gets text for Transport text field
323: * @return String text
324: */
325: public String getTransport() {
326: return txtTransport().getText();
327: }
328:
329: /** gets text for txtName
330: * @return String text
331: */
332: public String getName() {
333: return txtName().getText();
334: }
335:
336: /** sets text for Name text field
337: * @param text String text
338: */
339: public void setName(String text) {
340: txtName().clearText();
341: txtName().typeText(text);
342: }
343:
344: /** gets text for Timeout text field
345: * @return String text
346: */
347: public String getTimeout() {
348: return txtTimeout().getText();
349: }
350:
351: /** sets text for txtTimeoutMs
352: * @param text String text
353: */
354: public void setTimeout(String text) {
355: txtTimeout().clearText();
356: txtTimeout().typeText(text);
357: }
358:
359: /** gets text for Host text field
360: * @return String text
361: */
362: public String getHost() {
363: return txtHost().getText();
364: }
365:
366: /** sets text for Host
367: * @param text String text
368: */
369: public void setHost(String text) {
370: txtHost().clearText();
371: txtHost().typeText(text);
372: }
373:
374: /** gets text for Port text field
375: * @return String text
376: */
377: public String getPort() {
378: return txtPort().getText();
379: }
380:
381: /** sets text for Port
382: * @param text String text
383: */
384: public void setPort(String text) {
385: txtPort().clearText();
386: txtPort().typeText(text);
387: }
388:
389: //*****************************************
390: // High-level functionality definition part
391: //*****************************************
392:
393: /** Performs verification of AttachDialogOperator by accessing all its components.
394: */
395: public void verify() {
396: lblDebugger();
397: cboDebugger();
398: lblConnector();
399: cboConnector();
400: lblTransport();
401: txtTransport();
402: lblTimeout();
403: txtTimeout();
404: }
405: }
|