Package jsyntaxpane
Class DefaultSyntaxKit
java.lang.Object
javax.swing.text.EditorKit
javax.swing.text.DefaultEditorKit
jsyntaxpane.DefaultSyntaxKit
- All Implemented Interfaces:
Serializable,Cloneable,ViewFactory
- Direct Known Subclasses:
BashSyntaxKit,ClojureSyntaxKit,CSyntaxKit,DOSBatchSyntaxKit,JavaRegexKit,JavaScriptSyntaxKit,JavaSyntaxKit,LuaSyntaxKit,PlainSyntaxKit,PropertiesSyntaxKit,PythonSyntaxKit,RubySyntaxKit,ScalaSyntaxKit,SqlSyntaxKit,TALSyntaxKit,XHTMLSyntaxKit,XmlSyntaxKit,XPathSyntaxKit
The DefaultSyntaxKit is the main entry to SyntaxPane. To use the package, just
set the EditorKit of the EditorPane to a new instance of this class.
You need to pass a proper lexer to the class.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.text.DefaultEditorKit
DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddAbbreviation(String abbr, String template) Adds an abbrevisation to this kit's abbreviations.voidaddActions(JEditorPane editorPane) Add keyboard actions to this control using the Configuration we have This is revised to properly use InputMap and ActionMap of the component instead of using the KeyMaps directly.voidaddComponents(JEditorPane editorPane) Adds UI components to the panevoidaddPopupMenu(JEditorPane editorPane) Adds a popup menu to the editorPane if needed.voidaddToolBarActions(JEditorPane editorPane, JToolBar toolbar) Add all pop-up menu items to a Toolbar.This is called by Swing to create a Document for the JEditorPane document This may be called before you actually get a reference to the control.voiddeinstall(JEditorPane editorPane) voiddeinstallComponent(JEditorPane pane, String classname) Find the SyntaxCOmponent with given classname that is installed on the given pane, then deinstalls and removes it fom the editorComponents liststatic StringgetAbbreviation(String abbr) Get the template for the given abbreviationGet the configuration for this Objectstatic ConfigurationgetConfig(Class<? extends DefaultSyntaxKit> kit) Return the Configurations object for a Kit.static String[]Return all the content types supported by this library.getProperty(String key) Return the property with the given key.static voidinitKit()This is called to initialize the list ofLexers we have.voidinstall(JEditorPane editorPane) Install the View on the given EditorPane.voidinstallComponent(JEditorPane pane, String classname) Creates a SyntaxComponent of the the given classname and installs it on the panebooleanisComponentInstalled(JEditorPane pane, String classname) Checks if the component with given classname is installed on the pane.static voidregisterContentType(String type, String classname) Register the given content type to use the given class name as its kit When this is called, an entry is added into the private HashMap of the registered editors kits.voidsetConfig(Properties config) Merges the given properties with the configurations for this ObjectvoidsetProperty(String key, String value) Sets the given property to the given value.booleantoggleComponent(JEditorPane pane, String classname) Toggles the component with given classname.Methods inherited from class javax.swing.text.DefaultEditorKit
createCaret, getActions, read, read, write, write
-
Field Details
-
CONFIG_CARETCOLOR
- See Also:
-
CONFIG_SELECTION
- See Also:
-
CONFIG_COMPONENTS
- See Also:
-
CONFIG_MENU
- See Also:
-
CONFIG_TOOLBAR
- See Also:
-
CONFIG_TOOLBAR_ROLLOVER
- See Also:
-
CONFIG_TOOLBAR_BORDER
- See Also:
-
CONFIG_TOOLBAR_OPAQUE
- See Also:
-
CONFIG_TOOLBAR_BORDER_SIZE
- See Also:
-
-
Constructor Details
-
DefaultSyntaxKit
Create a new Kit for the given language- Parameters:
lexer-
-
-
Method Details
-
addComponents
Adds UI components to the pane- Parameters:
editorPane-
-
installComponent
Creates a SyntaxComponent of the the given classname and installs it on the pane- Parameters:
pane-classname-
-
deinstallComponent
Find the SyntaxCOmponent with given classname that is installed on the given pane, then deinstalls and removes it fom the editorComponents list- Parameters:
pane-classname-
-
isComponentInstalled
Checks if the component with given classname is installed on the pane.- Parameters:
pane-classname-- Returns:
- true if component is installed, false otherwise
-
toggleComponent
Toggles the component with given classname. If component is found and installed, then it is deinstalled. Otherwise a new one is installed- Parameters:
pane-classname-- Returns:
- true if component was installed, false if it was removed
-
addPopupMenu
Adds a popup menu to the editorPane if needed.- Parameters:
editorPane-
-
addToolBarActions
Add all pop-up menu items to a Toolbar. You need to call the validate method on the toolbar after this is done to layout the buttons. Only Actions which have a SMALL_ICON property will be added to the toolbar There are three Configuration Keys that affect the appearance of the added buttons: CONFIG_TOOLBAR_ROLLOVER, CONFIG_TOOLBAR_BORDER, CONFIG_TOOLBAR_OPAQUE- Parameters:
editorPane-toolbar-
-
getViewFactory
- Overrides:
getViewFactoryin classDefaultEditorKit
-
create
- Specified by:
createin interfaceViewFactory
-
install
Install the View on the given EditorPane. This is called by Swing and can be used to do anything you need on the JEditorPane control. Here I set some default Actions. -
deinstall
-
addActions
Add keyboard actions to this control using the Configuration we have This is revised to properly use InputMap and ActionMap of the component instead of using the KeyMaps directly.- Parameters:
editorPane-
-
createDefaultDocument
This is called by Swing to create a Document for the JEditorPane document This may be called before you actually get a reference to the control. We use it here to create a proper lexer and pass it to the SyntaxDcument we return.- Overrides:
createDefaultDocumentin classDefaultEditorKit- Returns:
-
initKit
public static void initKit()This is called to initialize the list ofLexers we have. You can call this at initialization, or it will be called when needed. The method will also add the appropriate EditorKit classes to the corresponding ContentType of the JEditorPane. After this is called, you can simply call the editor.setCOntentType("text/java") on the control and you will be done. -
registerContentType
Register the given content type to use the given class name as its kit When this is called, an entry is added into the private HashMap of the registered editors kits. This is needed so that the SyntaxPane library has it's own registration of all the EditorKits- Parameters:
type-classname-
-
getContentTypes
Return all the content types supported by this library. This will be the content types in the file WEB-INF/services/resources/jsyntaxpane/kitsfortypes- Returns:
- sorted array of all registered content types
-
setConfig
Merges the given properties with the configurations for this Object- Parameters:
config-
-
setProperty
Sets the given property to the given value. If the kit is not initialized, then calls initKit- Parameters:
key-value-
-
getProperty
Return the property with the given key. If the kit is not initialized, then calls initKit Be careful when changing property as the default property may be used- Parameters:
key-- Returns:
- value for given key
-
getConfig
Get the configuration for this Object- Returns:
-
getConfig
Return the Configurations object for a Kit. Perfrom lazy creation of a Configuration object if nothing is created.- Parameters:
kit-- Returns:
-
getAbbreviations
-
addAbbreviation
Adds an abbrevisation to this kit's abbreviations.- Parameters:
abbr-template-
-
getAbbreviation
Get the template for the given abbreviation- Parameters:
abbr-- Returns:
-
getContentType
- Overrides:
getContentTypein classDefaultEditorKit
-