|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoracle.ide.addin.AbstractView
oracle.ide.editor.AbstractEditor
oracle.jdeveloper.ceditor.CodeEditor
The CodeEditor
is the integration layer between the IDE
and the editor components to provide a code editor inside the IDE.
There are some public methods available for getting the state of the editor component, such as where the cursor position is, and whether there is a selection. There are also public methods available for manipulating the cursor position or selection, and for mapping between offsets and lines.
Note: Public methods in this class involving line numbers are all 1-based. Contrast this with the LineMap interface in the TextBuffer which is 0-based. Do not get this mixed up! If you use both the LineMap and CodeEditor together, you will need to take this into account.
For clients that wish to install EditorPlugins to newly created
editors, register an EditorPluginsFactory
instance
using registerFactory()
. This method will be called
when an editor is created.
Nested Class Summary |
Nested classes inherited from class oracle.ide.editor.AbstractEditor |
AbstractEditor.LayoutData |
Field Summary | |
static javax.swing.border.Border |
THIN_BEVEL_BORDER
This is a bevel border that is thinner (1 pixel) than the default bevel border (2 pixels) available in Swing. |
static java.lang.String |
TYPE_CPP
The syntax highlighting type for C++ files. |
static java.lang.String |
TYPE_HTML
The syntax highlighting type for HTML files. |
static java.lang.String |
TYPE_IDL
The syntax highlighting type for IDL files. |
static java.lang.String |
TYPE_JAVA
The syntax highlighting type for Java files. |
static java.lang.String |
TYPE_JSP
THe syntax highlighting type for JSP files. |
static java.lang.String |
TYPE_PLAIN
The syntax highlighting type for plain files. |
static java.lang.String |
TYPE_PLSQL
The syntax highlighting type for PL/SQL files. |
static java.lang.String |
TYPE_PROPERTIES
The syntax highlighting type for Properties files. |
static java.lang.String |
TYPE_SQL
The syntax highlighting type for SQL files. |
static java.lang.String |
TYPE_XML
The syntax highlighting type for XML files. |
Fields inherited from class oracle.ide.editor.AbstractEditor |
_context, _editorFrame, CUSTOM_BORDER |
Fields inherited from class oracle.ide.addin.AbstractView |
owner, SEPARATOR, viewListeners, viewSelectionListeners |
Fields inherited from interface oracle.ide.addin.View |
PROJECT_PROP, VISIBLE_PROP, WORKSPACE_PROP |
Constructor Summary | |
CodeEditor()
Constructs a new Code Editor which makes use of the editor package. |
Method Summary | |
void |
addCEToolTipProvider(CEToolTipProvider provider)
Registers a CEToolTipProvider implementation to
receive requests for tooltip information when the mouse travels
over the code editor. |
void |
addCursorListener(CursorListener listener)
Adds a CursorListener to the list of cursor listeners. |
void |
addHelpableProvider(HelpableProvider helpableProvider)
Adds a HelpableProvider for this class from which the
code editor can retrieve help info. |
protected boolean |
canCopy()
Deprecated. |
protected boolean |
canCut()
Deprecated. |
protected boolean |
canPaste()
Deprecated. |
void |
caretUpdate(javax.swing.event.CaretEvent event)
Called when the caret position is updated. |
void |
close()
Close this editor - this gives us a chance to clean up any resources. |
void |
close(Layout layout)
Close the given Layout . |
static HighlightStyle |
createHighlightStyle(java.lang.String internalName,
java.lang.String publicName,
int priority,
java.awt.Color fgColor,
java.awt.Color bgColor)
Utility routine to create a new highlight style that is registered with the code editor - this ensures the it is available for editing in the editor options panels. |
int |
getCaretLine()
Return the line that the caret is on. |
int |
getCaretPosition()
Returns the position of the text insertion caret for the editor component. |
Controller |
getController()
Gets the Controller associated with this view. |
java.awt.Component |
getDefaultFocusComponent()
This method is used to know what component should get the focus by default. |
protected BasicEditorPane |
getEditorComponent()
Primarily for the controller to use to get access to the component to do cut/copy/paste |
protected java.lang.String |
getEditorText()
Get the contents of the editor as a String for refreshing the IDE buffer. |
BasicEditorPane |
getFocusedEditorPane()
Fetches the focused (active) editor pane embedded in the editor in which to perform Find operations on. |
java.awt.Component |
getGUI()
Get the view's root graphical user interface component. |
CodeEditorGutter |
getGutter()
Fetches the gutter associated with this editor on the left margin. |
HelpableProvider |
getHelpableProvider()
Deprecated. |
HelpInfo |
getHelpInfo()
Fetch the HelpInfo topic to display for this view. |
int |
getLineCount()
Fetches the number of lines in this TextBuffer . |
int |
getLineEndOffset(int line)
Given a specified line, returns the offset from the beginning of a TextBuffer that the line ends at. |
int |
getLineFromOffset(int offset)
Given an offset from the beginning of the underlying TextBuffer , fetches the line number containing that
offset using a Forward bias. |
int |
getLineStartOffset(int line)
Given a specified line, returns the offset from the beginning of the TextBuffer for the start of the line. |
java.lang.String |
getSelectedText()
Returns the selected text contained in this TextComponent. |
int |
getSelectionEnd()
Returns the end position of the current text selection. |
int |
getSelectionStart()
Returns the start position of the current text selection. |
javax.swing.Icon |
getTabIcon()
Get the Icon to use when displaying this View as a tab in a JTabbedPane host such as the EditorFrame. |
java.lang.String |
getText(int offset,
int length)
Fetches a portion of the text represented by the component. |
java.lang.String |
getToolTipText(BasicEditorPane editorPane,
java.awt.event.MouseEvent mouseEvent,
int offset)
Requests from the editor client an appropriate tooltip to display for the given editor. |
boolean |
gotoLine(int line,
int column,
boolean highlightLine)
Moves the current cursor position to the beginning of the indicated line, and highlight the line if it is requested. |
boolean |
gotoOffset(int offset,
int selectionLength)
Moves the current cursor position to the given offset, and selects up to the given length after that offset. |
boolean |
hasSelectedText()
Return whether or not there is any text selected. |
void |
init(Layout layout)
Initialize this editor's layout information from the given Layout instance. |
void |
moveCaretPosition(int offset)
Moves the caret to a new position, leaving behind a mark defined by the last time setCaretPosition was called. |
void |
open()
Open this editor on the context set by a prior call to setContext. |
static void |
registerDocumentType(java.lang.Class documentClass,
java.lang.String highlightingType)
Registers the given document class for the given syntax highlighting type to use. |
static void |
registerFactory(EditorPluginsFactory factory)
Registers an EditorPluginsFactory with the CodeEditor
so that when a new Code Editor is created, the factory is given
a chance to create EditorPlugins to be installed into the editor
based on the node type that the Code Editor was created with. |
void |
removeCEToolTipProvider(CEToolTipProvider provider)
Deregisters a previously registered CEToolTipProvider
implementation when it no longer wants to handle tooltip requests. |
void |
removeCursorListener(CursorListener listener)
Removes a CursorListener from the list of cursor listeners. |
void |
removeHelpableProvider(HelpableProvider helpableProvider)
Removes a previously registered HelpableProvider . |
void |
replaceSelection(java.lang.String content)
Replaces the currently selected content with the new content represented by the given String. |
void |
save(Layout layout)
Save this editor's layout information to the given Layout instance. |
void |
setCaretPosition(int offset)
Sets the position of the text insertion caret for the editor component. |
void |
setContext(Context context)
Set the context behind this editor. |
void |
setHelpableProvider(HelpableProvider helpableProvider)
Deprecated. |
void |
setHelpInfo(HelpInfo helpInfo)
Sets the default help info topic that this code editor displays. |
void |
setSelectionEnd(int selectionEnd)
Sets the end of the selection to the specified position. |
void |
setSelectionStart(int selectionStart)
Sets the start of the selection to the specified position. |
void |
undoableEditHappened(javax.swing.event.UndoableEditEvent event)
An UndoableEdit happened in the editor. |
void |
update(java.lang.Object observed,
UpdateMessage change)
Notification message. |
Methods inherited from class oracle.ide.addin.AbstractView |
activate, addViewListener, addViewSelectionListener, deactivate, fireViewActivated, fireViewClosed, fireViewDeactivated, fireViewSelectionChanged, getId, getSelection, getToolbar, isVisible, loadToolbar, loadToolbar, removeViewListener, removeViewSelectionListener, setId, setOwner, show, updateTitle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface oracle.ide.addin.View |
activate, addViewListener, addViewSelectionListener, deactivate, getId, getSelection, getToolbar, removeViewListener, removeViewSelectionListener, updateTitle |
Methods inherited from interface oracle.ide.addin.Subview |
isVisible, show |
Field Detail |
public static final java.lang.String TYPE_PLAIN
public static final java.lang.String TYPE_JAVA
public static final java.lang.String TYPE_SQL
public static final java.lang.String TYPE_PLSQL
public static final java.lang.String TYPE_JSP
public static final java.lang.String TYPE_HTML
public static final java.lang.String TYPE_XML
public static final java.lang.String TYPE_PROPERTIES
public static final java.lang.String TYPE_IDL
public static final java.lang.String TYPE_CPP
public static final javax.swing.border.Border THIN_BEVEL_BORDER
Constructor Detail |
public CodeEditor()
Method Detail |
public static void registerFactory(EditorPluginsFactory factory)
EditorPluginsFactory
with the CodeEditor
so that when a new Code Editor is created, the factory is given
a chance to create EditorPlugins to be installed into the editor
based on the node type that the Code Editor was created with.
factory
- the EditorPluginsFactory to registerpublic static void registerDocumentType(java.lang.Class documentClass, java.lang.String highlightingType)
TYPE_*
public constants
specified in this class. The provided document class MUST
implement the TextDocument
interface, as only
TextDocument
implementations are editable by the
code editor.
documentClass
- the class of the document to registerhighlightingType
- the syntax highlighting type to usepublic static HighlightStyle createHighlightStyle(java.lang.String internalName, java.lang.String publicName, int priority, java.awt.Color fgColor, java.awt.Color bgColor)
internalName
- the (unique) name of the style used
internally for registration purposespublicName
- the (translated) name of the style that can be
used for UI purposes to identify the stylepriority
- the priority of the highlight when rendering,
from 1 to 100fgColor
- the color to use for the foreground of the text, null
not to change the foreground of the textbgColor
- the color to use for the background of the text, null
not to change the background of the textpublic java.lang.String getText(int offset, int length) throws javax.swing.text.BadLocationException
offset
- the starting offset >= 0length
- the length to retrieve >= 0
javax.swing.text.BadLocationException
- if the offset or length are invalidpublic void setCaretPosition(int offset)
offset
- the new caret position to setpublic void moveCaretPosition(int offset)
offset
- the offset to move the caret tosetCaretPosition(int)
public int getCaretPosition()
public int getCaretLine()
public void replaceSelection(java.lang.String content)
content
- the new content to replace the current selectionpublic boolean hasSelectedText()
public java.lang.String getSelectedText()
java.lang.IllegalArgumentException
- if the selection doesn't
have a valid mapping into the document for some reasonpublic int getSelectionStart()
public int getSelectionEnd()
public void setSelectionStart(int selectionStart)
selectionStart
- the new start of the selectionpublic void setSelectionEnd(int selectionEnd)
selectionEnd
- the new end of the selectionpublic void addCursorListener(CursorListener listener)
CursorListener
to the list of cursor listeners.
listener
- the listener to addpublic void removeCursorListener(CursorListener listener)
CursorListener
from the list of cursor listeners.
listener
- the listener to removepublic CodeEditorGutter getGutter()
public void addCEToolTipProvider(CEToolTipProvider provider)
CEToolTipProvider
implementation to
receive requests for tooltip information when the mouse travels
over the code editor. Note that only a single tooltip provider
can be registered at any given time. The LAST provider to
register for tooltips will be the one to be notified of requests.
provider
- the tooltip provider to registerpublic void removeCEToolTipProvider(CEToolTipProvider provider)
CEToolTipProvider
implementation when it no longer wants to handle tooltip requests.
Note that if the specified provider is not the current active
registered provider, then the request is ignored.
provider
- the provider to deregisterpublic boolean gotoOffset(int offset, int selectionLength)
offset
- the offset to move the cursor to (zero-based)selectionLength
- the length of the selection, 0 if not desired.
public boolean gotoLine(int line, int column, boolean highlightLine)
line
- the line to go to (one-based)column
- the column to go to (one-based)highlightLine
- whether to highlight the specified line
public BasicEditorPane getFocusedEditorPane()
getFocusedEditorPane
in interface oracle.jdeveloper.ceditor.find.FindableEditor
BasicEditorPane
that currently has focuspublic void caretUpdate(javax.swing.event.CaretEvent event)
caretUpdate
in interface javax.swing.event.CaretListener
event
- the caret eventpublic int getLineCount()
TextBuffer
. For
example, a 5-line TextBuffer
has lines 0 through 4.
TextBuffer
public int getLineFromOffset(int offset)
TextBuffer
, fetches the line number containing that
offset using a Forward bias. This means if line A starts with
offset B, and previous line A-1 ends with offset B,
getLineFromOffset(B)
will return line A.
public int getLineStartOffset(int line)
TextBuffer
for the start of the line.
line
- a line in the TextBuffer
public int getLineEndOffset(int line)
TextBuffer
that the line ends at.
line
- a line in the TextBuffer
public void setContext(Context context)
setContext
in interface Editor
setContext
in class AbstractEditor
public void open()
open
in interface Editor
Editor.setContext(oracle.ide.addin.Context)
public java.awt.Component getDefaultFocusComponent()
getDefaultFocusComponent
in interface Editor
getDefaultFocusComponent
in class AbstractEditor
public void close()
close
in interface Subview
close
in class AbstractEditor
public Controller getController()
Controller
associated with this view.
getController
in interface Subview
getController
in class AbstractView
public java.awt.Component getGUI()
getGUI
in interface Subview
public javax.swing.Icon getTabIcon()
getTabIcon
in interface Editor
getTabIcon
in class AbstractEditor
EditorFrame
public void update(java.lang.Object observed, UpdateMessage change)
update
in interface Observer
observed
- the subject whose state has changed.change
- what has changed.public java.lang.String getToolTipText(BasicEditorPane editorPane, java.awt.event.MouseEvent mouseEvent, int offset)
getToolTipText
in interface ToolTipProvider
editorPane
- the editor where the tooltip will be displayedmouseEvent
- the mouse event that generated the tooltipoffset
- the document offset where the mouse cursor is located
public void undoableEditHappened(javax.swing.event.UndoableEditEvent event)
undoableEditHappened
in interface javax.swing.event.UndoableEditListener
public void save(Layout layout)
Layout
instance.
The code editor saves the caret position and the vertical scrollbar value.
save
in interface BaseLayoutListener
layout
- the Layout
instancepublic void init(Layout layout)
Layout
instance.
The code editor restores the caret position and the vertical
scrollbar value from the values stored in the Layout
instance.
init
in interface BaseLayoutListener
layout
- the Layout
instancepublic void close(Layout layout)
Layout
.
close
in interface BaseLayoutListener
layout
- the Layout
instancepublic HelpInfo getHelpInfo()
HelpInfo
topic to display for this view.
getHelpInfo
in interface Helpable
getHelpInfo
in class AbstractView
public void setHelpInfo(HelpInfo helpInfo)
helpInfo
- the default help info topic that should be displayedpublic void addHelpableProvider(HelpableProvider helpableProvider)
HelpableProvider
for this class from which the
code editor can retrieve help info. This can be used to return
context-sensitive help info for the current editor caret
position. Note that the code editor will query registered
HelpableProvider's until it gets the first non-null help info.
To change the default non-context-sensitive help topic, use
setHelpInfo() instead.
helpableProvider
- the helpable provider to registerpublic void removeHelpableProvider(HelpableProvider helpableProvider)
HelpableProvider
.
helpableProvider
- the helpableProvider to deregisterpublic void setHelpableProvider(HelpableProvider helpableProvider)
HelpableProvider
for this class. The
helpableProvider
- The class to delegate to for help.public HelpableProvider getHelpableProvider()
HelpableProvider
for this class if one exists,
othewise null
will be returned. This is deprecated
and will always return null.
protected BasicEditorPane getEditorComponent()
protected java.lang.String getEditorText()
protected boolean canCut()
protected boolean canCopy()
protected boolean canPaste()
|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright ©1997, 2003, Oracle. All rights reserved.