Class JythonEditor

java.lang.Object
edu.wisc.ssec.mcidasv.ui.JythonEditor
All Implemented Interfaces:
EventListener, UndoableEditListener

public class JythonEditor extends Object implements UndoableEditListener
A bare-bones text editor that can do relatively robust syntax highlighting of Jython code.

This class relies very heavily upon the wonderful RSyntaxTextArea project.

  • Field Details

  • Constructor Details

    • JythonEditor

      public JythonEditor()
      Creates a new JythonEditor.
  • Method Details

    • getTextComponent

      Returns the text area responsible for syntax highlighting.
      Returns:
      Reference to textArea.
    • getScrollPane

      Returns the JScrollPane that contains textArea.
      Returns:
      JScrollPane with the text area. Suitable for adding to a JPanel.
    • setText

      public void setText(String text)
      Sets the text of this document to the given String.
      Parameters:
      text - New text to use in textArea.
    • getText

      public String getText()
      Returns a string containing the text of textArea.
      Returns:
      The current contents of the text area.
    • setEnabled

      public void setEnabled(boolean enabled)
      Controls whether or not changes can be made to the contents of textArea.
      Parameters:
      enabled - true if the editor should be enabled, false otherwise.
    • getLineNumberComponent

      Returns the component (aka "the gutter" that contains optional information like line numbers.
      Returns:
      JPanel that contains the line numbers.
    • copy

      public void copy()
      Copies selected text into system clipboard.
    • isEnabled

      public boolean isEnabled()
      Whether or not changes can be made to textArea.
      Returns:
      true if changes are allowed, false otherwise.
    • insertText

      public void insertText(String textToInsert)
      Insert the given text at the caret.
      Parameters:
      textToInsert - Text to insert.
    • undoableEditHappened

      Handles undoable edits
      Specified by:
      undoableEditHappened in interface UndoableEditListener
      Parameters:
      e - Event that represents the undoable edit.
    • addUndoableEditListener

      Adds the given undoable edit listener to textArea.
      Parameters:
      l - Listener to add.
    • removeUndoableEditListener

      Remove the given undoable edit listener from textArea.
      Parameters:
      l - Listener to remove.
    • createPopupMenu

      Returns the default JPopupMenu created by RSyntaxTextArea.createPopupMenu().
      Returns:
      Popup menu.