KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > operators > RefactoringOperator


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.test.subversion.operators;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.Container JavaDoc;
24 import javax.swing.JComponent JavaDoc;
25 import org.netbeans.jellytools.OutputTabOperator;
26 import org.netbeans.jellytools.TopComponentOperator;
27 import org.netbeans.jellytools.actions.Action;
28 import org.netbeans.jemmy.ComponentChooser;
29 import org.netbeans.jemmy.ComponentSearcher;
30 import org.netbeans.jemmy.operators.JButtonOperator;
31 import org.netbeans.jemmy.operators.JTabbedPaneOperator;
32 import org.netbeans.test.subversion.operators.actions.RefactoringAction;
33
34 public class RefactoringOperator extends TopComponentOperator {
35     
36     private static final Action invokeAction = new RefactoringAction();
37     private JButtonOperator _btDoRefactoring;
38     private JButtonOperator _btCancel;
39     
40     public JButtonOperator btDoRefactoring() {
41         if (_btDoRefactoring == null) {
42             _btDoRefactoring = new JButtonOperator(this, "Refactor");
43         }
44         return _btDoRefactoring;
45     }
46     
47     public JButtonOperator btCancel() {
48         if (_btCancel == null) {
49             _btCancel = new JButtonOperator(this, "Cancel");
50         }
51         return _btCancel;
52     }
53     
54     public void doRefactoring() {
55         btDoRefactoring().pushNoBlock();
56     }
57     
58     public void cancel() {
59         btCancel().pushNoBlock();
60     }
61     
62     /** Waits for refactoring window top component and creates a new operator for it. */
63     public RefactoringOperator() {
64         super(waitTopComponent(null, null, 0, renameChooser));
65     }
66     
67     /**
68      * Opens Output from main menu Window|Output and returns RefactoringOperator.
69      *
70      * @return instance of RefactoringOperator
71      */

72     public static RefactoringOperator invoke() {
73         invokeAction.perform();
74         return new RefactoringOperator();
75     }
76     
77     /** Returns active OutputTabOperator instance regardless it is the only one in
78      * output or it is in tabbed pane.
79      * @return active OutputTabOperator instance
80      *
81     private OutputTabOperator getActiveOutputTab() {
82         OutputTabOperator outputTabOper;
83         if(null != JTabbedPaneOperator.findJTabbedPane((Container)getSource(), ComponentSearcher.getTrueChooser(""))) {
84             outputTabOper = new OutputTabOperator(((JComponent)new JTabbedPaneOperator(this).getSelectedComponent()));
85             outputTabOper.copyEnvironment(this);
86         } else {
87             outputTabOper = new OutputTabOperator("");
88         }
89         return outputTabOper;
90     }*/

91
92     /**
93      * Returns instance of OutputTabOperator of given name.
94      * It is activated by default.
95      * @param tabName name of tab to be selected
96      * @return instance of OutputTabOperator
97      *
98     public OutputTabOperator getOutputTab(String tabName) {
99         return new OutputTabOperator(tabName);
100     }*/

101     
102     /**
103      * Returns text from the active tab.
104      * @return text from the active tab
105      *
106     public String getText() {
107         return getActiveOutputTab().getText();
108     }*/

109     
110     /********************************** Actions ****************************/
111     
112     /** Performs copy action on active tab.
113     public void copy() {
114         getActiveOutputTab().copy();
115     }*/

116     
117     /** Performs find action on active tab.
118     public void find() {
119         getActiveOutputTab().find();
120     }*/

121     
122     /** Performs find next action on active tab.
123     public void findNext() {
124         getActiveOutputTab().findNext();
125     }*/

126     
127     /** Performs select all action on active tab.
128     public void selectAll() {
129         getActiveOutputTab().selectAll();
130     }*/

131     
132     /** Performs next error action on active tab.
133     public void nextError() {
134         getActiveOutputTab().nextError();
135     }*/

136     
137     /** Performs next error action on active tab.
138     public void previousError() {
139         getActiveOutputTab().previousError();
140     }*/

141
142     /** Performs wrap text action on active tab.
143     public void wrapText() {
144         getActiveOutputTab().wrapText();
145     }*/

146     
147     /** Performs clear action on active tab.
148     public void clear() {
149         getActiveOutputTab().clear();
150     }*/

151
152     /** Performs save as action on active tab.
153     public void saveAs() {
154         getActiveOutputTab().saveAs();
155     }*/

156     
157     /** Performs verification by accessing all sub-components.
158     public void verify() {
159         // do nothing because output top component can be empty
160     }*/

161     
162     /** SubChooser to determine OutputWindow TopComponent
163      * Used in constructor.
164      */

165     private static final ComponentChooser renameChooser = new ComponentChooser() {
166         public boolean checkComponent(Component JavaDoc comp) {
167             return comp.getClass().getName().endsWith("RefactoringPanelContainer"); //NOI18N
168
}
169         
170         public String JavaDoc getDescription() {
171             return "component instanceof org.netbeans.refactoring.ui.RefactoringPanelContainer";// NOI18N
172
}
173     };
174 }
175
Popular Tags