public abstract class AbstractClickPlugin extends java.lang.Object implements EditorPlugin, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.event.CaretListener
AbstractClickPlugin
is an abstract starting point
for an EditorPlugin implementation which provides support for
performing some action when the user clicks over certain text in
an editor, usually with a modifier key held down. It also supports
displaying some hint text in the status bar, when the user hovers
(moves the mouse) over that text with modifier key held down, and
underlines it for additional feedback.Modifier and Type | Field and Description |
---|---|
protected static int |
ACTION_NONE
The constant for no action, or unknown action.
|
protected static int |
ALL_MODIFIER_MASK
Mask for all modifier keys.
|
protected static int |
DEFAULT_DELAY_TIME
The default delay time for updates (in ms).
|
Constructor and Description |
---|
AbstractClickPlugin() |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
Invoked when an action occurs.
|
void |
caretUpdate(javax.swing.event.CaretEvent e) |
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.
|
protected abstract int |
getActionTypeFor(java.awt.event.MouseEvent event)
Fetch the subclass-specific action type that corresponds to the
given event (which may be a mouse moved, or mouse clicked event).
|
protected BasicDocument |
getDocument()
Fetch the
BasicDocument instance that is being edited |
protected BasicEditorPane |
getEditorPane()
Fetch the
BasicEditorPane associated with this plugin,
or null if this plugin is not currently installed. |
protected abstract HighlightStyle |
getHighlightStyleFor(int actionType)
Fetch the
HighlightStyle which should be used for
highlighting the a given region for the specified action type. |
protected abstract java.lang.String |
getHintTextFor(int actionType)
Fetch the hint text that should be displayed in the editor status
bar for the given action type.
|
protected abstract NumberRange |
getRegionFor(int offset,
int actionType)
Fetch the
NumberRange instance for the underlinable
region that includes the given offset. |
protected TextBuffer |
getTextBuffer()
Private utility routine to fetch the text buffer of the document
being edited.
|
protected int |
getUpdateDelayTime()
Fetch the delay time in which underlines should be updated.
|
protected abstract void |
handleClickAction(java.awt.Point clickPoint,
int actionType)
Perform the subclass-specific click action at the given click point,
and action type.
|
protected boolean |
hasModifierEx(java.awt.event.MouseEvent event,
int modifierEx)
Check whether a given modifier is down for the mouse event, such
as
InputEvent.CTRL_DOWN_MASK . |
void |
install(BasicEditorPane editor)
Called when this plugin is being installed into the BasicEditorPane.
|
protected boolean |
isActionTrigger(java.awt.event.MouseEvent event)
Fetch whether the given event represents an action trigger.
|
void |
mouseClicked(java.awt.event.MouseEvent event)
Invoked when the mouse button has been clicked (pressed
and released) on a component.
|
void |
mouseDragged(java.awt.event.MouseEvent event) |
void |
mouseEntered(java.awt.event.MouseEvent event) |
void |
mouseExited(java.awt.event.MouseEvent event)
Invoked when the mouse exits a component.
|
void |
mouseMoved(java.awt.event.MouseEvent event)
Invoked when the mouse cursor has been moved onto a component
but no buttons have been pushed.
|
void |
mousePressed(java.awt.event.MouseEvent event) |
void |
mouseReleased(java.awt.event.MouseEvent event) |
void |
propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed.
|
protected void |
updateHighlight(java.awt.Point point,
int actionType)
Update the underline and feedback text that is displayed.
|
protected void |
updateHint(int actionType)
Update the current hint text that is displayed in the editor.
|
protected static final int ACTION_NONE
protected static final int DEFAULT_DELAY_TIME
protected static final int ALL_MODIFIER_MASK
public void install(BasicEditorPane editor)
install
in interface EditorPlugin
editor
- the editor panepublic void deinstall(BasicEditorPane editor)
deinstall
in interface EditorPlugin
editor
- the editor panepublic 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.public void mouseClicked(java.awt.event.MouseEvent event)
mouseClicked
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent event)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent event)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent event)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent event)
mouseExited
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent event)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent event)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void caretUpdate(javax.swing.event.CaretEvent e)
caretUpdate
in interface javax.swing.event.CaretListener
public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed
in interface java.awt.event.ActionListener
protected abstract int getActionTypeFor(java.awt.event.MouseEvent event)
event
- the mouse event that occurredprotected abstract void handleClickAction(java.awt.Point clickPoint, int actionType)
getActionTypeFor()
for the mouse click event.clickPoint
- the click point where the mouse click event occurredactionType
- the action type the modifiers on the event mapped toprotected abstract HighlightStyle getHighlightStyleFor(int actionType)
HighlightStyle
which should be used for
highlighting the a given region for the specified action type.actionType
- the action type the modifiers map toprotected abstract java.lang.String getHintTextFor(int actionType)
actionType
- the action type the modifiers map toprotected abstract NumberRange getRegionFor(int offset, int actionType)
NumberRange
instance for the underlinable
region that includes the given offset.offset
- the offset the mouse hovered overactionType
- the action type based on the modifiers of the eventprotected int getUpdateDelayTime()
protected boolean isActionTrigger(java.awt.event.MouseEvent event)
event
- the mouse event that occurredprotected boolean hasModifierEx(java.awt.event.MouseEvent event, int modifierEx)
InputEvent.CTRL_DOWN_MASK
.event
- the mouse event that occurredmodifierEx
- the modifier (JDK 1.4) to check forprotected TextBuffer getTextBuffer()
protected BasicEditorPane getEditorPane()
BasicEditorPane
associated with this plugin,
or null if this plugin is not currently installed.protected BasicDocument getDocument()
BasicDocument
instance that is being editedprotected void updateHighlight(java.awt.Point point, int actionType)
point
- the point to underlineactionType
- the subclass-specific action typeprotected void updateHint(int actionType)
actionType
- the subclass-specific action type