Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

oracle.ide.ceditor
Class CodeEditor

java.lang.Object
  extended by oracle.ide.view.View
      extended by oracle.ide.editor.Editor
          extended by oracle.ide.ceditor.CodeEditor
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.event.CaretListener, javax.swing.event.UndoableEditListener, oracle.ide.ceditor.find.FindableEditor, ControllerProvider, TextEditor, Helpable, BaseLayoutListener, LayoutSelector, Observer, StatusProvider, BasicEditorPaneContainer, PopupManager, ToolTipProvider

public final class CodeEditor
extends Editor
implements javax.swing.event.CaretListener, oracle.ide.ceditor.find.FindableEditor, BasicEditorPaneContainer, StatusProvider, ToolTipProvider, javax.swing.event.UndoableEditListener, BaseLayoutListener, PopupManager, TextEditor, java.beans.PropertyChangeListener

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
          Deprecated. use CodeEditorCon
static java.lang.String TYPE_CPP
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_DIFF
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_HTML
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_IDL
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_JAVA
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_JS
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_JSP
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_PLAIN
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_PLSQL
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_PROPERTIES
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_SQL
          Deprecated. use CodeEditorConstants
static java.lang.String TYPE_XML
          Deprecated. use CodeEditorConstants
 
Fields inherited from class oracle.ide.editor.Editor
_addin, _context, ATTRIBUTE_BACKGROUND_COLOR, ATTRIBUTE_CUSTOM_HORIZONTAL_SCROLLBAR, ATTRIBUTE_CUSTOM_VERTICAL_SCROLLBAR, ATTRIBUTE_DELAY_PALETTE_LOAD, ATTRIBUTE_HORIZONTAL_BLOCK_INCREMENT, ATTRIBUTE_HORIZONTAL_SCROLLBAR_POLICY, ATTRIBUTE_HORIZONTAL_UNIT_INCREMENT, ATTRIBUTE_MENU_ID, ATTRIBUTE_OLD_EDITOR, ATTRIBUTE_SCROLLABLE, ATTRIBUTE_VERTICAL_BLOCK_INCREMENT, ATTRIBUTE_VERTICAL_SCROLLBAR_POLICY, ATTRIBUTE_VERTICAL_UNIT_INCREMENT, CUSTOM_BORDER, PROPERTY_FIXED_BOTTOM_MARGIN, PROPERTY_FIXED_LEFT_MARGIN, PROPERTY_FIXED_RIGHT_MARGIN, PROPERTY_FIXED_TOP_MARGIN, PROPERTY_SCROLLABLE_LEFT_MARGIN, PROPERTY_SCROLLABLE_TOP_MARGIN
 
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  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)
          Deprecated. declarative registration via the ceditor.plugin or ceditor.plugin-factory hook is preferred
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 oracle.ide.editor.Editor
addPreferredLayoutListener, addPropertyChangeListener, editorHidden, editorShown, firePropertyChangeEvent, getBottomComponent, getContext, getContextMenu, getDependentNodes, getDisplayName, getEditorAddin, getFixedLeftMargin, getMiniToolbar, getPreferredLayoutBaseName, getPreferredLayoutURL, getScrollableTopMargin, getTabDescription, getTabLabel, getTitleLabel, getType, initializeActiveLayout, initializeLayout, isReady, newId, prepareForSaving, removePreferredLayoutListener, removePropertyChangeListener, setEditorAddin, setEditorAttribute, setPreferredLayoutBaseName, setPreferredLayoutURL, setType
 
Methods inherited from class oracle.ide.view.View
activate, addViewListener, addViewSelectionListener, addViewStateListener, deactivate, fireViewCollapsed, fireViewExpanded, fireViewSelectionChanged, getContext, getId, getSelection, getTabName, getViewWithoutDecoration, isVisible, loadLayout, loadManifestToolbar, loadManifestToolbar, owner, removeViewListener, removeViewSelectionListener, removeViewStateListener, saveLayout, scheduleUpdateSelection, setId, setOwner, setToolbarVisible, show, toString, updateSelection, updateSelectionImpl, updateTitle, updateToolbarActions, updateVisibleActions, updateVisibleActions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EDITOR_CONTEXT

@Deprecated
public static final java.lang.String EDITOR_CONTEXT
Deprecated. use CodeEditorCon
The property name for this editor's Context instance. If the context is changed (i.e., different project or workspace), then the editor's context property will be updated. Clients can listen for this change by adding themselves as PropertyChangeListeners to the editor component.

See Also:
Constant Field Values

TYPE_PLAIN

@Deprecated
public static final java.lang.String TYPE_PLAIN
Deprecated. use CodeEditorConstants
The syntax highlighting type for plain files.


TYPE_JAVA

@Deprecated
public static final java.lang.String TYPE_JAVA
Deprecated. use CodeEditorConstants
The syntax highlighting type for Java files.


TYPE_SQL

@Deprecated
public static final java.lang.String TYPE_SQL
Deprecated. use CodeEditorConstants
The syntax highlighting type for SQL files. Currently the same as PL/SQL.


TYPE_PLSQL

@Deprecated
public static final java.lang.String TYPE_PLSQL
Deprecated. use CodeEditorConstants
The syntax highlighting type for PL/SQL files.


TYPE_JSP

@Deprecated
public static final java.lang.String TYPE_JSP
Deprecated. use CodeEditorConstants
THe syntax highlighting type for JSP files.


TYPE_HTML

@Deprecated
public static final java.lang.String TYPE_HTML
Deprecated. use CodeEditorConstants
The syntax highlighting type for HTML files.


TYPE_XML

@Deprecated
public static final java.lang.String TYPE_XML
Deprecated. use CodeEditorConstants
The syntax highlighting type for XML files.


TYPE_PROPERTIES

@Deprecated
public static final java.lang.String TYPE_PROPERTIES
Deprecated. use CodeEditorConstants
The syntax highlighting type for Properties files.


TYPE_IDL

@Deprecated
public static final java.lang.String TYPE_IDL
Deprecated. use CodeEditorConstants
The syntax highlighting type for IDL files.


TYPE_CPP

@Deprecated
public static final java.lang.String TYPE_CPP
Deprecated. use CodeEditorConstants
The syntax highlighting type for C++ files.


TYPE_JS

@Deprecated
public static final java.lang.String TYPE_JS
Deprecated. use CodeEditorConstants
The syntax highlighting type for JavaScript files.


TYPE_DIFF

@Deprecated
public static final java.lang.String TYPE_DIFF
Deprecated. use CodeEditorConstants
The syntax highlighting type for diff files.

Constructor Detail

CodeEditor

public CodeEditor()
Constructs a new Code Editor which makes use of the editor package.

Method Detail

registerFactory

@Deprecated
public static void registerFactory(EditorPluginsFactory factory)
Deprecated. declarative registration via the ceditor.plugin or ceditor.plugin-factory hook is preferred

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.

Parameters:
factory - the EditorPluginsFactory to register

registerNodeType

public static void registerNodeType(java.lang.Class nodeClass,
                                    java.lang.String highlightingType)
Registers the given node class for the given syntax highlighting type to use. The syntax highlighting type specified should be one of the 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.

Parameters:
nodeClass - the class of the node to register
highlightingType - the syntax highlighting type to use

changeDocumentType

public void changeDocumentType(java.lang.String highlightingType)
Change the syntax highlighting type to use for this current CodeEditor instance. The syntax highlighting type specified must be one of the TYPE_* public constants specified in this class.

Parameters:
highlightingType - the syntax highlighting type to use

createHighlightStyle

public 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. This registers this highlight with the editor framework to ensure it is available for editing in the editor options panel. Addins should create their highlights during Addin initialization.

Parameters:
internalName - the (unique) name of the style used internally for registration purposes
publicName - the (translated) name of the style that can be displayed by the UI to identify the style to users
priority - 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 text
bgColor - the color to use for the background of the text, null not to change the background of the text

createHighlightStyle

public 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. This registers this highlight with the editor framework to ensure it is available for editing in the editor options panel. Addins should create their highlights during Addin initialization.

Parameters:
internalName - the (unique) name of the style used internally for registration purposes
publicName - the (translated) name of the style that can be displayed by the UI to identify the style to users
priority - 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 text
bgColor - the color to use for the background of the text, null not to change the background of the text
fontStyle - the font style to use, such as Font.BOLD
underlinePredefine - the underline predefined index to use, such as HighlightRegistry.SINGLE_UNDERLINE, or -1 for none
underlineColor - the underline color to use, or null for none

getToolbar

public Toolbar getToolbar()
Get the Toolbar that is the fixed top margin above the code editor view.

Overrides:
getToolbar in class View

setFixedBottomMarginComponent

public void setFixedBottomMarginComponent(java.awt.Component panel)
Installs a panel at the bottom of the code editor.

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.

Parameters:
panel - The panel to show at the bottom of the editor.
See Also:
getFixedBottomMargin()

getText

public java.lang.String getText(int offset,
                                int length)
                         throws javax.swing.text.BadLocationException
Fetches a portion of the text represented by the component. Returns an empty String if the length is 0.

Parameters:
offset - the starting offset >= 0
length - the length to retrieve >= 0
Returns:
the text requested
Throws:
javax.swing.text.BadLocationException - if the offset or length are invalid

setCaretPosition

public void setCaretPosition(int offset)
Sets the position of the text insertion caret for the editor component. The caret tracks change, so it may move if the underlying text of the component is changed.

Parameters:
offset - the new caret position to set

moveCaretPosition

public void moveCaretPosition(int offset)
Moves the caret to a new position, leaving behind a mark defined by the last time setCaretPosition was called. This forms a selection.

Parameters:
offset - the offset to move the caret to
See Also:
setCaretPosition(int)

getCaretPosition

public int getCaretPosition()
Returns the position of the text insertion caret for the editor component.

Returns:
the caret position of the editor

getCaretLine

public int getCaretLine()
Return the line that the caret is on. This will map the offset of the caret position to the given line in the document. Note that the line number is one-based and that the caret position biases to the right - this means if the caret is between a new line and a character, the line number returned is for the line of the character. This will return 0 if there is no document, or an error has occurred.

Returns:
the line number that the caret is on (1-based)

replaceSelection

public void replaceSelection(java.lang.String content)
Replaces the currently selected content with the new content represented by the given String. We override the implementation of JTextComponent so that the whole replace can be a single undoable operation.

Parameters:
content - the new content to replace the current selection

hasSelectedText

public boolean hasSelectedText()
Return whether or not there is any text selected.

Returns:
true if there is a text selection, false otherwise

getSelectedText

public java.lang.String getSelectedText()
Returns the selected text contained in this TextComponent. If the selection is null or the document empty, returns null.

Returns:
the currently selected text if any
Throws:
java.lang.IllegalArgumentException - if the selection doesn't have a valid mapping into the document for some reason

getSelectionStart

public int getSelectionStart()
Returns the start position of the current text selection. Returns 0 for an empty document, or the current caret offset if there is no selection.

Returns:
the start of the selection or the current caret position

getSelectionEnd

public int getSelectionEnd()
Returns the end position of the current text selection. Returns 0 for an empty document, or the current caret offset if there is no selection.

Returns:
the end of the selection or the current caret position

setSelectionStart

public void setSelectionStart(int selectionStart)
Sets the start of the selection to the specified position. The new starting point is constrained to be before or at the current selection end.

Parameters:
selectionStart - the new start of the selection

setSelectionEnd

public void setSelectionEnd(int selectionEnd)
Sets the end of the selection to the specified position. The new ending point is constrained to be at or after the current selection start.

Parameters:
selectionEnd - the new end of the selection

addCursorListener

public void addCursorListener(CursorListener listener)
Adds a 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);

Parameters:
listener - the listener to add

addCursorListener

public void addCursorListener(CursorListener listener,
                              boolean batchEvents)
Adds a CursorListener to the list of cursor listeners. Cursor listeners are notifed to changes in the caret position.

Parameters:
listener - the listener to add
batchEvents - if true quick cursor changes will be grouped into one notification. if false listeners will be notified of every caret change.

removeCursorListener

public void removeCursorListener(CursorListener listener)
Removes a CursorListener from the list of cursor listeners.

Parameters:
listener - the listener to remove

getGutter

public CodeEditorGutter getGutter()
Fetches the gutter associated with this editor on the left margin. This can be used for placing icons there.

Returns:
the gutter

getFileOverviewMargin

public FileOverviewMargin getFileOverviewMargin()

addCEToolTipProvider

public void addCEToolTipProvider(CEToolTipProvider provider)
Registers a CEToolTipProvider implementation to receive requests for tooltip information when the mouse travels over the code editor.

Parameters:
provider - the tooltip provider to register

removeCEToolTipProvider

public void removeCEToolTipProvider(CEToolTipProvider provider)
Deregisters a previously registered CEToolTipProvider implementation when it no longer wants to handle tooltip requests.

Parameters:
provider - the provider to deregister

gotoOffset

public 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. If the offset specified is invalid, it will attempt to move to the closest position to the offset. If the offset is valid but the selection length is invalid, it will not select anything.

Parameters:
offset - the offset to move the cursor to (zero-based)
selectionLength - the length of the selection, 0 if not desired.
Returns:
true if the offset and selectionLength specified is valid

gotoLine

public 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. If the line specified is invalid, it will attempt to move to the closest position and return false. If the line is offscreen, this will recenter the editor view on the line.

Specified by:
gotoLine in interface TextEditor
Parameters:
line - the line to go to (one-based)
column - the column to go to (one-based)
highlightLine - whether to highlight the specified line
Returns:
true if the line specified is valid

getCustomCells

public javax.swing.JComponent[] getCustomCells()
Get an array of custom cells to add to a StatusBar. The cells will be added to the StatusBar in the same order as they appear in the resulting array.

Specified by:
getCustomCells in interface StatusProvider
Returns:
an ordered array of custom status cells or null
See Also:
StatusBar

isExpandable

public boolean isExpandable(javax.swing.JComponent customCell)
Determine whether the given custom cell should expand to fill any extra space beyond its minimum requirements.

Specified by:
isExpandable in interface StatusProvider
Returns:
true if customCell should expand to fill extra space.
See Also:
StatusProvider.getCustomCells()

getFocusedEditorPane

public BasicEditorPane getFocusedEditorPane()
Fetches the focused (active) editor pane embedded in the editor in which to perform Find operations on. If there is more than one editor pane, the one with focus should be returned. If the focus is not currently on an editor pane, then null should be returned.

Specified by:
getFocusedEditorPane in interface BasicEditorPaneContainer
Returns:
the instance of the embedded BasicEditorPane that currently has focus

showPopup

public 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. The client is responsible for building/populating the popup menus (if necessary), and making it visible.

Specified by:
showPopup in interface PopupManager
Parameters:
editorPane - the editorPane that the user request occurred in
mouseEvent - the mouse event describing the location of the popup request.

hidePopup

public void hidePopup(BasicEditorPane editorPane)
Informs the editor client that the popup menu (if showing) should now be hidden. This may be in response to some user input or event.

Specified by:
hidePopup in interface PopupManager
Parameters:
editorPane - the editorPane for which the popup should be hidden

propertyChange

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

caretUpdate

public void caretUpdate(javax.swing.event.CaretEvent event)
Called when the caret position is updated.

Specified by:
caretUpdate in interface javax.swing.event.CaretListener
Parameters:
event - the caret event

getLineCount

public int getLineCount()
Fetches the number of lines in this TextBuffer. For example, a 5-line TextBuffer has lines 0 through 4.

Returns:
number of lines in TextBuffer

getLineFromOffset

public 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. This means if line A starts with offset B, and previous line A-1 ends with offset B, getLineFromOffset(B) will return line A.

Returns:
the line containing an offset

getLineStartOffset

public int getLineStartOffset(int line)
Given a specified line, returns the offset from the beginning of the TextBuffer for the start of the line.

Parameters:
line - a line in the TextBuffer
Returns:
the starting offset of the specified line

getLineEndOffset

public int getLineEndOffset(int line)
Given a specified line, returns the offset from the beginning of a TextBuffer that the line ends at.

Parameters:
line - a line in the TextBuffer
Returns:
the ending offset of the specified line

getContext

public static Context getContext(BasicEditorPane editor)
Fetch the IDE context associated with the given editor component.

Parameters:
editor - the editor pane
Returns:
the associated context, or null if none

getSelectionFromUI

protected Element[] getSelectionFromUI()
Description copied from class: View
This method retrieve's the selection in this View directly from the UI. Callers must invoke this method on the Swing/AWT event dispatch thread, and implementations can assume that calls are on the Swing/AWT event dispatch thread.

Overrides:
getSelectionFromUI in class View
Returns:
the selection from the UI.

registerViewSelectionHelperFactory

public static void registerViewSelectionHelperFactory(ViewSelectionHelperFactory factory)
Register a ViewSelectionHelperFactory with the code editor. During creation of a CodeEditor all registered factories will have their createSelectionHelper() methods called allowing the creation of SelectionHelpers. Later the SelectionHelpers will be called to attach to the CodeEditor and can from then on set view selection via the given CodeEditorViewSelectionSetter objects.


registerViewLimitProviderFactory

public static void registerViewLimitProviderFactory(ViewLimitProviderFactory factory)
Register a ViewLimitProviderFactory with the code editor. During creation of a CodeEditor all registered factories will have their createViewLimitProvider() methods called allowing the creation of ViewLimitProviders as appropriate. Later the ViewLimitProviders will be called to attach to the CodeEditor and may be called to limit the view.


getCodeEditor

public static CodeEditor getCodeEditor(BasicEditorPane editor)
Fetch the Code Editor associated with the given editor component.

Parameters:
editor - the editor pane
Returns:
the associated code editor, or null if none

setContext

public void setContext(Context context)
Set the context behind this editor.

Overrides:
setContext in class Editor

open

public void open()
Open this editor on the context set by a prior call to setContext.

Specified by:
open in class Editor
See Also:
Editor.setContext(oracle.ide.Context)

getDefaultFocusComponent

public java.awt.Component getDefaultFocusComponent()
This method is used to know what component should get the focus by default. The returned component should be a child of the component returned by getGUI() or getGUI() itself and should be requestFocusable. By contract, getGUI() will always be called before getDefaultFocusComponent()

Overrides:
getDefaultFocusComponent in class Editor
Returns:
the component that should take the focus

close

public void close()
Close this editor - this gives us a chance to clean up any resources. Note, although the editor is closed, the UndoableEdits continue to survive in the CommandProcessor queue! This means that we cannot clean out anything that that functionality (undo) depends on.

Once closed a CodeEditor instance should not be used again as behaviour cannot be guaranteed and exceptions may occur while calling methods.

Overrides:
close in class Editor

getController

public Controller getController()
Gets the Controller associated with this view.

Specified by:
getController in interface ControllerProvider
Overrides:
getController in class Editor
Returns:
the controller associated with this view.

getEditorAttribute

public java.lang.Object getEditorAttribute(java.lang.String attribute)
Overrides:
getEditorAttribute in class Editor
Parameters:
attribute - takes values from ATTRIBUTE_ constants.
Returns:
the value for the specified attribute.

saveSettings

public void saveSettings(StructuredPropertyAccess node)
Description copied from class: Editor
Saves the editor settings.

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);
     }
   }
 
Overrides:
saveSettings in class Editor

loadSettings

public void loadSettings(StructuredPropertyAccess node)
Description copied from class: Editor
Reloads the editor settings.

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);
       }
     }
 

Overrides:
loadSettings in class Editor

getGUI

public java.awt.Component getGUI()
Get the view's root graphical user interface component. Do not reply on this being a consistent type of Component.

Specified by:
getGUI in class View
Returns:
the root graphical user component

getScrollableLeftMargin

public java.awt.Component getScrollableLeftMargin()
Overrides:
getScrollableLeftMargin in class Editor
Returns:
the scrollable left margin if there is one or null.

getFixedRightMargin

public java.awt.Component getFixedRightMargin()
Overrides:
getFixedRightMargin in class Editor
Returns:
the non-scrollable right margin if there is one or null.

getFixedTopMargin

public java.awt.Component getFixedTopMargin()
Overrides:
getFixedTopMargin in class Editor
Returns:
the non-scrollable top margin if there is one or null.

getFixedBottomMargin

public java.awt.Component getFixedBottomMargin()
Overrides:
getFixedBottomMargin in class Editor
Returns:
the non-scrollable bottom margin if there is one or null.

getTabIcon

public javax.swing.Icon getTabIcon()
Get the Icon to use when displaying this View as a tab in a JTabbedPane host such as the EditorFrame.

Overrides:
getTabIcon in class Editor
See Also:
Editor

update

public void update(java.lang.Object observed,
                   UpdateMessage change)
Notification message. Subjects call this method when they notify their observers that the subjects state has changed.

Specified by:
update in interface Observer
Parameters:
observed - the subject whose state has changed.
change - what has changed.

getToolTipText

public 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. The mouseEvent describes where the cursor is an what the mouse event was (i.e., mouse moved), and the offset is the location in the editor (document) corresponding to the current mouse cursor.

Specified by:
getToolTipText in interface ToolTipProvider
Parameters:
editorPane - the editor where the tooltip will be displayed
mouseEvent - the mouse event that generated the tooltip
offset - the document offset where the mouse cursor is located
Returns:
the tooltip text to display

undoableEditHappened

public void undoableEditHappened(javax.swing.event.UndoableEditEvent event)
An UndoableEdit happened in the editor. Generate a matching one in the IDE.

Specified by:
undoableEditHappened in interface javax.swing.event.UndoableEditListener

save

public void save(Layout layout)
Save this editor's layout information to the given Layout instance.

The code editor saves the caret position and the vertical scrollbar value.

Specified by:
save in interface BaseLayoutListener
Parameters:
layout - the Layout instance

init

public void init(Layout layout)
Initialize this editor's layout information from the given Layout instance.

The code editor restores the caret position and the vertical scrollbar value from the values stored in the Layout instance.

Specified by:
init in interface BaseLayoutListener
Parameters:
layout - the Layout instance

close

public void close(Layout layout)
Close the given Layout.

Specified by:
close in interface BaseLayoutListener
Parameters:
layout - the Layout instance

getHelpInfo

public HelpInfo getHelpInfo()
Fetch the HelpInfo topic to display for this view.

Specified by:
getHelpInfo in interface Helpable
Overrides:
getHelpInfo in class View
Returns:
the help info to display

setHelpInfo

public void setHelpInfo(HelpInfo helpInfo)
Sets the default help info topic that this code editor displays.

Parameters:
helpInfo - the default help info topic that should be displayed

setToolbarHelpInfo

public void setToolbarHelpInfo(HelpInfo helpInfo)
Sets the default help info topic that the code editor toolbar displays.

Parameters:
helpInfo - the default help info topic that should be displayed for the toolbar

addHelpableProvider

public void addHelpableProvider(HelpableProvider helpableProvider)
Adds a 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.

Parameters:
helpableProvider - the helpable provider to register

removeHelpableProvider

public void removeHelpableProvider(HelpableProvider helpableProvider)
Removes a previously registered HelpableProvider.

Parameters:
helpableProvider - the helpableProvider to deregister

setHelpableProvider

@Deprecated
public void setHelpableProvider(HelpableProvider helpableProvider)
Deprecated. 

Sets the HelpableProvider for this class. The

Parameters:
helpableProvider - The class to delegate to for help.

getHelpableProvider

@Deprecated
public HelpableProvider getHelpableProvider()
Deprecated. 

Gets the HelpableProvider for this class if one exists, othewise null will be returned. This is deprecated and will always return null.


getEditorText

protected java.lang.String getEditorText()
Get the contents of the editor as a String for refreshing the IDE buffer.

Returns:
the contents of the editor document

canCut

@Deprecated
protected boolean canCut()
Deprecated. 

Determine whether we should enable the Edit->Cut menu.

Returns:
if we can perform a cut now

canCopy

@Deprecated
protected boolean canCopy()
Deprecated. 

Determine whether we should enable the Edit->Copy menu.

Returns:
if we can perform a copy now

canPaste

@Deprecated
protected boolean canPaste()
Deprecated. 

Determine whether we should enable the Edit->Paste menu.

Returns:
if we can perform a paste now

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

Copyright © 1997, 2011, Oracle. All rights reserved.