KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > editor > suites > abbrevs > JavaAbbreviationsTestPerformer


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 /*
21  * JavaAbbreviationsTest.java
22  *
23  * Created on August 29, 2002, 2:52 PM
24  */

25
26 package org.netbeans.test.editor.suites.abbrevs;
27
28 import java.awt.event.KeyEvent JavaDoc;
29 import org.netbeans.jellytools.EditorOperator;
30 import org.openide.cookies.EditorCookie;
31 import org.openide.filesystems.FileObject;
32 import org.openide.filesystems.Repository;
33 import org.openide.loaders.DataObject;
34 import org.openide.loaders.DataObjectNotFoundException;
35
36 /**
37  *
38  * @author Jan Lahoda
39  */

40 public class JavaAbbreviationsTestPerformer extends AbbreviationsTest {
41
42     /** Creates a new instance of JavaAbbreviationsTest */
43     public JavaAbbreviationsTestPerformer(String JavaDoc name) {
44         super(name);
45     }
46     
47     /**
48      * @param args the command line arguments
49      */

50     public static void main(String JavaDoc[] args) {
51         //new JavaAbbreviationsTestPerformer("testAbbreviationTest").testAbbreviationTest();
52
/* new JavaAbbreviationsTestPerformer("testAbbreviationWithoutExpansion").testAbbreviationWithoutExpansion();
53         new JavaAbbreviationsTestPerformer("testAbbreviationInsideComment").testAbbreviationInsideComment();
54         new JavaAbbreviationsTestPerformer("testAbbreviationAdd").testAbbreviationAdd();
55         new JavaAbbreviationsTestPerformer("testAbbreviationRemove").testAbbreviationRemove();
56         new JavaAbbreviationsTestPerformer("testAbbreviationChange").testAbbreviationChange();
57         new JavaAbbreviationsTestPerformer("testAbbreviationOKCancel").testAbbreviationOKCancel();*/

58 /* JavaAbbreviationsTest j = new JavaAbbreviationsTestPerformer("testAbbreviationTest");
59  
60         j.prepareEditor();
61         j.moveCaretIntoCode();*/

62         // printAbbreviations("Java Editor");
63
}
64     
65     public Abbreviation[] getAbbreviationsToAdd() {
66         return new Abbreviation[] {
67             new Abbreviation("test", "testIk", "", ""),
68             new Abbreviation("ttest", "test|test", "", ""),
69             new Abbreviation("tryc", "try {\n |\n} catch (Exception ex) {\n ex.printStackTrace();\n}", "", "")
70         };
71     }
72     
73     public Abbreviation[] getAbbreviationsToModify() {
74         return new Abbreviation[] {
75             new Abbreviation("cl1", "clazz", "cl", "class"),
76         };
77     }
78     
79     public Abbreviation[] getAbbreviationsToRemove() {
80         return new Abbreviation[] {
81             new Abbreviation("Psfb", "", "", ""),
82         };
83     }
84     
85     public Abbreviation[] getDefaultAbbreviations() {
86         return new Abbreviation[] {
87             new Abbreviation("sh", "short ", "", ""),
88             new Abbreviation("Psfb", "public static final boolean ", "", ""),
89             new Abbreviation("cl", "class ", "", ""),
90             new Abbreviation("Re", "Rectangle", "", ""),
91             new Abbreviation("ie", "interface ", "", ""),
92             new Abbreviation("tw", "throw ", "", ""),
93             new Abbreviation("df", "default:", "", ""),
94             new Abbreviation("tds", "Thread.dumpStack();", "", ""),
95             new Abbreviation("St", "String", "", ""),
96             new Abbreviation("tr", "transient ", "", ""),
97             new Abbreviation("pr", "private ", "", ""),
98             new Abbreviation("th", "throws ", "", ""),
99             new Abbreviation("impb", "import java.beans.", "", ""),
100             new Abbreviation("imps", "import javax.swing.", "", ""),
101             new Abbreviation("Ve", "Vector", "", ""),
102             new Abbreviation("iof", "instanceof ", "", ""),
103             new Abbreviation("le", "length", "", ""),
104             new Abbreviation("fa", "false", "", ""),
105             new Abbreviation("wh", "while (", "", ""),
106             new Abbreviation("sw", "switch (", "", ""),
107             new Abbreviation("Psf", "public static final ", "", ""),
108             new Abbreviation("psfs", "private static final String ", "", ""),
109             new Abbreviation("sy", "synchronized ", "", ""),
110             new Abbreviation("serr", "System.err.println(\"|\");", "", ""),
111             new Abbreviation("Psfs", "public static final String ", "", ""),
112             new Abbreviation("pe", "protected ", "", ""),
113             new Abbreviation("ab", "abstract ", "", ""),
114             new Abbreviation("Psfi", "public static final int ", "", ""),
115             new Abbreviation("Ex", "Exception", "", ""),
116             new Abbreviation("st", "static ", "", ""),
117             new Abbreviation("eq", "equals", "", ""),
118             new Abbreviation("Gr", "Graphics", "", ""),
119             new Abbreviation("bo", "boolean ", "", ""),
120             new Abbreviation("ir", "import ", "", ""),
121             new Abbreviation("pu", "public ", "", ""),
122             new Abbreviation("twn", "throw new ", "", ""),
123             new Abbreviation("fy", "finally ", "", ""),
124             new Abbreviation("impS", "import com.sun.java.swing.", "", ""),
125             new Abbreviation("psfb", "private static final boolean ", "", ""),
126             new Abbreviation("ca", "catch (", "", ""),
127             new Abbreviation("impa", "import java.awt.", "", ""),
128             new Abbreviation("impd", "import org.netbeans.", "", ""),
129             new Abbreviation("pst", "printStackTrace();", "", ""),
130             new Abbreviation("twne", "throw new Error();", "", ""),
131             new Abbreviation("psf", "private static final ", "", ""),
132             new Abbreviation("psfi", "private static final int ", "", ""),
133             new Abbreviation("fi", "final ", "", ""),
134             new Abbreviation("impj", "import java.", "", ""),
135             new Abbreviation("fl", "float ", "", ""),
136             new Abbreviation("ex", "extends ", "", ""),
137             new Abbreviation("im", "implements ", "", ""),
138             new Abbreviation("cn", "continue", "", ""),
139             new Abbreviation("Ob", "Object", "", ""),
140             new Abbreviation("sout", "System.out.println(\"|\");", "", ""),
141             new Abbreviation("En", "Enumeration", "", ""),
142             new Abbreviation("re", "return ", "", ""),
143             new Abbreviation("br", "break", "", ""),
144             new Abbreviation("twni", "throw new InternalError();", "", ""),
145             new Abbreviation("impq", "import javax.sql.", "", ""),
146         };
147     }
148     
149     public String JavaDoc getEditorName() {
150         return "Java Editor";
151     }
152     
153     private EditorOperator editor = null;
154     
155     public synchronized EditorOperator getTestEditor() {
156         if (editor == null) {
157             
158             FileObject fo = Repository.getDefault().findResource("org/netbeans/test/editor/suites/abbrevs/data/testfiles/JavaAbbreviationsTest/Test.java");
159             
160             try {
161                 DataObject od = DataObject.find(fo);
162                 EditorCookie ec = (EditorCookie) od.getCookie(EditorCookie.class);
163                 
164                 ec.open();
165                 
166                 editor = new EditorOperator("Test");
167             } catch (DataObjectNotFoundException e) {
168                 assertTrue(false);
169             }
170         }
171         
172         return editor;
173     }
174     
175     public void moveCaretIntoCode() {
176         getTestEditor().pushKey(KeyEvent.VK_END, KeyEvent.CTRL_MASK);
177     }
178     
179     public void moveCaretIntoComment() {
180         moveCaretIntoCode();
181         getTestEditor().txtEditorPane().typeText("/* */");
182         getTestEditor().pushKey(KeyEvent.VK_LEFT);
183         getTestEditor().pushKey(KeyEvent.VK_LEFT);
184     }
185     
186     public void prepareEditor() {
187         EditorOperator op = getTestEditor();
188         
189         op.pushKey(KeyEvent.VK_HOME, KeyEvent.CTRL_MASK);
190         op.pushKey(KeyEvent.VK_END, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK);
191         // op.select(op.getText());
192
// op.select(1, op.getLineNumber());
193
op.pushKey(KeyEvent.VK_DELETE);
194     }
195     
196     public String JavaDoc getEditorOptionsClassName() {
197         return "org.netbeans.modules.java.editor.options.JavaOptions";
198     }
199     
200     public void finishEditor() {
201         getTestEditor().closeDiscard();
202     }
203     
204 }
205
Popular Tags