Package jsyntaxpane

Class DefaultSyntaxKit

    • Nested Class Summary

      • 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

      Fields 
      Modifier and Type Field Description
      static java.lang.String CONFIG_CARETCOLOR  
      static java.lang.String CONFIG_COMPONENTS  
      static java.lang.String CONFIG_MENU  
      static java.lang.String CONFIG_SELECTION  
      static java.lang.String CONFIG_TOOLBAR  
      static java.lang.String CONFIG_TOOLBAR_BORDER  
      static java.lang.String CONFIG_TOOLBAR_BORDER_SIZE  
      static java.lang.String CONFIG_TOOLBAR_OPAQUE  
      static java.lang.String CONFIG_TOOLBAR_ROLLOVER  
      • 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

      Constructors 
      Constructor Description
      DefaultSyntaxKit​(Lexer lexer)
      Create a new Kit for the given language
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void addAbbreviation​(java.lang.String abbr, java.lang.String template)
      Adds an abbrevisation to this kit's abbreviations.
      void addActions​(javax.swing.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.
      void addComponents​(javax.swing.JEditorPane editorPane)
      Adds UI components to the pane
      void addPopupMenu​(javax.swing.JEditorPane editorPane)
      Adds a popup menu to the editorPane if needed.
      void addToolBarActions​(javax.swing.JEditorPane editorPane, javax.swing.JToolBar toolbar)
      Add all pop-up menu items to a Toolbar.
      javax.swing.text.View create​(javax.swing.text.Element element)  
      javax.swing.text.Document 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.
      void deinstall​(javax.swing.JEditorPane editorPane)  
      void deinstallComponent​(javax.swing.JEditorPane pane, java.lang.String classname)
      Find the SyntaxCOmponent with given classname that is installed on the given pane, then deinstalls and removes it fom the editorComponents list
      static java.lang.String getAbbreviation​(java.lang.String abbr)
      Get the template for the given abbreviation
      java.util.Map<java.lang.String,​java.lang.String> getAbbreviations()  
      Configuration getConfig()
      Get the configuration for this Object
      static Configuration getConfig​(java.lang.Class<? extends DefaultSyntaxKit> kit)
      Return the Configurations object for a Kit.
      java.lang.String getContentType()  
      static java.lang.String[] getContentTypes()
      Return all the content types supported by this library.
      java.lang.String getProperty​(java.lang.String key)
      Return the property with the given key.
      javax.swing.text.ViewFactory getViewFactory()  
      static void initKit()
      This is called to initialize the list of Lexers we have.
      void install​(javax.swing.JEditorPane editorPane)
      Install the View on the given EditorPane.
      void installComponent​(javax.swing.JEditorPane pane, java.lang.String classname)
      Creates a SyntaxComponent of the the given classname and installs it on the pane
      boolean isComponentInstalled​(javax.swing.JEditorPane pane, java.lang.String classname)
      Checks if the component with given classname is installed on the pane.
      static void registerContentType​(java.lang.String type, java.lang.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.
      void setConfig​(java.util.Properties config)
      Merges the given properties with the configurations for this Object
      void setProperty​(java.lang.String key, java.lang.String value)
      Sets the given property to the given value.
      boolean toggleComponent​(javax.swing.JEditorPane pane, java.lang.String classname)
      Toggles the component with given classname.
      • Methods inherited from class javax.swing.text.DefaultEditorKit

        createCaret, getActions, read, read, write, write
      • Methods inherited from class javax.swing.text.EditorKit

        clone
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultSyntaxKit

        public DefaultSyntaxKit​(Lexer lexer)
        Create a new Kit for the given language
        Parameters:
        lexer -
    • Method Detail

      • addComponents

        public void addComponents​(javax.swing.JEditorPane editorPane)
        Adds UI components to the pane
        Parameters:
        editorPane -
      • installComponent

        public void installComponent​(javax.swing.JEditorPane pane,
                                     java.lang.String classname)
        Creates a SyntaxComponent of the the given classname and installs it on the pane
        Parameters:
        pane -
        classname -
      • deinstallComponent

        public void deinstallComponent​(javax.swing.JEditorPane pane,
                                       java.lang.String classname)
        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

        public boolean isComponentInstalled​(javax.swing.JEditorPane pane,
                                            java.lang.String classname)
        Checks if the component with given classname is installed on the pane.
        Parameters:
        pane -
        classname -
        Returns:
        true if component is installed, false otherwise
      • toggleComponent

        public boolean toggleComponent​(javax.swing.JEditorPane pane,
                                       java.lang.String classname)
        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

        public void addPopupMenu​(javax.swing.JEditorPane editorPane)
        Adds a popup menu to the editorPane if needed.
        Parameters:
        editorPane -
      • addToolBarActions

        public void addToolBarActions​(javax.swing.JEditorPane editorPane,
                                      javax.swing.JToolBar toolbar)
        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

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

        public javax.swing.text.View create​(javax.swing.text.Element element)
        Specified by:
        create in interface javax.swing.text.ViewFactory
      • install

        public void install​(javax.swing.JEditorPane editorPane)
        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.
        Overrides:
        install in class javax.swing.text.EditorKit
        Parameters:
        editorPane -
      • deinstall

        public void deinstall​(javax.swing.JEditorPane editorPane)
        Overrides:
        deinstall in class javax.swing.text.EditorKit
      • addActions

        public void addActions​(javax.swing.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.
        Parameters:
        editorPane -
      • createDefaultDocument

        public javax.swing.text.Document 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:
        createDefaultDocument in class javax.swing.text.DefaultEditorKit
        Returns:
      • initKit

        public static void initKit()
        This is called to initialize the list of Lexers 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

        public static void registerContentType​(java.lang.String type,
                                               java.lang.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. This is needed so that the SyntaxPane library has it's own registration of all the EditorKits
        Parameters:
        type -
        classname -
      • getContentTypes

        public static java.lang.String[] 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

        public void setConfig​(java.util.Properties config)
        Merges the given properties with the configurations for this Object
        Parameters:
        config -
      • setProperty

        public void setProperty​(java.lang.String key,
                                java.lang.String value)
        Sets the given property to the given value. If the kit is not initialized, then calls initKit
        Parameters:
        key -
        value -
      • getProperty

        public java.lang.String getProperty​(java.lang.String key)
        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

        public Configuration getConfig()
        Get the configuration for this Object
        Returns:
      • getConfig

        public static Configuration getConfig​(java.lang.Class<? extends DefaultSyntaxKit> kit)
        Return the Configurations object for a Kit. Perfrom lazy creation of a Configuration object if nothing is created.
        Parameters:
        kit -
        Returns:
      • getAbbreviations

        public java.util.Map<java.lang.String,​java.lang.String> getAbbreviations()
      • addAbbreviation

        public static void addAbbreviation​(java.lang.String abbr,
                                           java.lang.String template)
        Adds an abbrevisation to this kit's abbreviations.
        Parameters:
        abbr -
        template -
      • getAbbreviation

        public static java.lang.String getAbbreviation​(java.lang.String abbr)
        Get the template for the given abbreviation
        Parameters:
        abbr -
        Returns:
      • getContentType

        public java.lang.String getContentType()
        Overrides:
        getContentType in class javax.swing.text.DefaultEditorKit