com.japisoft.sc
Class ScEditorKit

java.lang.Object
  |
  +--javax.swing.text.EditorKit
        |
        +--javax.swing.text.DefaultEditorKit
              |
              +--com.japisoft.sc.ScEditorKit
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class ScEditorKit
extends javax.swing.text.DefaultEditorKit

The SyntaxColor JAPISOFT editorKit. Usage sample :

 ScEditorKit sc = new ScEditorKit();
 sc.readSyntaxColorDescriptor( "sql.prop" );
 JEditorPane myEditor = new JEditorPane();
 myEditor.setEditorKit( sc );
 

Here a property file sample

  Properties p = new Properties();
  p.setProperty( "token_toto","print:goto" );
  p.setProperty( "color_toto","red" );
  p.setProperty( "token_titi","[\";\"]" );
  p.setProperty( "color_titi","10:40:50" );
  p.setProperty( "border_toto", "true" );
  p.setProperty( "ignoreCase", "true" );
  ScEditorKit sc = new ScEditorKit();
  sc.setSyntaxColorDescriptor( p );
 

This is equals to the following property file myLanguage.prop

 token_toto=print:goto
 color_toto=red
 token_titi=[";"]
 color_titi=10:40:50
 border_toto=true
 ignoreCase=true
 

 ScEditorKit sc = new ScEditorKit();
 sc.readSyntaxColorDescriptor( "myLanguage.prop" );
 
The property file is read both by searching on the current classpath and on the file system. For sample, "myLanguage.prop" is loaded searching on the current application classpath and finally search on the current path

Author:
(c) 2002-2003 JAPISOFT
See Also:
Serialized Form

Field Summary
 
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
ScEditorKit()
           
ScEditorKit(java.util.Properties propertyFile)
          Use this property file describing the syntax attributes
ScEditorKit(java.lang.String propertyFile)
          Read the property file describing the syntax attributes
 
Method Summary
 javax.swing.text.Document createDefaultDocument()
          Build a default PlainDocument
 SyntaxFileMapper getSyntaxFileMapper()
           
 javax.swing.text.ViewFactory getViewFactory()
           
 void readSyntaxColorDescriptor(java.lang.String propertyFile)
          Read a syntax color table.
 void setSyntaxColorDescriptor(java.util.Properties p)
          Reset the syntax color descriptor
 
Methods inherited from class javax.swing.text.DefaultEditorKit
createCaret, getActions, getContentType, read, read, write, write
 
Methods inherited from class javax.swing.text.EditorKit
clone, deinstall, install
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScEditorKit

public ScEditorKit()

ScEditorKit

public ScEditorKit(java.lang.String propertyFile)
            throws java.io.FileNotFoundException
Read the property file describing the syntax attributes


ScEditorKit

public ScEditorKit(java.util.Properties propertyFile)
Use this property file describing the syntax attributes

Method Detail

createDefaultDocument

public javax.swing.text.Document createDefaultDocument()
Build a default PlainDocument

Overrides:
createDefaultDocument in class javax.swing.text.DefaultEditorKit

getSyntaxFileMapper

public SyntaxFileMapper getSyntaxFileMapper()
Returns:
a tool for making a relation between a syntax descriptor and a loaded file extension

readSyntaxColorDescriptor

public void readSyntaxColorDescriptor(java.lang.String propertyFile)
                               throws java.io.FileNotFoundException
Read a syntax color table. This property file contains all data for parsing the document and showing syntax color. This file is read with two methods, by the classLoader or if this file is not found by a full path.

Throws:
java.io.FileNotFoundException - will be thrown for unknown file
java.lang.RuntimeException - will be thrown for invalid format

setSyntaxColorDescriptor

public void setSyntaxColorDescriptor(java.util.Properties p)
Reset the syntax color descriptor


getViewFactory

public javax.swing.text.ViewFactory getViewFactory()
Overrides:
getViewFactory in class javax.swing.text.DefaultEditorKit