|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.6.0) E13403-07 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.ide.view.View oracle.ide.editor.Editor oracle.ide.ceditor.CodeEditor
public final class 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 | |
---|---|
protected class |
CodeEditor.CEToolbar
Our override of the Toolbar class so that it is invisible when it is empty. |
Field Summary | |
---|---|
static java.lang.String |
EDITOR_CONTEXT
The property name for this editor's Context instance. |
static java.lang.String |
TYPE_CPP
The syntax highlighting type for C++ files. |
static java.lang.String |
TYPE_DIFF
The syntax highlighting type for diff 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_JS
The syntax highlighting type for JavaScript 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.view.View |
---|
EMPTY_SELECTION, 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 |
addCursorListener(CursorListener listener,
boolean batchEvents)
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 |
changeDocumentType(java.lang.String highlightingType)
Change the syntax highlighting type to use for this current CodeEditor instance. |
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 with background and foreground attributes. |
static HighlightStyle |
createHighlightStyle(java.lang.String internalName,
java.lang.String publicName,
int priority,
java.awt.Color fgColor,
java.awt.Color bgColor,
int fontStyle,
int underlinePredefine,
java.awt.Color underlineColor)
Utility routine to create a new highlight style with background, foreground, font, and underline attributes. |
int |
getCaretLine()
Return the line that the caret is on. |
int |
getCaretPosition()
Returns the position of the text insertion caret for the editor component. |
static CodeEditor |
getCodeEditor(BasicEditorPane editor)
Fetch the Code Editor associated with the given editor component. |
static Context |
getContext(BasicEditorPane editor)
Fetch the IDE context associated with the given editor component. |
Controller |
getController()
Gets the Controller associated with this view. |
javax.swing.JComponent[] |
getCustomCells()
Get an array of custom cells to add to a StatusBar. |
java.awt.Component |
getDefaultFocusComponent()
This method is used to know what component should get the focus by default. |
java.lang.Object |
getEditorAttribute(java.lang.String attribute)
|
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. |
FileOverviewMargin |
getFileOverviewMargin()
|
java.awt.Component |
getFixedBottomMargin()
|
java.awt.Component |
getFixedRightMargin()
|
java.awt.Component |
getFixedTopMargin()
|
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.awt.Component |
getScrollableLeftMargin()
|
java.lang.String |
getSelectedText()
Returns the selected text contained in this TextComponent. |
int |
getSelectionEnd()
Returns the end position of the current text selection. |
protected Element[] |
getSelectionFromUI()
This method retrieve's the selection in this View directly from the UI. |
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. |
Toolbar |
getToolbar()
Get the Toolbar that is the fixed top margin above the code editor view. |
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 |
hidePopup(BasicEditorPane editorPane)
Informs the editor client that the popup menu (if showing) should now be hidden. |
void |
init(Layout layout)
Initialize this editor's layout information from the given Layout instance. |
boolean |
isExpandable(javax.swing.JComponent customCell)
Determine whether the given custom cell should expand to fill any extra space beyond its minimum requirements. |
void |
loadSettings(StructuredPropertyAccess node)
Reloads the editor settings. |
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. |
void |
propertyChange(java.beans.PropertyChangeEvent event)
|
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. |
static void |
registerNodeType(java.lang.Class nodeClass,
java.lang.String highlightingType)
Registers the given node class for the given syntax highlighting type to use. |
static void |
registerViewLimitProviderFactory(ViewLimitProviderFactory factory)
Register a ViewLimitProviderFactory with the code editor. |
static void |
registerViewSelectionHelperFactory(ViewSelectionHelperFactory factory)
Register a ViewSelectionHelperFactory with the code editor. |
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 |
saveSettings(StructuredPropertyAccess node)
Saves the editor settings. |
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 |
setFixedBottomMarginComponent(java.awt.Component panel)
Installs a panel at the bottom of the code 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 |
setToolbarHelpInfo(HelpInfo helpInfo)
Sets the default help info topic that the code editor toolbar displays. |
void |
showPopup(BasicEditorPane editorPane,
java.awt.event.MouseEvent mouseEvent)
Informs the editor client that the user requested a popup menu in the given editor pane, at the location specified in the mouseEvent. |
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String EDITOR_CONTEXT
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 java.lang.String TYPE_JS
public static final java.lang.String TYPE_DIFF
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 registerNodeType(java.lang.Class nodeClass, java.lang.String highlightingType)
TYPE_*
public constants
specified in this class. The provided node class MUST
implement the TextNode
interface, as only
TextNode
implementations are editable by the
code editor.
nodeClass
- the class of the node to registerhighlightingType
- the syntax highlighting type to usepublic void changeDocumentType(java.lang.String highlightingType)
TYPE_*
public constants specified in this class.
highlightingType
- 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
displayed by the UI to identify the style to userspriority
- the priority of the highlight when rendering (1-100)fgColor
- 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 static HighlightStyle createHighlightStyle(java.lang.String internalName, java.lang.String publicName, int priority, java.awt.Color fgColor, java.awt.Color bgColor, int fontStyle, int underlinePredefine, java.awt.Color underlineColor)
internalName
- the (unique) name of the style used internally for
registration purposespublicName
- the (translated) name of the style that can be
displayed by the UI to identify the style to userspriority
- the priority of the highlight when rendering (1-100)fgColor
- 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 textfontStyle
- the font style to use, such as Font.BOLDunderlinePredefine
- the underline predefined index to use, such as
HighlightRegistry.SINGLE_UNDERLINE, or -1 for noneunderlineColor
- the underline color to use, or null for nonepublic Toolbar getToolbar()
getToolbar
in class View
public void setFixedBottomMarginComponent(java.awt.Component panel)
This method must be called during the plugins installation, the panel will not appear if the method is called after the editor has been displayed.
This panel will be shared among the different plugins. If a panel has already been installed, this method will throw.
panel
- The panel to show at the bottom of the editor.getFixedBottomMargin()
public 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.
Cursor listeners are notifed to changes in the caret position.
Cursor listeners added here are notified immediately of caret position changes
(same as calling addCursorListener(listener, false);
listener
- the listener to addpublic void addCursorListener(CursorListener listener, boolean batchEvents)
CursorListener
to the list of cursor listeners.
Cursor listeners are notifed to changes in the caret position.
listener
- the listener to addbatchEvents
- if true quick cursor changes will be grouped into
one notification. if false listeners will be notified of every caret change.public void removeCursorListener(CursorListener listener)
CursorListener
from the list of cursor listeners.
listener
- the listener to removepublic CodeEditorGutter getGutter()
public FileOverviewMargin getFileOverviewMargin()
public void addCEToolTipProvider(CEToolTipProvider provider)
CEToolTipProvider
implementation to
receive requests for tooltip information when the mouse travels
over the code editor.
provider
- the tooltip provider to registerpublic void removeCEToolTipProvider(CEToolTipProvider provider)
CEToolTipProvider
implementation when it no longer wants to handle tooltip requests.
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)
gotoLine
in interface TextEditor
line
- the line to go to (one-based)column
- the column to go to (one-based)highlightLine
- whether to highlight the specified line
public javax.swing.JComponent[] getCustomCells()
getCustomCells
in interface StatusProvider
StatusBar
public boolean isExpandable(javax.swing.JComponent customCell)
isExpandable
in interface StatusProvider
StatusProvider.getCustomCells()
public BasicEditorPane getFocusedEditorPane()
getFocusedEditorPane
in interface oracle.ide.ceditor.find.FindableEditor
BasicEditorPane
that currently has focuspublic void showPopup(BasicEditorPane editorPane, java.awt.event.MouseEvent mouseEvent)
showPopup
in interface PopupManager
editorPane
- the editorPane that the user request occurred inmouseEvent
- the mouse event describing the location of the
popup request.public void hidePopup(BasicEditorPane editorPane)
hidePopup
in interface PopupManager
editorPane
- the editorPane for which the popup should be hiddenpublic void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
public 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 static Context getContext(BasicEditorPane editor)
editor
- the editor pane
protected Element[] getSelectionFromUI()
View
getSelectionFromUI
in class View
public static void registerViewSelectionHelperFactory(ViewSelectionHelperFactory factory)
public static void registerViewLimitProviderFactory(ViewLimitProviderFactory factory)
public static CodeEditor getCodeEditor(BasicEditorPane editor)
editor
- the editor pane
public void setContext(Context context)
setContext
in class Editor
public void open()
open
in class Editor
Editor.setContext(oracle.ide.Context)
public java.awt.Component getDefaultFocusComponent()
getDefaultFocusComponent
in class Editor
public void close()
close
in class Editor
public Controller getController()
Controller
associated with this view.
getController
in interface ControllerProvider
getController
in class Editor
public java.lang.Object getEditorAttribute(java.lang.String attribute)
getEditorAttribute
in class Editor
attribute
- takes values from ATTRIBUTE_ constants.
public void saveSettings(StructuredPropertyAccess node)
Editor
Example:
public void saveSettings(Element element) { String value = "value"; element.setAttribute("key", value); Node ownerNode = element.getOwnerNode(); for(int i=0;i<3;i++) { Element subElement = ownerNode.createElement("sub"); String subValue = "sub-value-"+i; subElement.setAttribute("sub-key", subValue); element.appendChild(subElement); } }
saveSettings
in class Editor
public void loadSettings(StructuredPropertyAccess node)
Editor
This method will be called when the the product is restarted but also when an editor is split. If the new editor is of the same type as the original, the settings will be taken from the original (saveSettings) and will be applied to the new editor (loadSettings). If your editor needs to make the difference, it can test for the element.getName() which will return "DUPLICATON". Example:
String value = element.getAttribute("key"); System.out.println("value = " + value); NodeList childNodes = element.getChildNodes(); int length = childNodes.getLength(); for(int i=0;i<length;i++) { Node childNode = childNodes.item(i); if ("sub".equals(childNode.getNodeName())) { Element subElement = (Element) childNode; String subValue = subElement.getAttribute("sub-key"); System.out.println("subValue = " + subValue); } }
loadSettings
in class Editor
public java.awt.Component getGUI()
getGUI
in class View
public java.awt.Component getScrollableLeftMargin()
getScrollableLeftMargin
in class Editor
public java.awt.Component getFixedRightMargin()
getFixedRightMargin
in class Editor
public java.awt.Component getFixedTopMargin()
getFixedTopMargin
in class Editor
public java.awt.Component getFixedBottomMargin()
getFixedBottomMargin
in class Editor
public javax.swing.Icon getTabIcon()
getTabIcon
in class Editor
Editor
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 View
public void setHelpInfo(HelpInfo helpInfo)
helpInfo
- the default help info topic that should be displayedpublic void setToolbarHelpInfo(HelpInfo helpInfo)
helpInfo
- the default help info topic that should be displayed for the toolbarpublic 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()
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.6.0) E13403-07 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |