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.properties;
043:
044: import java.awt.Component;
045: import java.awt.Container;
046: import javax.swing.JComponent;
047: import org.netbeans.jemmy.ComponentChooser;
048: import org.netbeans.jemmy.JemmyException;
049: import org.netbeans.jemmy.operators.ContainerOperator;
050: import org.netbeans.jemmy.operators.JButtonOperator;
051: import org.netbeans.jemmy.operators.JComponentOperator;
052: import org.netbeans.jemmy.operators.JToggleButtonOperator;
053:
054: /**
055: * Handles org.openide.explorer.propertysheet.PropertySheetToolbar which
056: * represents toolbar in the properties sheet. It includes three sort option
057: * toggle buttons, show editable toggle button, customizer button and help
058: * button.
059: * <p>
060: * Usage:<br>
061: * <pre>
062: * PropertySheetOperator pso = new PropertySheetOperator("Properties of MyClass");
063: * PropertySheetToolbarOperator psto = new PropertySheetToolbarOperator(pso);
064: * psto.unsorted();
065: * psto.sortByType();
066: * System.out.println("Help enabled="+psto.btHelp().isEnabled());
067: * </pre>
068: *
069: * @deprecated Tool bar is no more present in property sheet.
070: */
071: public class PropertySheetToolbarOperator extends JComponentOperator {
072: // in IDE PropertySheetToolbar extends JPanel
073:
074: /** Component operators */
075: private JToggleButtonOperator _btUnsorted;
076: private JToggleButtonOperator _btSortByName;
077: private JToggleButtonOperator _btSortByType;
078: private JToggleButtonOperator _btShowEditable;
079: private JButtonOperator _btCustomizer;
080: private JButtonOperator _btHelp;
081:
082: /** Waits for PropertySheetToolbar in given container.
083: * @param contOper where to find
084: * @deprecated Tool bar is no more present in property sheet.
085: */
086: public PropertySheetToolbarOperator(ContainerOperator contOper) {
087: super ((JComponent) waitPropertySheetToolbar(contOper));
088: }
089:
090: /** Gets instance of JToggleButtonOperator of "Unsorted" button.
091: * @return JToggleButtonOperator instance
092: * @deprecated Tool bar is no more present in property sheet.
093: */
094: public JToggleButtonOperator btUnsorted() {
095: if (_btUnsorted == null) {
096: _btUnsorted = new JToggleButtonOperator(this , 0);
097: }
098: return _btUnsorted;
099: }
100:
101: /** Gets instance of JToggleButtonOperator of "Sort by Name" button.
102: * @return JToggleButtonOperator instance
103: * @deprecated Tool bar is no more present in property sheet.
104: */
105: public JToggleButtonOperator btSortByName() {
106: if (_btSortByName == null) {
107: _btSortByName = new JToggleButtonOperator(this , 1);
108: }
109: return _btSortByName;
110: }
111:
112: /** Gets instance of JToggleButtonOperator of "Sort by Type" button.
113: * @return JToggleButtonOperator instance
114: * @deprecated Tool bar is no more present in property sheet.
115: */
116: public JToggleButtonOperator btSortByType() {
117: if (_btSortByType == null) {
118: _btSortByType = new JToggleButtonOperator(this , 2);
119: }
120: return _btSortByType;
121: }
122:
123: /** Gets instance of JToggleButtonOperator of "Show Editable Properties
124: * Only" button.
125: * @return JToggleButtonOperator instance
126: * @deprecated Tool bar is no more present in property sheet.
127: */
128: public JToggleButtonOperator btShowEditable() {
129: if (_btShowEditable == null) {
130: _btShowEditable = new JToggleButtonOperator(this , 3);
131: }
132: return _btShowEditable;
133: }
134:
135: /** Gets instance of JButtonOperator of "Customizer" button.
136: * @return JButtonOperator instance
137: * @deprecated Tool bar is no more present in property sheet.
138: */
139: public JButtonOperator btCustomizer() {
140: if (_btCustomizer == null) {
141: _btCustomizer = new JButtonOperator(this , 0);
142: }
143: return _btCustomizer;
144: }
145:
146: /** Gets instance of JButtonOperator of "Help" button.
147: * @return JButtonOperator instance
148: * @deprecated Tool bar is no more present in property sheet.
149: */
150: public JButtonOperator btHelp() {
151: if (_btHelp == null) {
152: _btHelp = new JButtonOperator(this , 1);
153: }
154: return _btHelp;
155: }
156:
157: /** Pushes "Unsorted" button.
158: * @deprecated Tool bar is no more present in property sheet.
159: */
160: public void unsorted() {
161: btUnsorted().push();
162: }
163:
164: /** Pushes "Sort by Name" button.
165: * @deprecated Tool bar is no more present in property sheet.
166: */
167: public void sortByName() {
168: btSortByName().push();
169: }
170:
171: /** Pushes "Sort by Type" button.
172: * @deprecated Tool bar is no more present in property sheet.
173: */
174: public void sortByType() {
175: btSortByType().push();
176: }
177:
178: /** Sets "Show Editable Properties Only" toggle button to desired state.
179: * @param show true - select button (show only editable properties);
180: * false - unselect button (show all properties)
181: * @deprecated Tool bar is no more present in property sheet.
182: */
183: public void showEditable(boolean show) {
184: btShowEditable().setSelected(show);
185: }
186:
187: /** Pushes "Customizer" button and no block further execution.
188: * @deprecated Tool bar is no more present in property sheet.
189: */
190: public void customizer() {
191: btCustomizer().pushNoBlock();
192: }
193:
194: /** Pushes "Help" button.
195: * @deprecated Tool bar is no more present in property sheet.
196: */
197: public void help() {
198: btHelp().push();
199: }
200:
201: /** Waits for instance of PropertySheetToolbar in a container. */
202: private static Component waitPropertySheetToolbar(
203: ContainerOperator contOper) {
204: throw new JemmyException(
205: "Don't use this! No tool bar is present in property sheet.");
206: /*
207: ComponentChooser chooser = new ComponentChooser() {
208: public boolean checkComponent(Component comp) {
209: return comp.getClass().getName().indexOf("PropertySheetToolbar") != -1;
210: }
211:
212: public String getDescription() {
213: return "org.openide.explorer.propertysheet.PropertySheetToolbar";
214: }
215: };
216: return contOper.waitComponent((Container)contOper.getSource(), chooser);
217: */
218: }
219:
220: /** Performs verification by accessing all sub-components
221: * @deprecated Tool bar is no more present in property sheet.
222: */
223: public void verify() {
224: btCustomizer();
225: btHelp();
226: btShowEditable();
227: btSortByName();
228: btSortByType();
229: btUnsorted();
230: }
231: }
|