KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > css > editor > CssEditorKit


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * CssEditorKit.java
22  *
23  * Created on December 9, 2004, 5:02 PM
24  */

25
26 package org.netbeans.modules.css.editor;
27
28 import org.netbeans.modules.css.actions.CssRuleCreateAction;
29 import java.awt.Component JavaDoc;
30 import javax.swing.Action JavaDoc;
31 import javax.swing.JEditorPane JavaDoc;
32 import javax.swing.text.Document JavaDoc;
33 import javax.swing.text.TextAction JavaDoc;
34 import org.netbeans.modules.editor.NbEditorDocument;
35 import org.netbeans.modules.languages.dataobject.LanguagesEditorKit;
36
37 /**
38  * Editor kit implementation for a document of content type "text/css"
39  * @author Winston Prakash
40  * @version 1.0
41  */

42 public class CssEditorKit extends LanguagesEditorKit {
43
44     public static final String JavaDoc CSS_MIME_TYPE = "text/x-css"; // NOI18N
45

46     public static final String JavaDoc createRuleAction = "create-rule"; // NOI18N
47

48     /** Creates a new instance of CssEditorKit */
49     public CssEditorKit() {
50         super(CSS_MIME_TYPE);
51     }
52
53     public Document JavaDoc createDefaultDocument() {
54         Document JavaDoc doc = new NbEditorDocument(getClass()){
55             public Component JavaDoc createEditor(JEditorPane JavaDoc editorPane) {
56                 return new CssCustomEditor(editorPane);
57             }
58         };
59         schliemanizeDocument(doc); //schliemann hack
60
return doc;
61     }
62
63     /**
64      * Get the content type supported by this editor
65      */

66     public String JavaDoc getContentType() {
67         return CSS_MIME_TYPE;
68     }
69
70     protected Action[] createActions() {
71         Action[] cssEditorActions = new Action[] {
72             new CssRuleCreateAction()
73         };
74         return TextAction.augmentList(super.createActions(), cssEditorActions);
75     }
76     
77     public Object JavaDoc clone () {
78         return new CssEditorKit ();
79     }
80 }
81
Popular Tags