com.borland.primetime.editor
Class EditorPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.text.JTextComponent
                          |
                          +--javax.swing.JEditorPane
                                |
                                +--com.borland.primetime.editor.EditorPane

public class EditorPane
extends javax.swing.JEditorPane
implements java.awt.event.FocusListener, java.beans.PropertyChangeListener

This is the editor component for the PrimeTime framework. The EditorPane is the focused component when the user is typing into the editor, thus it is responsible for sending keys to the current keymap. In addition, the EditorPane also does some undo management, as well as providing a facility for emphasizing particular lines through a highlight mark and temporary mark facility.

The EditorPane uses an EditorDocument class as the model, and an EditorView class as the view (to do the actual rendering of the text).

Through this component, other systems can call the editor APIs to manipulate the text contained in this component.

See Also:
EditorPane, EditorDocument, Serialized Form

Inner Class Summary
static class EditorPane.HighlightMark
          This is the highlight mark, placed on a line within the editor (through the document) to emphasize that line.
 
Inner classes inherited from class javax.swing.JEditorPane
javax.swing.JEditorPane.AccessibleJEditorPane, javax.swing.JEditorPane.AccessibleJEditorPaneHTML, javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport
 
Inner classes inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int CENTER_ALWAYS
           
static int CENTER_IF_NEAR_EDGE
           
static int CENTER_IF_OFFSCREEN
           
static int CENTER_NEVER
           
protected  int fontHeight
           
protected  java.awt.FontMetrics fontMetrics
           
protected  int fontWidth
           
protected  EditorPane.HighlightMark highlightMark
           
 ModalKeymap.ModeStateInfo keymapStateInfo
          This member records information specific to a particular keymap, including state info.
protected  javax.swing.Action lastAction
          This member records the last Action object executed on this editor instance.
static int LINE_PADDING
           
protected  boolean popupEnabled
           
 boolean processedKeyPressed
           
protected  LineMark temporaryMark
           
protected static ToolTipProvider toolTipProvider
          The editor will delegate to this object when it is asked for ToolTipText
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
EditorPane()
          Constructs a new EditorPane.
 
Method Summary
 int calcCaretPosition(int lineNumber, int column)
          Calculcate the caret position for a particular line and column of the the document.
 boolean canRedo()
          Check to see if we can redo in this editor.
 boolean canUndo()
          Check to see if we can undo in this editor.
 void clearHighlight()
          Clear the highlight.
 void clearTemporaryMark()
          Clear the temporary mark.
 void deleteNextChar()
          This method deletes the character immediately after the caret.
 void deletePrevChar()
          This method deletes the character immediately before the caret.
 void endUndoGroup()
          End the active undo group.
 void endUndoSegment()
          End the active undo segment.
 void focusGained(java.awt.event.FocusEvent e)
          Called when this editor gains focus.
 void focusLost(java.awt.event.FocusEvent e)
          Called when this editor loses focus.
 int getColumnNumber(int p0)
          Get the 1-based column number containing a particular position in the document.
 int getFontHeight()
          Return the height of the current font.
 java.awt.FontMetrics getFontMetrics()
          Return the FontMetrics of the current font.
 int getFontWidth()
          Return the width of the current font.
 ModalKeymap.ModeStateInfo getKeymapStateInfo()
          Get the state info object associated with this editor instance.
 javax.swing.Action getLastAction()
           
 int getLineCount()
          Get the number of lines in the document.
 int getLineNumber(int p0)
          Get the 1-based line number containing a particular position in the document.
 java.awt.Dimension getPreferredSize()
          Gets the preferred size of this component.
 int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Override this method so that vertical block scrolling will scroll one page at a time (determined by fontHeight), and that horizontal scrolling will scroll by the visible horizontal width.
 boolean getScrollableTracksViewportWidth()
          Return false here to allow horizontal scrolling.
 int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Override this method so that vertical unit scrolling will scroll one line at a time (determined by fontHeight), and that horizontal scrolling will scroll by 10% of the visible horizontal width.
 java.lang.String getTextLine(int lineNumber)
          Get the text contained in a particular line in the document.
 java.lang.String getToolTipText(java.awt.event.MouseEvent e)
          Get the text which should be displayed in a tooltip.
 void gotoLine(int lineNumber)
          Go to a particular line in the document.
 void gotoLine(int lineNumber, boolean highlight)
          Go to a particular line in the document.
 void gotoLine(int lineNumber, boolean highlight, int centerPolicy)
          Go to a particular line in the document.
 void gotoOffset(int p0)
          Go to a particular offset within the document.
 void gotoOffset(int p0, boolean highlight)
          Go to a particular offset within the document.
 void gotoOffset(int p0, boolean highlight, int centerPolicy)
          Go to a particular offset within the document.
 void gotoPosition(int line, int column)
          Go to a particular line and column position within the document.
 void gotoPosition(int line, int column, boolean highlight)
          Go to a particular line and column position within the document.
 void gotoPosition(int line, int column, boolean highlight, int centerPolicy)
          Go to a particular line and column position within the document.
 void insertAt(int lineNumber, int column, java.lang.String text)
          This is a convenience method to insert text at a particular position in the document.
 void insertAt(int p0, java.lang.String text)
          This is a convenience method to insert text at a particular position in the document.
 void insertChar(java.lang.String content)
          This method inserts the text in content (usually a single character) immediately after the caret.
 boolean isPopupEnabled()
          See if we should bring up a popup window in the editor's current state.
 void overwriteChar(java.lang.String content)
          This method deletes the character immediately after the caret, replacing it with the text in content (usually a single character).
 void paste()
          Transfers the contents of the system clipboard into the associated text model.
protected  void positionCaret(int point, int mark)
          Position the caret point and mark.
 void propertyChange(java.beans.PropertyChangeEvent e)
           
 void redo()
          Cause a redo in this editor.
 void redo(boolean checkPosition)
          Cause a redo in this editor.
static void registerToolTipProvider(ToolTipProvider provider)
          Register a tooltip provider for all editors to use.
 void repaintLine(int lineNumber)
          Repaints a particular line of the document.
 void replaceSelection(java.lang.String content)
          This method replaces the current selection with the text in content.
 void selectCharacters(int numChars)
          This is a convenience method used to select a number of characters from the current caret offset.
 void setCaret(javax.swing.text.Caret c)
          Set a new Caret for this EditorPane.
 void setCaretPosition(int lineNumber, int column)
          Set the caret to a particular line and column within the document.
 void setFont(java.awt.Font f)
          Sets the font of this component.
 void setHighlight(int lineNumber)
          Set the highlight to a particular line number.
 void setLastAction(javax.swing.Action action)
           
 void setPopupEnabled(boolean enabled)
          Set the editor to enable or disable popup windows.
 void setTemporaryMark(int lineNumber, LineMark mark)
          Set a temporary mark on a particular line number.
 void setTopLine(int lineNumber)
          Set the indicated line number to be the first line visible in the in the editor viewport.
 void startUndoGroup()
          Start an undo group.
 void startUndoSegment(int type)
          Start an undo segment.
 void undo()
          Cause an undo in this editor.
 void undo(boolean checkPosition)
          Cause an undo in this editor.
 void updateColors()
           
 void updateColors(javax.swing.text.StyleContext context)
           
 void updateUI()
          Override this method to reset our caret and keymap after the UI is changed.
 
Methods inherited from class javax.swing.JEditorPane
addHyperlinkListener, createDefaultEditorKit, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitForContentType, getPage, getScrollableTracksViewportHeight, getStream, getText, getUIClassID, isManagingFocus, paramString, processComponentKeyEvent, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, scrollToReference, setContentType, setEditorKit, setEditorKitForContentType, setPage, setPage, setText
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretPosition, getDisabledTextColor, getDocument, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getPreferredScrollableViewportSize, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getUI, isEditable, isFocusTraversable, isOpaque, loadKeymap, modelToView, moveCaretPosition, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, select, selectAll, setCaretColor, setCaretPosition, setDisabledTextColor, setDocument, setEditable, setEnabled, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setOpaque, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

toolTipProvider

protected static ToolTipProvider toolTipProvider
The editor will delegate to this object when it is asked for ToolTipText

highlightMark

protected EditorPane.HighlightMark highlightMark

temporaryMark

protected LineMark temporaryMark

processedKeyPressed

public boolean processedKeyPressed

popupEnabled

protected boolean popupEnabled

fontMetrics

protected java.awt.FontMetrics fontMetrics

fontWidth

protected int fontWidth

fontHeight

protected int fontHeight

keymapStateInfo

public ModalKeymap.ModeStateInfo keymapStateInfo
This member records information specific to a particular keymap, including state info.
See Also:
ModalKeymap

lastAction

protected javax.swing.Action lastAction
This member records the last Action object executed on this editor instance.

CENTER_ALWAYS

public static final int CENTER_ALWAYS

CENTER_IF_NEAR_EDGE

public static final int CENTER_IF_NEAR_EDGE

CENTER_IF_OFFSCREEN

public static final int CENTER_IF_OFFSCREEN

CENTER_NEVER

public static final int CENTER_NEVER

LINE_PADDING

public static int LINE_PADDING
Constructor Detail

EditorPane

public EditorPane()
Constructs a new EditorPane.
Method Detail

setLastAction

public void setLastAction(javax.swing.Action action)

getLastAction

public javax.swing.Action getLastAction()

updateUI

public void updateUI()
Override this method to reset our caret and keymap after the UI is changed.
Overrides:
updateUI in class javax.swing.text.JTextComponent
See Also:
JComponent.updateUI()

updateColors

public void updateColors()

updateColors

public void updateColors(javax.swing.text.StyleContext context)

setCaret

public void setCaret(javax.swing.text.Caret c)
Set a new Caret for this EditorPane. If a caret is already installed for this editor, we'll preserve the selection points so we can restore them in the new caret.
Overrides:
setCaret in class javax.swing.text.JTextComponent
Parameters:
c - the new Caret to set.

setFont

public void setFont(java.awt.Font f)
Sets the font of this component. We override this so that we can track specific things about the current font.
Overrides:
setFont in class javax.swing.JComponent
Parameters:
f - The font to become this component's font.
See Also:
Component.getFont()

getFontHeight

public int getFontHeight()
Return the height of the current font.

getFontWidth

public int getFontWidth()
Return the width of the current font. This actually returns the width of the space character, ' ', because this is assumed to be a fixed pitch font (where each character is the same width).

getFontMetrics

public java.awt.FontMetrics getFontMetrics()
Return the FontMetrics of the current font.

getKeymapStateInfo

public ModalKeymap.ModeStateInfo getKeymapStateInfo()
Get the state info object associated with this editor instance.

isPopupEnabled

public boolean isPopupEnabled()
See if we should bring up a popup window in the editor's current state.

setPopupEnabled

public void setPopupEnabled(boolean enabled)
Set the editor to enable or disable popup windows. Note that this is simply a marker flag that should be used by codeInsight and other such windows. When a system is going to bring up a popup window, that system should set this flag to false, so that *other* systems do not bring up popup windows, and so that the system in question doesn't bring itself up twice (unless the programmer really knows what he's doing).

It is also very important that any system which uses this flag resets it to the correct value when the system is finished, so that other systems can come up.


startUndoGroup

public void startUndoGroup()
Start an undo group. Subsequent edits are automatically added to the active undo group until endUndoGroup is called. This method passes the state of the caret to the UndoManager so that it can be restored if this undo group is undone.
See Also:
endUndoGroup()

endUndoGroup

public void endUndoGroup()
End the active undo group. This method passes the state of the caret to the UndoManager so that it can be restored if this undo group is redone.
See Also:
startUndoGroup()

startUndoSegment

public void startUndoSegment(int type)
Start an undo segment. Subsequent edits of the same type are automatically added to the active undo segment until endUndoSegment is called. This method passes the state of the caret to the UndoManager so that it can be restored if this undo group is undone.
Parameters:
type - The type of modification this undoSegment will contain. Valid types are:
  • JBUndoManager.INSERT
  • JBUndoManager.OVERWRITE
  • JBUndoManager.REMOVE
See Also:
endUndoSegment()

endUndoSegment

public void endUndoSegment()
End the active undo segment. This method passes the state of the caret to the UndoManager so that it can be restored if this undo group is redone.
See Also:
startUndoSegment(int)

canUndo

public boolean canUndo()
Check to see if we can undo in this editor.
See Also:
undo(), JBUndoManager

canRedo

public boolean canRedo()
Check to see if we can redo in this editor.
See Also:
undo(), JBUndoManager

undo

public void undo()
Cause an undo in this editor.

This method checks the caret positioning after the appropriate edit in the UndoManager. If the caret is not currently in that position, it is moved to that position. If it is already in that position, then the appropriate edit is undone.

See Also:
redo(), JBUndoManager

undo

public void undo(boolean checkPosition)
Cause an undo in this editor.

Parameters:
checkPosition - If true, this method checks the caret positioning after the appropriate edit in the UndoManager. If the caret is not currently in that position, it is moved to that position. If it is already in that position, then the appropriate edit is undone.
See Also:
redo(), JBUndoManager

redo

public void redo()
Cause a redo in this editor.

This method checks the caret positioning before the appropriate edit in the UndoManager. If the caret is not currently in that position, it is moved to that position. If it is already in that position, then the appropriate edit is redone.

See Also:
undo(), JBUndoManager

redo

public void redo(boolean checkPosition)
Cause a redo in this editor.

Parameters:
checkPosition - If true, this method checks the caret positioning after the appropriate edit in the UndoManager. If the caret is not currently in that position, it is moved to that position. If it is already in that position, then the appropriate edit is redone.
See Also:
redo(), JBUndoManager

positionCaret

protected void positionCaret(int point,
                             int mark)
Position the caret point and mark.
Parameters:
point - The offset at which to position the caret dot. If this value is -1, the caret is not moved.
mark - The offset at which to position the caret mark. If this value is -1, no mark is placed.

insertChar

public void insertChar(java.lang.String content)
                throws javax.swing.text.BadLocationException
This method inserts the text in content (usually a single character) immediately after the caret. After this operation, the caret is located after the newly inserted text.
Parameters:
content - A string consisting of the new content to insert. Null or an empty string here removes the character after the caret.

deleteNextChar

public void deleteNextChar()
                    throws javax.swing.text.BadLocationException
This method deletes the character immediately after the caret.

deletePrevChar

public void deletePrevChar()
                    throws javax.swing.text.BadLocationException
This method deletes the character immediately before the caret.

overwriteChar

public void overwriteChar(java.lang.String content)
                   throws javax.swing.text.BadLocationException
This method deletes the character immediately after the caret, replacing it with the text in content (usually a single character). After this operation, the caret is located after the newly inserted text.
Parameters:
content - A string consisting of the new content to insert. Null or an empty string here removes the character after the caret.

replaceSelection

public void replaceSelection(java.lang.String content)
This method replaces the current selection with the text in content.

This method should only be used when doing a non-trivial change, or when being called from within an undo group. This is because this method creates an undo group so that the removal of the current selection, and the insertion of the new text are treated as a unit. Since an undo group is used, these operations cannot be coalesced.

If a "primitive" operation is being performed, use deleteNextChar, deletePrevChar, overwriteChar, or insertChar.

Overrides:
replaceSelection in class javax.swing.JEditorPane
Parameters:
content - A string consisting of the new content to insert. Null or an empty string here simply deletes the existing selection.
See Also:
deleteNextChar(), #deletePreChar, overwriteChar(java.lang.String), insertChar(java.lang.String)

paste

public void paste()
Transfers the contents of the system clipboard into the associated text model. If there is a selection in the associated view, it is replaced with the contents of the clipboard. If there is no selection, the clipboard contents are inserted in front of the current insert position in the associated view. If the clipboard is empty, does nothing.

The one additional thing this method does is ensures that the pasted text uses linefeed characters as line separators.

Overrides:
paste in class javax.swing.text.JTextComponent
See Also:
replaceSelection(java.lang.String)

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the preferred size of this component. This is overridden so that we have a constant preferred width of 1028 characters, which eliminates the performance problems we see when we're trying to expand the width of the editor dynamically.
Overrides:
getPreferredSize in class javax.swing.JEditorPane
Returns:
A dimension object indicating this component's preferred size.
See Also:
Component.getPreferredSize()

getScrollableUnitIncrement

public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Override this method so that vertical unit scrolling will scroll one line at a time (determined by fontHeight), and that horizontal scrolling will scroll by 10% of the visible horizontal width.
Overrides:
getScrollableUnitIncrement in class javax.swing.text.JTextComponent
Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "unit" increment for scrolling in the specified direction
See Also:
Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)

getScrollableBlockIncrement

public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Override this method so that vertical block scrolling will scroll one page at a time (determined by fontHeight), and that horizontal scrolling will scroll by the visible horizontal width. The horizontal scrolling is written so that the the view always scrolls in whole multiples of one line height, so that lines do not appear to "crawl" up and down the screen as the user pages up and down.
Overrides:
getScrollableBlockIncrement in class javax.swing.text.JTextComponent
Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "block" increment for scrolling in the specified direction.
See Also:
Scrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Return false here to allow horizontal scrolling.
Overrides:
getScrollableTracksViewportWidth in class javax.swing.JEditorPane
Returns:
True if a viewport should force the Scrollables width to match its own.
See Also:
Scrollable.getScrollableTracksViewportWidth()

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Called when this editor gains focus. Here we notify EditorAction that the focused editor has changed so that any EditorActions which are invoked will have the correct target.
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Called when this editor loses focus. Here we do nothing because we may lose focus for a number of reasons. If the actual target for an EditorAction should change, it will be handled by either the new editor which gets focus, or by another component //!MT - (which one?) acting as a BrowserListener.
Specified by:
focusLost in interface java.awt.event.FocusListener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

setTemporaryMark

public void setTemporaryMark(int lineNumber,
                             LineMark mark)
Set a temporary mark on a particular line number. A temporary mark is "temporary" because it will go away as soon as the editor gets focus. It's primarily used to draw the users attention to a particular line in the editor when the editor is being driven from an external source.

There can only be one temporary mark per editor, so this method has the side effect of removing the previous temporary mark.

Parameters:
lineNumber - the 1-based line number where the temporary mark should be placed.
mark - The LineMark to use as the temporary mark.

setHighlight

public void setHighlight(int lineNumber)
Set the highlight to a particular line number. There can only be one highlighted line per document, so this method has the side effect of removing the previous highlighted line.
Parameters:
lineNumber - the 1-based line number that should be highlighted.

clearHighlight

public void clearHighlight()
Clear the highlight.

clearTemporaryMark

public void clearTemporaryMark()
Clear the temporary mark.

repaintLine

public void repaintLine(int lineNumber)
Repaints a particular line of the document.
Parameters:
lineNumber - the line number to repaint.

getLineCount

public int getLineCount()
Get the number of lines in the document.
Returns:
the number of lines in the document.

gotoOffset

public void gotoOffset(int p0,
                       boolean highlight,
                       int centerPolicy)
Go to a particular offset within the document.

NOTE: The gotoOffset(...) methods are generally used when driving the editor from an outside source. If you simply wish to position the caret within an EditorAction, you should probably use setCaretPosition().

Parameters:
p0 - The offset to go to.
highlight - True if the editor should highlight the line.
center - True if the editor should center on the line containing the offset. If false, the editor will simply ensure that the line is within the viewport.

gotoOffset

public void gotoOffset(int p0,
                       boolean highlight)
Go to a particular offset within the document. This will center the line on which the offset occurs.

NOTE: The gotoOffset(...) methods are generally used when driving the editor from an outside source. If you simply wish to position the caret within an EditorAction, you should probably use setCaretPosition().

Parameters:
p0 - The offset to go to.
highlight - True if the editor should highlight the line.

gotoOffset

public void gotoOffset(int p0)
Go to a particular offset within the document. This will center the line on which the offset occurs.

NOTE: The gotoOffset(...) methods are generally used when driving the editor from an outside source. If you simply wish to position the caret within an EditorAction, you should probably use setCaretPosition().

Parameters:
p0 - The offset to go to.

gotoLine

public void gotoLine(int lineNumber,
                     boolean highlight,
                     int centerPolicy)
Go to a particular line in the document.
Parameters:
lineNumber - the 1-based line number to go to
highlight - True if the editor should highlight the line.
center - True if the editor should center on the line in question. If false, the editor will simply ensure that the line is within the viewport.

gotoLine

public void gotoLine(int lineNumber,
                     boolean highlight)
Go to a particular line in the document. This will center the line.
Parameters:
lineNumber - the line number to go to
highlight - True if the editor should highlight the line.

gotoLine

public void gotoLine(int lineNumber)
Go to a particular line in the document. This will center and highlight the line.
Parameters:
lineNumber - the line number to go to

gotoPosition

public void gotoPosition(int line,
                         int column,
                         boolean highlight,
                         int centerPolicy)
Go to a particular line and column position within the document.
Parameters:
line - The 1-based line number to go to.
column - The 1-based column number to go to.
highlight - True if the editor should highlight the line.
center - True if the editor should center on the line containing the position in question. If false, the editor will simply ensure that the line is within the viewport.

gotoPosition

public void gotoPosition(int line,
                         int column,
                         boolean highlight)
Go to a particular line and column position within the document. This will center on the line in which the position occurs.
Parameters:
line - The 1-based line number to go to.
column - The 1-based column number to go to.
highlight - True if the editor should highlight the line.
center - True if the editor should center on the line containing the position in question. If false, the editor will simply ensure that the line is within the viewport.

gotoPosition

public void gotoPosition(int line,
                         int column)
Go to a particular line and column position within the document. This will center on the line in which the position occurs.
Parameters:
line - The 1-based line number to go to.
column - The 1-based column number to go to.

getLineNumber

public int getLineNumber(int p0)
Get the 1-based line number containing a particular position in the document.
Parameters:
p0 - the position for which to return the line number.
Returns:
the 1-based line number containing the position p0.

getColumnNumber

public int getColumnNumber(int p0)
Get the 1-based column number containing a particular position in the document.
Parameters:
p0 - the position for which to return the column number.
Returns:
the 1-based column number containing the position p0.

getTextLine

public java.lang.String getTextLine(int lineNumber)
Get the text contained in a particular line in the document.
Parameters:
lineNumber - the 1-based linenumber for which to retrieve the text.
Returns:
the text contained on the indicated line. If lineNumber is out of the range of the document, this method returns null.

insertAt

public void insertAt(int p0,
                     java.lang.String text)
This is a convenience method to insert text at a particular position in the document.
Parameters:
p0 - The position in which to insert the text.
text - The text to insert at position p0.

insertAt

public void insertAt(int lineNumber,
                     int column,
                     java.lang.String text)
This is a convenience method to insert text at a particular position in the document.
Parameters:
line - The line number on which to insert the text. This parameter is 1-based.
column - The column number on which to insert the text. This parameter is 1-based.
text - The text to insert.

setCaretPosition

public void setCaretPosition(int lineNumber,
                             int column)
Set the caret to a particular line and column within the document. If the line is past the last line in the document, the caret is placed on the last line. If the column is past the last column on the indicated line, the caret is placed in the last column.
Parameters:
line - The line number on which to position the caret. This parameter is 1-based.
column - The column number on which to position the caret. This parameter is 1-based.

calcCaretPosition

public int calcCaretPosition(int lineNumber,
                             int column)
Calculcate the caret position for a particular line and column of the the document.
Parameters:
line - The line number for which to calculate the position. This parameter is 1-based. If this is out of the document's range, it is treated as either the first or last line of the document.
column - The column number for which to calculate the position. This parameter is 1-based. If this is out of the line's range, it is treated as the first column of the line.
Returns:
the offset corresponding to the line and column passed.

selectCharacters

public void selectCharacters(int numChars)
This is a convenience method used to select a number of characters from the current caret offset. Any previous selection is unselected by this operation.
Parameters:
numChars - the number of characters to select from the current caret offset.

setTopLine

public void setTopLine(int lineNumber)
Set the indicated line number to be the first line visible in the in the editor viewport.
Parameters:
lineNumber - the 1-based lineNumber to make the first visible line.

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
Get the text which should be displayed in a tooltip.
Overrides:
getToolTipText in class javax.swing.JComponent

registerToolTipProvider

public static void registerToolTipProvider(ToolTipProvider provider)
Register a tooltip provider for all editors to use.