Class RSyntaxTextAreaEditorKit.DecreaseIndentAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
    Enclosing class:
    RSyntaxTextAreaEditorKit

    public static class RSyntaxTextAreaEditorKit.DecreaseIndentAction
    extends RecordableTextAction
    Action for when un-indenting lines (either the current line if there is selection, or all selected lines if there is one).
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.swing.text.Segment s  
      private static long serialVersionUID  
      • Fields inherited from class javax.swing.AbstractAction

        changeSupport, enabled
      • Fields inherited from interface javax.swing.Action

        ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformedImpl​(java.awt.event.ActionEvent e, RTextArea textArea)
      The actual meat of the action.
      java.lang.String getMacroID()
      Returns the identifier for this macro.
      private void handleDecreaseIndent​(javax.swing.text.Element elem, javax.swing.text.Document doc, int tabSize)
      Actually does the "de-indentation." This method finds where the given element's leading whitespace ends, then, if there is indeed leading whitespace, removes either the last char in it (if it is a tab), or removes up to the number of spaces equal to a tab in the specified document (i.e., if the tab size was 5 and there were 3 spaces at the end of the leading whitespace, the three will be removed; if there were 8 spaces, only the first 5 would be removed).
      • Methods inherited from class javax.swing.text.TextAction

        augmentList, getFocusedComponent, getTextComponent
      • Methods inherited from class javax.swing.AbstractAction

        addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.Action

        accept
    • Field Detail

      • s

        private javax.swing.text.Segment s
    • Constructor Detail

      • DecreaseIndentAction

        public DecreaseIndentAction()
      • DecreaseIndentAction

        public DecreaseIndentAction​(java.lang.String name)
    • Method Detail

      • getMacroID

        public final java.lang.String getMacroID()
        Description copied from class: RecordableTextAction
        Returns the identifier for this macro. This method makes it so that you can create an instance of the RTextAreaEditorKit.CutAction action, for example, rename it to "Remove", and it will still be recorded as a "cut" action. Subclasses should return a unique string from this method; preferably the name of the action.

        If you subclass a RecordableTextAction, you should NOT override this method; if you do, the action may not be properly recorded in a macro.

        Specified by:
        getMacroID in class RecordableTextAction
        Returns:
        The internally-used macro ID.
      • handleDecreaseIndent

        private void handleDecreaseIndent​(javax.swing.text.Element elem,
                                          javax.swing.text.Document doc,
                                          int tabSize)
                                   throws javax.swing.text.BadLocationException
        Actually does the "de-indentation." This method finds where the given element's leading whitespace ends, then, if there is indeed leading whitespace, removes either the last char in it (if it is a tab), or removes up to the number of spaces equal to a tab in the specified document (i.e., if the tab size was 5 and there were 3 spaces at the end of the leading whitespace, the three will be removed; if there were 8 spaces, only the first 5 would be removed).
        Parameters:
        elem - The element to "de-indent."
        doc - The document containing the specified element.
        tabSize - The size of a tab, in spaces.
        Throws:
        javax.swing.text.BadLocationException