public class TextEditorPane extends RSyntaxTextArea implements javax.swing.event.DocumentListener
RSyntaxTextArea
that adds information about the file being edited, such as:
When saving UTF-8 files, whether or not a BOM is written is controlled by
the UnicodeWriter
class.
Use UnicodeWriter.setWriteUtf8BOM(boolean)
to toggle writing BOMs
for UTF-8 files.
Both local and remote files (e.g. ftp) are supported. See the
FileLocation
class for more information.
FileLocation
,
Serialized FormRTextArea.RTextAreaMutableCaretEvent
RTextAreaBase.RTAMouseListener
javax.swing.JTextArea.AccessibleJTextArea
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.DropLocation, javax.swing.text.JTextComponent.KeyBinding
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DIRTY_PROPERTY
Property change event fired when the text area's dirty flag changes.
|
static java.lang.String |
ENCODING_PROPERTY
Property change event fired when the text area's encoding changes.
|
static java.lang.String |
FULL_PATH_PROPERTY
Property change event fired when the file path this text area references
is updated.
|
static long |
LAST_MODIFIED_UNKNOWN
The value returned by
getLastSaveOrLoadTime() for remote files. |
static java.lang.String |
READ_ONLY_PROPERTY
Property change event fired when the text area should be treated as
read-only, and previously it should not, or vice-versa.
|
ANIMATE_BRACKET_MATCHING_PROPERTY, ANTIALIAS_PROPERTY, AUTO_INDENT_PROPERTY, BRACKET_MATCHING_PROPERTY, CLEAR_WHITESPACE_LINES_PROPERTY, CLOSE_CURLY_BRACES_PROPERTY, CLOSE_MARKUP_TAGS_PROPERTY, CODE_FOLDING_PROPERTY, EOL_VISIBLE_PROPERTY, FOCUSABLE_TIPS_PROPERTY, FRACTIONAL_FONTMETRICS_PROPERTY, HIGHLIGHT_SECONDARY_LANGUAGES_PROPERTY, HYPERLINKS_ENABLED_PROPERTY, MARK_OCCURRENCES_PROPERTY, MARKED_OCCURRENCES_CHANGED_PROPERTY, PAINT_MATCHED_BRACKET_PAIR_PROPERTY, PARSER_NOTICES_PROPERTY, SYNTAX_SCHEME_PROPERTY, SYNTAX_STYLE_PROPERTY, TAB_LINE_COLOR_PROPERTY, TAB_LINES_PROPERTY, USE_SELECTED_TEXT_COLOR_PROPERTY, VISIBLE_WHITESPACE_PROPERTY
COPY_ACTION, CUT_ACTION, DELETE_ACTION, INSERT_MODE, MARK_ALL_COLOR_PROPERTY, MARK_ALL_OCCURRENCES_CHANGED_PROPERTY, MARK_ALL_ON_OCCURRENCE_SEARCHES_PROPERTY, OVERWRITE_MODE, PASTE_ACTION, REDO_ACTION, SELECT_ALL_ACTION, UNDO_ACTION
BACKGROUND_IMAGE_PROPERTY, CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY, CURRENT_LINE_HIGHLIGHT_FADE_PROPERTY, HIGHLIGHT_CURRENT_LINE_PROPERTY, ROUNDED_SELECTION_PROPERTY
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
SYNTAX_STYLE_ACTIONSCRIPT, SYNTAX_STYLE_ASSEMBLER_X86, SYNTAX_STYLE_BBCODE, SYNTAX_STYLE_C, SYNTAX_STYLE_CLOJURE, SYNTAX_STYLE_CPLUSPLUS, SYNTAX_STYLE_CSHARP, SYNTAX_STYLE_CSS, SYNTAX_STYLE_D, SYNTAX_STYLE_DART, SYNTAX_STYLE_DELPHI, SYNTAX_STYLE_DOCKERFILE, SYNTAX_STYLE_DTD, SYNTAX_STYLE_FORTRAN, SYNTAX_STYLE_GROOVY, SYNTAX_STYLE_HOSTS, SYNTAX_STYLE_HTACCESS, SYNTAX_STYLE_HTML, SYNTAX_STYLE_INI, SYNTAX_STYLE_JAVA, SYNTAX_STYLE_JAVASCRIPT, SYNTAX_STYLE_JSON, SYNTAX_STYLE_JSON_WITH_COMMENTS, SYNTAX_STYLE_JSP, SYNTAX_STYLE_LATEX, SYNTAX_STYLE_LESS, SYNTAX_STYLE_LISP, SYNTAX_STYLE_LUA, SYNTAX_STYLE_MAKEFILE, SYNTAX_STYLE_MXML, SYNTAX_STYLE_NONE, SYNTAX_STYLE_NSIS, SYNTAX_STYLE_PERL, SYNTAX_STYLE_PHP, SYNTAX_STYLE_PROPERTIES_FILE, SYNTAX_STYLE_PYTHON, SYNTAX_STYLE_RUBY, SYNTAX_STYLE_SAS, SYNTAX_STYLE_SCALA, SYNTAX_STYLE_SQL, SYNTAX_STYLE_TCL, SYNTAX_STYLE_TYPESCRIPT, SYNTAX_STYLE_UNIX_SHELL, SYNTAX_STYLE_VISUAL_BASIC, SYNTAX_STYLE_WINDOWS_BATCH, SYNTAX_STYLE_XML, SYNTAX_STYLE_YAML
Constructor and Description |
---|
TextEditorPane()
Constructor.
|
TextEditorPane(int textMode)
Constructor.
|
TextEditorPane(int textMode,
boolean wordWrapEnabled)
Creates a new
TextEditorPane . |
TextEditorPane(int textMode,
boolean wordWrapEnabled,
FileLocation loc)
Creates a new
TextEditorPane . |
TextEditorPane(int textMode,
boolean wordWrapEnabled,
FileLocation loc,
java.lang.String defaultEnc)
Creates a new
TextEditorPane . |
Modifier and Type | Method and Description |
---|---|
void |
changedUpdate(javax.swing.event.DocumentEvent e)
Callback for when styles in the current document change.
|
java.lang.String |
getEncoding()
Returns the encoding to use when reading or writing this file.
|
java.lang.String |
getFileFullPath()
Returns the full path to this document.
|
java.lang.String |
getFileName()
Returns the file name of this document.
|
long |
getLastSaveOrLoadTime()
Returns the timestamp for when this file was last loaded or saved
by this editor pane.
|
java.lang.Object |
getLineSeparator()
Returns the line separator used when writing this file (e.g.
|
void |
insertUpdate(javax.swing.event.DocumentEvent e)
Callback for when text is inserted into the document.
|
boolean |
isDirty()
Returns whether or not the text in this editor has unsaved changes.
|
boolean |
isLocal()
Returns whether this file is a local file.
|
boolean |
isLocalAndExists()
Returns whether this is a local file that already exists.
|
boolean |
isModifiedOutsideEditor()
Returns whether the text file has been modified outside of this editor
since the last load or save operation.
|
boolean |
isReadOnly()
Returns whether or not the text area should be treated as read-only.
|
void |
load(FileLocation loc,
java.lang.String defaultEnc)
Loads the specified file in this editor.
|
static void |
main(java.lang.String[] args) |
void |
reload()
Reloads this file from disk.
|
void |
removeUpdate(javax.swing.event.DocumentEvent e)
Called whenever text is removed from this editor.
|
void |
save()
Saves the file in its current encoding.
|
void |
saveAs(FileLocation loc)
Saves this file in a new local location.
|
void |
setDirty(boolean dirty)
Sets whether or not this text in this editor has unsaved changes.
|
void |
setDocument(javax.swing.text.Document doc)
Sets the document for this editor.
|
void |
setEncoding(java.lang.String encoding)
Sets the encoding to use when reading or writing this file.
|
void |
setLineSeparator(java.lang.String separator)
Sets the line separator sequence to use when this file is saved (e.g.
|
void |
setLineSeparator(java.lang.String separator,
boolean setDirty)
Sets the line separator sequence to use when this file is saved (e.g.
|
void |
setReadOnly(boolean readOnly)
Sets whether or not this text area should be treated as read-only.
|
void |
syncLastSaveOrLoadTimeToActualFile()
Syncs this text area's "last saved or loaded" time to that of the file
being edited, if that file is local and exists.
|
addActiveLineRangeListener, addHyperlinkListener, addNotify, addParser, appendFoldingMenu, clearParsers, configurePopupMenu, copyAsRtf, createDefaultModel, createMouseListener, createPopupMenu, createRTextAreaUI, doBracketMatching, fireCaretUpdate, foldToggled, forceReparsing, forceReparsing, getAnimateBracketMatching, getAntiAliasingEnabled, getBackgroundForToken, getCloseCurlyBraces, getCloseMarkupTags, getCodeTemplateManager, getDefaultBracketMatchBGColor, getDefaultBracketMatchBorderColor, getDefaultSelectionColor, getDefaultSyntaxScheme, getEOLMarkersVisible, getFoldManager, getFontForTokenType, getFontMetricsForTokenType, getForegroundForToken, getForegroundForTokenType, getFractionalFontMetricsEnabled, getHighlightSecondaryLanguages, getHyperlinkForeground, getHyperlinksEnabled, getLastVisibleOffset, getLineHeight, getLinkGenerator, getMarkAllHighlightRanges, getMarkedOccurrences, getMarkOccurrences, getMarkOccurrencesColor, getMarkOccurrencesDelay, getMatchedBracketBGColor, getMatchedBracketBorderColor, getMaxAscent, getPaintMarkOccurrencesBorder, getPaintMatchedBracketPair, getPaintTabLines, getParser, getParserCount, getParserDelay, getParserNotices, getRightHandSideCorrection, getSecondaryLanguageBackground, getSecondaryLanguageCount, getShouldIndentNextLine, getShowMatchedBracketPopup, getSyntaxEditingStyle, getSyntaxScheme, getTabLineColor, getTemplatesEnabled, getTokenListForLine, getToolTipText, getToolTipTextImpl, getUnderlineForToken, getUseFocusableTips, getUseSelectedTextColor, init, isAutoIndentEnabled, isBracketMatchingEnabled, isClearWhitespaceLinesEnabled, isCodeFoldingEnabled, isWhitespaceVisible, modelToToken, paintComponent, redoLastAction, removeActiveLineRangeListener, removeHyperlinkListener, removeNotify, removeParser, restoreDefaultSyntaxScheme, saveTemplates, setActiveLineRange, setAnimateBracketMatching, setAntiAliasingEnabled, setAutoIndentEnabled, setBracketMatchingEnabled, setClearWhitespaceLinesEnabled, setCloseCurlyBraces, setCloseMarkupTags, setCodeFoldingEnabled, setEOLMarkersVisible, setFont, setFractionalFontMetricsEnabled, setHighlighter, setHighlightSecondaryLanguages, setHyperlinkForeground, setHyperlinksEnabled, setLinkGenerator, setLinkScanningMask, setMarkOccurrences, setMarkOccurrencesColor, setMarkOccurrencesDelay, setMatchedBracketBGColor, setMatchedBracketBorderColor, setPaintMarkOccurrencesBorder, setPaintMatchedBracketPair, setPaintTabLines, setParserDelay, setRightHandSideCorrection, setSecondaryLanguageBackground, setShowMatchedBracketPopup, setSyntaxEditingStyle, setSyntaxScheme, setTabLineColor, setTemplateDirectory, setTemplatesEnabled, setUseFocusableTips, setUseSelectedTextColor, setWhitespaceVisible, undoLastAction, viewToToken
addLineHighlight, beginAtomicEdit, beginRecordingMacro, canRedo, canUndo, createPopupMenuItem, createUndoManager, discardAllEdits, endAtomicEdit, endRecordingMacro, getAction, getCurrentMacro, getDefaultMarkAllHighlightColor, getIconGroup, getMarkAllHighlightColor, getMarkAllOnOccurrenceSearches, getPopupMenu, getSelectedOccurrenceText, getTextMode, getToolTipSupplier, getUndoManager, handleReplaceSelection, isRecordingMacro, loadMacro, paste, playbackLastMacro, print, read, removeAllLineHighlights, removeLineHighlight, replaceRange, replaceSelection, setActionProperties, setActionProperties, setCaret, setCaretStyle, setIconGroup, setMarkAllHighlightColor, setMarkAllOnOccurrenceSearches, setPopupMenu, setRoundedSelectionEdges, setSelectedOccurrenceText, setTextMode, setToolTipSupplier, setUI, setUndoManager
convertSpacesToTabs, convertTabsToSpaces, forceCurrentLineHighlightRepaint, getBackground, getBackgroundImage, getBackgroundObject, getCaretLineNumber, getCaretOffsetFromLineStart, getCurrentCaretY, getCurrentLineHighlightColor, getDefaultCaretColor, getDefaultCurrentLineHighlightColor, getDefaultFont, getDefaultForeground, getDefaultMarginLineColor, getDefaultMarginLinePosition, getDefaultTabSize, getFadeCurrentLineHighlight, getHighlightCurrentLine, getLineEndOffsetOfCurrentLine, getLineStartOffsetOfCurrentLine, getMarginLineColor, getMarginLinePixelLocation, getMarginLinePosition, getRoundedSelectionEdges, getTabsEmulated, isMarginLineEnabled, isOSX, possiblyUpdateCurrentLineHighlightLocation, processComponentEvent, setBackground, setBackgroundImage, setBackgroundObject, setCurrentLineHighlightColor, setFadeCurrentLineHighlight, setHighlightCurrentLine, setLineWrap, setMargin, setMarginLineColor, setMarginLineEnabled, setMarginLinePosition, setRTextAreaUI, setTabsEmulated, setTabSize, updateMarginLineX, yForLine, yForLineContaining
append, getAccessibleContext, getColumns, getColumnWidth, getLineCount, getLineEndOffset, getLineOfOffset, getLineStartOffset, getLineWrap, getPreferredScrollableViewportSize, getPreferredSize, getRowHeight, getRows, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getTabSize, getUIClassID, getWrapStyleWord, insert, paramString, setColumns, setRows, setWrapStyleWord
addCaretListener, addInputMethodListener, addKeymap, copy, cut, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, print, print, print, processInputMethodEvent, removeCaretListener, removeKeymap, restoreComposedText, saveComposedText, select, selectAll, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setKeymap, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, updateUI, viewToModel, write
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String FULL_PATH_PROPERTY
public static final java.lang.String DIRTY_PROPERTY
setDirty(boolean)
,
Constant Field Valuespublic static final java.lang.String READ_ONLY_PROPERTY
setReadOnly(boolean)
,
Constant Field Valuespublic static final java.lang.String ENCODING_PROPERTY
setEncoding(String)
,
Constant Field Valuespublic static final long LAST_MODIFIED_UNKNOWN
getLastSaveOrLoadTime()
for remote files.public TextEditorPane()
public TextEditorPane(int textMode)
textMode
- Either INSERT_MODE
or
OVERWRITE_MODE
.public TextEditorPane(int textMode, boolean wordWrapEnabled)
TextEditorPane
. The file will be given
a default name.textMode
- Either INSERT_MODE
or
OVERWRITE_MODE
.wordWrapEnabled
- Whether or not to use word wrap in this pane.public TextEditorPane(int textMode, boolean wordWrapEnabled, FileLocation loc) throws java.io.IOException
TextEditorPane
.textMode
- Either INSERT_MODE
or
OVERWRITE_MODE
.wordWrapEnabled
- Whether or not to use word wrap in this pane.loc
- The location of the text file being edited. If this value
is null
, a file named "Untitled.txt" in the current
directory is used.java.io.IOException
- If an IO error occurs reading the file at
loc
. This of course won't happen if
loc
is null
.public TextEditorPane(int textMode, boolean wordWrapEnabled, FileLocation loc, java.lang.String defaultEnc) throws java.io.IOException
TextEditorPane
.textMode
- Either INSERT_MODE
or
OVERWRITE_MODE
.wordWrapEnabled
- Whether or not to use word wrap in this pane.loc
- The location of the text file being edited. If this value
is null
, a file named "Untitled.txt" in the current
directory is used. This file is displayed as empty even if it
actually exists.defaultEnc
- The default encoding to use when opening the file,
if the file is not Unicode. If this value is null
,
a system default value is used.java.io.IOException
- If an IO error occurs reading the file at
loc
. This of course won't happen if
loc
is null
.public void changedUpdate(javax.swing.event.DocumentEvent e)
changedUpdate
in interface javax.swing.event.DocumentListener
e
- The document event.public java.lang.String getEncoding()
setEncoding(String)
public java.lang.String getFileFullPath()
public java.lang.String getFileName()
public long getLastSaveOrLoadTime()
For remote files, this method will always return
LAST_MODIFIED_UNKNOWN
.
LAST_MODIFIED_UNKNOWN
if it is a remote file.isModifiedOutsideEditor()
public java.lang.Object getLineSeparator()
\n
", "\r\n
", or "\r
").
Note that this value is an Object
and not a
String
as that is the way the Document
interface
defines its property values. If you always use
setLineSeparator(String)
to modify this value, then the value
returned from this method will always be a String
.
null
, then
the system default line separator is used (usually the value
of System.getProperty("line.separator")
).setLineSeparator(String)
,
setLineSeparator(String, boolean)
public void insertUpdate(javax.swing.event.DocumentEvent e)
insertUpdate
in interface javax.swing.event.DocumentListener
e
- Information on the insertion.public boolean isDirty()
setDirty(boolean)
public boolean isLocal()
public boolean isLocalAndExists()
public boolean isModifiedOutsideEditor()
false
.This method may be used by applications to implement a reloading feature, where the user is prompted to reload a file if it has been modified since their last open or save.
getLastSaveOrLoadTime()
public boolean isReadOnly()
setReadOnly(boolean)
public void load(FileLocation loc, java.lang.String defaultEnc) throws java.io.IOException
FULL_PATH_PROPERTY
.loc
- The location of the file to load. This cannot be
null
.defaultEnc
- The encoding to use when loading/saving the file.
This encoding will only be used if the file is not Unicode.
If this value is null
, the system default encoding
is used.java.io.IOException
- If an IO error occurs.save()
,
saveAs(FileLocation)
public void reload() throws java.io.IOException
The file's "dirty" state will be set to false
after this
operation. If this is a local file, its "last modified" time is
updated to reflect that of the actual file.
Note that if the file has been modified on disk, and is now a Unicode
encoding when before it wasn't (or if it is a different Unicode now),
this will cause this TextEditorPane
's encoding to change.
Otherwise, the file's encoding will stay the same.
java.io.IOException
- If the file does not exist, or if an IO error
occurs reading the file.isLocalAndExists()
public void removeUpdate(javax.swing.event.DocumentEvent e)
removeUpdate
in interface javax.swing.event.DocumentListener
e
- The document event.public void save() throws java.io.IOException
The text area's "dirty" state is set to false
, and if
this is a local file, its "last modified" time is updated.
java.io.IOException
- If an IO error occurs.saveAs(FileLocation)
,
load(FileLocation, String)
public void saveAs(FileLocation loc) throws java.io.IOException
FULL_PATH_PROPERTY
.loc
- The location to save to.java.io.IOException
- If an IO error occurs.save()
,
load(FileLocation, String)
public void setDirty(boolean dirty)
DIRTY_PROPERTY
.
Applications will usually have no need to call this method directly; the
only time you might have a need to call this method directly is if you
have to initialize an instance of TextEditorPane with content that does
not come from a file. TextEditorPane
automatically sets its
own dirty flag when its content is edited, when its encoding is changed,
or when its line ending property is changed. It is cleared whenever
load()
, reload()
, save()
, or
saveAs()
are called.
dirty
- Whether or not the text has been modified.isDirty()
public void setDocument(javax.swing.text.Document doc)
setDocument
in class RSyntaxTextArea
doc
- The new document.public void setEncoding(java.lang.String encoding)
ENCODING_PROPERTY
.encoding
- The new encoding.java.nio.charset.UnsupportedCharsetException
- If the encoding is not supported.java.lang.NullPointerException
- If encoding
is
null
.getEncoding()
public void setLineSeparator(java.lang.String separator)
\n
", "\r\n
" or "\r
").
Besides parameter checking, this method is preferred over
getDocument().putProperty()
because it sets the editor's
dirty flag when the line separator is changed.separator
- The new line separator.java.lang.NullPointerException
- If separator
is
null
.java.lang.IllegalArgumentException
- If separator
is not one
of "\n
", "\r\n
" or "\r
".getLineSeparator()
public void setLineSeparator(java.lang.String separator, boolean setDirty)
\n
", "\r\n
" or "\r
").
Besides parameter checking, this method is preferred over
getDocument().putProperty()
because can set the editor's
dirty flag when the line separator is changed.separator
- The new line separator.setDirty
- Whether the dirty flag should be set if the line
separator is changed.java.lang.NullPointerException
- If separator
is
null
.java.lang.IllegalArgumentException
- If separator
is not one
of "\n
", "\r\n
" or "\r
".getLineSeparator()
public void setReadOnly(boolean readOnly)
READ_ONLY_PROPERTY
.readOnly
- Whether or not the document is read-only.isReadOnly()
public void syncLastSaveOrLoadTimeToActualFile()
You normally do not have to call this method, as the "last saved or
loaded" time for TextEditorPane
s is kept up-to-date internally
during such operations as save()
, reload()
, etc.
getLastSaveOrLoadTime()
,
isModifiedOutsideEditor()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception