1 19 package org.netbeans.test.editor.app.core; 20 21 import org.netbeans.modules.java.editor.options.JavaOptions; 22 import org.netbeans.test.editor.app.gui.*; 23 import javax.swing.text.EditorKit ; 24 import javax.swing.JEditorPane ; 25 import org.netbeans.modules.editor.java.JavaKit; 26 import org.netbeans.modules.editor.html.HTMLKit; 27 import org.netbeans.modules.editor.plain.PlainKit; 28 import javax.swing.text.PlainDocument ; 30 import org.openide.text.IndentEngine; 32 import org.openide.options.SystemOption; 33 import org.netbeans.modules.editor.options.BaseOptions; 34 import java.util.Enumeration ; 35 import org.netbeans.test.editor.app.util.Scheduler; 36 import javax.swing.SwingUtilities ; 37 import org.netbeans.test.editor.app.Main; 38 import org.netbeans.test.editor.app.core.TestSetAction; 39 import org.netbeans.test.editor.app.core.properties.ArrayProperty; 40 import org.netbeans.test.editor.app.core.properties.BadPropertyNameException; 41 import org.netbeans.test.editor.app.core.properties.Properties; 42 import org.netbeans.test.editor.app.gui.actions.TestDeleteAction; 43 import org.netbeans.test.editor.app.gui.tree.ActionsCache; 44 import org.w3c.dom.Element ; 45 50 public class TestSetKitAction extends TestSetAction { 51 52 private String kit; 53 54 public static final String KIT="Kit"; 55 56 public static String [] editorKitsNames={"PlainKit","JavaKit","HTMLKit"}; 57 public static String [] kitsTypes={PlainKit.PLAIN_MIME_TYPE, 58 JavaKit.JAVA_MIME_TYPE,HTMLKit.HTML_MIME_TYPE}; 59 60 61 62 public TestSetKitAction(int num) { 63 this("set"+Integer.toString(num)); 64 } 65 66 public TestSetKitAction(String name) { 67 super(name); 68 kit=editorKitsNames[0]; 69 } 70 71 public TestSetKitAction(Element node) { 72 super(node); 73 kit = node.getAttribute(KIT); 74 } 75 76 public Element toXML(Element node) { 77 node = super.toXML(node); 78 79 node.setAttribute(KIT, kit); 80 return node; 81 } 82 83 public void fromXML(Element node) throws BadPropertyNameException { 84 super.fromXML(node); 85 kit = node.getAttribute(KIT); 86 } 87 88 public Properties getProperties() { 89 Properties ret=super.getProperties(); 90 ret.put(KIT, new ArrayProperty(kit, editorKitsNames)); 91 return ret; 92 } 93 94 public Object getProperty(String name) throws BadPropertyNameException { 95 if (name.compareTo(KIT) == 0) { 96 return new ArrayProperty(kit, editorKitsNames); 97 } else { 98 return super.getProperty(name); 99 } 100 } 101 102 public void setProperty(String name, Object value) throws BadPropertyNameException { 103 if (name.compareTo(KIT) == 0) { 104 setKit(((ArrayProperty)value).getProperty()); 105 } else { 106 super.setProperty(name, value); 107 } 108 } 109 110 public void setKit(String value) { 111 String oldValue = kit; 112 kit = value; 113 firePropertyChange(KIT, oldValue, kit); 114 } 115 116 public String getKit() { 117 return kit; 118 } 119 120 public int getKitI() { 121 for (int i=0;i < editorKitsNames.length;i++) { 122 if (kit.compareTo(editorKitsNames[i]) == 0) { 123 return i; 124 } 125 } 126 return 0; 127 } 128 129 public String [] getKits() { 130 return editorKitsNames; 131 } 132 133 public void perform() { 134 super.perform(); 135 try { 136 SwingUtilities.invokeAndWait(new Runnable () { 137 public void run() { 138 Main.frame.getEditor().setEditorKit(getKitI()); 139 } 140 }); 141 } catch (Exception e) { 142 e.printStackTrace(System.err); 143 } 144 } 145 146 public void stop() { 147 } 148 } 149 | Popular Tags |