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.ResultView;
049: import org.netbeans.modules.visualweb.gravy.TopComponentOperator;
050:
051: import java.awt.Component;
052: import org.netbeans.jellytools.Bundle;
053:
054: import org.netbeans.jemmy.ComponentChooser;
055:
056: import org.netbeans.jemmy.operators.ContainerOperator;
057: import org.netbeans.jemmy.operators.JComponentOperator;
058: import org.netbeans.jemmy.operators.JButtonOperator;
059: import org.netbeans.jemmy.operators.JPopupMenuOperator;
060: import org.netbeans.jemmy.operators.JRadioButtonOperator;
061: import org.netbeans.jemmy.operators.JTreeOperator;
062: import org.netbeans.jemmy.operators.Operator;
063:
064: import javax.swing.*;
065:
066: /**
067: * SearchResultsOperator class
068: * @author <a href="mailto:sva@sparc.spb.su">Vladimir Strigun</a>
069: */
070: public class SearchResultsOperator extends TopComponentOperator {
071:
072: JTreeOperator tree;
073:
074: public SearchResultsOperator(ContainerOperator cont) {
075: super (cont, new SearchResultsChooser());
076: }
077:
078: public SearchResultsOperator() {
079: //this(Util.getMainTab());
080: this (Util.getMainWindow());
081: }
082:
083: public static class SearchResultsChooser implements
084: ComponentChooser {
085: public SearchResultsChooser() {
086: }
087:
088: public boolean checkComponent(Component comp) {
089: Class curClass = comp.getClass();
090: while (curClass != null) {
091: if (curClass.getName().equals(
092: "org.netbeans.modules.search.ResultView")) {
093: return (true);
094: }
095: curClass = curClass.getSuperclass();
096: }
097: return (false);
098: }
099:
100: public String getDescription() {
101: return ("org.netbeans.modules.search.ResultView");
102: }
103: }
104:
105: public JTreeOperator getTree() {
106: if (tree == null) {
107: makeComponentVisible();
108: tree = new JTreeOperator(this );
109: }
110: return (tree);
111: }
112:
113: public void close() {
114: //pushButton(Bundle.getStringTrimmed("org.netbeans.modules.search.Bundle", "TEXT_BUTTON_CANCEL"));
115: super .close();
116: }
117:
118: public void pushButton(String title) {
119: Util.getMainTab().setSelectedIndex(
120: Util.getMainTab().findPage("Search Results"));
121: (new JButtonOperator(this , title)).push();
122: }
123:
124: public void help() {
125: pushButton(Bundle.getStringTrimmed(
126: "org.netbeans.modules.search.Bundle",
127: "TEXT_BUTTON_HELP"));
128: }
129:
130: public void modifySearch() {
131: pushButton(Bundle.getStringTrimmed(
132: "org.netbeans.modules.search.Bundle",
133: "TEXT_BUTTON_CUSTOMIZE"));
134: }
135:
136: public void showAllDetails() {
137: pushButton(Bundle.getStringTrimmed(
138: "org.netbeans.modules.search.Bundle",
139: "TEXT_BUTTON_FILL"));
140: }
141:
142: public void stopSearch() {
143: pushButton(Bundle.getStringTrimmed(
144: "org.netbeans.modules.search.Bundle",
145: "TEXT_BUTTON_STOP"));
146: }
147:
148: public void showInExplorer() {
149: pushButton(Bundle.getStringTrimmed(
150: "org.netbeans.modules.search.Bundle",
151: "TEXT_BUTTON_SHOW"));
152: }
153:
154: public void sortByName() {
155: (new JRadioButtonOperator(this , Bundle.getStringTrimmed(
156: "org.netbeans.modules.search.Bundle",
157: "TEXT_BUTTON_SORT"))).doClick();
158: }
159:
160: public void sortByDefault() {
161: (new JRadioButtonOperator(this , Bundle.getStringTrimmed(
162: "org.netbeans.modules.search.Bundle",
163: "TEXT_BUTTON_UNSORT"))).doClick();
164: }
165:
166: public void selectFoundedFile(String node) {
167: JTreeOperator resTree = getTree();
168: tree.selectPath(tree.findPath(node));
169: }
170:
171: public String getFoundedFileName(int index) {
172: JTreeOperator resTree = getTree();
173: return (tree.getChild(tree.getRoot(), index)).toString();
174: }
175:
176: public int getFoundedFilesCount() {
177: JTreeOperator resTree = getTree();
178: return tree.getChildCount(tree.getRoot());
179: }
180:
181: }
|