|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.javatools.editor.insight.AbstractInsight
The AbstractInsight
class provides some of the common
functionality of all Insight implementations, such as handling the
delayed timer, trapping of editor commands, displaying of the
Insight window, and so on.
Notes on when to update Insight:
The following are the ways that the source file can be modified, requiring Insight to be updated:
The main problem is that the CaretEvent and DocumentEvent are not ordered with respective to each other - because of this, there is no way to know which one will fire first. It is undesirable to update Insight twice (especially if it causes "flashing".)
Another possibility is to fire a delayed timer when either of these events are generated so that we only update once - the problem with this is that it is possible for the user to issue a command (i.e., hitting "Enter" to complete Insight) before the timer fires, which could potentially cause incorrect results. This is also undesirable.
So what if we choose to listen to just one of the events? Listening to just DocumentEvents will cause us to miss case (1), while listening to just CaretEvents will cause us to miss case (4). Missing case (1) is bad because the user may navigate out of the insight critical area using the mouse. Missing case (4) is not a huge deal as the Insight information is generated primarily using the information before the cursor.
If you combine the use of OffsetMarks with the CaretEvent, you could guess the approximate location of the document change (if any.)
This implementation will take care of locking when
InsightProvider.getInsightData()
and
InsightProvider.updateInsightData()
are called.
Completion implementations should return COMPLETION_TYPE
in getInsightType()
, while Tooltip implementations should
return TOOLTIP_TYPE
. This will ensure that the correct
action redirection occurs. Currently, for API compatibility, this
abstract class always returns COMPLETION_TYPE
for
getInsightType()
. This will be changed to an abstract
method at some point in the future, so clients should update their
implementations accordingly.
Insight
,
InsightProvider
,
InsightData
,
InsightView
Field Summary | |
protected static int[] |
COMPLETION_LOCATIONS
The preferred positions for a COMPLETION_TYPE insight. |
static int |
COMPLETION_TYPE
Constant describing an Insight completion type implementation. |
protected static int[] |
TOOLTIP_LOCATIONS
The preferred positions for a TOOLTIP_TYPE insight. |
static int |
TOOLTIP_TYPE
Constant describing an Insight tooltype type implementation. |
Fields inherited from interface oracle.javatools.editor.popup.PopupWindowListener |
CLOSED_AUTO, CLOSED_NORMAL |
Constructor Summary | |
AbstractInsight()
|
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent event)
This is invoked when an action is performed. |
void |
caretUpdate(javax.swing.event.CaretEvent event)
Called when the caret position is updated. |
void |
characterTyped(BasicEditorPane editorPane,
int offset,
char typedChar)
Providers notification that a character was typed by the user and inserted into the editor pane. |
void |
clearPopupTimer()
Clears the delay timer for auto-popping up Insight, effectively cancelling the request. |
protected abstract InsightProvider |
createInsightProvider()
Creates an InsightProvider to be used with this Insight instance. |
void |
deinstall(BasicEditorPane editor)
Called when the plugin is being removed from the BasicEditorPane (for example when the editor is closed.) This is used to notify plugins that they should unregister any listeners that were attached. |
void |
editorFocusGained(oracle.javatools.editor.popup.PopupWindow popupWindow)
Notifies the listener that the editor (or one of its popups) have regained focus. |
void |
editorFocusLost(oracle.javatools.editor.popup.PopupWindow popupWindow,
boolean isTemporary)
Notifies the listener that the editor and any managed popups have lost focus. |
void |
focusGained(java.awt.event.FocusEvent event)
Invoked when a component gains the keyboard focus. |
void |
focusLost(java.awt.event.FocusEvent event)
Invoked when a component loses the keyboard focus. |
int |
getCaretPosition()
Utility routine to fetch the caret position in the text buffer associated with a particular pane. |
BasicDocument |
getDocument()
Fetch the underlying document of the editor pane that this Insight instance is installed in. |
BasicEditorPane |
getEditorPane()
Fetches the editor pane that this Insight instance is installed in. |
protected int |
getInsightType()
Fetches the Insight implementation type, whether completion or tooltip. |
protected int[] |
getPreferredLocations()
Fetch an array of preferred locations where this insight implementation would like to display its view. |
java.awt.Rectangle |
getShowRectangle()
Get the rectangle (relative to editor) where the insight window should be shown. |
TextBuffer |
getTextBuffer()
Utility routine to fetch the text buffer associated with the particular editor pane. |
void |
hideInsight()
Cancels an existing insight window that is displaying insight information. |
void |
install(BasicEditorPane editor)
Called when this plugin is being installed into the BasicEditorPane. |
boolean |
invokeAction(java.lang.String actionKey)
Invokes the Action corresponding to the given actionKey. |
protected boolean |
invokeCompletionTypeAction(int command)
Implementation specific routine to invoke the given action that was trapped by the editor. |
protected boolean |
invokeTooltipTypeAction(int command)
Implementation specific routine to invoke the given action that was trapped by the editor. |
protected boolean |
isExactMatch(InsightData data)
Fetch whether the current insight data instance represents an exact match. |
protected boolean |
isExactMatchSupported(InsightData data)
Fetch whether exact match completion should be enabled for the given insight data instance. |
abstract boolean |
isInsightTriggerChar(char typedChar)
Returns whether the given typed character should be treated as a trigger for firing the auto-popup timer for Insight. |
boolean |
isInsightVisible()
Returns whether there is an Insight window displayed right now. |
protected static int |
lookupCommand(java.lang.String actionKey)
Utility routine which maps an action name (such as "caret-down") to one of our private constants (like UP_COMMAND.) |
void |
popupClosed(oracle.javatools.editor.popup.PopupWindow popupWindow,
int how)
Notifies the listener that the popup window has been closed. |
void |
propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed. |
protected void |
propertyChangeImpl(java.beans.PropertyChangeEvent event)
Version of propertyChange() for implementations to override if they choose. |
void |
restartPopupTimer()
Starts (or restarts) the auto-popup delay timer for this Insight feature. |
void |
setAccessibleName(java.lang.String name)
|
void |
showInsight()
Instructs this insight to check whether there is insight information availble, and if so, to bring up an insight window. |
protected void |
updateInsight()
Utility routine which takes care of updating the Insight information which is currently displayed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int COMPLETION_TYPE
public static final int TOOLTIP_TYPE
protected static final int[] COMPLETION_LOCATIONS
protected static final int[] TOOLTIP_LOCATIONS
Constructor Detail |
public AbstractInsight()
Method Detail |
protected abstract InsightProvider createInsightProvider()
public abstract boolean isInsightTriggerChar(char typedChar)
typedChar
- the character that was typed
protected boolean isExactMatchSupported(InsightData data)
Note that there global property for whether exact match is enabled still overrides language implementations - if exact-match is disabled globally, this method will never get called.
data
- the current insight data instance
protected boolean isExactMatch(InsightData data)
If this indicates that there is a single exact match, and exact-match completion is on, the completion will be performed automatically on the *default* data item.
data
- the current insight data instance
protected int getInsightType()
public final BasicEditorPane getEditorPane()
public final BasicDocument getDocument()
public TextBuffer getTextBuffer()
public int getCaretPosition()
public void setAccessibleName(java.lang.String name)
public void characterTyped(BasicEditorPane editorPane, int offset, char typedChar)
characterTyped
in interface CharacterTypedListener
editorPane
- the editor pane where the character was typedoffset
- the offset where the character was insertedtypedChar
- the character that was typedpublic boolean invokeAction(java.lang.String actionKey)
invokeAction
in interface ActionHookInvoker
actionKey
- the published key for the action
protected boolean invokeCompletionTypeAction(int command)
command
- the internal command id, such as UP_COMMAND
protected boolean invokeTooltipTypeAction(int command)
command
- the internal command id, such as UP_COMMAND
public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed
in interface java.awt.event.ActionListener
event
- the action eventpublic void install(BasicEditorPane editor)
install
in interface EditorPlugin
editor
- the editor panepublic void deinstall(BasicEditorPane editor)
deinstall
in interface EditorPlugin
editor
- the editor panepublic final void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
event
- A PropertyChangeEvent object describing the event source
and the property that has changed.protected void propertyChangeImpl(java.beans.PropertyChangeEvent event)
event
- A PropertyChangeEvent object describing the event source
and the property that has changed.public void restartPopupTimer()
restartPopupTimer
in interface Insight
public void clearPopupTimer()
clearPopupTimer
in interface Insight
Insight.restartPopupTimer()
public boolean isInsightVisible()
isInsightVisible
in interface Insight
public java.awt.Rectangle getShowRectangle()
public void showInsight()
showInsight
in interface Insight
public void hideInsight()
hideInsight
in interface Insight
public void focusGained(java.awt.event.FocusEvent event)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent event)
focusLost
in interface java.awt.event.FocusListener
public void popupClosed(oracle.javatools.editor.popup.PopupWindow popupWindow, int how)
popupClosed
in interface oracle.javatools.editor.popup.PopupWindowListener
popupWindow
- the popup window that this notification is being
delivered forhow
- how the popup was closed, either CLOSED_NORMAL or
CLOSED_AUTO.public void editorFocusGained(oracle.javatools.editor.popup.PopupWindow popupWindow)
editorFocusGained
in interface oracle.javatools.editor.popup.PopupWindowListener
popupWindow
- the popup window that this notification is being
delivered forpublic void editorFocusLost(oracle.javatools.editor.popup.PopupWindow popupWindow, boolean isTemporary)
editorFocusLost
in interface oracle.javatools.editor.popup.PopupWindowListener
popupWindow
- the popup window that this notification is being
delivered forisTemporary
- whether the loss of focus is temporarypublic void caretUpdate(javax.swing.event.CaretEvent event)
caretUpdate
in interface javax.swing.event.CaretListener
event
- the caret eventprotected void updateInsight()
protected int[] getPreferredLocations()
protected static int lookupCommand(java.lang.String actionKey)
actionKey
- the name of the action
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.