Source Code Cross Referenced for SheetButtonOperator.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » gravy » properties » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » visualweb.api.designer » org.netbeans.modules.visualweb.gravy.properties 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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 java.lang.reflect.Method;
047:        import javax.swing.JComponent;
048:        import org.netbeans.jemmy.Action;
049:        import org.netbeans.jemmy.ActionProducer;
050:        import org.netbeans.jemmy.ComponentChooser;
051:        import org.netbeans.jemmy.JemmyException;
052:        import org.netbeans.jemmy.operators.ContainerOperator;
053:        import org.netbeans.jemmy.operators.JComponentOperator;
054:        import org.netbeans.jemmy.operators.Operator;
055:        import org.netbeans.jemmy.util.MouseVisualizer;
056:        import org.openide.explorer.propertysheet.PropertyPanel;
057:
058:        /**
059:         * Handle sheet button in IDE property sheets. SheetButton extends JPanel
060:         * and it can show property name, property value or customizer button ("..." button).
061:         * It is not recommended to use it directly but to use Property class and its
062:         * descendants.
063:         *
064:         * @deprecated JTable used instead of array of SheetButtons. 
065:         * Use {@link Property} to change value of property.
066:         */
067:        public class SheetButtonOperator extends JComponentOperator {
068:
069:            /** Index of name button (number of row) */
070:            private int nameButtonIndex;
071:            /** Temporary storage */
072:            private static int temporaryNameButtonIndex;
073:
074:            /** Create new instance. Use getters below to construct a new instance. 
075:             * @deprecated JTable used instead of array of SheetButtons. 
076:             * Use {@link Property} to change value of property.
077:             */
078:            private SheetButtonOperator(Component button) {
079:                super ((JComponent) button);
080:            }
081:
082:            /** Waits for sheet button representing specified property name. It sets
083:             * index of button in sheet.
084:             * @param contOper where to find button
085:             * @param propertyName name of property
086:             * @return  SheetButtonOperator instance
087:             * @see #getNameButtonIndex()
088:             * @deprecated JTable used instead of array of SheetButtons. 
089:             * Use {@link Property} to change value of property.
090:             */
091:            public static synchronized SheetButtonOperator nameButton(
092:                    ContainerOperator contOper, String propertyName) {
093:                SheetButtonOperator sbo = new SheetButtonOperator(
094:                        waitNameButton(contOper, propertyName, 0));
095:                sbo.nameButtonIndex = temporaryNameButtonIndex;
096:                return sbo;
097:            }
098:
099:            /** Waits for index-th sheet button representing property name. It sets
100:             * index of button in sheet.
101:             * @param contOper where to find button
102:             * @param index index of button (row in sheet - starts at 0)
103:             * @return  SheetButtonOperator instance
104:             * @see #getNameButtonIndex()
105:             * @deprecated JTable used instead of array of SheetButtons. 
106:             * Use {@link Property} to change value of property.
107:             */
108:            public static SheetButtonOperator nameButton(
109:                    ContainerOperator contOper, int index) {
110:                SheetButtonOperator sbo = new SheetButtonOperator(
111:                        waitNameButton(contOper, null, index));
112:                sbo.nameButtonIndex = index;
113:                return sbo;
114:            }
115:
116:            /** Waits for sheet button representing value of property. It is identified
117:             * by index which can be found by name button.
118:             * @param contOper where to find
119:             * @param nameButtonIndex index of property in sheet
120:             * @return  SheetButtonOperator instance
121:             * @deprecated JTable used instead of array of SheetButtons. 
122:             * Use {@link Property} to change value of property.
123:             */
124:            public static SheetButtonOperator valueButton(
125:                    ContainerOperator contOper, int nameButtonIndex) {
126:                return new SheetButtonOperator(waitValueButton(contOper,
127:                        nameButtonIndex));
128:            }
129:
130:            /** Waits for customizer button ("..." button) in given ContainerOperator.
131:             * @param contOper where to find button
132:             * @return  SheetButtonOperator instance
133:             * @deprecated JTable used instead of array of SheetButtons. 
134:             * Use {@link Property} to change value of property.
135:             */
136:            public static SheetButtonOperator customizerButton(
137:                    ContainerOperator contOper) {
138:                return new SheetButtonOperator(waitCustomizerButton(contOper));
139:            }
140:
141:            /** Waits LazyToolTipSheetButton by its name and index. Sets index of
142:             * property in sheet. */
143:            private static Component waitNameButton(ContainerOperator contOper,
144:                    String name, int index) {
145:                throw new JemmyException(
146:                        "Don't use this! SheetButton no more used in property sheet.");
147:                /*SheetButtonChooser chooser = new SheetButtonChooser(name, contOper.getComparator());
148:                Component comp = contOper.waitComponent((Container)contOper.getSource(), chooser, index);
149:                temporaryNameButtonIndex = chooser.getIndex();
150:                return comp;*/
151:            }
152:
153:            /** Waits "..." button which is SheetButton class. */
154:            private static Component waitCustomizerButton(
155:                    ContainerOperator contOper) {
156:                throw new JemmyException(
157:                        "Don't use this! SheetButton no more used in property sheet.");
158:                /*ComponentChooser chooser = new ComponentChooser() {
159:                    public boolean checkComponent(Component comp) {
160:                        return comp.getClass().getName().indexOf("propertysheet.SheetButton") != -1;
161:                    }
162:                    
163:                    public String getDescription() {
164:                        return "SheetButton \"...\"";
165:                    }
166:                };
167:                return contOper.waitComponent((Container)contOper.getSource(), chooser);*/
168:            }
169:
170:            /** Waits value button which is instance of PropertySheetButton. First
171:             * it finds nameButtonIndex-th PropertyPanel and inside it it tries to find
172:             * PropertySheetButton.
173:             */
174:            private static Component waitValueButton(
175:                    ContainerOperator contOper, int nameButtonIndex) {
176:                throw new JemmyException(
177:                        "Don't use this! SheetButton no more used in property sheet.");
178:                /*ComponentChooser chooser = new ComponentChooser() {
179:                    public boolean checkComponent(Component comp) {
180:                        return comp.getClass().getName().indexOf("PropertySheetButton") != -1;
181:                    }
182:                    
183:                    public String getDescription() {
184:                        return "PropertySheetButton";
185:                    }
186:                };
187:                Component propertyPanel = waitPropertyPanel(contOper, nameButtonIndex);
188:                return contOper.waitComponent((Container)propertyPanel, chooser);*/
189:            }
190:
191:            /** Waits org.openide.explorer.propertysheet.PropertyPanel with given index.
192:             * PropertyPanel represents container for a value both in editable and
193:             * non editable states.
194:             */
195:            static Component waitPropertyPanel(ContainerOperator contOper,
196:                    int nameButtonIndex) {
197:                throw new JemmyException(
198:                        "Don't use this! SheetButton no more used in property sheet.");
199:                /*ComponentChooser chooser = new ComponentChooser() {
200:                    public boolean checkComponent(Component comp) {
201:                        return comp instanceof PropertyPanel;
202:                    }
203:                    
204:                    public String getDescription() {
205:                        return "org.openide.explorer.propertysheet.PropertyPanel";
206:                    }
207:                };
208:                return contOper.waitComponent((Container)contOper.getSource(), chooser, nameButtonIndex);*/
209:            }
210:
211:            /** Chooser to find instance LazyToolTipSheetButton by property name.
212:             * getIndex() method can be used to get index of found button.
213:             * It is also used by PropertySheetTabOperator. */
214:            static class SheetButtonChooser implements  ComponentChooser {
215:                private String propertyName;
216:                private int index = -1;
217:                private StringComparator comparator;
218:
219:                public SheetButtonChooser(String propertyName,
220:                        StringComparator comparator) {
221:                    this .propertyName = propertyName;
222:                    this .comparator = comparator;
223:                }
224:
225:                public boolean checkComponent(Component comp) {
226:                    if (comp.getClass().getName().indexOf(
227:                            "LazyToolTipSheetButton") != -1) {
228:                        index++;
229:                        return comparator.equals(getButtonLabel(comp),
230:                                propertyName);
231:                    }
232:                    return false;
233:                }
234:
235:                public String getDescription() {
236:                    return "\""
237:                            + (propertyName == null ? "index-th" : propertyName)
238:                            + "\" SheetButton";
239:                }
240:
241:                public int getIndex() {
242:                    return index;
243:                }
244:            }
245:
246:            /** Gets label of given sheet button by reflection call. */
247:            private static String getButtonLabel(Component sheetButton) {
248:                try {
249:                    Class clazz = Class
250:                            .forName("org.openide.explorer.propertysheet.SheetButton");
251:                    Method getLabelMethod = clazz.getDeclaredMethod("getLabel",
252:                            null);
253:                    getLabelMethod.setAccessible(true);
254:                    return getLabelMethod.invoke(sheetButton, null).toString();
255:                } catch (Exception e) {
256:                    throw new JemmyException(
257:                            "SheetButton.getLabel() by reflection failed.", e);
258:                }
259:            }
260:
261:            /** Gets label of this sheet button.
262:             * @return  label of this button
263:             */
264:            public String getLabel() {
265:                return getButtonLabel(getSource());
266:            }
267:
268:            /** Gets index (row) of name button in property sheet. Each row represents
269:             * one property.
270:             * @return  index (row) of name button
271:             */
272:            public int getNameButtonIndex() {
273:                return nameButtonIndex;
274:            }
275:
276:            /** If needed, it scrolls to be this button visible, and clicks on 
277:             * this button by mouse.
278:             */
279:            public void push() {
280:                // Possibly we don't need to scroll and makeVisible, if we use only
281:                // setText, setSelectedItem (not typeText, selectItem) in Property 
282:                // and its descendants
283:                MouseVisualizer mv = new MouseVisualizer(MouseVisualizer.TOP,
284:                        0.5, 10, false);
285:                mv.scroll(true);
286:                mv.makeVisible(this );
287:                clickMouse();
288:            }
289:
290:            /** If needed, it scrolls to be this button visible, and clicks 
291:             * on this button by mouse and no block further execution. */
292:            public void pushNoBlock() {
293:                try {
294:                    new ActionProducer(new Action() {
295:                        public Object launch(Object obj) {
296:                            push();
297:                            return null;
298:                        }
299:
300:                        public String getDescription() {
301:                            return ("Push \"" + getLabel() + "\" button - don't wait");
302:                        }
303:                    }, false).produceAction(null);
304:                } catch (Exception e) {
305:                    throw new JemmyException("Push \"" + getLabel()
306:                            + "\" button action failed.", e);
307:                }
308:            }
309:
310:            /** If needed, it scrolls to be this button visible, and clicks for popup
311:             * on this button.
312:             */
313:            public void clickForPopup() {
314:                MouseVisualizer mv = new MouseVisualizer(MouseVisualizer.TOP,
315:                        0.5, 10, false);
316:                mv.scroll(true);
317:                mv.makeVisible(this);
318:                super.clickForPopup();
319:            }
320:
321:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.