1 19 20 25 26 package org.netbeans.test.editor.suites.abbrevs; 27 28 import java.awt.event.KeyEvent ; 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 40 public class JavaAbbreviationsTestPerformer extends AbbreviationsTest { 41 42 43 public JavaAbbreviationsTestPerformer(String name) { 44 super(name); 45 } 46 47 50 public static void main(String [] args) { 51 58 62 } 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 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.pushKey(KeyEvent.VK_DELETE); 194 } 195 196 public String 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 |