|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.jidesoft.editor.CodeEditor
public class CodeEditor
CodeEditor is a text component for source code viewing and editing.
It containsCodeEditorPainter
as its major area to display/edit the code. If you want to add mouse
listener, please make sure you invoke yourCodeEditor.getPainter().addMouseListener()
. Same rule applies
to mouse motion listeners and key listeners.
On the left of the major edit area, it's margin area panel, you could invoke getMarginArea()
to get the
panel and add new margin area to it. By default, we added RowNumberMargin
to the left, you could add other
margin components to that area if you want to customize it to have something like break point, bookmark, etc. You
could invoke setLineNumberVisible(boolean)
to make the default line number margin invisible.
Each CodeEditor could define a single MarkerArea
. It's not part of the CodeEditor.
However, usually you would layout it on the right of the major edit area and the vertical scroll bar. With the help
of MarkerArea, you would be able to add some parse information to that area to indicate wrong input or warning
information. Please check out PhpSyntaxParsingDemo
for the detail implementations.
To help searching inside the CodeEditor, CodeEditor provides two solutions. One is integrated FindAndReplace
which could be triggered with CTRL+F. That will provide REGEX searching or normal
wildcard searching options. Another searching option is the uninstallable CodeEditorSearchable
. You could find the detail implementation at CodeEditorDemo
Please invoke getHighlighter()
to highlight some part of your target documents if necessary.
Sometimes, the customers may need to collapse several parts of code to help reviewing or editing. In this case, you
may utilize getFoldingModel()
and invoke FoldingModel.addFoldingSpan(int,
int, String)
to add the folding spans. As long as you define your folding spans with initial index, CodeEditor will
update the indices appropriately based on the recent character inputs. You could leverage CodeFoldingMargin
to help your customer gain a better sense of where the code folding is.
Please be noted that, so far if you allow tabs in your document, this feature would behave incorrectly. We will fix
this issue in later releases.
Please invoke setTokenMarker(com.jidesoft.editor.tokenmarker.TokenMarker)
to set your customized token
marker. JIDE provided several default TokenMakers for your quick use.
Please invoke getInputHandler()
to get the InputHandler instance. If you want to change the default key
combinations, you would need access that class.
In normal cases, please just invoke setText(String)
to feed CodeEditor the string to review or edit. Please
invoke getText()
to get current string in the memory after editing to output. However, if you are reviewing
or editing a large document and worry about the memory, please invoke setFileName(String)
)} to feed
CodeEditor with strings from the input stream. In this case, CodeEditor will utilize LazyLoadDocument
to load the file page by page to save the memory. You would need invoke exportToOutputStream(java.io.OutputStream)
to output the string after editing. If you do have a large file, please
try not to invoke getText()
. Otherwise, it may cause heap memory used up.
Nested Class Summary | |
---|---|
static class |
CodeEditor.DefaultUIResourceHighlighter
|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
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 |
Fields inherited from interface com.jidesoft.editor.LineBreak |
---|
CR, LF, LINE_BREAK_CODE_EDITOR, LINE_BREAK_MAC, LINE_BREAK_MIXED, LINE_BREAK_PC, LINE_BREAK_UNIX, LINE_BREAK_UNKNOWN, STRING_CR, STRING_CR_LF, STRING_LF |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
CodeEditor()
Creates a new CodeEditor with the default settings. |
|
CodeEditor(DefaultSettings defaults)
Creates a new CodeEditor with the specified settings. |
Method Summary | |
---|---|
int |
_offsetToX(int offset)
Converts an offset in a document into an x co-ordinate. |
int |
_offsetToX(int line,
int offset)
Deprecated. replaced by _offsetToX(int) |
void |
addCodeInspector(CodeInspector inspector)
|
void |
addColumnGuide(ColumnGuide guide)
Adds a column guide and repaint the code editor. |
void |
addNotify()
|
protected void |
adjustColumnSelectionModelOnCaretMoving(boolean select)
Adjusts the column seletion model to false when the caret is moving without selection. |
void |
append(String text)
|
void |
backspaceChar()
Deletes a char before the caret if there is no selection. |
void |
backspaceWord()
Deletes from current caret to the start of the word if the caret is not at the start of the word or to the start of the previous word if the caret is currently at the start of the word. |
void |
blinkCaret()
Blinks the caret. |
void |
blockComments()
Comments the selected text using block comments. |
void |
caretUpdated(CaretEvent e)
This method will be called whenever caret position changes. |
static void |
clearClipboards()
Clears clipboards memory. |
void |
clipboardCopy()
Places the selected text into the clipboard. |
void |
clipboardCut()
Deletes the selected text from the text area and places it into the clipboard. |
void |
clipboardMove(int offset)
Moves the selected text to the offset. |
void |
clipboardPaste()
Inserts the clipboard contents into the document. |
void |
collapseAll()
Collapses all expanded spans. |
void |
collapseFolding()
Collapses the expanded span if any. |
int |
columnToX(int column)
Deprecated. as this method doesn't consider the actual font it is used so when the font is not fix-width, this method will return the wrong result. The correct one to use is columnToX(int, int) which takes the line
index. |
int |
columnToX(int line,
int column)
Converts from the column to x position (in pixels). |
void |
commentLine()
|
void |
commentLine(int line)
|
void |
configureStyledLabel(StyledLabel styledLabel,
Object userObject)
Configure the styled label to display the find result. |
protected ClipboardOwner |
createClipboardOwner()
Create ClipboardOwner instance. |
protected CodeEditorPainter |
createCodeEditorPainter(CodeEditor editor)
|
protected TransferHandler |
createDefaultTransferHandler()
Creates the default TransferHandler. |
protected Highlighter |
createHighlighter()
Creates the object to use for adding highlights. |
protected LazyLoadDocument |
createLazyLoadDocument()
Creates the LazyLoadDocument instance. |
protected OutputStreamWriter |
createOutputStreamWriter(OutputStream outputStream)
|
JComponent |
createOverlay()
|
protected DocumentEvent |
createReplaceAllDocumentEvent()
Creates the DocumentEvent for replace all. |
protected JScrollBar |
createScrollBar(int orientation)
Creates the scroll bars used by the CodeEditor. |
protected Searchable |
createSearchable(CodeEditor editor)
Creates a Searchable for the CodeEditor . |
protected SelectionModel |
createSelectionModel()
Create selection model for CodeEditor. |
protected void |
customizeDialog(StandardDialog dialog)
Customizes the dialog to be visible. |
protected void |
customizeDialogData(StandardDialog dialog)
Customizes the dialog to be pack. |
void |
deleteChar()
Deletes a char at the caret if there is no selection. |
void |
deleteLine()
Deletes the entire line including line break associated with the line. |
void |
deleteWord()
Deletes from current caret to the start of the next word. |
void |
discardAllEdits()
|
void |
dispose()
Disposes the CodeEditor. |
protected void |
documentChanged(DocumentEvent evt)
|
void |
duplicateSelection()
Inserts the selected text to the start of the current selection. |
void |
escape()
Clears the selection if any. |
void |
expandAll()
Expands all folded spans. |
void |
expandFolding()
Expands the folded span if any. |
protected int |
exportText(String in,
StringBuffer out)
Converts text with LINE_BREAK_CODE_EDITOR as line break to the line break style on this code editor. |
boolean |
exportToOutputStream(OutputStream outputStream)
Exports the contents inside the CodeEditor to an output stream. |
void |
find()
Shows a find dialog to let the customer input searching text then search the text in the document or the current selected text. |
void |
findNext()
Looks for the next match in the document or the current selected text. |
void |
findPrevious()
Looks for the previous match in the document or the current selected text. |
int |
getAnchorSelectionOffset()
Gets the anchor offset of the selection. |
Color |
getBracketHighlightColor()
Returns the bracket highlight color. |
int |
getBracketLine()
|
int |
getBracketPosition()
|
Color |
getCaretColor()
Returns the caret color. |
Point |
getCaretLocation()
|
Point |
getCaretLocationOnScreen()
|
CaretModel |
getCaretModel()
|
int |
getCaretPosition()
|
CodeInspector |
getCodeInspector(int i)
|
int |
getCodeInspectorCount()
|
CodeInspector[] |
getCodeInspectors()
|
ColumnGuide[] |
getColumnGuides()
Gets all the column guides. |
Dimension |
getContentSize()
|
int |
getCorrespondingColumn(int column,
int oldLine,
int newLine)
Get corresponding column in the new line which visually in the same column of the column in the old line. |
int |
getCurrentIndentForLine(int lineIndex,
int[] whitespaceChars)
Returns the line's current leading indent. |
String |
getCurrentWord()
|
String |
getCurrentWord(String noWordDelimiters)
|
int[] |
getCurrentWordBounds()
|
int[] |
getCurrentWordBounds(String nonwordDelimiters)
|
int |
getDefaultLineBreakStyle()
Gets the default line break style. |
SyntaxDocument |
getDocument()
Returns the document this text area is editing. |
int |
getDocumentLength()
Returns the length of the document. |
boolean |
getDragEnabled()
Gets the value of the dragEnabled property. |
int |
getElectricScroll()
Returns the number of lines from the top and button of the text area that are always visible. |
String |
getFileName()
Get the full path to the file that the CodeEditor is currently editing. |
FindAndReplace |
getFindAndReplace()
|
int |
getFirstLine()
Returns the first line displayed at the text area's origin. |
Highlighter |
getFixedHighlighter()
Fetches the object responsible for making fixed highlights that can only be changed through code. |
boolean |
getFocusCycleRoot()
|
boolean |
getFocusTraversalKeysEnabled()
|
FoldingModel |
getFoldingModel()
|
Highlighter |
getHighlighter()
Fetches the object responsible for making highlights. |
int |
getHorizontalOffset()
Returns the horizontal offset of drawn lines. |
JScrollBar |
getHorizontalScrollBar()
Gets the horizontal scroll bar used by CodeEditor. |
int |
getHorizontalScrollBarPolicy()
Get the horizontal scroll bar policy. |
InputHandler |
getInputHandler()
Returns the input handler. |
InputMethodRequests |
getInputMethodRequests()
|
int |
getLeadSelectionOffset()
Gets the lead offset of the selection. |
String |
getLeftWordPart()
|
String |
getLeftWordPart(String nonwordDelimiters)
|
int |
getLineBreakStyle()
|
int |
getLineCount()
Returns the number of lines in the document. |
int |
getLineEndOffset(int line)
Returns the end offset of the specified line. |
int |
getLineHeight()
|
Color |
getLineHighlightColor()
Returns the line highlight color. |
int |
getLineLength(int line)
Gets the length of the specified line. |
int |
getLineNumber(int offset)
Returns the line containing the specified offset. |
RowNumberMargin |
getLineNumberMargin()
|
int |
getLineStartOffset(int line)
Returns the start offset of the specified line. |
int |
getLineStartOffsetNoSpace(int line)
Returns the start offset of the specified line exclude the spaces. |
String |
getLineText(int lineIndex)
Returns the text on the specified line. |
boolean |
getLineText(int lineIndex,
Segment segment)
Copies the text on the specified line into a segment. |
int |
getMagicCaretPosition()
Returns the `magic' caret position. |
MarginArea |
getMarginArea()
|
MarkerArea |
getMarkerArea()
|
MarkerModel |
getMarkerModel()
|
int |
getMarkPosition()
Returns the mark position. |
int |
getMaxNumberOfClipboards()
|
CodeEditorPainter |
getPainter()
Get CodeEditorPainter instance. |
String |
getRawText()
Returns the entire text of this text area. |
String |
getResourceString(String key)
Gets the resource string used by CodeEditor. |
Searchable |
getSearchable()
|
String |
getSelectedText()
|
Color |
getSelectionColor()
Returns the selection color. |
int |
getSelectionEnd()
|
int |
getSelectionEnd(int line)
Gets the offset where the selection ends on the specified line. |
int |
getSelectionEndLine()
|
SelectionModel |
getSelectionModel()
|
int |
getSelectionStart()
Gets the selection start offset on the entire document. |
int |
getSelectionStart(int line)
Gets the offset where the selection starts on the specified line. |
int |
getSelectionStartLine()
Gets the selection start line. |
Color |
getSpecialCharactersColor()
Returns the special characters such as space, tab and end of line color. |
SyntaxStyleSchema |
getStyles()
Returns the syntax styles used to paint colorized text. |
int |
getTabSize()
|
String |
getText()
Returns the entire text of this text area. |
String |
getText(int start,
int len)
Returns the specified substring of the document. |
void |
getText(int start,
int len,
Segment segment)
Copies the specified substring of the document into a segment. |
TokenMarker |
getTokenMarker()
Returns the document's token marker. |
TransferHandler |
getTransferHandler()
|
JScrollBar |
getVerticalScrollBar()
Gets the vertical scroll bar used by CodeEditor. |
int |
getVerticalScrollBarPolicy()
Get the vertical scroll bar policy. |
int |
getVisibleLines()
|
int |
getVisualLineCount()
|
void |
gotoEndOfLine()
|
void |
gotoLine(int line)
Go to the model line. |
void |
gotoLineAtView(int line)
Go to the view line. |
void |
gotoOffset(int offset)
Go to the offset. |
protected int |
importText(String in,
StringBuffer out)
Converts the text with any line break style to LINE_BREAK_CODE_EDITOR style (LF only). |
void |
indentLine(int line)
|
boolean |
indentLine(int lineIndex,
boolean decrease)
|
void |
indentLinesBetween(int startLine,
int endLine)
|
void |
indentSelectedLines()
|
void |
indentSelection()
Indents all selected lines no matter if the selection is a line selection or not if there is a selection. |
void |
initializeDefaultSettings(DefaultSettings defaults)
setPainter must be called first |
void |
insertBreak()
Deletes current selected text if any then inserts a line break. |
void |
insertChar(String str)
Inserts the string into the document. |
void |
inspectCode()
Triggers CodeInspector s added to this CodeEditor to inspect the code. |
void |
inspectCode(DocumentEvent event)
Triggers CodeInspector s added to this CodeEditor to inspect the code. |
protected List<ColumnGuide> |
internalGetColumnGuides()
Gets all the column guides. |
boolean |
isAdjustColumnSelectionOnMouseEvent()
Gets the flag indicating if the column selection mode should be automatically adjusted on mouse dragging. |
boolean |
isAutoInspecting()
Check if autoInspecting is on. |
boolean |
isBlink()
Gets the flag indicating if the caret currently is blinking. |
boolean |
isBlockCaret()
Checks if the block caret is used. |
boolean |
isBracketHighlightVisible()
Checks if the bracket highlight is visible. |
boolean |
isCaretBlinks()
Returns true if the caret is blinking, false otherwise. |
boolean |
isCaretVisible()
Returns true if the caret is visible, false otherwise. |
boolean |
isChangePromptDialogPosition()
Gets the flag indicating if prompt dialog position should be changed to show current selected text. |
protected boolean |
isColumnSelectionMode(MouseEvent evt)
Checks if the mouse event indicates a ColumnSelectionModel. |
boolean |
isContentVisible()
Get the flag indicating if the content should be visible right now. |
boolean |
isCopyVisibleTextOnly()
Gets the flag indicating if only visible text should be copied to clipboard or dragged. |
boolean |
isDelayContentsOnLoading()
Get the flag indicating if the contents in the code editor should be hidden while the page need to be loaded. |
boolean |
isEditable()
Returns true if this text area is editable, false otherwise. |
boolean |
isIndentOnPasting()
Gets the flag indicating if the pasted multiple-line text should respect the indent of the previous line. |
boolean |
isLineBreakStyleMixed()
|
boolean |
isLineHighlightVisible()
Checks if the line highlight is visible. |
boolean |
isLineNumberVisible()
|
boolean |
isManagingFocus()
Returns if this component can be traversed by pressing the Tab key. |
boolean |
isOverwriteEnabled()
|
boolean |
isPaintInvalid()
Get the paint invalid flag. |
boolean |
isReplaceTabWithSpace()
|
boolean |
isSelectionRectangular()
|
boolean |
isShowToolTipOverMarkedText()
Get the flag indicating if the tooltip should be displayed while the mouse hover on a marked text. |
boolean |
isSkipsEmptyLinesOnLineComments()
Gets the flag indicating if the line comment action should skip the empty lines. |
boolean |
isSpecialCharactersVisible()
Get the flag indicating if the special characters are visible. |
boolean |
isTabAlignment()
Get the flag indicating TAB key is to alignment or just add fixed number of spaces. |
boolean |
isVirtualSpaceAllowed()
|
void |
joinLines()
Joins all selected lines by deleting line breaks and the empty spaces leading the lines. |
void |
lineComments()
Comments all selected lines using line comments no matter if the selection is a line selection or not if there is a selection. |
int |
lineToY(int line)
Converts a line index to y coordinate. |
void |
loadActionMap()
Loads the default actions to the ActionMap so that other tools can look up the action map to find out the actions. |
int |
modelPositionToOffset(CaretPosition p)
|
Rectangle |
modelToView(int offset)
|
Rectangle |
modelToView(int startOffset,
int endOffset)
|
int |
modelToViewLine(int line)
|
CaretPosition |
modelToViewPosition(CaretPosition p)
Get view position from model position. |
void |
moveToDocumentEnd(boolean select)
Moves the caret to the end of the document. |
void |
moveToDocumentStart(boolean select)
Moves the caret to the start of the document. |
void |
moveToLineEnd(boolean select)
Moves the caret to the end of the line where the caret resides. |
void |
moveToLineStart(boolean select)
Moves the caret to the start of the line where the caret resides. |
void |
moveToNextChar(boolean select)
Moves the caret to the next column if isVirtualSpaceAllowed() is true. |
void |
moveToNextLine(boolean select)
Moves the caret to the next line. |
void |
moveToNextPage(boolean select)
Moves the caret to the next page. |
void |
moveToNextWord(boolean select)
Moves caret to the the word start of the next word. |
void |
moveToNextWord(boolean select,
boolean toWordStart)
If toWordStart is false, moves caret to the the word end of the current word if the caret is not on the end of the current word or to the word end of the next word if the caret is on the end of the current word. |
void |
moveToPreviousChar(boolean select)
Moves the caret to the previous column or stay at column 0 if isVirtualSpaceAllowed() is true. |
void |
moveToPreviousLine(boolean select)
Moves the caret to the previous line. |
void |
moveToPreviousPage(boolean select)
Moves the caret to the previous page. |
void |
moveToPreviousWord(boolean select)
Moves caret to the the word start of the current word if the caret is not on the start of the current word or to the word start of the previous word if the caret is on the start of the current word. |
void |
moveToPreviousWord(boolean select,
boolean toWordEnd)
If toWordEnd is false, moves caret to the the word start of the current word if the caret is not on the start of the current word or to the word start of the previous word if the caret is on the start of the current word. |
int |
offsetToLine(int offset)
Deprecated. replaced by offsetToViewPosition(int) |
CaretPosition |
offsetToModelPosition(int offset)
|
CaretPosition |
offsetToViewPosition(int offset)
|
int |
offsetToX(int offset)
Converts an offset in a document into an x co-ordinate. |
int |
offsetToX(int line,
int offset)
Deprecated. replaced by offsetToX(int) |
void |
overwriteSetSelectedText(String str)
Similar to setSelectedText() , but overwrite the appropriate number of characters if overwrite mode
is enabled. |
protected void |
pageLoadFailedHandling(PageLoadEvent e)
The action to take while page loading process is failed. |
void |
pasteWithDialog()
Shows a dialog so that the customer could choose text from the clipboard contents to paste. |
void |
pauseBlink()
Pauses the blink and set caret to display. |
void |
processKeyEvent(KeyEvent evt)
Forwards key events directly to the input handler. |
void |
promptGotoLine()
Shows a dialog so that the customer could input a line number then jump to the line. |
void |
promptGotoLineAtView()
|
void |
promptGotoOffset()
|
void |
propertyChange(PropertyChangeEvent evt)
|
void |
quickSearch(String searchingText)
Shows a Searchable popup to start searching quickly. |
protected Dimension |
recalculateContentSize()
|
void |
recalculateVisibleLines()
Recalculates the number of visible lines. |
void |
redo()
Redo the last action (if possible). |
void |
removeAllColumnGuides()
Removes all column guides that were added before and repaint the code editor. |
void |
removeCodeInspector(CodeInspector inspector)
|
void |
removeColumnGuide(ColumnGuide guide)
Removes a column guide and repaint the code editor. |
void |
removeNotify()
|
void |
repaint()
|
void |
repaint(long tm)
|
void |
repaint(long tm,
int x,
int y,
int width,
int height)
|
void |
replace()
Shows a find and replace dialog to let the customer input searching text then search the text in the document or the current selected text. |
protected void |
resetContentSize()
|
void |
scrollDownPage()
Scrolls down by one page. |
boolean |
scrollTo(CaretPosition position)
Ensures that the specified line and offset is visible by scrolling the text area if necessary. |
boolean |
scrollToCaret()
Ensures that the caret is visible by scrolling the text area if necessary. |
boolean |
scrollToViewPosition(CaretPosition vp)
Ensures that the specified line and offset is visible by scrolling the text area if necessary. |
protected boolean |
scrollToViewPosition(CaretPosition vp,
CaretPosition anotherVp)
Ensures that the specified line and offset is visible by scrolling the text area if necessary. |
void |
scrollUpPage()
Scrolls up by one page. |
void |
select(int caret)
Sets the caret position. |
void |
select(int start,
int end)
Selects from the start offset to the end offset. |
void |
select(int start,
int end,
boolean scroll)
Selects from the start offset to the end offset. |
void |
selectAll()
Selects all text in the document. |
void |
selectBlock()
Selects the code block surrounding the caret. |
void |
selectionChanged(SelectionEvent e)
Called when selection changed. |
void |
selectLine(int line)
Select the model line. |
void |
selectLines(int start,
int end)
Select the model lines. |
void |
selectNone()
Moves the mark to the caret position. |
void |
selectToMatchingBracket()
Selects the block between the closest pair of brackets which contains current caret. |
void |
selectWord()
Selects the word in current caret position. |
void |
selectWord(String noWordSep)
|
void |
setAdjustColumnSelectionOnMouseEvent(boolean adjustColumnSelectionOnMouseEvent)
Sets the flag indicating if the column selection mode should be automatically adjusted on mouse dragging. |
void |
setAutoInspecting(boolean autoInspecting)
Sets autoInspecting option. |
void |
setBlink(boolean blink)
Sets the flag indicating if the caret currently is blinking. |
void |
setBlockCaret(boolean blockCaret)
Sets if the caret should be drawn as a block, false otherwise. |
void |
setBracketHighlightColor(Color bracketHighlightColor)
Sets the bracket highlight color. |
void |
setBracketHighlightVisible(boolean bracketHighlight)
Enables or disables bracket highlighting. |
void |
setCaretBlinks(boolean caretBlinks)
Toggles caret blinking. |
void |
setCaretColor(Color caretColor)
Sets the caret color. |
void |
setCaretPosition(int offset)
|
void |
setCaretVisible(boolean caretVisible)
Sets if the caret should be visible. |
void |
setChangePromptDialogPosition(boolean changePromptDialogPosition)
Sets the flag indicating if prompt dialog position should be changed to show current selected text. |
void |
setContentVisible(boolean contentVisible)
Set the flag indicating if the content should be visible right now. |
void |
setCopyVisibleTextOnly(boolean copyVisibleTextOnly)
Sets the flag indicating if only visible text should be copied to clipboard or dragged. |
void |
setDelayContentsOnLoading(boolean delayContentsOnLoading)
Set the flag indicating if the contents in the code editor should be hidden while the page need to be loaded. |
void |
setDocument(SyntaxDocument document)
Sets the document this text area is editing. |
void |
setDragEnabled(boolean b)
Sets the dragEnabled property, which must be true to enable automatic drag handling
(the first part of drag and drop) on this component. |
void |
setEditable(boolean editable)
Sets if this component is editable. |
void |
setElectricScroll(int electricScroll)
Sets the number of lines from the top and bottom of the text area that are always visible |
void |
setFileName(String pathToFile)
Set the full path to a local file on the CodeEditor. |
void |
setFirstLine(int firstLine)
Sets the line displayed at the text area's origin without updating the scroll bars. |
void |
setFixedHighlighter(Highlighter h)
Sets the fixed highlighter to be used. |
void |
setFoldingModel(FoldingModel foldingModel)
|
void |
setFont(Font font)
|
void |
setHighlighter(Highlighter h)
Sets the highlighter to be used. |
void |
setHorizontalOffset(int horizontalOffset)
Sets the horizontal offset of drawn lines. |
void |
setHorizontalScrollBarPolicy(int horizontalScrollBarPolicy)
Set the horizontal scroll bar policy. |
void |
setIndentOnPasting(boolean indentOnPasting)
Sets the flag indicating if the pasted multiple-line text should respect the indent of the previous line. |
void |
setInputHandler(InputHandler inputHandler)
Sets the input handler. |
void |
setLineBreakStyle(int lineBreakStyle)
|
void |
setLineHighlight(boolean lineHighlight)
Enables or disables current line highlighting. |
void |
setLineHighlightColor(Color lineHighlightColor)
Sets the line highlight color. |
void |
setLineNumberVisible(boolean visible)
|
void |
setLineText(int lineIndex,
String text)
Sets the text on the specified line. |
void |
setMagicCaretPosition(int magicCaret)
Sets the `magic' caret position. |
void |
setMarginArea(MarginArea marginArea)
|
void |
setMarkerArea(MarkerArea markerArea)
|
void |
setMarkerModel(MarkerModel markerModel)
|
void |
setMaxNumberOfClipboards(int maxNumberOfClipboards)
|
boolean |
setOrigin(int firstLine,
int horizontalOffset)
A fast way of changing both the first line and horizontal offset. |
void |
setOverlayVisible(boolean visible)
|
void |
setOverwriteEnabled(boolean overwrite)
Sets if overwrite mode should be enabled. |
void |
setPaintInvalid(boolean paintInvalid)
Sets if invalid lines are to be painted as red tildes. |
void |
setRawText(String text)
Sets the content of the code editor. |
void |
setReplaceTabWithSpace(boolean replaceTabWithSpace)
|
void |
setSelectedText(String selectedText)
Replaces the selection with the specified text. |
void |
setSelectionColor(Color selectionColor)
Sets the selection color. |
void |
setSelectionEnd(int selectionEnd)
Sets the selection end. |
void |
setSelectionRectangular(boolean rectSelect)
Sets if the selection should be rectangular. |
void |
setSelectionStart(int selectionStart)
Sets the selection start. |
void |
setShowToolTipOverMarkedText(boolean showToolTipOverMarkedText)
Set the flag indicating if tooltip should be displayed while the mouse hover on a marked text. |
void |
setSkipsEmptyLinesOnLineComments(boolean skipsEmptyLinesOnLineComments)
Sets the flag indicating if the line comment action should skip the empty lines. |
void |
setSpecialCharactersColor(Color specialCharactersColor)
Sets the special characters such as space, tab and end of line color. |
void |
setSpecialCharactersVisible(boolean visible)
Sets if special characters such as space, tab and end of line are to be drawn. |
void |
setStyles(SyntaxStyleSchema styles)
Sets the syntax styles used to paint colorized text. |
void |
setTabAlignment(boolean tabAlignment)
Set the flag indicating TAB key is to alignment or just add fixed number of spaces. |
void |
setTabSize(int tabSize)
|
void |
setText(String text)
Sets the entire text of this CodeEditor. |
void |
setTokenMarker(TokenMarker tokenMarker)
Sets the document's token marker. |
void |
setVerticalScrollBarPolicy(int verticalScrollBarPolicy)
Set the vertical scroll bar policy. |
void |
setVirtualSpaceAllowed(boolean virtualSpaceAllowed)
|
void |
showMessage(String message)
|
void |
splitLine()
Deletes current selected text if any then inserts a line break. |
void |
startNewLine()
Inserts a line break after the end of the line where the caret is. |
void |
stopInspectCode()
Interrupts the inspection, if it is inspecting. |
void |
surroundSelection(String prefix,
String postfix)
Surrounds the selected text with prefix and postfix . |
void |
swap()
Swaps the left and right component. |
void |
toggleCase()
Toggles the case when typing an alphabetic char. |
void |
toggleFoldingSelection()
If there is no folding and has selection, the selected text will be folded and shown as "...". |
void |
toggleOverwrite()
Toggles the editing mode between overwrite and insert. |
void |
undo()
Undo the last action (if possible). |
void |
unindentSelection()
Indents all selected lines no matter if the selection is a line selection or not if there is a selection. |
protected void |
updateBracketHighlight(int newCaretPosition)
|
void |
updateScrollBars()
Updates the state of the scroll bars. |
int |
viewToModelLine(int line)
|
CaretPosition |
viewToModelPosition(CaretPosition p)
Get model position from view position. |
int |
xToColumn(int x)
Deprecated. as this method doesn't consider the actual font it is used so when the font is not fix-width, this method will return the wrong result. The correct one to use is xToColumn(int, int) which takes the line
index. |
int |
xToColumn(int viewLine,
int x)
Converts from x position (in pixels) to column. |
int |
xToOffset(int viewLine,
int x)
Converts an x co-ordinate to an offset within a document. |
int |
xyToOffset(int x,
int y)
Converts a point to an offset in the document. |
int |
yToLine(int y)
Converts a y co-ordinate to a line index. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static String LEFT_OF_SCROLLBAR
public static final String PROPERTY_OVERWRITE_ENABLED
public static final String PROPERTY_FIRST_LINE
public static final String PROPERTY_VISIBLE_LINES
public static final String PROPERTY_COLUMN_SELECTION_ENABLED
public MarginArea _marginArea
public RowNumberMargin _lineNumberMargin
protected static List<Transferable> _clipboards
public Searchable _searchable
public Timer _inspectionTimer
protected CodeEditorSettings _defaultSettings
protected DefaultCodeEditorSettings _localSettings
public static final String PROPERTY_EDITABLE
protected static String CENTER
protected static String RIGHT
protected static String LEFT
protected static String BOTTOM
@Deprecated protected static CodeEditor focusedComponent
@Deprecated protected static Timer caretTimer
protected CodeEditorPainter _painter
protected boolean _caretVisible
protected boolean _editable
protected CodeEditorSettings _settings
protected int _firstLine
protected int _visibleLines
protected int _horizontalOffset
protected JScrollBar _verticalScrollBar
protected JScrollBar _horizontalScrollBar
protected boolean _scrollBarsInitialized
protected SyntaxDocument _document
protected com.jidesoft.editor.CodeEditor.DocumentHandler _documentHandler
protected UndoableEditListener _undoableEditListener
public Segment lineSegment
protected boolean biasLeft
protected int bracketPosition
protected int bracketLine
protected int _magicCaret
protected boolean _overwrite
protected CaretModel _caretModel
protected SelectionModel _selectionModel
public static final String PROPERTY_TAB_SIZE
public static final String PROPERTY_REPLACE_TAB_WITH_SPACE
public static final String PROPERTY_LINE_BREAK_STYLE
public static final String PROPERTY_MAX_NUMBER_OF_CLIPBOARDS
public static final String SMART_HOME_END_PROPERTY
Constructor Detail |
---|
public CodeEditor()
public CodeEditor(DefaultSettings defaults)
defaults
- The default settingsMethod Detail |
---|
protected Searchable createSearchable(CodeEditor editor)
Searchable
for the CodeEditor
.
editor
- the CodeEditor
.
Searchable
for CodeEditor
.public void swap()
protected CodeEditorPainter createCodeEditorPainter(CodeEditor editor)
protected TransferHandler createDefaultTransferHandler()
protected JScrollBar createScrollBar(int orientation)
orientation
- the orientation of the scroll bar.
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
public TransferHandler getTransferHandler()
getTransferHandler
in class JComponent
public final SyntaxStyleSchema getStyles()
Token
public final void setStyles(SyntaxStyleSchema styles)
styles
- The syntax stylesToken
public final Color getCaretColor()
public final void setCaretColor(Color caretColor)
caretColor
- The caret colorpublic final Color getSelectionColor()
public final void setSelectionColor(Color selectionColor)
selectionColor
- The selection colorpublic final Color getLineHighlightColor()
public final void setLineHighlightColor(Color lineHighlightColor)
lineHighlightColor
- The line highlight colorpublic final boolean isLineHighlightVisible()
public final void setLineHighlight(boolean lineHighlight)
lineHighlight
- True if current line highlight should be enabled, false otherwisepublic final Color getBracketHighlightColor()
public final void setBracketHighlightColor(Color bracketHighlightColor)
bracketHighlightColor
- The bracket highlight colorpublic final boolean isBracketHighlightVisible()
public final void setBracketHighlightVisible(boolean bracketHighlight)
bracketHighlight
- True if bracket highlighting should be enabled, false otherwisepublic final boolean isBlockCaret()
public final void setBlockCaret(boolean blockCaret)
blockCaret
- True if the caret should be drawn as a block, false otherwise.public final boolean isCaretBlinks()
public void setCaretBlinks(boolean caretBlinks)
caretBlinks
- True if the caret should blink, false otherwisepublic final Color getSpecialCharactersColor()
public final void setSpecialCharactersColor(Color specialCharactersColor)
specialCharactersColor
- The EOL marker colorpublic final boolean isSpecialCharactersVisible()
public final void setSpecialCharactersVisible(boolean visible)
visible
- True if special characters such as space, tab and end of line should be drawn, false otherwisepublic boolean isPaintInvalid()
public void setPaintInvalid(boolean paintInvalid)
paintInvalid
- True if invalid lines should be drawn, false otherwisepublic boolean isVirtualSpaceAllowed()
public void setVirtualSpaceAllowed(boolean virtualSpaceAllowed)
public MarkerArea getMarkerArea()
public void setMarkerArea(MarkerArea markerArea)
public void initializeDefaultSettings(DefaultSettings defaults)
defaults
- the default settingspublic void addCodeInspector(CodeInspector inspector)
public void removeCodeInspector(CodeInspector inspector)
public CodeInspector[] getCodeInspectors()
public int getCodeInspectorCount()
public CodeInspector getCodeInspector(int i)
public boolean isAutoInspecting()
public void setAutoInspecting(boolean autoInspecting)
autoInspecting
- true to turn autoInspecting on. False to turn it off.public void stopInspectCode()
public void inspectCode()
CodeInspector
s added to this CodeEditor to inspect the code.
public void inspectCode(DocumentEvent event)
CodeInspector
s added to this CodeEditor to inspect the code.
event
- the DocumentEvent. It's up to CodeInspector
if it will look at the DocumentEvent to do
incremental inspection.public int getLineHeight()
public final boolean isManagingFocus()
isManagingFocus
in class JComponent
public final CodeEditorPainter getPainter()
public final InputHandler getInputHandler()
public void setInputHandler(InputHandler inputHandler)
inputHandler
- The new input handlerpublic final boolean isCaretVisible()
public void setCaretVisible(boolean caretVisible)
caretVisible
- True if the caret should be visible, false otherwisepublic final void blinkCaret()
public final int getElectricScroll()
public final void setElectricScroll(int electricScroll)
electricScroll
- The number of lines always visible from the top or bottompublic void updateScrollBars()
public final int getFirstLine()
public void setFirstLine(int firstLine)
firstLine
- the first view line to display.public final int getVisibleLines()
public final void recalculateVisibleLines()
public final int getHorizontalOffset()
public void setHorizontalOffset(int horizontalOffset)
horizontalOffset
- offset The new horizontal offsetpublic boolean setOrigin(int firstLine, int horizontalOffset)
firstLine
- The new first linehorizontalOffset
- The new horizontal offset
public boolean scrollToCaret()
public boolean scrollTo(CaretPosition position)
position
- the caret model position
public boolean scrollToViewPosition(CaretPosition vp)
vp
- the caret view position
protected boolean scrollToViewPosition(CaretPosition vp, CaretPosition anotherVp)
vp
- the caret view positionanotherVp
- another caret view position. non-null value means this view position is better to be considered
on scrolling
protected DocumentEvent createReplaceAllDocumentEvent()
public int lineToY(int line)
line
- the view line index
public int yToLine(int y)
y
- The y coordinate
public final int offsetToX(int offset)
offset
- the offset in a document
@Deprecated public final int offsetToX(int line, int offset)
offsetToX(int)
line
- The lineoffset
- The model offset, from the start of the line
@Deprecated public int _offsetToX(int line, int offset)
_offsetToX(int)
line
- The lineoffset
- The offset, from the start of the line
public int _offsetToX(int offset)
offset
- The offset, from the start of the line
public int xToColumn(int x)
xToColumn(int, int)
which takes the line
index.
x
- the x position in pixels. The x position is not counted from the line beginning but from the first
visible pixel because of the scroll bar.
public int xToColumn(int viewLine, int x)
xToOffset(0, 66)
will return 10 but xToColumn(0, 66)
will return 11.
The meaning of the input parameter is changed to view line since 2.10.2. If you ever invoked this method before,
please re-check and make sure you will invoke this method with view line index instead of model line index.
viewLine
- the view line indexx
- the x position in pixels
@Deprecated public int columnToX(int column)
columnToX(int, int)
which takes the line
index.
column
- the column
public int columnToX(int line, int column)
offsetToX(0, 11)
will return 60 but columnToX(0,
11)
will return 66.
line
- the view line indexcolumn
- the view column
public int xToOffset(int viewLine, int x)
int viewLine = modelToViewLine(modelLine); int offsetInDocument = xToOffset(viewLine, x);
int offsetInLine = offsetInDocument - getLineStartOffset(modelLine);
viewLine
- the view linex
- The x co-ordinate
public int xyToOffset(int x, int y)
x
- The x co-ordinate of the pointy
- The y co-ordinate of the point
public final SyntaxDocument getDocument()
public void setDocument(SyntaxDocument document)
document
- The documentpublic final TokenMarker getTokenMarker()
getDocument().getTokenMarker()
.
public final void setTokenMarker(TokenMarker tokenMarker)
getDocument().setTokenMarker()
.
tokenMarker
- The token markerpublic final int getDocumentLength()
getDocument().getLength()
.
public final int getLineCount()
public int getVisualLineCount()
public final int getLineNumber(int offset)
offset
- The offset
public int getLineStartOffset(int line)
line
- The line
public int getLineStartOffsetNoSpace(int line)
line
- The line
public int getLineEndOffset(int line)
line
- The line
public int getLineLength(int line)
line
- the line
public String getText()
public void setText(String text)
importText(String,
StringBuffer)
to convert. If you know your text doesn't have any inconsistency in the line breaks, you can use
setRawText(String)
to avoid the unnecessary conversion. Otherwise we will try to import the first 1000
(of course only if the text length is less than 1000) to see what the line style is.
text
- the new text.public void append(String text)
public final String getText(int start, int len)
start
- The start offsetlen
- The length of the substring
public final void getText(int start, int len, Segment segment)
start
- The start offsetlen
- The length of the substringsegment
- The segmentprotected int exportText(String in, StringBuffer out)
in
- the text with LINE_BREAK_CODE_EDITOR as line break.out
- the text using the line break style set on the code editor as line break.
protected int importText(String in, StringBuffer out)
in
- the text with any line break style.out
- the text with LINE_BREAK_CODE_EDITOR as line break style.
public String getRawText()
exportText(String,
StringBuffer)
)} instead.
public void setRawText(String text)
setText(String)
, this method assumes the line break
used in the text is LF only. If you are not sure about this, you should use setText(String)
instead.
text
- the raw text.public final String getLineText(int lineIndex)
lineIndex
- The line
public final boolean getLineText(int lineIndex, Segment segment)
lineIndex
- The linesegment
- the segment
public final void setLineText(int lineIndex, String text)
lineIndex
- the line indextext
- the textpublic final int getSelectionStart()
public int getSelectionStart(int line)
line
- the specified line
public final int getSelectionStartLine()
public final void setSelectionStart(int selectionStart)
selectionStart
- The selection startselect(int, int)
public final void surroundSelection(String prefix, String postfix)
prefix
and postfix
.
prefix
- Stringpostfix
- Stringpublic void selectWord()
public void selectWord(String noWordSep)
public int[] getCurrentWordBounds()
public String getLeftWordPart()
public String getLeftWordPart(String nonwordDelimiters)
public int[] getCurrentWordBounds(String nonwordDelimiters)
public String getCurrentWord()
public String getCurrentWord(String noWordDelimiters)
public void selectToMatchingBracket()
public void selectBlock()
public void gotoEndOfLine()
public void commentLine(int line)
public void commentLine()
public void indentSelectedLines()
public void indentLinesBetween(int startLine, int endLine)
public void indentLine(int line)
public void selectLine(int line)
line
- the model line indexpublic void selectLines(int start, int end)
start
- the start model line indexend
- the end model line indexpublic final int getSelectionEnd()
public int getSelectionEnd(int line)
line
- the specified line
public final int getSelectionEndLine()
public final void setSelectionEnd(int selectionEnd)
selectionEnd
- The selection endselect(int, int)
public int getLeadSelectionOffset()
public int getAnchorSelectionOffset()
public final int getMarkPosition()
public final void select(int caret)
caret
- The caret positionselect(int, int)
public final void selectAll()
public final void selectNone()
public void select(int start, int end)
start
- The start offsetend
- The end offsetpublic void select(int start, int end, boolean scroll)
start
- The start offsetend
- The end offsetscroll
- true or false. True to scroll the caret visible after selecting the text.public final String getSelectedText()
public void setSelectedText(String selectedText)
selectedText
- The replacement text for the selectionpublic final boolean isEditable()
public final void setEditable(boolean editable)
editable
- True if this text area should be editable, false otherwisepublic final int getMagicCaretPosition()
public final void setMagicCaretPosition(int magicCaret)
magicCaret
- The magic caret positionpublic void overwriteSetSelectedText(String str)
setSelectedText()
, but overwrite the appropriate number of characters if overwrite mode
is enabled.
str
- The stringsetSelectedText(String)
,
isOverwriteEnabled()
public final boolean isOverwriteEnabled()
public final void setOverwriteEnabled(boolean overwrite)
overwrite
- True if overwrite mode should be enabled, false otherwise.public final boolean isSelectionRectangular()
public final void setSelectionRectangular(boolean rectSelect)
rectSelect
- True if the selection should be rectangular, false otherwise.public final int getBracketPosition()
public final int getBracketLine()
public void undo()
public void redo()
public void addNotify()
addNotify
in class JComponent
public void removeNotify()
removeNotify
in class JComponent
public void processKeyEvent(KeyEvent evt)
processKeyEvent
in class JComponent
protected void updateBracketHighlight(int newCaretPosition)
protected void documentChanged(DocumentEvent evt)
public boolean isBlink()
public void setBlink(boolean blink)
blink
- the flagpublic void pauseBlink()
blinkCaret()
to restart
the caret blinking.
public boolean isTabAlignment()
isReplaceTabWithSpace()
returns true.
The default value of this flag is false to keep original behavior. If you want to make tab align the column,
please set this flag to true.
public void setTabAlignment(boolean tabAlignment)
tabAlignment
- the flagisTabAlignment()
public int getHorizontalScrollBarPolicy()
ScrollPane.SCROLLBARS_ALWAYS
, ScrollPane.SCROLLBARS_AS_NEEDED
or ScrollPane.SCROLLBARS_NEVER
. By default the value is ScrollPane.SCROLLBARS_ALWAYS
for backward
compatibility.
public void setHorizontalScrollBarPolicy(int horizontalScrollBarPolicy)
horizontalScrollBarPolicy
- the policy.getHorizontalScrollBarPolicy()
public int getVerticalScrollBarPolicy()
ScrollPane.SCROLLBARS_ALWAYS
, ScrollPane.SCROLLBARS_AS_NEEDED
or ScrollPane.SCROLLBARS_NEVER
. By default the value is ScrollPane.SCROLLBARS_ALWAYS
for backward
compatibility.
public void setVerticalScrollBarPolicy(int verticalScrollBarPolicy)
verticalScrollBarPolicy
- the policy.getVerticalScrollBarPolicy()
public boolean isShowToolTipOverMarkedText()
getMarkerModel()
public void setShowToolTipOverMarkedText(boolean showToolTipOverMarkedText)
showToolTipOverMarkedText
- the flagisShowToolTipOverMarkedText()
public String getFileName()
public void setFileName(String pathToFile)
setText(String)
where the content of the
file is loaded fully into memory, CodeEditor will load the file using lazy-loading.
pathToFile
- the full path to a local file.protected LazyLoadDocument createLazyLoadDocument()
public boolean exportToOutputStream(OutputStream outputStream) throws IOException, BadLocationException
getFileName()
outputStream
- the output stream
IOException
- if there is any I/O issue.
BadLocationException
- if there is any document reading issue.protected OutputStreamWriter createOutputStreamWriter(OutputStream outputStream)
public boolean isContentVisible()
setContentVisible(boolean)
public void setContentVisible(boolean contentVisible)
contentVisible
- the flagpublic boolean isDelayContentsOnLoading()
setDelayContentsOnLoading(boolean)
public void setDelayContentsOnLoading(boolean delayContentsOnLoading)
delayContentsOnLoading
- the flagpublic boolean isChangePromptDialogPosition()
setChangePromptDialogPosition(boolean)
public void setChangePromptDialogPosition(boolean changePromptDialogPosition)
changePromptDialogPosition
- the flagpublic boolean isIndentOnPasting()
setIndentOnPasting(boolean)
public void setIndentOnPasting(boolean indentOnPasting)
indentOnPasting
- the flagpublic boolean isCopyVisibleTextOnly()
setCopyVisibleTextOnly(boolean)
public void setCopyVisibleTextOnly(boolean copyVisibleTextOnly)
copyVisibleTextOnly
- the flagpublic boolean isSkipsEmptyLinesOnLineComments()
setSkipsEmptyLinesOnLineComments(boolean)
public void setSkipsEmptyLinesOnLineComments(boolean skipsEmptyLinesOnLineComments)
skipsEmptyLinesOnLineComments
- the flagprotected void pageLoadFailedHandling(PageLoadEvent e)
e
- the page load event.public boolean getFocusTraversalKeysEnabled()
getFocusTraversalKeysEnabled
in class Component
public boolean getFocusCycleRoot()
protected boolean isColumnSelectionMode(MouseEvent evt)
return (evt.getModifiers() & InputEvent.CTRL_MASK) != 0;
evt
- the mouse event
public void scrollUpPage()
public void scrollDownPage()
public MarginArea getMarginArea()
public void setMarginArea(MarginArea marginArea)
public void setLineNumberVisible(boolean visible)
public boolean isLineNumberVisible()
public RowNumberMargin getLineNumberMargin()
public CaretModel getCaretModel()
public SelectionModel getSelectionModel()
public void selectionChanged(SelectionEvent e)
SelectionListener
selectionChanged
in interface SelectionListener
protected ClipboardOwner createClipboardOwner()
public void caretUpdated(CaretEvent e)
CaretListener
caretUpdated
in interface CaretListener
e
- the CaretEvent.protected SelectionModel createSelectionModel()
public CaretPosition viewToModelPosition(CaretPosition p)
p
- the view position.
public CaretPosition modelToViewPosition(CaretPosition p)
p
- the model position.
public CaretPosition offsetToModelPosition(int offset)
public CaretPosition offsetToViewPosition(int offset)
public int modelPositionToOffset(CaretPosition p)
@Deprecated public int offsetToLine(int offset)
offsetToViewPosition(int)
getLineNumber(int)
instead.
offset
- the offset in the document
public int getTabSize()
public void setTabSize(int tabSize)
public boolean isReplaceTabWithSpace()
public void setReplaceTabWithSpace(boolean replaceTabWithSpace)
public int getDefaultLineBreakStyle()
public int getLineBreakStyle()
public boolean isLineBreakStyleMixed()
public void setLineBreakStyle(int lineBreakStyle)
public void discardAllEdits()
public void promptGotoLine()
public void promptGotoLineAtView()
public void promptGotoOffset()
public void gotoLine(int line)
line
- the model line indexpublic void gotoLineAtView(int line)
line
- the view line indexpublic void gotoOffset(int offset)
offset
- the offset in the documentpublic MarkerModel getMarkerModel()
public void setMarkerModel(MarkerModel markerModel)
public int getMaxNumberOfClipboards()
public void setMaxNumberOfClipboards(int maxNumberOfClipboards)
public void setDragEnabled(boolean b)
dragEnabled
property, which must be true
to enable automatic drag handling
(the first part of drag and drop) on this component. The transferHandler
property needs to be set to
a non-null
value for the drag to do anything. The default value of the dragEnabled
false.
When automatic drag handling is enabled, most look and feels begin a drag-and-drop operation whenever the user
presses the mouse button over a selection and then moves the mouse a few pixels. Setting this property to
true
can therefore have a subtle effect on how selections behave.
Some look and feels might not support automatic drag and drop; they will ignore this property. You can work
around such look and feels by modifying the component to directly call the exportAsDrag
method of a
TransferHandler
.
b
- the value to set the dragEnabled
property to
HeadlessException
- if b
is true
and GraphicsEnvironment.isHeadless()
returns true
GraphicsEnvironment.isHeadless()
,
getDragEnabled()
,
JComponent.setTransferHandler(javax.swing.TransferHandler)
,
TransferHandler
public boolean getDragEnabled()
dragEnabled
property.
dragEnabled
propertysetDragEnabled(boolean)
public void setFont(Font font)
setFont
in class JComponent
public Searchable getSearchable()
public FindAndReplace getFindAndReplace()
public Point getCaretLocation()
public Point getCaretLocationOnScreen()
public void showMessage(String message)
public void find()
public void findNext()
public void findPrevious()
public void replace()
public void quickSearch(String searchingText)
searchingText
- the searching textpublic void moveToLineEnd(boolean select)
select
- the flag indicating if the caret moving will extend selection or notpublic void moveToLineStart(boolean select)
select
- the flag indicating if the caret moving will extend selection or notpublic void moveToDocumentStart(boolean select)
select
- the flag indicating if the caret moving will extend selection or notpublic void moveToDocumentEnd(boolean select)
select
- the flag indicating if the caret moving will extend selection or notpublic void moveToNextChar(boolean select)
isVirtualSpaceAllowed()
is true. Otherwise moves the caret to the
next char excluding line breaks. Extends the selection if the select parameter is true.
select
- the flag indicating if the caret moving will extend selection or notisVirtualSpaceAllowed()
public void moveToNextLine(boolean select)
isVirtualSpaceAllowed()
is false. Extends the
selection if the select parameter is true.
select
- the flag indicating if the caret moving will extend selection or notisVirtualSpaceAllowed()
public void moveToNextPage(boolean select)
isVirtualSpaceAllowed()
is false. Extends the
selection if the select parameter is true.
select
- the flag indicating if the caret moving will extend selection or notisVirtualSpaceAllowed()
public void moveToNextWord(boolean select)
select
- the flag indicating if the text between current caret and new caret should be selected.public void moveToNextWord(boolean select, boolean toWordStart)
select
- the flag indicating if the text between current caret and new caret should be selectedtoWordStart
- the flag indicating if the caret should be put at the start of the wordpublic void moveToPreviousChar(boolean select)
isVirtualSpaceAllowed()
is true. Otherwise
moves the caret to the previous char excluding line breaks. Extends the selection if the select parameter is
true.
select
- the flag indicating if the caret moving will extend selection or notisVirtualSpaceAllowed()
public void moveToPreviousLine(boolean select)
isVirtualSpaceAllowed()
is false. Extends
the selection if the select parameter is true.
select
- the flag indicating if the caret moving will extend selection or notisVirtualSpaceAllowed()
public void moveToPreviousPage(boolean select)
isVirtualSpaceAllowed()
is false. Extends
the selection if the select parameter is true.
select
- the flag indicating if the caret moving will extend selection or notisVirtualSpaceAllowed()
public void moveToPreviousWord(boolean select)
select
- the flag indicating if the text between current caret and new caret should be selected.public void moveToPreviousWord(boolean select, boolean toWordEnd)
select
- the flag indicating if the text between current caret and new caret should be selected.toWordEnd
- the flag indicating if the caret should be put at the end of the wordprotected void adjustColumnSelectionModelOnCaretMoving(boolean select)
select
- if this caret moving causes a new selectionpublic void toggleOverwrite()
public void splitLine()
public void insertBreak()
public void startNewLine()
public void indentSelection()
isReplaceTabWithSpace()
,
getTabSize()
public void unindentSelection()
public boolean indentLine(int lineIndex, boolean decrease)
public int getCurrentIndentForLine(int lineIndex, int[] whitespaceChars)
lineIndex
- The line numberwhitespaceChars
- If this is non-null, the number of whitespace characters is stored at the 0 index
public void insertChar(String str)
str
- the string to insertpublic void joinLines()
public void toggleCase()
public void duplicateSelection()
public void backspaceChar()
public void backspaceWord()
public void deleteChar()
public void deleteWord()
public void deleteLine()
public void clipboardCut()
public void clipboardMove(int offset)
offset
- the offsetpublic void clipboardCopy()
public void clipboardPaste()
public void pasteWithDialog()
public void lineComments()
public void blockComments()
public FoldingModel getFoldingModel()
public void setFoldingModel(FoldingModel foldingModel)
public void expandFolding()
public void collapseFolding()
public void expandAll()
public void collapseAll()
public void toggleFoldingSelection()
public int modelToViewLine(int line)
public int viewToModelLine(int line)
public void repaint()
repaint
in class Component
public void repaint(long tm)
repaint
in class Component
public Dimension getContentSize()
protected Dimension recalculateContentSize()
protected void resetContentSize()
public void configureStyledLabel(StyledLabel styledLabel, Object userObject)
FindResultIntepreter
configureStyledLabel
in interface FindResultIntepreter
public String getResourceString(String key)
key
- the resource key
public Rectangle modelToView(int offset) throws BadLocationException
BadLocationException
public Rectangle modelToView(int startOffset, int endOffset) throws BadLocationException, IllegalArgumentException
startOffset
- the start offsetendOffset
- the end offset
BadLocationException
- if the startOffset or endOffset is out of the boundary of the document.
IllegalArgumentException
- if the startOffset and endOffset is not in the same visible line.public Highlighter getHighlighter()
public void setHighlighter(Highlighter h)
null
to disable it. A
PropertyChange event ("highlighter") is fired when a new highlighter is installed.
h
- the highlightergetHighlighter()
public Highlighter getFixedHighlighter()
public void setFixedHighlighter(Highlighter h)
h
- the highlightergetHighlighter()
protected Highlighter createHighlighter()
public ColumnGuide[] getColumnGuides()
protected List<ColumnGuide> internalGetColumnGuides()
public void addColumnGuide(ColumnGuide guide)
guide
- the column guidepublic void removeColumnGuide(ColumnGuide guide)
guide
- the column guidepublic void removeAllColumnGuides()
public void escape()
public void loadActionMap()
public void setCaretPosition(int offset)
public int getCaretPosition()
public JScrollBar getVerticalScrollBar()
public JScrollBar getHorizontalScrollBar()
public int getCorrespondingColumn(int column, int oldLine, int newLine)
column
- the column in the old lineoldLine
- the old linenewLine
- the new line
public InputMethodRequests getInputMethodRequests()
getInputMethodRequests
in class Component
public void setOverlayVisible(boolean visible)
public JComponent createOverlay()
public void repaint(long tm, int x, int y, int width, int height)
repaint
in class JComponent
protected void customizeDialog(StandardDialog dialog)
dialog
- the dialog to be customized.protected void customizeDialogData(StandardDialog dialog)
dialog
- the dialog to be customized.public static void clearClipboards()
public boolean isAdjustColumnSelectionOnMouseEvent()
setAdjustColumnSelectionOnMouseEvent(boolean)
public void setAdjustColumnSelectionOnMouseEvent(boolean adjustColumnSelectionOnMouseEvent)
adjustColumnSelectionOnMouseEvent
- the flagpublic void dispose()
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |