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.jellytools;
042:
043: import javax.swing.JComboBox;
044: import org.netbeans.jemmy.operators.JButtonOperator;
045: import org.netbeans.jemmy.operators.JLabelOperator;
046: import org.netbeans.jemmy.operators.JTextFieldOperator;
047: import org.netbeans.jemmy.operators.JCheckBoxOperator;
048: import org.netbeans.jemmy.operators.JComboBoxOperator;
049: import javax.swing.JTextField;
050:
051: /**
052: * Handle "Name And Location" panel of the New Web Project wizard.
053: * Components on the panel differs according to type of project selected.<br><br>
054: * <u>Web Application</u><br>
055: * <ol>
056: * <li>Label and TextField Project Name: <code>txtProjectName().setText()</code>
057: * <li>Label and TextField Project Location: <code>txtProjectLocation().setText()</code>
058: * <li>Button for browsing Project Location: <code>btBrowseLocation().pushNoBlock()</code>
059: * <li>Label and TextField Project Folder: <code>txtProjectFolder().getText()</code>
060: * <li>ComboBox SourceStructure: <code>cbSourceStructure().selectItem("item")</code>
061: * <li>ComboBox Server: <code>cbSourceStructure().selectItem("item")</code>
062: * <li>ComboBox J2EE Version: <code>cbJ2EEVersion().selectItem("item")</code>
063: * <li>Label and TextField Context Path: <code>txtContextPath().getText()</code>
064: * <li>CheckBox Set as Main Project: <code>cbSetAsMainProject().setSelected(true)</code>
065: * </ol>
066: * <u>Web Project with Existing Sources</u><br>
067: * <ol>
068: * <li>Label and TextField Location: <code>txtProjectLocation().setText()</code>
069: * <li>Button for browsing Location: <code>btBrowseLocation().pushNoBlock()</code>
070: * <li>Button for browsing Project Folder: <code>btBrowseFolder().pushNoBlock()</code>
071: * <ol>
072: * @author ms113234
073: */
074: public class NewWebProjectNameLocationStepOperator extends
075: NewProjectWizardOperator {
076:
077: /** Components operators. */
078: //Web Application
079: private JLabelOperator _lblProjectName;
080: private JTextFieldOperator _txtProjectName;
081: private JLabelOperator _lblProjectLocation;
082: private JTextFieldOperator _txtProjectLocation;
083: private JButtonOperator _btBrowseProjectLocation;
084: private JLabelOperator _lblLocation;
085: private JTextFieldOperator _txtLocation;
086: private JLabelOperator _lblProjectFolder;
087: private JTextFieldOperator _txtProjectFolder;
088: private JLabelOperator _lblSourceStructure;
089: private JComboBoxOperator _cbSourceStructure;
090: private JLabelOperator _lblServer;
091: private JComboBoxOperator _cbServer;
092: private JLabelOperator _lblJ2EEVersion;
093: private JComboBoxOperator _cbJ2EEVersion;
094: private JLabelOperator _lblContextPath;
095: private JTextFieldOperator _txtContextPath;
096: private JCheckBoxOperator _cbSetAsMainProject;
097: //Web Project With Existing Sources
098: private JButtonOperator _btBrowseFolder;
099:
100: /** Returns operator for label Project Name
101: * @return JLabelOperator
102: */
103: public JLabelOperator lblProjectName() {
104: if (_lblProjectName == null) {
105: _lblProjectName = new JLabelOperator(
106: this ,
107: Bundle
108: .getStringTrimmed(
109: "org.netbeans.modules.web.project.ui.wizards.Bundle",
110: "LBL_NWP1_ProjectName_Label"));
111: }
112: return _lblProjectName;
113: }
114:
115: /** Returns operator of project name textfield
116: * @return JTextOperator
117: */
118: public JTextFieldOperator txtProjectName() {
119: if (_txtProjectName == null) {
120: if (lblProjectName().getLabelFor() != null) {
121: _txtProjectName = new JTextFieldOperator(
122: (JTextField) lblProjectName().getLabelFor());
123: }
124: }
125: return _txtProjectName;
126: }
127:
128: /** Sets given name in text field Project Name.
129: * @param name project name
130: */
131: public void setProjectName(String name) {
132: txtProjectName().setText(name);
133: }
134:
135: /** Returns operator for label Project Location
136: * @return JLabelOperator
137: */
138: public JLabelOperator lblProjectLocation() {
139: if (_lblProjectLocation == null) {
140: _lblProjectLocation = new JLabelOperator(
141: this ,
142: Bundle
143: .getStringTrimmed(
144: "org.netbeans.modules.web.project.ui.wizards.Bundle",
145: "LBL_NWP1_ProjectLocation_Label"));
146: }
147: return _lblProjectLocation;
148: }
149:
150: /** Returns operator of project location text field
151: * @return JTextOperator
152: */
153: public JTextFieldOperator txtProjectLocation() {
154: if (_txtProjectLocation == null) {
155: if (lblProjectLocation().getLabelFor() != null) {
156: _txtProjectLocation = new JTextFieldOperator(
157: (JTextField) lblProjectLocation().getLabelFor());
158: }
159: }
160: return _txtProjectLocation;
161: }
162:
163: /** Sets given project location
164: /** Returns operator for browse project location button
165: * @return JButtonOperator
166: */
167: public JButtonOperator btBrowseProjectLocation() {
168: if (_btBrowseProjectLocation == null) {
169: _btBrowseProjectLocation = new JButtonOperator(
170: this ,
171: Bundle
172: .getStringTrimmed(
173: "org.netbeans.modules.web.project.ui.wizards.Bundle",
174: "LBL_NWP1_BrowseLocation_Button"));
175: }
176: return _btBrowseProjectLocation;
177: }
178:
179: /** Sets given location in text field Project Location.
180: * @param location project location
181: */
182: public void setProjectLocation(String location) {
183: txtProjectLocation().setText(location);
184: }
185:
186: /** Returns operator for label Project Location
187: * @return JLabelOperator
188: */
189: public JLabelOperator lblLocation() {
190: if (_lblLocation == null) {
191: _lblLocation = new JLabelOperator(
192: this ,
193: Bundle
194: .getStringTrimmed(
195: "org.netbeans.modules.web.project.ui.wizards.Bundle",
196: "LBL_IW_LocationSrc_Label"));
197: }
198: return _lblLocation;
199: }
200:
201: /** Returns operator of project location text field
202: * @return JTextOperator
203: */
204: public JTextFieldOperator txtLocation() {
205: if (_txtLocation == null) {
206: if (lblLocation().getLabelFor() != null) {
207: _txtLocation = new JTextFieldOperator(
208: (JTextField) lblLocation().getLabelFor());
209: }
210: }
211: return _txtLocation;
212: }
213:
214: /** Returns operator for browse project location button
215: * @return JButtonOperator
216: */
217: public JButtonOperator btBrowseLocation() {
218: if (_btBrowseProjectLocation == null) {
219: _btBrowseProjectLocation = new JButtonOperator(
220: this ,
221: Bundle
222: .getStringTrimmed(
223: "org.netbeans.modules.web.project.ui.wizards.Bundle",
224: "LBL_NWP1_BrowseLocation_Button"));
225: }
226: return _btBrowseProjectLocation;
227: }
228:
229: /** Sets given location in text field Location.
230: * @param location Project With Existing Sources location
231: */
232: public void setLocation(String location) {
233: txtLocation().setText(location);
234: }
235:
236: /** Returns operator for label Project Folder
237: * @return JLabelOperator
238: */
239: public JLabelOperator lblProjectFolder() {
240: if (_lblProjectFolder == null) {
241: _lblProjectFolder = new JLabelOperator(
242: this ,
243: Bundle
244: .getStringTrimmed(
245: "org.netbeans.modules.web.project.ui.wizards.Bundle",
246: "LBL_NWP1_CreatedProjectFolder_Label"));
247: }
248: return _lblProjectFolder;
249: }
250:
251: /** Returns operator of project folder textfield
252: * @return JTextOperator
253: */
254: public JTextFieldOperator txtProjectFolder() {
255: if (_txtProjectFolder == null) {
256: if (lblProjectFolder().getLabelFor() != null) {
257: _txtProjectFolder = new JTextFieldOperator(
258: (JTextField) lblProjectFolder().getLabelFor());
259: }
260: }
261: return _txtProjectFolder;
262: }
263:
264: /** Returns operator for label Source Structure:
265: * @return JLabelOperator
266: */
267: public JLabelOperator lblSourceStructure() {
268: if (_lblSourceStructure == null) {
269: _lblSourceStructure = new JLabelOperator(
270: this ,
271: Bundle
272: .getStringTrimmed(
273: "org.netbeans.modules.web.project.ui.wizards.Bundle",
274: "LBL_NWP1_SourceStructure_Label"));
275: }
276: return _lblSourceStructure;
277: }
278:
279: /** Returns operator of Source Structure combo box
280: * @return JComboBoxOperator
281: */
282: public JComboBoxOperator cbSourceStructure() {
283: if (_cbSourceStructure == null) {
284: if (lblSourceStructure().getLabelFor() != null) {
285: _cbSourceStructure = new JComboBoxOperator(
286: (JComboBox) lblSourceStructure().getLabelFor());
287: }
288: }
289: return _cbSourceStructure;
290: }
291:
292: /** Selects structure in Source Structure combo box
293: */
294: public void selectSourceStructure(String structure) {
295: cbSourceStructure().selectItem(structure);
296: }
297:
298: /** Returns operator of J2EE Specification Level combo box
299: * @return JComboBoxOperator
300: */
301: public JComboBoxOperator cbServer() { //TODO fix using labelFor - #55369
302: if (_cbServer == null) {
303: _cbServer = new JComboBoxOperator(this , 3);
304: }
305: return _cbServer;
306: }
307:
308: /** Selects level in J2EE Specification Level combo box
309: */
310: public void selectServer(String server) {
311: cbServer().selectItem(server);
312: }
313:
314: /** Returns operator for label J2EE Version:
315: * @return JLabelOperator
316: */
317: public JLabelOperator lblJ2EEVersion() {
318: if (_lblSourceStructure == null) {
319: _lblSourceStructure = new JLabelOperator(
320: this ,
321: Bundle
322: .getStringTrimmed(
323: "org.netbeans.modules.web.project.ui.wizards.Bundle",
324: "LBL_NWP1_J2EESpecLevel_Label"));
325: }
326: return _lblSourceStructure;
327: }
328:
329: /** Returns operator of J2EE version combo box
330: * @return JComboBoxOperator
331: */
332: public JComboBoxOperator cbJ2EEVersion() {
333: if (_cbJ2EEVersion == null) {
334: if (lblJ2EEVersion().getLabelFor() != null) {
335: _cbJ2EEVersion = new JComboBoxOperator(
336: (JComboBox) lblJ2EEVersion().getLabelFor());
337: }
338: }
339: return _cbJ2EEVersion;
340: }
341:
342: /** Selects structure in J2EE version combo box
343: */
344: public void selectJ2EEVersion(String version) {
345: cbJ2EEVersion().selectItem(version);
346: }
347:
348: /** Returns operator for label ContextPath:
349: * @return JLabelOperator
350: */
351: public JLabelOperator lblContextPath() {
352: if (_lblContextPath == null) {
353: _lblContextPath = new JLabelOperator(
354: this ,
355: Bundle
356: .getStringTrimmed(
357: "org.netbeans.modules.web.project.ui.wizards.Bundle",
358: "LBL_NWP1_ContextPath_Label"));
359: }
360: return _lblContextPath;
361: }
362:
363: /** Returns operator of Context Path: text field
364: * @return JTextOperator
365: */
366: public JTextFieldOperator txtContextPath() {
367: if (lblContextPath().getLabelFor() != null) {
368: _txtContextPath = new JTextFieldOperator(
369: (JTextField) lblContextPath().getLabelFor());
370: }
371: return _txtContextPath;
372: }
373:
374: /** Returns operator for checkbox 'Set as Main Project'
375: * @return JCheckBoxOperator
376: */
377: public JCheckBoxOperator cbSetAsMainProject() {
378: if (_cbSetAsMainProject == null) {
379: _cbSetAsMainProject = new JCheckBoxOperator(
380: this ,
381: Bundle
382: .getString(
383: "org.netbeans.modules.web.project.ui.wizards.Bundle",
384: "LBL_NWP1_SetAsMain_CheckBox"));
385: }
386: return _cbSetAsMainProject;
387: }
388:
389: /** Returns operator for browse project folder button
390: * @return JButtonOperator
391: */
392: public JButtonOperator btBrowseFolder() {
393: if (_btBrowseFolder == null) {
394: _btBrowseFolder = new JButtonOperator(
395: this ,
396: Bundle
397: .getStringTrimmed(
398: "org.netbeans.modules.web.project.ui.wizards.Bundle",
399: "LBL_NWP1_BrowseLocation_Button"),
400: 1);
401: }
402: return _btBrowseFolder;
403: }
404:
405: /** Performs verification by accessing all sub-components */
406: public void verify() {
407: /*
408: lblProjectName();
409: txtProjectName();
410: lblProjectLocation();
411: txtProjectLocation();
412: lblProjectFolder();
413: txtProjectFolder();
414: btBrowseLocation();
415: lblSourceStructure();
416: cbSourceStructure();
417: lblServer();
418: cbServer();
419: lblJ2EEVersion();
420: cbJ2EEVersion();
421: lblContextPath();
422: txtContextPath();
423: cbSetAsMainProject();
424: btBrowseFolder();
425: */
426: }
427: }
|