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.search;
043:
044: import java.awt.Point;
045:
046: import org.netbeans.modules.visualweb.gravy.Util;
047:
048: import org.netbeans.modules.search.SearchPanel;
049:
050: import java.awt.Component;
051:
052: import org.netbeans.jellytools.Bundle;
053:
054: import org.netbeans.jemmy.ComponentChooser;
055:
056: import org.netbeans.jemmy.operators.JComboBoxOperator;
057: import org.netbeans.jemmy.operators.ContainerOperator;
058: import org.netbeans.jemmy.operators.JButtonOperator;
059: import org.netbeans.jemmy.operators.JCheckBoxOperator;
060: import org.netbeans.jemmy.operators.JDialogOperator;
061: import org.netbeans.jemmy.operators.JTabbedPaneOperator;
062: import org.netbeans.jemmy.operators.JPopupMenuOperator;
063: import org.netbeans.jemmy.operators.JRadioButtonOperator;
064: import org.netbeans.jemmy.operators.JTextFieldOperator;
065: import org.netbeans.jemmy.operators.Operator;
066:
067: /**
068: * SearchPanelOperator class
069: * @author <a href="mailto:sva@sparc.spb.su">Vladimir Strigun</a>
070: */
071: public class SearchPanelOperator extends JDialogOperator {
072:
073: JTabbedPaneOperator tabbedPane;
074:
075: public SearchPanelOperator() {
076: super ("Find In FIles");
077: }
078:
079: public void switchToObjectNameTab() {
080: switchToTab(1);
081: }
082:
083: public void switchToTypeTab() {
084: switchToTab(2);
085: }
086:
087: public Component switchToTab(int index) {
088: SearchPanelOperator searchPanel = new SearchPanelOperator();
089: if (tabbedPane == null)
090: this .tabbedPane = new JTabbedPaneOperator(searchPanel, 0);
091: return tabbedPane.selectPage(index);
092: }
093:
094: public void close() {
095: pushButton(Bundle.getStringTrimmed(
096: "org.netbeans.modules.search.Bundle",
097: "TEXT_BUTTON_CANCEL"));
098: }
099:
100: public void search() {
101: pushButton(Bundle.getStringTrimmed(
102: "org.netbeans.modules.search.Bundle",
103: "TEXT_BUTTON_SEARCH"));
104: }
105:
106: public void help() {
107: pushButton(Bundle.getStringTrimmed(
108: "org.netbeans.modules.search.Bundle",
109: "TEXT_BUTTON_HELP"));
110: }
111:
112: private void pushButton(String title) {
113: (new JButtonOperator(new SearchPanelOperator(), title)).push();
114: }
115:
116: public static class SearchPanelChooser implements ComponentChooser {
117: public SearchPanelChooser() {
118: }
119:
120: public boolean checkComponent(Component comp) {
121: return (comp instanceof org.netbeans.modules.search.SearchPanel);
122: }
123:
124: public String getDescription() {
125: return (SearchPanel.class.getName());
126: }
127: }
128:
129: public void setDateBetween(int dateNum, String date) {
130: switchToTab(3);
131: (new JTextFieldOperator(this , dateNum)).typeText(date);
132: }
133:
134: public void setWithinDate(String date) {
135: switchToTab(3);
136: (new JTextFieldOperator(this , 0)).typeText(date);
137: }
138:
139: public void pressCriterion(int tabNumber, boolean check) {
140: switchToTab(tabNumber);
141: (new JCheckBoxOperator(this , 2)).changeSelection(check);
142: }
143:
144: public void setSubstringText(int tabNumber, String text) {
145: switchToTab(tabNumber);
146: (new JTextFieldOperator(this , 0)).typeText(text);
147: }
148:
149: public String getSubstringText(int tabNumber) {
150: switchToTab(tabNumber);
151: return (new JTextFieldOperator(this , 0)).getText();
152: }
153:
154: public void setRegularExpression(int tabNumber, String text) {
155: switchToTab(tabNumber);
156: (new JTextFieldOperator(this , 1)).typeText(text);
157: }
158:
159: public void matchCase(int tabNumber, boolean matchCase) {
160: Component tab = switchToTab(tabNumber);
161: (new JRadioButtonOperator(this , 0)).doClick();
162: (new JCheckBoxOperator(this , 0)).changeSelection(matchCase);
163: }
164:
165: public boolean getCaseState(int tabNumber) {
166: Component tab = switchToTab(tabNumber);
167: (new JRadioButtonOperator(this , 0)).doClick();
168: return (new JCheckBoxOperator(this , 0)).isSelected();
169: }
170:
171: public void matchWholeWords(int tabNumber, boolean wholeWords) {
172: Component tab = switchToTab(tabNumber);
173: (new JRadioButtonOperator(this , 0)).doClick();
174: (new JCheckBoxOperator(this , 1)).changeSelection(wholeWords);
175: }
176:
177: public boolean getWholeWordsState(int tabNumber) {
178: Component tab = switchToTab(tabNumber);
179: (new JRadioButtonOperator(this , 0)).doClick();
180: return (new JCheckBoxOperator(this , 1)).isSelected();
181: }
182:
183: public boolean getCriterionState(int tabNumber) {
184: Component tab = switchToTab(tabNumber);
185: (new JRadioButtonOperator(this , 0)).doClick();
186: return (new JCheckBoxOperator(this , 2)).isSelected();
187: }
188:
189: public void saveSettings(int tabNumber, String name) {
190: Component tab = switchToTab(tabNumber);
191: (new JButtonOperator(this , Bundle.getStringTrimmed(
192: "org.netbeans.modules.search.Bundle",
193: "TEXT_BUTTON_SAVE_AS"))).push();
194: JDialogOperator dialog = new JDialogOperator(Bundle
195: .getStringTrimmed("org.netbeans.modules.search.Bundle",
196: "TEXT_LABEL_SAVE_CRITERION"));
197: (new JTextFieldOperator(dialog)).typeText(name);
198: (new JButtonOperator(dialog, "OK")).push();
199: }
200:
201: public void restoreSettings(int tabNumber, String name) {
202: Component tab = switchToTab(tabNumber);
203: (new JButtonOperator(this , Bundle.getStringTrimmed(
204: "org.netbeans.modules.search.Bundle",
205: "TEXT_BUTTON_RESTORE"))).push();
206: JDialogOperator dialog = new JDialogOperator(Bundle
207: .getStringTrimmed("org.netbeans.modules.search.Bundle",
208: "TEXT_LABEL_RESTORE_CRITERION"));
209: (new JComboBoxOperator(dialog)).selectItem(name);
210: (new JButtonOperator(dialog, "OK")).push();
211: }
212:
213: }
|