Package edu.wisc.ssec.mcidasv.ui
Class JythonEditor
java.lang.Object
edu.wisc.ssec.mcidasv.ui.JythonEditor
- All Implemented Interfaces:
EventListener
,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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private final org.fife.ui.rtextarea.RTextScrollPane
Scroll pane fortextArea
.private final JythonEditor.McvJythonTextArea
Text area that contains the syntax-highlighted text.private final UndoManager
Undo manager. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given undoable edit listener totextArea
.void
copy()
Copies selected text into system clipboard.Returns the defaultJPopupMenu
created byRSyntaxTextArea.createPopupMenu()
.Returns the component (aka "the gutter" that contains optional information like line numbers.Returns theJScrollPane
that containstextArea
.getText()
Returns a string containing the text oftextArea
.Returns the text area responsible for syntax highlighting.void
insertText
(String textToInsert) Insert the given text at the caret.boolean
Whether or not changes can be made totextArea
.void
Remove the given undoable edit listener fromtextArea
.void
setEnabled
(boolean enabled) Controls whether or not changes can be made to the contents oftextArea
.void
Sets the text of this document to the givenString
.void
Handles undoable edits
-
Field Details
-
logger
-
textArea
Text area that contains the syntax-highlighted text. -
scrollPane
Scroll pane fortextArea
. -
undo
Undo manager.
-
-
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 theJScrollPane
that containstextArea
.- Returns:
JScrollPane
with the text area. Suitable for adding to aJPanel
.
-
setText
Sets the text of this document to the givenString
.- Parameters:
text
- New text to use intextArea
.
-
getText
Returns a string containing the text oftextArea
.- Returns:
- The current contents of the text area.
-
setEnabled
Controls whether or not changes can be made to the contents oftextArea
.- 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
Copies selected text into system clipboard. -
isEnabled
Whether or not changes can be made totextArea
.- Returns:
true
if changes are allowed,false
otherwise.
-
insertText
Insert the given text at the caret.- Parameters:
textToInsert
- Text to insert.
-
undoableEditHappened
Handles undoable edits- Specified by:
undoableEditHappened
in interfaceUndoableEditListener
- Parameters:
e
- Event that represents the undoable edit.
-
addUndoableEditListener
Adds the given undoable edit listener totextArea
.- Parameters:
l
- Listener to add.
-
removeUndoableEditListener
Remove the given undoable edit listener fromtextArea
.- Parameters:
l
- Listener to remove.
-
createPopupMenu
Returns the defaultJPopupMenu
created byRSyntaxTextArea.createPopupMenu()
.- Returns:
- Popup menu.
-