public class BasicEditorPane extends javax.swing.JEditorPane implements ActionInvoker, java.awt.dnd.Autoscroll, java.beans.PropertyChangeListener
BasicEditorPane
is an extension of the
JEditorPane
to provide more flexible syntax and
background highlighting functionality at a reduced memory and
performance footprint. It can be used anywhere a
JEditorPane
instance can be used. Clients are
strongly encouraged to call dispose()
when the
the editor pane is no longer needed, but this is not an absolute
requirement. This allows us to clean up as well as notify
editor plugins that the editor is no longer being used. Undo Support:
The editor framework provides some support for naming edits,
grouping together similar edits, and undo of navigation. When
making a change to the document using insertString()
or remove()
, or through the editor using
replaceSelection()
, cut()
, or
paste()
, you can specify a name for the edit by
creating an EditDescriptor
for the edit, and
passing it to BasicEditorPane.beginEdit(EditDescriptor)
.
Additionally, you can use it for grouping together a group of
edits as a single undoable unit by placing your edits between
a call to BasicEditorPane.beginEdit(EditDescriptor)
and
BasicEditorPane.endEdit(EditDescriptor)
.
The edit name which you specify through the EditDescriptor
is made available through the UndoableEdit
using
getPresentationName()
. This allows you to name your
edits like "Add Button", or "Add Field" so that it better describes
the edit operation the Undo or Redo applies to.
Built-in actions have pre-defined names used for the
EditDescriptor
already. Additionally, the editor
provides automatic support for merging simple edits. Currently,
the simple edit consists of a key-typed insert (insert mode),
a key-typed replace (overwrite mode), delete next (Delete key), or
delete previous (Backspace key). These simple edits may be
merged with other consecutive simple edits of the same type. That
means two inserts in a row will be automatically merged if merging
for key-typed inserts is enabled, and the merge count allowed
is set to greater than two. Look in EditorProperties
for the properties to set to enable merging of simple edits, and
for setting the merge count.
The editor also provides support for undoing navigation (without
associated document changes) using beginNavigation()
and endNavigation()
. Client code which causes
a navigation in the editor (such as "Go to Line", or "Find")
should always wrap their navigation commands with calls to
beginNavigation()
and endNavigation
.
The current default for the editor is to generate undo events
for navigation, though this can be disabled with the appropriate
property in EditorProperties
. If the editor is
set to not generate undos for navigation, the
beginNavigation()
and endNavigation()
will
just be NOP calls.
As with the Swing text framework, the UndoableEditListener should
be attached to the document (BasicDocument
). Undo
edits (including navigation) will be delivered through the
document.
Highlight Support:
For highlight and underline support, refer to the documentation for the
HighlightLayer
class.
Tooltip Support:
For tooltip support, refer to the documentation for the
TooltipProvider
interface.
Popup Support:
For popup (context) menu support, refer to the documentation
for the PopupManager
interface.
javax.swing.JEditorPane.AccessibleJEditorPane, javax.swing.JEditorPane.AccessibleJEditorPaneHTML, javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.DropLocation, javax.swing.text.JTextComponent.KeyBinding
javax.swing.JComponent.AccessibleJComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
BasicEditorPane()
Creates a new instance of a BasicEditorPane.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionHookInvoker(ActionHookInvoker invoker)
Adds an ActionHookInvoker to the list so that it has a chance to
override the default action temporarily.
|
void |
addActionPostInvoker(ActionPostInvoker invoker)
Adds an ActionPostInvoker to the list so that it gets notified
of successfully completed actions just after the fact.
|
void |
addCharacterTypedListener(CharacterTypedListener listener)
Adds a character typed listener to the list so that it can receive
notifications of characters typed into this editor pane.
|
void |
addFeedbackManager(FeedbackManager manager)
Installs the given
FeedbackManager for displaying
feedback messages to the user for this editor pane. |
void |
addNavigationListener(NavigationListener navigationListener)
Add a listener for navigation events.
|
void |
addPopupManager(PopupManager manager)
Installs the given
PopupManager for managing popup menus
for this editor pane. |
void |
addPreActionInvoker(ActionPreInvoker invoker,
double weight)
Adds an actionInvoker that will be called before anyone else.
The ActionInvoker will be invoked for any action, including actions that would normally be handled by the IDE. |
void |
addToolTipProvider(ToolTipProvider provider)
Installs the given
ToolTipProvider for providing
tooltips for the editor pane. |
void |
autoscroll(java.awt.Point location)
Notify the
Component to autoscroll. |
void |
beginEdit(EditDescriptor editDescriptor)
Marks the start of an Undoable edit applied through this editor.
|
void |
beginFormatEdit(EditDescriptor editDescriptor)
This is a special form of beginEdit without calling beginEdit in
realTextBuffer
|
void |
beginNavigation()
Marks the start of a navigation through this editor.
|
boolean |
canCopy()
Fetches whether a copy operation can be performed by calling
copy().
|
boolean |
canCut()
Fetches whether a cut operation can be performed by calling
cut().
|
boolean |
canPaste()
Fetches whether the paste operation can be performed by calling
paste().
|
void |
copy() |
protected javax.swing.text.EditorKit |
createDefaultEditorKit()
Creates the default editor kit for when the component is first
created.
|
HighlightLayer |
createHighlightLayer()
Creates a new highlight layer that can be used for highlighting
text in this editor pane.
|
javax.swing.JToolTip |
createToolTip()
Overriden to provide a MultiLineToolTip by default.
|
void |
cut() |
protected void |
deinstallAllPlugins()
Utility routine to deinstall all plugins.
|
protected void |
deinstallKeyboardSupport()
Support routine to deinitialize the keyboard support for
this editor pane instance.
|
void |
deinstallPlugin(EditorPlugin plugin)
This deinstalls an editor plugin from the editor.
|
void |
destroyHighlightLayer(HighlightLayer layer)
Destroys a highlight layer that is no longer needed.
|
void |
dispose()
Instructs this editor pane that it is no longer needed, and that
it can clear up resources and references.
|
void |
duplicateSelection()
Copies the selected text amd places the copy immediately after he original
selection.
|
void |
endEdit()
Marks the end of an Undoable edit applied through this editor.
|
void |
endEdit(boolean mergeIntoPrevious)
Marks the end of an Undoable edit applied through this editor.
|
void |
endEdit(boolean mergeIntoPrevious,
javax.swing.undo.UndoableEdit wrappedEdit)
Marks the end of an Undoable edit applied through this editor.
|
void |
endFormatEdit(boolean mergeIntoPrevious,
javax.swing.undo.UndoableEdit formattedEdit)
This is a special endEdit without calling endEdit in realTextBuffer.
|
void |
endNavigation()
Marks the end of a navigation through this editor.
|
void |
ensureCaretVisible()
Recenters the parent viewport vertically and horizontally around
the caret, if the caret position is offscreen.
|
void |
ensurePositionVisible(int position)
Recenters the parent viewport vertically and horizontally around
the specified position, if the position is offscreen.
|
protected void |
ensureVisibleAndCentered(int location) |
protected void |
ensureVisibleAndCentered(java.awt.Rectangle positionRect)
Utility routine to ensure that the given position is
visible vertically and horizontally.
|
protected void |
ensureVisibleAndCentered(java.awt.Rectangle positionRect,
boolean force)
Utility routine to ensure that the given position is
visible vertically and horizontally.
|
protected void |
finalize()
Finalizer to clean up the editor in case it was not disposed of
properly.
|
protected void |
fireCharacterTypedEvent(int offset,
char charTyped)
Utility routine used to notify listeners that a character
was typed.
|
protected void |
fireNavigationEvent(int offset)
Inform listeners that the caret has moved in response to an external event.
|
javax.accessibility.AccessibleContext |
getAccessibleContext() |
ActionInvoker |
getActionInvoker()
Fetches the action invoker to use to execute some particular action.
|
java.awt.Insets |
getAutoscrollInsets()
This method returns the
Insets describing the
autoscrolling region or border relative to the geometry of the
implementing Component. |
boolean |
getBooleanProperty(java.lang.String key)
Fetch the boolean property stored by the given key.
|
java.awt.Color |
getDisabledBackgroundColor()
Fetches the current color used to render the disabled background.
|
FeedbackManager |
getFeedbackManager()
Fetches the current installed
FeedbackManager . |
FontHelper |
getFontHelper()
Convenience method for getting the current font helper.
|
javax.swing.text.Highlighter |
getHighlighter()
Fetches the object responsible for making highlights.
|
protected java.util.Iterator<HighlightLayer> |
getHighlightLayers()
Fetches an iterator to access the highlight layers associated
with this editor pane.
|
HighlightRegistry |
getHighlightRegistry()
Fetch the global highlight registry used for all editor panes.
|
int |
getIntegerProperty(java.lang.String key)
Fetch the integer property stored by the given key.
|
LanguageSupport |
getLanguageSupport() |
int |
getLineCount()
Fetches the number of lines in this
TextBuffer . |
int |
getLineEndOffset(int line)
Given a specified line, returns the offset from the beginning
of a
TextBuffer that the line ends at. |
int |
getLineFromOffset(int offset)
Given an offset from the beginning of the underlying
TextBuffer , fetches the line number containing that
offset using a Forward bias. |
int |
getLineFromRow(int row)
Fetch the first line that occurs on this row, taking in to account folded
blocks.
|
int |
getLineLength(int line) |
int |
getLineStartOffset(int line)
Given a specified line, returns the offset from the beginning
of the
TextBuffer for the start of the line. |
PopupManager |
getPopupManager()
Fetches the current installed
PopupManager . |
java.lang.Object |
getProperty(java.lang.String key)
Get the property associated with the given key.
|
int |
getRowForLine(int line)
Return the row that the given line appears on.
|
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Components that display logical rows or columns should compute
the scroll increment that will completely expose one block
of rows or columns, depending on the value of orientation.
|
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Components that display logical rows or columns should compute
the scroll increment that will completely expose one new row
or column, depending on the value of orientation.
|
java.lang.String |
getSelectedText() |
StyleRegistry |
getStyleRegistry()
Fetch the global style registry used for all editor panes.
|
TextBuffer |
getTextBuffer() |
ToolTipProvider |
getToolTipProvider()
Fetches the current installed
ToolTipProvider . |
java.lang.String |
getToolTipText()
Returns the tooltip string that has been set with setToolTipText().
|
java.lang.String |
getToolTipText(java.awt.event.MouseEvent event)
Returns the string to be used as the tooltip for event.
|
int |
getValidOffsetEnd() |
int |
getValidOffsetStart() |
boolean |
gotoLine(int line,
int column,
boolean highlightLine)
Moves the current cursor position to the beginning of the
indicated line, and highlight the line if it is requested.
|
boolean |
hasSelection()
Fetches whether there is currently a selection in the editor.
|
void |
insertString(int offs,
java.lang.String str,
javax.swing.text.AttributeSet a)
Insert the given string into the document at the given offset.
|
protected void |
installBuiltInPlugins()
Utility routine to install known, built-in plugins.
|
protected void |
installKeyboardSupport()
Support routine to initialize the keyboard support for this
editor pane instance.
|
void |
installPlugin(EditorPlugin plugin)
This installs an editor plugin into the editor.
|
void |
invokeAction(java.lang.String actionKey)
Invokes the Action corresponding to the given actionKey.
|
protected boolean |
isCutCopyLineEnabled()
Checks whether Cut/Copy on current line with no selection is
enabled.
|
boolean |
isDisposed() |
boolean |
isOffsetVisible(int offset)
Determine is an offset is currently visible.
|
boolean |
isProtected()
Fetches whether the editor's content is protected or not - this
may be used by clients to indicate that the document is some
sort of protected content, and that changes cannot be made directly
through the editor, but through other wizards or dialogs instead.
|
boolean |
isUndoInProgress()
Fetches whether the editor is in the middle of having an
undo/redo applied to it.
|
boolean |
isValidClipboardContent()
Checks if the current content of the clipboard can be pasted into the editor.
|
boolean |
makeEditable()
Attempts to makes the document editable through consumers registered as
VetoableChangeListener s. |
void |
mergeReplaceSelection(java.lang.String content)
Like replaceSelection(String content), except it mergres this edit to the
previous edit.
|
void |
moveCaretPosition(int position)
Moves the caret to a new position, leaving behind a mark defined
by the last time setCaretPosition was called.
|
void |
moveCaretPositionCenter(int position)
Moves the caret to a new position, leaving behind a mark defined
by the last time setCaretPosition was called.
|
void |
paste() |
protected void |
pasteFromClipboard(java.awt.Toolkit toolkit,
java.awt.datatransfer.Clipboard clipboard)
Utility routine to perform a paste operation from the given
clipboard.
|
boolean |
preInvokeAction(java.lang.String actionKey)
Invoke the pre-actionInvokers for an action.
|
protected void |
processInputMethodEvent(java.awt.event.InputMethodEvent e) |
void |
propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed.
|
void |
putBooleanProperty(java.lang.String key,
boolean value)
Sets the boolean property and value in the property table.
|
void |
putIntegerProperty(java.lang.String key,
int value)
Sets the integer property and value in the property table.
|
void |
putProperty(java.lang.String key,
java.lang.Object value)
Store the property associated with the given key.
|
void |
registerPainter(BasicEditorPainter painter)
Register a BasicEditorPainter to paint custom graphics into the editor
|
void |
remove(int offs,
int len)
Remove the given section from the document.
|
void |
removeActionHookInvoker(ActionHookInvoker invoker)
Removes an ActionHookInvoker from our list.
|
void |
removeActionPostInvoker(ActionPostInvoker invoker)
Removes an ActionPostInvoker from our list.
|
void |
removeCharacterTypedListener(CharacterTypedListener listener)
Removes a character typed listener from the list so that it
no longer receives notifications.
|
void |
removeFeedbackManager(FeedbackManager manager)
Deinstalls the given
FeedbackManager that was previously
installed for handling feedback messages for this editor pane. |
void |
removeNavigationListener(NavigationListener navigationListener) |
void |
removePopupManager(PopupManager manager)
Deinstalls the given
PopupManager that was previously
installed for managing popup menus for the editor pane. |
void |
removePreActionInvoker(ActionPreInvoker invoker,
double weight)
Remove a pre-actionInvoker.
|
void |
removeToolTipProvider(ToolTipProvider provider)
Deinstalls the given
ToolTipProvider that was
previously installed for getting tooltip info for the editor pane. |
void |
replaceSelection(java.lang.String content)
Replaces the currently selected content with the new content
represented by the given String.
|
void |
select(int selectionStart,
int selectionEnd)
Selects the text found between the specified start and end
locations.
|
void |
selectAll()
Selects all the text in the TextComponent.
|
void |
setBaseFont(java.lang.String fontFamily,
int fontSize)
Set the base font of this editor pane independently from the
global base font.
|
void |
setCaretPosition(int position)
Sets the position of the text insertion caret for the TextComponent.
|
void |
setCaretPosition(int position,
boolean isNavigation)
Sets the position of the text insertion caret for the TextComponent.
|
void |
setCaretPositionCenter(int position)
Sets the position of the text insertion caret for the
TextComponent.
|
static void |
setClipboard(java.awt.datatransfer.Clipboard clip)
Sets the clipboard used by BasicEditorPane.
|
protected void |
setClipboardContents(java.lang.String contentText)
Utility routine to set the contents of the given text into the
clipboard.
|
void |
setDisabledBackgroundColor(java.awt.Color c)
Sets the current color used to render the
disabled background.
|
void |
setDocument(javax.swing.text.Document doc)
Associates the editor with the text document.
|
void |
setEditable(boolean editable)
Sets the specified boolean to indicate whether or not this
TextComponent should be editable.
|
void |
setFont(java.awt.Font font)
We override the
setFont implementation, as the
font handling in the editor framework is different. |
void |
setHighlighter(javax.swing.text.Highlighter h)
Sets the highlighter to be used.
|
void |
setHighlightRegistry(HighlightRegistry registry)
Replace the global highlight registry used for all editor panes.
|
void |
setLanguageSupport(java.lang.String fileName)
Sets the LanguageSupport for editing the type of content indicated
by the specified filename.
|
void |
setProtected(boolean makeProtected)
Sets the editor in protected mode or not.
|
void |
setStyleRegistry(StyleRegistry registry)
Replace the global style registry used for all editor panes.
|
void |
setText(java.lang.String text)
Sets the text of this
TextComponent to the specified
content. |
void |
setToolTipText(java.lang.String text)
Registers the text to display in a tool tip.
|
void |
setValidOffsetBounds(int startOffset,
int endOffset)
Set the bounds between which user editing and caret navigation is permitted.
|
void |
unregisterPainter(BasicEditorPainter painter) |
void |
unselect()
Unselects the current text selection (if any), but leaves the
caret where it is.
|
protected void |
updateColors()
Utility routine to update our Swing color stuff.
|
void |
updateUI()
Reloads the pluggable UI.
|
protected boolean |
useDefaultKeyHandling()
Fetches whether the default use of the multi-key handler should
be used.
|
protected void |
validateVisibleRect(java.awt.Rectangle visibleRect)
Utility method to ensure that the visible rectangle does not go
beyond the edges of the editor view.
|
addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getText, getUIClassID, paramString, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, scrollToReference, setContentType, setEditorKit, setEditorKitForContentType, setPage, setPage
addCaretListener, addInputMethodListener, addKeymap, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getUI, isEditable, loadKeymap, modelToView, print, print, print, read, removeCaretListener, removeKeymap, removeNotify, restoreComposedText, saveComposedText, setCaret, setCaretColor, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setFocusAccelerator, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, viewToModel, write
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, 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, getBackground, 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, processComponentEvent, 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 BasicEditorPane()
dispose()
public static void setClipboard(java.awt.datatransfer.Clipboard clip)
clip
- clipboard that should be used.public void setLanguageSupport(java.lang.String fileName)
fileName
- the name of the filepublic LanguageSupport getLanguageSupport()
public void beginEdit(EditDescriptor editDescriptor)
editDescriptor
- the edit descriptor describes this edit, such
as providing a human-readable namepublic void beginFormatEdit(EditDescriptor editDescriptor)
public void endEdit(boolean mergeIntoPrevious, javax.swing.undo.UndoableEdit wrappedEdit)
mergeIntoPrevious
- whether the edit should be merged into
the previous editwrappedEdit
- an edit to wrap.public void endFormatEdit(boolean mergeIntoPrevious, javax.swing.undo.UndoableEdit formattedEdit)
mergeIntoPrevious
- sets whether to merge this edit into the
previous edit.formattedEdit
- is the formatted undoable edit.public void endEdit()
public void endEdit(boolean mergeIntoPrevious)
mergeIntoPrevious
- whether the edit should be merged into
the previous editpublic void beginNavigation()
public void endNavigation()
public void unselect()
public void setCaretPositionCenter(int position)
setCaretPosition()
except that if the new caret
position is offscreen, it recenters the new position vertically
into the center of the parent view port.position
- the positionpublic void moveCaretPositionCenter(int position)
setCaretPositionCenter
in that if the new position
is offscreen, it recenters the new position vertically into the
center of the parent view port.position
- the positionpublic void ensureCaretVisible()
public void ensurePositionVisible(int position)
position
- the positionpublic boolean isOffsetVisible(int offset)
offset
- protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void dispose()
public boolean isDisposed()
public boolean isProtected()
public void setProtected(boolean makeProtected)
makeProtected
- true to set the editor in protected modeprotected boolean isCutCopyLineEnabled()
public boolean canCut()
public boolean canCopy()
public boolean canPaste()
public boolean isValidClipboardContent()
public boolean hasSelection()
public FontHelper getFontHelper()
public void setBaseFont(java.lang.String fontFamily, int fontSize)
fontFamily
- the font family of the base fontfontSize
- the font size of the base fontpublic StyleRegistry getStyleRegistry()
public void setStyleRegistry(StyleRegistry registry)
registry
- the new registry to usepublic HighlightRegistry getHighlightRegistry()
public void setHighlightRegistry(HighlightRegistry registry)
registry
- the new registry to usepublic boolean gotoLine(int line, int column, boolean highlightLine)
line
- the line to go to (one-based)column
- the column to go to (one-based)highlightLine
- whether to highlight the specified linepublic void setFont(java.awt.Font font)
setFont
implementation, as the
font handling in the editor framework is different. Since this
editor is capable of rendering different styles for the same
font, and since we are using global fonts from our properties, we
ignore the normal Swing/AWT set font mechanism. To change the
base font of this editor by itself, use
BasicEditorPane.setBaseFont()
. To change the global
base font of the editor framework, use
EditorProperties.setBaseFont()
.setFont
in class javax.swing.JComponent
font
- the font to setpublic void setEditable(boolean editable)
setEditable
in class javax.swing.text.JTextComponent
editable
- the boolean to be setprotected javax.swing.text.EditorKit createDefaultEditorKit()
createDefaultEditorKit
in class javax.swing.JEditorPane
public void updateUI()
updateUI
in class javax.swing.text.JTextComponent
public TextBuffer getTextBuffer()
public void setDocument(javax.swing.text.Document doc)
setDocument
in class javax.swing.text.JTextComponent
doc
- the new document, must be of type BasicDocumentpublic java.lang.String getSelectedText()
getSelectedText
in class javax.swing.text.JTextComponent
protected void setClipboardContents(java.lang.String contentText)
contentText
- the content text to setpublic void cut()
cut
in class javax.swing.text.JTextComponent
public void copy()
copy
in class javax.swing.text.JTextComponent
public void paste()
paste
in class javax.swing.text.JTextComponent
public void duplicateSelection()
protected void pasteFromClipboard(java.awt.Toolkit toolkit, java.awt.datatransfer.Clipboard clipboard)
clipboard
- the clipboard to paste frompublic void setText(java.lang.String text)
TextComponent
to the specified
content.setText
in class javax.swing.JEditorPane
text
- public void mergeReplaceSelection(java.lang.String content)
content
- to be replacedpublic void replaceSelection(java.lang.String content)
replaceSelection
in class javax.swing.JEditorPane
content
- the new content to replace the current selectionpublic void selectAll()
selectAll
in class javax.swing.text.JTextComponent
public void select(int selectionStart, int selectionEnd)
select
in class javax.swing.text.JTextComponent
selectionStart
- the start position of the text >= 0selectionEnd
- the end position of the text >= 0setCaretPosition(int)
,
moveCaretPosition(int)
public javax.swing.text.Highlighter getHighlighter()
getHighlighter
in class javax.swing.text.JTextComponent
public void setHighlighter(javax.swing.text.Highlighter h)
setHighlighter
in class javax.swing.text.JTextComponent
h
- the highlighterpublic java.awt.Color getDisabledBackgroundColor()
public void setDisabledBackgroundColor(java.awt.Color c)
c
- the colorJTextComponent.getDisabledTextColor()
public void setToolTipText(java.lang.String text)
setToolTipText
in class javax.swing.JComponent
text
- the text to display in a tool tip.public java.lang.String getToolTipText()
getToolTipText
in class javax.swing.JComponent
public javax.swing.JToolTip createToolTip()
createToolTip
in class javax.swing.JComponent
public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
getToolTipText
in class javax.swing.text.JTextComponent
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface javax.swing.Scrollable
getScrollableUnitIncrement
in class javax.swing.text.JTextComponent
visibleRect
- The view area visible within the viewportorientation
- Either SwingConstants.VERTICAL or
SwingConstants.HORIZONTAL.direction
- Less than zero to scroll up/left, greater
than zero for down/right.JScrollBar.setUnitIncrement(int)
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableBlockIncrement
in interface javax.swing.Scrollable
getScrollableBlockIncrement
in class javax.swing.text.JTextComponent
visibleRect
- The view area visible within the viewportorientation
- Either SwingConstants.VERTICAL or
SwingConstants.HORIZONTAL.direction
- Less than zero to scroll up/left, greater
than zero for down/right.JScrollBar.setBlockIncrement(int)
public void setCaretPosition(int position)
setCaretPosition
in class javax.swing.text.JTextComponent
position
- the positionpublic void setCaretPosition(int position, boolean isNavigation)
position
- the positionisNavigation
- if true this change is considered a navigation and a
navigation event isfired.public void remove(int offs, int len) throws javax.swing.text.BadLocationException
offs
- the start offset to removelen
- the number of characters to removejavax.swing.text.BadLocationException
- if the removal is outside of any view limits,
or if the document itself throws a BadLocationException.public void insertString(int offs, java.lang.String str, javax.swing.text.AttributeSet a) throws javax.swing.text.BadLocationException
offs
- the start offset to insertstr
- the string to inserta
- the attribute set to usejavax.swing.text.BadLocationException
- if the insert is outside of any view limits,
or if the document itself throws a BadLocationException.public void moveCaretPosition(int position)
moveCaretPosition
in class javax.swing.text.JTextComponent
position
- public java.awt.Insets getAutoscrollInsets()
Insets
describing the
autoscrolling region or border relative to the geometry of the
implementing Component.
This value is read once by the DropTarget
upon entry
of the drag Cursor
into the associated
Component
.
getAutoscrollInsets
in interface java.awt.dnd.Autoscroll
public void autoscroll(java.awt.Point location)
Component
to autoscroll.autoscroll
in interface java.awt.dnd.Autoscroll
location
- the Point
location that triggered
this autoscroll.protected void validateVisibleRect(java.awt.Rectangle visibleRect)
visibleRect
- the visible rect to validatepublic final java.lang.Object getProperty(java.lang.String key)
key
- the property to getEditorProperties
public final void putProperty(java.lang.String key, java.lang.Object value)
key
- the property to storevalue
- the value to storeEditorProperties
public boolean getBooleanProperty(java.lang.String key)
key
- the property to getjava.lang.ClassCastException
- if the property is not a boolean propertypublic void putBooleanProperty(java.lang.String key, boolean value)
key
- the property namevalue
- the property valuepublic int getIntegerProperty(java.lang.String key)
key
- the property to getjava.lang.ClassCastException
- if the property is not a integer propertypublic void putIntegerProperty(java.lang.String key, int value)
key
- the property namevalue
- the property valuepublic void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
event
- A PropertyChangeEvent object describing the event source
and the property that has changed.public int getLineCount()
TextBuffer
. For
example, a 5-line TextBuffer
has lines 0 through 4.TextBuffer
public int getLineFromOffset(int offset)
TextBuffer
, fetches the line number containing that
offset using a Forward bias. This means if line A starts with
offset B, and previous line A-1 ends with offset B,
getLineFromOffset(B)
will return line A.public int getLineStartOffset(int line)
TextBuffer
for the start of the line.line
- a line in the TextBuffer
public int getLineEndOffset(int line)
TextBuffer
that the line ends at.line
- a line in the TextBuffer
public int getLineLength(int line)
line
- the line to find the length ofpublic int getLineFromRow(int row)
row
- the row to get the line forpublic int getRowForLine(int line)
line
- public void addPreActionInvoker(ActionPreInvoker invoker, double weight)
The weight
defines the priority. Invokers with a lowest
weight are called first.
If two invokers have the same priority, the last one to be added is
called first. This is the behavior of a stack.
Pre-invokers should be used for temporary situations where actions must be intercepted before to reach their normal destination. A typical example is the coordination of popups where one popup needs to receive its input before another.
invoker
- The invoker to addweight
- The wheight defines the priority.public void removePreActionInvoker(ActionPreInvoker invoker, double weight)
public boolean preInvokeAction(java.lang.String actionKey)
actionKey
- the name of the action.addPreActionInvoker(ActionPreInvoker, double)
public void addActionHookInvoker(ActionHookInvoker invoker)
invoker
- the invoker to addpublic void removeActionHookInvoker(ActionHookInvoker invoker)
invoker
- the invoker to removepublic void addActionPostInvoker(ActionPostInvoker invoker)
invoker
- the invoker to addpublic void removeActionPostInvoker(ActionPostInvoker invoker)
invoker
- the invoker to removepublic ActionInvoker getActionInvoker()
public void invokeAction(java.lang.String actionKey)
invokeAction
in interface ActionInvoker
actionKey
- the published key for the actionpublic void installPlugin(EditorPlugin plugin)
install()
method of
the plugin as well as add the plugin as a
PropertyChangeListener
of the editor to receive
property change events.plugin
- the plugin to installpublic void deinstallPlugin(EditorPlugin plugin)
deinstall()
method of
the plugin as well as remove the plugin from being a
PropertyChangeListener
of the editor.plugin
- the plugin to deinstallprotected void installBuiltInPlugins()
protected void deinstallAllPlugins()
public HighlightLayer createHighlightLayer()
public void destroyHighlightLayer(HighlightLayer layer)
layer
- the highlight layer to removeprotected java.util.Iterator<HighlightLayer> getHighlightLayers()
public void addPopupManager(PopupManager manager)
PopupManager
for managing popup menus
for this editor pane. When the user requests a popup menu, usually
by right-clicking in the editor content, the showPopup()
method of the PopupManager
will be called. Only one
PopupManager
can be installed at any given time (but
this is not enforced programmatically at the current time.)manager
- the popup manager to installpublic void removePopupManager(PopupManager manager)
PopupManager
that was previously
installed for managing popup menus for the editor pane.manager
- the popup manager to de-installpublic PopupManager getPopupManager()
PopupManager
. This is
primarily used within the editor component, for example by the
BasicCaret, to notify the appropriate PopupManager
for handling events related to popup menus. This will return
null if there is no popup manager installed.PopupMenu
public void addToolTipProvider(ToolTipProvider provider)
ToolTipProvider
for providing
tooltips for the editor pane. When the user requests a tooltip
(by moving the mouse over text in the editor and waiting), the
getToolTipText()
method of the
ToolTipProvider
will be called. Only one
ToolTipProvider
can be installed at any given time
(but this is not enforced programmatically currently.)provider
- the tool tip provider to installpublic void removeToolTipProvider(ToolTipProvider provider)
ToolTipProvider
that was
previously installed for getting tooltip info for the editor pane.provider
- the tooltip provider to de-install.public ToolTipProvider getToolTipProvider()
ToolTipProvider
. This
is primarily used within the editor component, for example when a
tool tip needs to be popped up. This will return null if there
is no popup manager installed.ToolTipProvider
public void addFeedbackManager(FeedbackManager manager)
FeedbackManager
for displaying
feedback messages to the user for this editor pane. Only
one FeedbackManager
can be installed at any given
time (this is not enforce programmatically however.)manager
- the feedback manager to installpublic void removeFeedbackManager(FeedbackManager manager)
FeedbackManager
that was previously
installed for handling feedback messages for this editor pane.manager
- the feedback manager to de-installpublic FeedbackManager getFeedbackManager()
FeedbackManager
. This
is can be used for displaying feedback messages to the user
associated with this editor pane. This will return null if there
is no feedback manager installed.FeedbackMenu
public void addCharacterTypedListener(CharacterTypedListener listener)
listener
- the listener to addpublic void removeCharacterTypedListener(CharacterTypedListener listener)
listener
- the listener to removeprotected void fireCharacterTypedEvent(int offset, char charTyped)
offset
- the offset where the character was typedcharTyped
- the character that was typedpublic void addNavigationListener(NavigationListener navigationListener)
navigationListener
- the NavigationListener to receive eventspublic void removeNavigationListener(NavigationListener navigationListener)
protected void fireNavigationEvent(int offset)
offset
- the new offset after navigationpublic void setValidOffsetBounds(int startOffset, int endOffset)
startOffset
- the start of the limited bounds, or -1 for no limitendOffset
- the end of the limited bounds, or -1 for no limitpublic int getValidOffsetStart()
public int getValidOffsetEnd()
protected void updateColors()
protected boolean useDefaultKeyHandling()
protected void installKeyboardSupport()
protected void deinstallKeyboardSupport()
protected void ensureVisibleAndCentered(int location)
protected void ensureVisibleAndCentered(java.awt.Rectangle positionRect)
positionRect
- the rectangle to make sure if visibleprotected void ensureVisibleAndCentered(java.awt.Rectangle positionRect, boolean force)
positionRect
- the rectangle to make sure if visibleforce
- whether to force centeringpublic void registerPainter(BasicEditorPainter painter)
painter
- public void unregisterPainter(BasicEditorPainter painter)
public boolean makeEditable()
VetoableChangeListener
s.true
if the document was successfully made editable.protected void processInputMethodEvent(java.awt.event.InputMethodEvent e)
processInputMethodEvent
in class javax.swing.text.JTextComponent
public boolean isUndoInProgress()
public javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext
in interface javax.accessibility.Accessible
getAccessibleContext
in class javax.swing.JEditorPane