|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.text.JTextComponent | +--javax.swing.JEditorPane | +--com.borland.primetime.editor.EditorPane
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.
EditorPane
,
EditorDocument
, Serialized FormInner 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 |
protected static ToolTipProvider toolTipProvider
protected EditorPane.HighlightMark highlightMark
protected LineMark temporaryMark
public boolean processedKeyPressed
protected boolean popupEnabled
protected java.awt.FontMetrics fontMetrics
protected int fontWidth
protected int fontHeight
public ModalKeymap.ModeStateInfo keymapStateInfo
ModalKeymap
protected javax.swing.Action lastAction
public static final int CENTER_ALWAYS
public static final int CENTER_IF_NEAR_EDGE
public static final int CENTER_IF_OFFSCREEN
public static final int CENTER_NEVER
public static int LINE_PADDING
Constructor Detail |
public EditorPane()
Method Detail |
public void setLastAction(javax.swing.Action action)
public javax.swing.Action getLastAction()
public void updateUI()
JComponent.updateUI()
public void updateColors()
public void updateColors(javax.swing.text.StyleContext context)
public void setCaret(javax.swing.text.Caret c)
c
- the new Caret to set.public void setFont(java.awt.Font f)
f
- The font to become this component's font.Component.getFont()
public int getFontHeight()
public int getFontWidth()
public java.awt.FontMetrics getFontMetrics()
public ModalKeymap.ModeStateInfo getKeymapStateInfo()
public boolean isPopupEnabled()
public void setPopupEnabled(boolean enabled)
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.
public void startUndoGroup()
endUndoGroup()
public void endUndoGroup()
startUndoGroup()
public void startUndoSegment(int type)
type
- The type of modification this undoSegment will contain. Valid
types are:endUndoSegment()
public void endUndoSegment()
startUndoSegment(int)
public boolean canUndo()
undo()
,
JBUndoManager
public boolean canRedo()
undo()
,
JBUndoManager
public void undo()
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.
redo()
,
JBUndoManager
public void undo(boolean checkPosition)
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.redo()
,
JBUndoManager
public void redo()
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.
undo()
,
JBUndoManager
public void redo(boolean checkPosition)
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.redo()
,
JBUndoManager
protected void positionCaret(int point, int mark)
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.public void insertChar(java.lang.String content) throws javax.swing.text.BadLocationException
content
- A string consisting of the new content to insert. Null or
an empty string here removes the character after the caret.public void deleteNextChar() throws javax.swing.text.BadLocationException
public void deletePrevChar() throws javax.swing.text.BadLocationException
public void overwriteChar(java.lang.String content) throws javax.swing.text.BadLocationException
content
- A string consisting of the new content to insert. Null or
an empty string here removes the character after the caret.public void replaceSelection(java.lang.String 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.
content
- A string consisting of the new content to insert. Null or
an empty string here simply deletes the existing selection.deleteNextChar()
,
#deletePreChar
,
overwriteChar(java.lang.String)
,
insertChar(java.lang.String)
public void paste()
The one additional thing this method does is ensures that the pasted text uses linefeed characters as line separators.
replaceSelection(java.lang.String)
public java.awt.Dimension getPreferredSize()
Component.getPreferredSize()
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
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.Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
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.Scrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)
public boolean getScrollableTracksViewportWidth()
Scrollable.getScrollableTracksViewportWidth()
public void focusGained(java.awt.event.FocusEvent e)
public void focusLost(java.awt.event.FocusEvent e)
public void propertyChange(java.beans.PropertyChangeEvent e)
public void setTemporaryMark(int lineNumber, LineMark mark)
There can only be one temporary mark per editor, so this method has the side effect of removing the previous temporary mark.
lineNumber
- the 1-based line number where the temporary mark should
be placed.mark
- The LineMark to use as the temporary mark.public void setHighlight(int lineNumber)
lineNumber
- the 1-based line number that should be highlighted.public void clearHighlight()
public void clearTemporaryMark()
public void repaintLine(int lineNumber)
lineNumber
- the line number to repaint.public int getLineCount()
public void gotoOffset(int p0, boolean highlight, int centerPolicy)
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().
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.public void gotoOffset(int p0, boolean highlight)
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().
p0
- The offset to go to.highlight
- True if the editor should highlight the line.public void gotoOffset(int p0)
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().
p0
- The offset to go to.public void gotoLine(int lineNumber, boolean highlight, int centerPolicy)
lineNumber
- the 1-based line number to go tohighlight
- 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.public void gotoLine(int lineNumber, boolean highlight)
lineNumber
- the line number to go tohighlight
- True if the editor should highlight the line.public void gotoLine(int lineNumber)
lineNumber
- the line number to go topublic void gotoPosition(int line, int column, boolean highlight, int centerPolicy)
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.public void gotoPosition(int line, int column, boolean highlight)
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.public void gotoPosition(int line, int column)
line
- The 1-based line number to go to.column
- The 1-based column number to go to.public int getLineNumber(int p0)
p0
- the position for which to return the line number.public int getColumnNumber(int p0)
p0
- the position for which to return the column number.public java.lang.String getTextLine(int lineNumber)
lineNumber
- the 1-based linenumber for which to retrieve the text.public void insertAt(int p0, java.lang.String text)
p0
- The position in which to insert the text.text
- The text to insert at position p0.public void insertAt(int lineNumber, int column, java.lang.String text)
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.public void setCaretPosition(int lineNumber, int column)
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.public int calcCaretPosition(int lineNumber, int column)
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.public void selectCharacters(int numChars)
numChars
- the number of characters to select from the current caret
offset.public void setTopLine(int lineNumber)
lineNumber
- the 1-based lineNumber to make the first visible line.public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
public static void registerToolTipProvider(ToolTipProvider provider)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |