Source Code Cross Referenced for KeyBindingsEditorOperator.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » gravy » properties » editors » 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.editors 
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:        /*
043:         * KeyBindings.java
044:         *
045:         * Created on 10/17/02 12:54 PM
046:         */
047:        package org.netbeans.modules.visualweb.gravy.properties.editors;
048:
049:        import java.io.File;
050:        import java.io.FileWriter;
051:        import java.io.PrintWriter;
052:        import org.netbeans.jemmy.operators.*;
053:        import java.util.*;
054:
055:        import javax.swing.ListModel;
056:        import org.netbeans.modules.visualweb.gravy.OptionsOperator;
057:        import org.netbeans.modules.visualweb.gravy.properties.PropertySheetOperator;
058:        import org.netbeans.modules.visualweb.gravy.properties.PropertySheetTabOperator;
059:        import org.netbeans.modules.visualweb.gravy.properties.TextFieldProperty;
060:        import org.netbeans.jemmy.EventTool;
061:
062:        import javax.swing.JDialog;
063:        import org.netbeans.jellytools.Bundle;
064:        import org.netbeans.modules.visualweb.gravy.NbDialogOperator;
065:        import org.netbeans.jemmy.operators.*;
066:
067:        /** Class implementing all necessary methods for handling "Key Bindings" NbDialog.
068:         */
069:        public class KeyBindingsEditorOperator extends NbDialogOperator {
070:
071:            /** Creates new KeyBindings that can handle it.
072:             */
073:            public KeyBindingsEditorOperator() {
074:                super ("Key Bindings");
075:                //                java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("PROP_keyBindings"));
076:            }
077:
078:            /** Creates new StringArrayCustomEditorOperator
079:             * @param wrapper JDialogOperator wrapper for custom editor */
080:            public KeyBindingsEditorOperator(JDialogOperator wrapper) {
081:                super ((JDialog) wrapper.getSource());
082:            }
083:
084:            private JRadioButtonOperator _rbSortByName;
085:            private JRadioButtonOperator _rbSortByAction;
086:            private JListOperator _lstActions;
087:            private JButtonOperator _btMetalScrollButton;
088:            private JButtonOperator _btMetalScrollButton2;
089:            private JLabelOperator _lblKeybindings;
090:            private JListOperator _lstKeybindings;
091:            private JButtonOperator _btAdd;
092:            private JButtonOperator _btRemove;
093:            private JButtonOperator _btOK;
094:            private JButtonOperator _btCancel;
095:            private JButtonOperator _btHelp;
096:
097:            //******************************
098:            // Subcomponents definition part
099:            //******************************
100:
101:            /** Tries to find " Sort by Name" JRadioButton in this dialog.
102:             * @return JRadioButtonOperator
103:             */
104:            public JRadioButtonOperator rbSortByName() {
105:                if (_rbSortByName == null) {
106:                    _rbSortByName = new JRadioButtonOperator(
107:                            this ,
108:                            java.util.ResourceBundle
109:                                    .getBundle(
110:                                            "org.netbeans.modules.editor.options.Bundle")
111:                                    .getString("KBEP_name_sort_button"));
112:                }
113:                return _rbSortByName;
114:            }
115:
116:            /** Tries to find " Sort by Action" JRadioButton in this dialog.
117:             * @return JRadioButtonOperator
118:             */
119:            public JRadioButtonOperator rbSortByAction() {
120:                if (_rbSortByAction == null) {
121:                    _rbSortByAction = new JRadioButtonOperator(
122:                            this ,
123:                            java.util.ResourceBundle
124:                                    .getBundle(
125:                                            "org.netbeans.modules.editor.options.Bundle")
126:                                    .getString("KBEP_action_sort_button"));
127:                }
128:                return _rbSortByAction;
129:            }
130:
131:            /** Tries to find null JList in this dialog.
132:             * @return JListOperator
133:             */
134:            public JListOperator lstActions() {
135:                if (_lstActions == null) {
136:                    _lstActions = new JListOperator(this );
137:                }
138:                return _lstActions;
139:            }
140:
141:            /** Tries to find "" MetalScrollButton in this dialog.
142:             * @return JButtonOperator
143:             */
144:            public JButtonOperator btMetalScrollButton() {
145:                if (_btMetalScrollButton == null) {
146:                    _btMetalScrollButton = new JButtonOperator(this , "");
147:                }
148:                return _btMetalScrollButton;
149:            }
150:
151:            /** Tries to find "" MetalScrollButton in this dialog.
152:             * @return JButtonOperator
153:             */
154:            public JButtonOperator btMetalScrollButton2() {
155:                if (_btMetalScrollButton2 == null) {
156:                    _btMetalScrollButton2 = new JButtonOperator(this , "", 1);
157:                }
158:                return _btMetalScrollButton2;
159:            }
160:
161:            /** Tries to find "Keybindings:" JLabel in this dialog.
162:             * @return JLabelOperator
163:             */
164:            public JLabelOperator lblKeybindings() {
165:                if (_lblKeybindings == null) {
166:                    _lblKeybindings = new JLabelOperator(
167:                            this ,
168:                            java.util.ResourceBundle
169:                                    .getBundle(
170:                                            "org.netbeans.modules.editor.options.Bundle")
171:                                    .getString("KBEP_Sequences"));
172:                }
173:                return _lblKeybindings;
174:            }
175:
176:            /** Tries to find null JList in this dialog.
177:             * @return JListOperator
178:             */
179:            public JListOperator lstKeybindings() {
180:                if (_lstKeybindings == null) {
181:                    _lstKeybindings = new JListOperator(this , 1);
182:                }
183:                return _lstKeybindings;
184:            }
185:
186:            /** Tries to find "Add..." JButton in this dialog.
187:             * @return JButtonOperator
188:             */
189:            public JButtonOperator btAdd() {
190:                if (_btAdd == null) {
191:                    _btAdd = new JButtonOperator(
192:                            this ,
193:                            java.util.ResourceBundle
194:                                    .getBundle(
195:                                            "org.netbeans.modules.editor.options.Bundle")
196:                                    .getString("KBEP_Add"));
197:                }
198:                return _btAdd;
199:            }
200:
201:            /** Tries to find "Remove" JButton in this dialog.
202:             * @return JButtonOperator
203:             */
204:            public JButtonOperator btRemove() {
205:                if (_btRemove == null) {
206:                    _btRemove = new JButtonOperator(
207:                            this ,
208:                            java.util.ResourceBundle
209:                                    .getBundle(
210:                                            "org.netbeans.modules.editor.options.Bundle")
211:                                    .getString("KBEP_Remove"));
212:                }
213:                return _btRemove;
214:            }
215:
216:            /** Tries to find "OK" JButton in this dialog.
217:             * @return JButtonOperator
218:             */
219:            public JButtonOperator btOK() {
220:                if (_btOK == null) {
221:                    _btOK = new JButtonOperator(
222:                            this ,
223:                            java.util.ResourceBundle
224:                                    .getBundle(
225:                                            "org.netbeans.modules.editor.options.Bundle")
226:                                    .getString("KBEP_OK_LABEL"));
227:                }
228:                return _btOK;
229:            }
230:
231:            /** Tries to find "Cancel" JButton in this dialog.
232:             * @return JButtonOperator
233:             */
234:            public JButtonOperator btCancel() {
235:                if (_btCancel == null) {
236:                    _btCancel = new JButtonOperator(this ,
237:                            java.util.ResourceBundle.getBundle(
238:                                    "org.netbeans.core.awt.Bundle").getString(
239:                                    "CancelButton"));
240:                }
241:                return _btCancel;
242:            }
243:
244:            /** Tries to find "Help" JButton in this dialog.
245:             * @return JButtonOperator
246:             */
247:            public JButtonOperator btHelp() {
248:                if (_btHelp == null) {
249:                    _btHelp = new JButtonOperator(
250:                            this ,
251:                            java.util.ResourceBundle
252:                                    .getBundle(
253:                                            "org.openide.explorer.propertysheet.Bundle")
254:                                    .getString("CTL_Help"));
255:                }
256:                return _btHelp;
257:            }
258:
259:            //****************************************
260:            // Low-level functionality definition part
261:            //****************************************
262:
263:            /** clicks on " Sort by Name" JRadioButton
264:             */
265:            public void sortByName() {
266:                rbSortByName().push();
267:            }
268:
269:            /** clicks on " Sort by Action" JRadioButton
270:             */
271:            public void sortByAction() {
272:                rbSortByAction().push();
273:            }
274:
275:            /** clicks on "" MetalScrollButton
276:             */
277:            public void metalScrollButton() {
278:                btMetalScrollButton().push();
279:            }
280:
281:            /** clicks on "" MetalScrollButton
282:             */
283:            public void metalScrollButton2() {
284:                btMetalScrollButton2().push();
285:            }
286:
287:            /** clicks on "Add..." JButton
288:             */
289:            public void add() {
290:                btAdd().push();
291:            }
292:
293:            /** clicks on "Remove" JButton
294:             */
295:            public void remove() {
296:                btRemove().push();
297:            }
298:
299:            /** clicks on "OK" JButton
300:             */
301:            public void oK() {
302:                btOK().push();
303:            }
304:
305:            /** clicks on "Cancel" JButton
306:             */
307:            public void cancel() {
308:                btCancel().push();
309:            }
310:
311:            /** clicks on "Help" JButton
312:             */
313:            public void help() {
314:                btHelp().push();
315:            }
316:
317:            //*****************************************
318:            // High-level functionality definition part
319:            //*****************************************
320:
321:            /** Performs verification of KeyBindings by accessing all its components.
322:             */
323:            public void verify() {
324:                rbSortByName();
325:                rbSortByAction();
326:                lstActions();
327:                btMetalScrollButton();
328:                btMetalScrollButton2();
329:                lblKeybindings();
330:                lstKeybindings();
331:                btAdd();
332:                btRemove();
333:                btOK();
334:                btCancel();
335:                btHelp();
336:            }
337:
338:            public List listActions() {
339:                ListModel model = lstActions().getModel();
340:                List ret = new Vector();
341:                for (int i = 0; i < model.getSize(); i++) {
342:                    ret.add(model.getElementAt(i));
343:                }
344:                return ret;
345:            }
346:
347:            public List listKeyBindings(String actionName) {
348:                JListOperator jlist = lstActions();
349:                jlist.selectItem(actionName);
350:                ListModel model = lstKeybindings().getModel();
351:                List ret = new Vector();
352:                for (int i = 0; i < model.getSize(); i++) {
353:                    ret.add(model.getElementAt(i));
354:                }
355:                return ret;
356:            }
357:
358:            /**
359:             * @param editorName
360:             * @return KeyBindingEditorOperator
361:             */
362:            public static KeyBindingsEditorOperator invoke(String editorName) {
363:                OptionsOperator options = OptionsOperator.invoke();
364:                options.advanced();
365:                try {
366:                    Thread.sleep(1000);
367:                } catch (Exception ex) {
368:                }
369:                options.selectOption(ResourceBundle.getBundle(
370:                        "org/netbeans/core/Bundle").getString(
371:                        "UI/Services/Editing")
372:                        + "|"
373:                        + ResourceBundle.getBundle(
374:                                "org/netbeans/modules/editor/options/Bundle")
375:                                .getString("OPTIONS_all") + "|" + editorName);
376:                //new EventTool().waitNoEvent(500);
377:                try {
378:                    Thread.sleep(1000);
379:                } catch (Exception ex) {
380:                }
381:                PropertySheetOperator property = new PropertySheetOperator(
382:                        options);
383:                PropertySheetTabOperator psto = new PropertySheetTabOperator(
384:                        property);
385:                TextFieldProperty tfp = new TextFieldProperty(psto,
386:                        ResourceBundle.getBundle(
387:                                "org/netbeans/modules/editor/options/Bundle")
388:                                .getString("PROP_KeyBindings"));
389:                tfp.openEditor();
390:                KeyBindingsEditorOperator ret = new KeyBindingsEditorOperator();
391:                //options.close();
392:                return ret;
393:            }
394:
395:            /**
396:             * Get list of KeyBindingsEditor's actions.
397:             * @param editorName Name of KeyBindingsEditor.
398:             * @return List of KeyBindingsEditor's actions.
399:             */
400:            public static List listActions(String editorName) {
401:                KeyBindingsEditorOperator instance = invoke(editorName);
402:                List result = instance.listActions();
403:                instance.oK();
404:                return result;
405:            }
406:
407:            /**
408:             * Get list of KeyBindingsEditor's bindings.
409:             * @param editorName Name of KeyBindingsEditor.
410:             * @return List of KeyBindingsEditor's bindings.
411:             */
412:            public static Hashtable listAllKeyBindings(String editorName) {
413:                KeyBindingsEditorOperator instance = invoke(editorName);
414:                List result = instance.listActions();
415:                Hashtable ret = new Hashtable();
416:                for (int i = 0; i < result.size(); i++) {
417:                    ret.put(result.get(i).toString(), instance
418:                            .listKeyBindings(result.get(i).toString()));
419:                }
420:                instance.oK();
421:                return ret;
422:            }
423:
424:            /** Performs simple test of KeyBindings
425:             * @param args the command line arguments
426:             */
427:            public static void main(String args[]) {
428:                //repeating test
429:                String[] names = new String[] { "Plain Editor", "HTML Editor",
430:                        "Java Editor" };
431:                List list;
432:                for (int j = 0; j < 20; j++) {
433:
434:                    for (int i = 0; i < names.length; i++) {
435:                        list = KeyBindingsEditorOperator.listActions(names[i]);
436:                        System.out.println("step " + j + " output size="
437:                                + list.size());
438:                    }
439:                }
440:
441:                /*String name="Java Editor";
442:                Hashtable table;
443:                table = KeyBindings.listAllKeyBindings(name);
444:                Object[] keys=table.keySet().toArray();
445:                Arrays.sort(keys);
446:                List list;
447:                try {
448:                    File out=new File("/tmp/"+name+" actions.lst");
449:                    PrintWriter pw=new PrintWriter(new FileWriter(out));
450:                    for (int i=0;i < keys.length;i++) {
451:                        pw.print(keys[i]+": ");
452:                        list=(List)table.get(keys[i]);
453:                        for (int j=0;j < list.size();j++) {
454:                            pw.print(list.get(j)+" ");
455:                        }
456:                        pw.println();
457:                    }
458:                    pw.close();
459:                } catch (Exception ex) {
460:                    ex.printStackTrace();
461:                }*/
462:            }
463:        }
w___w_w___._j___a_v_a2__s.__c_o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.