edu.rice.cs.drjava.model.definitions
Class DefinitionsEditorKit

java.lang.Object
  extended by javax.swing.text.EditorKit
      extended by javax.swing.text.DefaultEditorKit
          extended by javax.swing.text.StyledEditorKit
              extended by edu.rice.cs.drjava.model.definitions.DefinitionsEditorKit
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class DefinitionsEditorKit
extends javax.swing.text.StyledEditorKit

The editor kit class for editing Java source files. It functions as the controller in an MVC hierarchy. It also implements a factory for new documents and a factory for Views (the things that render the document). May only be used as the EditorKit for panes extending AbstractDJPane. In fact, only used as the EditorKit for DefintionsPanes. Stored as a field of DefinitionsPane.

Version:
$Id: DefinitionsEditorKit.java 5439 2011-08-11 17:13:04Z rcartwright $
See Also:
Serialized Form

Nested Class Summary
(package private) static class DefinitionsEditorKit.BeginWordAction
          Brings the cursor to the beginning of the current word separated by whitespace or a delimiting character.
(package private) static class DefinitionsEditorKit.EndWordAction
          Sets the cursor at the end of the current word separated by whitespace or a delimiting character.
(package private) static class DefinitionsEditorKit.NextWordAction
          Moves the cursor from the current word to the beginning of the next word, stopping at delimiting characters and at the end of a line
(package private) static class DefinitionsEditorKit.PreviousWordAction
          Moves the cursor to the beginning of the previous word.
(package private) static class DefinitionsEditorKit.SelectWordAction
          Defines the action for word selection as in when double-clicking a word.
 
Nested classes/interfaces inherited from class javax.swing.text.StyledEditorKit
javax.swing.text.StyledEditorKit.AlignmentAction, javax.swing.text.StyledEditorKit.BoldAction, javax.swing.text.StyledEditorKit.FontFamilyAction, javax.swing.text.StyledEditorKit.FontSizeAction, javax.swing.text.StyledEditorKit.ForegroundAction, javax.swing.text.StyledEditorKit.ItalicAction, javax.swing.text.StyledEditorKit.StyledTextAction, javax.swing.text.StyledEditorKit.UnderlineAction
 
Nested classes/interfaces 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
private  javax.swing.Action[] _actions
           
private static javax.swing.text.ViewFactory _factory
           
private  GlobalEventNotifier _notifier
           
static java.lang.String DELIMITERS
           
 
Fields inherited from class javax.swing.text.DefaultEditorKit
backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deleteNextWordAction, deletePrevCharAction, deletePrevWordAction, 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
DefinitionsEditorKit(GlobalEventNotifier notifier)
          Creates a new editor kit with the given listeners.
 
Method Summary
private  DefinitionsDocument _createDefaultTypedDocument()
          Creates a new DefinitionsDocument.
 DefinitionsDocument createNewDocument()
          Creates a new DefinitionsDocument.
 javax.swing.Action[] getActions()
           
 java.lang.String getContentType()
          Get the MIME content type of the document
 javax.swing.text.ViewFactory getViewFactory()
          We want to use our ColoringView to render text, so here we return a factory that creates ColoringViews.
 
Methods inherited from class javax.swing.text.StyledEditorKit
clone, createDefaultDocument, createInputAttributes, deinstall, getCharacterAttributeRun, getInputAttributes, install
 
Methods inherited from class javax.swing.text.DefaultEditorKit
createCaret, read, read, write, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELIMITERS

public static final java.lang.String DELIMITERS
See Also:
Constant Field Values

_notifier

private GlobalEventNotifier _notifier

_actions

private javax.swing.Action[] _actions

_factory

private static javax.swing.text.ViewFactory _factory
Constructor Detail

DefinitionsEditorKit

public DefinitionsEditorKit(GlobalEventNotifier notifier)
Creates a new editor kit with the given listeners.

Parameters:
notifier - Keeps track of the listeners to the model
Method Detail

getActions

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

createNewDocument

public DefinitionsDocument createNewDocument()
Creates a new DefinitionsDocument. Formerly named createDefaultDocument() because the view (DefinitionsPane) would create a DefinitionsDocument by default when it was constructed. However, this default document was immediately discarded because a DefinitionsDocument for the constructed DefinitionsPane already existed. Unfortunately, JEditorPane does not have a constructor that takes a Document as input. We conceivably could design this EditorKit to return the pre-existing document when the JEditorPane requests a new one, but the EditorKit is specified by a static field of DefinitionsPane so there is no clean way to install the proper EditorKit before the JEditorPane constructor asks for the Document. As an easier alternative, we just let the DefaultEditorKit return a PlainDocument (much lighter weight), which is thrown away when the true DefinitionsDocument is assigned Improvements to this approach are welcome... :)


_createDefaultTypedDocument

private DefinitionsDocument _createDefaultTypedDocument()
Creates a new DefinitionsDocument.

Returns:
a new DefinitionsDocument.

getContentType

public java.lang.String getContentType()
Get the MIME content type of the document

Overrides:
getContentType in class javax.swing.text.DefaultEditorKit
Returns:
"text/java"

getViewFactory

public final javax.swing.text.ViewFactory getViewFactory()
We want to use our ColoringView to render text, so here we return a factory that creates ColoringViews.

Overrides:
getViewFactory in class javax.swing.text.StyledEditorKit