Source Code Cross Referenced for AbbreviationsEditorOperator.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:         * Abbreviations.java
044:         *
045:         * Created on 1/2/03 4:04 PM
046:         */
047:        package org.netbeans.modules.visualweb.gravy.properties.editors;
048:
049:        import java.util.*;
050:        import javax.swing.table.TableModel;
051:        import org.netbeans.modules.visualweb.gravy.OptionsOperator;
052:        import org.netbeans.modules.visualweb.gravy.properties.PropertySheetOperator;
053:        import org.netbeans.modules.visualweb.gravy.properties.PropertySheetTabOperator;
054:        import org.netbeans.modules.visualweb.gravy.properties.TextFieldProperty;
055:        import org.netbeans.jemmy.EventTool;
056:        import org.netbeans.jemmy.operators.*;
057:
058:        import javax.swing.JDialog;
059:        import org.netbeans.jellytools.Bundle;
060:        import org.netbeans.modules.visualweb.gravy.NbDialogOperator;
061:        import org.netbeans.jemmy.operators.*;
062:
063:        /** Class implementing all necessary methods for handling "Abbreviations" NbDialog.
064:         */
065:        public class AbbreviationsEditorOperator extends NbDialogOperator {
066:
067:            /** Creates new Abbreviations that can handle it.
068:             */
069:            public AbbreviationsEditorOperator() {
070:                super (java.util.ResourceBundle.getBundle(
071:                        "org/netbeans/modules/editor/options/Bundle")
072:                        .getString("PROP_Abbreviations"));
073:            }
074:
075:            /** Creates new StringArrayCustomEditorOperator
076:             * @param wrapper JDialogOperator wrapper for custom editor */
077:            public AbbreviationsEditorOperator(JDialogOperator wrapper) {
078:                super ((JDialog) wrapper.getSource());
079:            }
080:
081:            private JTableOperator _tabAbbreviations;
082:            private JButtonOperator _btMetalScrollButton;
083:            private JButtonOperator _btMetalScrollButton2;
084:            private JButtonOperator _btAdd;
085:            private JButtonOperator _btEdit;
086:            private JButtonOperator _btRemove;
087:            private JButtonOperator _btOK;
088:            private JButtonOperator _btCancel;
089:            private JButtonOperator _btHelp;
090:
091:            //******************************
092:            // Subcomponents definition part
093:            //******************************
094:
095:            /** Tries to find null JTable in this dialog.
096:             * @return JTableOperator
097:             */
098:            public JTableOperator tabAbbreviations() {
099:                if (_tabAbbreviations == null) {
100:                    _tabAbbreviations = new JTableOperator(this );
101:                }
102:                return _tabAbbreviations;
103:            }
104:
105:            /** Tries to find "" MetalScrollButton in this dialog.
106:             * @return JButtonOperator
107:             */
108:            public JButtonOperator btMetalScrollButton() {
109:                if (_btMetalScrollButton == null) {
110:                    _btMetalScrollButton = new JButtonOperator(this , "");
111:                }
112:                return _btMetalScrollButton;
113:            }
114:
115:            /** Tries to find "" MetalScrollButton in this dialog.
116:             * @return JButtonOperator
117:             */
118:            public JButtonOperator btMetalScrollButton2() {
119:                if (_btMetalScrollButton2 == null) {
120:                    _btMetalScrollButton2 = new JButtonOperator(this , "", 1);
121:                }
122:                return _btMetalScrollButton2;
123:            }
124:
125:            /** Tries to find "Add..." JButton in this dialog.
126:             * @return JButtonOperator
127:             */
128:            public JButtonOperator btAdd() {
129:                if (_btAdd == null) {
130:                    _btAdd = new JButtonOperator(
131:                            this ,
132:                            java.util.ResourceBundle
133:                                    .getBundle(
134:                                            "org.netbeans.modules.editor.options.Bundle")
135:                                    .getString("KBEP_Add"));
136:                }
137:                return _btAdd;
138:            }
139:
140:            /** Tries to find "Edit..." JButton in this dialog.
141:             * @return JButtonOperator
142:             */
143:            public JButtonOperator btEdit() {
144:                if (_btEdit == null) {
145:                    _btEdit = new JButtonOperator(
146:                            this ,
147:                            java.util.ResourceBundle
148:                                    .getBundle(
149:                                            "org/netbeans/modules/editor/options/Bundle")
150:                                    .getString("AEP_Edit"));
151:                }
152:                return _btEdit;
153:            }
154:
155:            /** Tries to find "Remove" JButton in this dialog.
156:             * @return JButtonOperator
157:             */
158:            public JButtonOperator btRemove() {
159:                if (_btRemove == null) {
160:                    _btRemove = new JButtonOperator(
161:                            this ,
162:                            java.util.ResourceBundle
163:                                    .getBundle(
164:                                            "org/netbeans/modules/editor/options/Bundle")
165:                                    .getString("Remove"));
166:                }
167:                return _btRemove;
168:            }
169:
170:            /** Tries to find "OK" JButton in this dialog.
171:             * @return JButtonOperator
172:             */
173:            public JButtonOperator btOK() {
174:                if (_btOK == null) {
175:                    _btOK = new JButtonOperator(
176:                            this ,
177:                            java.util.ResourceBundle
178:                                    .getBundle(
179:                                            "org/netbeans/modules/editor/options/Bundle")
180:                                    .getString("KBEP_OK_LABEL"));
181:                }
182:                return _btOK;
183:            }
184:
185:            /** Tries to find "Cancel" JButton in this dialog.
186:             * @return JButtonOperator
187:             */
188:            public JButtonOperator btCancel() {
189:                if (_btCancel == null) {
190:                    _btCancel = new JButtonOperator(
191:                            this ,
192:                            java.util.ResourceBundle
193:                                    .getBundle(
194:                                            "org.openide.explorer.propertysheet.Bundle")
195:                                    .getString("CTL_Cancel"));
196:                }
197:                return _btCancel;
198:            }
199:
200:            /** Tries to find "Help" JButton in this dialog.
201:             * @return JButtonOperator
202:             */
203:            public JButtonOperator btHelp() {
204:                if (_btHelp == null) {
205:                    _btHelp = new JButtonOperator(
206:                            this ,
207:                            java.util.ResourceBundle
208:                                    .getBundle(
209:                                            "org.openide.explorer.propertysheet.Bundle")
210:                                    .getString("CTL_Help"));
211:                }
212:                return _btHelp;
213:            }
214:
215:            //****************************************
216:            // Low-level functionality definition part
217:            //****************************************
218:
219:            /** clicks on "" MetalScrollButton
220:             */
221:            public void metalScrollButton() {
222:                btMetalScrollButton().push();
223:            }
224:
225:            /** clicks on "" MetalScrollButton
226:             */
227:            public void metalScrollButton2() {
228:                btMetalScrollButton2().push();
229:            }
230:
231:            /** clicks on "Add..." JButton
232:             */
233:            public void add() {
234:                btAdd().push();
235:            }
236:
237:            /** clicks on "Edit..." JButton
238:             */
239:            public void edit() {
240:                btEdit().push();
241:            }
242:
243:            /** clicks on "Remove" JButton
244:             */
245:            public void remove() {
246:                btRemove().push();
247:            }
248:
249:            /** clicks on "OK" JButton
250:             */
251:            public void oK() {
252:                btOK().push();
253:            }
254:
255:            /** clicks on "Cancel" JButton
256:             */
257:            public void cancel() {
258:                btCancel().push();
259:            }
260:
261:            /** clicks on "Help" JButton
262:             */
263:            public void help() {
264:                btHelp().push();
265:            }
266:
267:            //*****************************************
268:            // High-level functionality definition part
269:            //*****************************************
270:
271:            /** Performs verification of Abbreviations by accessing all its components.
272:             */
273:            public void verify() {
274:                tabAbbreviations();
275:                btMetalScrollButton();
276:                btMetalScrollButton2();
277:                btAdd();
278:                btEdit();
279:                btRemove();
280:                btOK();
281:                btCancel();
282:                btHelp();
283:            }
284:
285:            /**
286:             * Add specified abbreviation with specified expansion.
287:             * @param abbreviation Name of abbreviation.
288:             * @param expansion Name of expansion.
289:             */
290:            public void addAbbreviation(String abbreviation, String expansion) {
291:                btAdd().pushNoBlock();
292:                EnterAbbreviation enter = new EnterAbbreviation();
293:                enter.fillAbbreviation(abbreviation, expansion);
294:                enter.oK();
295:            }
296:
297:            /**
298:             * Edit specified abbreviation.
299:             * @param abbreviationName Name of abbreviations.
300:             * @param newAbbreviationName New name of abbreviations.
301:             * @param newExpansion New name of expansion.
302:             */
303:            public boolean editAbbreviation(String abbreviationName,
304:                    String newAbbreviationName, String newExpansion) {
305:                int row = tabAbbreviations().findCellRow(abbreviationName);
306:
307:                if (row == (-1))
308:                    return false;
309:
310:                tabAbbreviations().selectCell(row, 0);
311:                btEdit().pushNoBlock();
312:
313:                EnterAbbreviation enter = new EnterAbbreviation();
314:
315:                enter.fillAbbreviation(newAbbreviationName, newExpansion);
316:                enter.oK();
317:
318:                return true;
319:            }
320:
321:            /**
322:             * Edit specified abbreviation or add if it isn't exist.
323:             * @param abbreviationName Name of abbreviations.
324:             * @param newAbbreviationName New name of abbreviations.
325:             * @param newExpansion New name of expansion.
326:             */
327:            public void addOrEditAbbreviation(String abbreviationName,
328:                    String newAbbreviationName, String newExpansion) {
329:                if (!editAbbreviation(abbreviationName, newAbbreviationName,
330:                        newExpansion))
331:                    addAbbreviation(newAbbreviationName, newExpansion);
332:            }
333:
334:            /**
335:             * Remove specified abbreviation.
336:             * @param abbreviation Name of abbreviations.
337:             * @return True if abbreviation was removed.
338:             */
339:            public boolean removeAbbreviation(String abbreviation) {
340:                int row = tabAbbreviations().findCellRow(abbreviation,
341:                        new Operator.DefaultStringComparator(true, true));
342:
343:                if (row == (-1))
344:                    return false;
345:
346:                tabAbbreviations().selectCell(row, 0);
347:                btRemove().pushNoBlock();
348:
349:                return true;
350:            }
351:
352:            /**
353:             * Get map of abbreviations.
354:             * @return Map of abbreviations.
355:             */
356:            public Map listAbbreviations() {
357:                TableModel model = tabAbbreviations().getModel();
358:                int rowCount = model.getRowCount();
359:                Map result = new HashMap();
360:
361:                for (int cntr = 0; cntr < rowCount; cntr++) {
362:                    result.put((String) model.getValueAt(cntr, 0),
363:                            (String) model.getValueAt(cntr, 1));
364:                }
365:
366:                return result;
367:            }
368:
369:            /**
370:             * Get abbreviations editor.
371:             * @return AbbreviationsEditorOperator.
372:             */
373:            public static AbbreviationsEditorOperator invoke(String editorName) {
374:                OptionsOperator options = OptionsOperator.invoke();
375:                new EventTool().waitNoEvent(500);
376:
377:                options.advanced();
378:                new EventTool().waitNoEvent(500);
379:
380:                options.selectOption(ResourceBundle.getBundle(
381:                        "org/netbeans/core/Bundle").getString(
382:                        "UI/Services/Editing")
383:                        + "|"
384:                        + ResourceBundle.getBundle(
385:                                "org/netbeans/modules/editor/options/Bundle")
386:                                .getString("OPTIONS_all") + "|" + editorName);
387:                new EventTool().waitNoEvent(500);
388:                PropertySheetOperator property = new PropertySheetOperator(
389:                        options);
390:                PropertySheetTabOperator psto = new PropertySheetTabOperator(
391:                        property);
392:                new TextFieldProperty(psto, ResourceBundle.getBundle(
393:                        "org/netbeans/modules/editor/options/Bundle")
394:                        .getString("PROP_Abbreviations")).openEditor();
395:
396:                AbbreviationsEditorOperator abbs = new AbbreviationsEditorOperator();
397:
398:                options.close(); /*??? not sure whether this is assured to work*/
399:                return abbs;
400:            }
401:
402:            /**
403:             * Add specified abbreviation with specified expansion with specified editor.
404:             * @param editorName Name of editor.
405:             * @param abbreviation Name of abbreviation.
406:             * @param expansion Name of expansion.
407:             */
408:            public static void addAbbreviation(String editorName,
409:                    String abbreviation, String expansion) {
410:                AbbreviationsEditorOperator instance = invoke(editorName);
411:
412:                instance.addAbbreviation(abbreviation, expansion);
413:                instance.oK();
414:            }
415:
416:            /**
417:             * Edit specified abbreviation or add if it isn't exist with specified editor.
418:             * @param editorName Name of editor.
419:             * @param abbreviationName Name of abbreviations.
420:             * @param newAbbreviationName New name of abbreviations.
421:             * @param newExpansion New name of expansion.
422:             */
423:            public static void addOrEditAbbreviation(String editorName,
424:                    String abbreviationName, String newAbbreviationName,
425:                    String newExpansion) {
426:                AbbreviationsEditorOperator instance = invoke(editorName);
427:
428:                instance.addOrEditAbbreviation(abbreviationName,
429:                        newAbbreviationName, newExpansion);
430:                instance.oK();
431:            }
432:
433:            /**
434:             * Remove specified abbreviation with specified editor.
435:             * @param editorName Name of editor.
436:             * @param abbreviation Name of abbreviations.
437:             * @return True if abbreviation was removed.
438:             */
439:            public static boolean removeAbbreviation(String editorName,
440:                    String abbreviation) {
441:                AbbreviationsEditorOperator instance = invoke(editorName);
442:                boolean result = instance.removeAbbreviation(abbreviation);
443:
444:                instance.oK();
445:                return result;
446:            }
447:
448:            /**
449:             * Edit specified abbreviation with specified editor.
450:             * @param editorName Name of editor.
451:             * @param abbreviationName Name of abbreviations.
452:             * @param newAbbreviationName New name of abbreviations.
453:             * @param newExpansion New name of expansion.
454:             */
455:            public static boolean editAbbreviation(String editorName,
456:                    String abbreviationName, String newAbbreviationName,
457:                    String newExpansion) {
458:                AbbreviationsEditorOperator instance = invoke(editorName);
459:                boolean result = instance.editAbbreviation(abbreviationName,
460:                        newAbbreviationName, newExpansion);
461:
462:                instance.oK();
463:                return result;
464:            }
465:
466:            /**
467:             * Get map of abbreviations.
468:             * @param editorName Name of AbbreviationsEditor.
469:             * @return Map of abbreviations.
470:             */
471:            public static Map listAbbreviations(String editorName) {
472:                AbbreviationsEditorOperator instance = invoke(editorName);
473:                Map result = instance.listAbbreviations();
474:
475:                instance.oK();
476:
477:                return result;
478:            }
479:
480:            /** Performs simple test of Abbreviations
481:             * @param args the command line arguments
482:             */
483:            public static void main(String args[]) {
484:                AbbreviationsEditorOperator.addAbbreviation("Java Editor",
485:                        "aaa", "All abbrev");
486:                /*try {
487:                    //java.io.PrintWriter pw= new java.io.PrintWriter(new java.io.FileWriter("/tmp/abbrevs.java"));
488:                    Map map=Abbreviations.listAbbreviations(java.util.ResourceBundle.getBundle("org/netbeans/modules/editor/options/Bundle").getString("OPTIONS_java"));
489:                    java.util.Iterator keys=map.keySet().iterator();
490:                    String key;
491:                    while (keys.hasNext()) {
492:                        key=(String)(keys.next());
493:                        System.out.println(key+" "+map.get(key));
494:                        //  pw.println("new Abbreviation(\""+key+"\", \""+map.get(key)+"\", \"\", \"\"),");
495:                    }
496:                    //pw.close();
497:                } catch (Exception ex) {
498:                    ex.printStackTrace();
499:                }*/
500:            }
501:        }
w___w_w.___j__a_va_2__s.___co___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.