001: /*
002: * Copyright (C) 2005 Jeff Tassin
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package com.jeta.swingbuilder.codegen.gui.editor;
020:
021: import javax.swing.Action;
022: import javax.swing.text.Document;
023:
024: import org.netbeans.editor.BaseDocument;
025: import org.netbeans.editor.EditorUI;
026: import org.netbeans.editor.Formatter;
027: import org.netbeans.editor.MultiKeyBinding;
028: import org.netbeans.editor.Settings;
029: import org.netbeans.editor.Syntax;
030: import org.netbeans.editor.SyntaxSupport;
031: import org.netbeans.editor.ext.Completion;
032: import org.netbeans.editor.ext.ExtEditorUI;
033: import org.netbeans.editor.ext.ExtKit;
034: import org.netbeans.editor.ext.java.JavaCompletion;
035: import org.netbeans.editor.ext.java.JavaFormatter;
036: import org.netbeans.editor.ext.java.JavaSettingsInitializer;
037: import org.netbeans.editor.ext.java.JavaSyntax;
038: import org.netbeans.editor.ext.java.JavaSyntaxSupport;
039:
040: /**
041: * Java editor kit with appropriate document
042: *
043: * @author Jeff Tassin
044: */
045:
046: public class JavaKit extends ExtKit {
047:
048: static {
049: try {
050: javax.swing.JEditorPane.registerEditorKitForContentType(
051: "text/x-java", "JavaKit", JavaKit.class
052: .getClassLoader());
053: Settings.addInitializer(new JavaSettingsInitializer(
054: JavaKit.class));
055: Settings.reset();
056: } catch (Exception e) {
057: e.printStackTrace();
058: }
059: }
060:
061: /**
062: * ctor
063: */
064: public JavaKit() {
065:
066: }
067:
068: public String getContentType() {
069: return "text/x-java";
070: }
071:
072: /**
073: * Create new instance of syntax coloring scanner
074: *
075: * @param doc
076: * document to operate on. It can be null in the cases the syntax
077: * creation is not related to the particular document
078: */
079: public Syntax createSyntax(Document doc) {
080: return new JavaSyntax();
081: }
082:
083: /** Create syntax support */
084: public SyntaxSupport createSyntaxSupport(BaseDocument doc) {
085: return new JavaSyntaxSupport(doc);
086: }
087:
088: public Completion createCompletion(ExtEditorUI extEditorUI) {
089: return new JavaCompletion(extEditorUI);
090: }
091:
092: /** Create the formatter appropriate for this kit */
093: public Formatter createFormatter() {
094: return new JavaFormatter(this .getClass());
095: }
096:
097: protected EditorUI createEditorUI() {
098: return new ExtEditorUI();
099: }
100:
101: /**
102: * List all actions supported by this class.
103: */
104: public static Action[] listDefaultActions() {
105: return new Action[0];
106: }
107:
108: /**
109: * Get the default bindings. We are using a different method for
110: * initializing default bindings than the netbeans callback method.
111: */
112: public static MultiKeyBinding[] listDefaultKeyBindings() {
113: MultiKeyBinding[] bindings = new MultiKeyBinding[0];
114: return bindings;
115: }
116: }
|