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.jellytools;
043:
044: import org.netbeans.jellytools.actions.FindInFilesAction;
045: import org.netbeans.jellytools.nodes.Node;
046: import org.netbeans.jemmy.operators.JButtonOperator;
047: import org.netbeans.jemmy.operators.JCheckBoxOperator;
048: import org.netbeans.jemmy.operators.JTextFieldOperator;
049:
050: /**
051: * Provides access to the Find in Files/Projects dialog.
052: */
053: public class FindInFilesOperator extends NbDialogOperator {
054:
055: private static final FindInFilesAction invokeAction = new FindInFilesAction();
056: private JButtonOperator _btFind;
057:
058: /**
059: * Waits for dialog displayed.
060: */
061: public FindInFilesOperator() {
062: super (Bundle.getString("org.netbeans.modules.search.Bundle",
063: "LBL_FindInProjects"));
064: }
065:
066: /**
067: * Invokes dialog by selecting a node and pushing menu.
068: */
069: public static FindInFilesOperator invoke(Node node) {
070: invokeAction.perform(node);
071: return new FindInFilesOperator();
072: }
073:
074: /**
075: * Returns operator for a Find button.
076: * @return JButtonOperator instance
077: */
078: public JButtonOperator btFind() {
079: if (_btFind == null) {
080: _btFind = new JButtonOperator(this , Bundle
081: .getStringTrimmed(
082: "org.netbeans.modules.search.Bundle",
083: "TEXT_BUTTON_SEARCH"));
084: }
085: return _btFind;
086: }
087:
088: /**
089: * Returns operator for the "Whole Words" check box.
090: * @return JCheckBoxOperator instance
091: */
092: public JCheckBoxOperator cbWholeWords() {
093: String text = Bundle.getStringTrimmed(
094: "org.netbeans.modules.search.Bundle",
095: "BasicSearchForm.chkWholeWords.text");
096: return new JCheckBoxOperator(this , text);
097: }
098:
099: /**
100: * Returns operator for the "Case Sensitive" check box.
101: * @return JCheckBoxOperator instance
102: */
103: public JCheckBoxOperator cbCase() {
104: String text = Bundle.getStringTrimmed(
105: "org.netbeans.modules.search.Bundle",
106: "BasicSearchForm.chkCaseSensitive.text");
107: return new JCheckBoxOperator(this , text);
108: }
109:
110: /**
111: * Returns operator for the "Regular Expression" check box.
112: * @return JCheckBoxOperator instance
113: */
114: public JCheckBoxOperator cbRegExpr() {
115: String text = Bundle.getStringTrimmed(
116: "org.netbeans.modules.search.Bundle",
117: "BasicSearchForm.chkRegexp.text");
118: return new JCheckBoxOperator(this , text);
119: }
120:
121: /**
122: * Returns operator for the "Containing Text:" text field.
123: * @return JTextFieldOperator instance
124: */
125: public JTextFieldOperator txtText() {
126: return new JTextFieldOperator(this );
127: }
128:
129: /**
130: * Returns operator for the "File Name Patterns:" text field.
131: * @return JTextFieldOperator instance
132: */
133: public JTextFieldOperator txtPatterns() {
134: return new JTextFieldOperator(this , 1);
135: }
136:
137: /**
138: * Pushes Find button.
139: * @return "Search Result" window.
140: */
141: public SearchResultsOperator find() {
142: btFind().push();
143: SearchResultsOperator results = new SearchResultsOperator();
144: results.waitEndOfSearch();
145: return results;
146: }
147:
148: /** Performs verification by accessing all sub-components */
149: public void verify() {
150: btFind();
151: btClose();
152: btHelp();
153: cbRegExpr();
154: cbWholeWords();
155: cbCase();
156: txtText();
157: txtPatterns();
158: }
159: }
|