com.borland.primetime.editor
Class TextEditorKit

java.lang.Object
  |
  +--javax.swing.text.EditorKit
        |
        +--javax.swing.text.DefaultEditorKit
              |
              +--com.borland.primetime.editor.TextEditorKit

public class TextEditorKit
extends javax.swing.text.DefaultEditorKit

This is the base editor kit that the PrimeTime text editor is going to use. It defines which view and document types will be used, and also controls how to read and write to a document.

In addition, a TextEditorKit defines a StyleMap and Scanner implementation to be used when this editor kit is in effect.

Note that we do not use any of the Action objects defined in the superclass, DefaultEditorKit, because they do not do targetting properly. Instead, we use the Actions from BaseEditorActions and EditorActions.

See Also:
BaseEditorActions, EditorActions, DefaultEditorKit, Serialized Form

Inner classes inherited from class javax.swing.text.DefaultEditorKit
javax.swing.text.DefaultEditorKit.BeepAction, javax.swing.text.DefaultEditorKit.CopyAction, javax.swing.text.DefaultEditorKit.CutAction, javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction, javax.swing.text.DefaultEditorKit.InsertBreakAction, javax.swing.text.DefaultEditorKit.InsertContentAction, javax.swing.text.DefaultEditorKit.InsertTabAction, javax.swing.text.DefaultEditorKit.PasteAction
 
Field Summary
static java.lang.String EndOfLineStringProperty
          When reading a document if a CRLF is encountered a property with this name is added and the value will be "\r\n".
protected  java.util.Map registeredKeymaps
           
protected  BasicStyleMap styleMap
           
 
Fields inherited from class javax.swing.text.DefaultEditorKit
backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deletePrevCharAction, downAction, endAction, endLineAction, EndOfLineStringProperty, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, selectLineAction, selectParagraphAction, selectWordAction, upAction, writableAction
 
Constructor Summary
TextEditorKit()
           
 
Method Summary
 java.lang.Object clone()
          Create a copy of the editor kit.
 javax.swing.text.Caret createCaret()
          Fetches a caret that can navigate through views produced by the associated ViewFactory.
 javax.swing.text.Document createDefaultDocument()
          Creates an uninitialized text storage model that is appropriate for this type of editor.
 Scanner createScanner()
          Create an instance of the appropriate Scanner class to use with this kit.
 javax.swing.Action[] getActions()
           
 java.lang.String getContentType()
          Get the MIME type of the data that this kit represents support for.
 javax.swing.text.Keymap getKeymap(java.lang.String keymapName)
          Retrieve a keymap by name.
 BasicStyleMap getStyleMap()
          Return the StyleMap to use when rendering Documents created with this kit.
 javax.swing.text.ViewFactory getViewFactory()
          Fetches a factory that is suitable for producing views of any models that are produced by this kit.
static void initOpenTool(byte majorVersion, byte minorVersion)
           
 void install(javax.swing.JEditorPane c)
          Called when the kit is being installed into a JEditorPane.
 void read(java.io.InputStream in, javax.swing.text.Document doc, int pos)
          Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler.
 void read(java.io.Reader in, javax.swing.text.Document doc, int pos)
          Inserts content from the given stream, which will be treated as plain text.
 void registerKeymap(javax.swing.text.Keymap keymap)
          Register a keymap.
 void write(java.io.OutputStream out, javax.swing.text.Document doc, int pos, int len)
          Writes content from a document to the given stream in a format appropriate for this kind of content handler.
 void write(java.io.Writer out, javax.swing.text.Document doc, int pos, int len)
          Writes content from a document to the given stream as plain text.
 
Methods inherited from class javax.swing.text.EditorKit
deinstall
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registeredKeymaps

protected java.util.Map registeredKeymaps

styleMap

protected BasicStyleMap styleMap

EndOfLineStringProperty

public static final java.lang.String EndOfLineStringProperty
When reading a document if a CRLF is encountered a property with this name is added and the value will be "\r\n".
Constructor Detail

TextEditorKit

public TextEditorKit()
Method Detail

initOpenTool

public static void initOpenTool(byte majorVersion,
                                byte minorVersion)

createScanner

public Scanner createScanner()
Create an instance of the appropriate Scanner class to use with this kit.

Note that the default implementation returns a static instance of the NullScanner, which is OK since the NullScanner does nothing. Subclasses that have actual scanners should create a new instance here.

Returns:
A Scanner instance appropriate for documents of this class.

getStyleMap

public BasicStyleMap getStyleMap()
Return the StyleMap to use when rendering Documents created with this kit.

registerKeymap

public void registerKeymap(javax.swing.text.Keymap keymap)
Register a keymap. Keymaps are stored in a map and retrieved using their name as the key.
Parameters:
kit - The TextEditorKit to register.
See Also:
#getEditorKit

getKeymap

public javax.swing.text.Keymap getKeymap(java.lang.String keymapName)
Retrieve a keymap by name.
Parameters:
keymapName - The name of the Keymap being retrieved.
See Also:
registerKeymap(javax.swing.text.Keymap)

install

public void install(javax.swing.JEditorPane c)
Called when the kit is being installed into a JEditorPane.
Overrides:
install in class javax.swing.text.EditorKit
Parameters:
c - the JEditorPane

getContentType

public java.lang.String getContentType()
Get the MIME type of the data that this kit represents support for. This kit supports the type text/java.
Overrides:
getContentType in class javax.swing.text.DefaultEditorKit

clone

public java.lang.Object clone()
Create a copy of the editor kit. This allows an implementation to serve as a prototype for others, so that they can be quickly created.
Overrides:
clone in class javax.swing.text.DefaultEditorKit

createDefaultDocument

public javax.swing.text.Document createDefaultDocument()
Creates an uninitialized text storage model that is appropriate for this type of editor. This method sets the scanner class to the appropriate type for this kit.

The PrimeTime EditorKit classes always return an instance of EditorDocument.

Overrides:
createDefaultDocument in class javax.swing.text.DefaultEditorKit
Returns:
the Document

getViewFactory

public final javax.swing.text.ViewFactory getViewFactory()
Fetches a factory that is suitable for producing views of any models that are produced by this kit.

The PrimeTime EditorKit classes always return a ViewFactory that creates a EditorView.

Overrides:
getViewFactory in class javax.swing.text.DefaultEditorKit
Returns:
the view factory

createCaret

public javax.swing.text.Caret createCaret()
Fetches a caret that can navigate through views produced by the associated ViewFactory.
Overrides:
createCaret in class javax.swing.text.DefaultEditorKit
Returns:
the caret

read

public void read(java.io.InputStream in,
                 javax.swing.text.Document doc,
                 int pos)
          throws java.io.IOException,
                 javax.swing.text.BadLocationException
Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler.
Overrides:
read in class javax.swing.text.DefaultEditorKit
Parameters:
in - The stream to read from
doc - The destination for the insertion.
pos - The location in the document to place the content >= 0.
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException - if pos represents an invalid location within the document.

write

public void write(java.io.OutputStream out,
                  javax.swing.text.Document doc,
                  int pos,
                  int len)
           throws java.io.IOException,
                  javax.swing.text.BadLocationException
Writes content from a document to the given stream in a format appropriate for this kind of content handler.
Overrides:
write in class javax.swing.text.DefaultEditorKit
Parameters:
out - The stream to write to
doc - The source for the write.
pos - The location in the document to fetch the content >= 0.
len - The amount to write out >= 0.
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException - if pos represents an invalid location within the document.

read

public void read(java.io.Reader in,
                 javax.swing.text.Document doc,
                 int pos)
          throws java.io.IOException,
                 javax.swing.text.BadLocationException
Inserts content from the given stream, which will be treated as plain text.
Overrides:
read in class javax.swing.text.DefaultEditorKit
Parameters:
in - The stream to read from
doc - The destination for the insertion.
pos - The location in the document to place the content >= 0.
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException - if pos represents an invalid location within the document.

write

public void write(java.io.Writer out,
                  javax.swing.text.Document doc,
                  int pos,
                  int len)
           throws java.io.IOException,
                  javax.swing.text.BadLocationException
Writes content from a document to the given stream as plain text.
Overrides:
write in class javax.swing.text.DefaultEditorKit
Parameters:
out - The stream to write to
doc - The source for the write.
pos - The location in the document to fetch the content from >= 0.
len - The amount to write out >= 0.
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException - if pos is not within 0 and the length of the document.

getActions

public javax.swing.Action[] getActions()
Overrides:
getActions in class javax.swing.text.DefaultEditorKit