|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.AbstractAction javax.swing.text.TextAction oracle.javatools.editor.BasicAction
The BasicAction
is an abstract class that all editor
actions should extend from. This provides some utility routines
that can be used by subclasses. The primary purpose of this class
is to track the last action executed within the editor. This is
needed as certain actions (particularly Emacs ones) depend on this
information.
Field Summary |
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
BasicAction(java.lang.String actionName)
Constructs this object with the appropriate action name. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent event)
The operation to perform when this action is triggered. |
abstract void |
actionPerformed(java.awt.event.ActionEvent event,
BasicEditorPane editor,
BasicDocument document)
The operation to perform when this action is triggered in a BasicEditorPane . |
static void |
beep(BasicEditorPane editor)
Utility routine which just emits a beep. |
static java.lang.String |
buildIndent(boolean useTabs,
int tabSize,
int numColumns)
Utility routine to build a String that can be used to indent a line by a certain size (not necessarily a single indent.) This is used for example if the document does use tab characters and the user indents the line - we may need to convert spaces to tabs to do the right thing. |
static int |
getFontHeight(BasicEditorPane editor)
Utility routine which fetches the height of the current font of the editor. |
BasicAction |
getLastAction(BasicEditorPane editor)
Utility routine which retrieves the last action executed (prior to the current one.) If there was no previous action, null is returned. |
static java.awt.Point |
getMagicCaretPosition(BasicEditorPane editor)
Reads the magic caret position from the editor's caret, or if there is none, the current horizontal position of the cursor. |
protected java.lang.String |
getName()
Utility routine to return the name of this action instance. |
static SmartIndentProvider |
getSmartIndentProvider(BasicEditorPane editor,
BasicDocument document)
Fetch the SmartIndentProvider for the current document. |
static java.lang.String |
getSpaces(int numSpaces)
Get a String with the specified number of space characters |
static java.lang.String |
getTab(boolean useTabs,
int tabSize)
Utility routine to fetch the tab or equivalent spaces to use. |
static java.lang.String |
getTabs(int numTabs)
Get a String with the specified number of tab characters |
static int |
getTabSizeProperty(BasicEditorPane editor)
Utility routine to fetch the tab stop size for the given editor. |
static boolean |
getUseAutoIndentProperty(BasicEditorPane editor)
Utility routine to fetch whether auto-indentation should be done for the given editor. |
static boolean |
getUseTabsProperty(BasicEditorPane editor)
Utility routine to fetch whether a tab character should be used for the given editor. |
static java.awt.Rectangle |
getVisibleRect(BasicEditorPane editor)
Utility routine to fetch the current visible rectangle of the editor. |
static boolean |
isEditable(BasicEditorPane editor,
boolean beepIfNotEditable)
Utility routine which checks if the editor is editable, and beeps if it isn't (if requested.) |
static void |
setMagicCaretPosition(BasicEditorPane editor,
java.awt.Point magicPosition)
Stores the magic caret position into the editor's caret. |
static void |
showMessage(BasicEditorPane editor,
java.lang.String message)
Utility routine to show a feedback message in the editor. |
static int |
skipLeadingIndent(TextBuffer textBuffer,
int lineStart,
int lineEnd)
Utility routine to find the offset of the first character after the leading indent (if any), or -1 for an empty line or line containing only whitespace. |
Methods inherited from class javax.swing.text.TextAction |
augmentList, getFocusedComponent, getTextComponent |
Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BasicAction(java.lang.String actionName)
Method Detail |
public abstract void actionPerformed(java.awt.event.ActionEvent event, BasicEditorPane editor, BasicDocument document)
BasicEditorPane
. Implementations should override
this method. Implementations are guaranteed that the document
read lock is held for the duration of this call.
event
- the action eventeditor
- the editor this action was invoked indocument
- the document associated with the editorpublic void actionPerformed(java.awt.event.ActionEvent event)
event
- the action eventprotected final java.lang.String getName()
public final BasicAction getLastAction(BasicEditorPane editor)
editor
- the editor to check the last action executed
public static java.awt.Point getMagicCaretPosition(BasicEditorPane editor) throws javax.swing.text.BadLocationException
editor
- the editor in which the vertical navigation occurred
javax.swing.text.BadLocationException
- this is generally unexpected, and
may signal something more seriouspublic static void setMagicCaretPosition(BasicEditorPane editor, java.awt.Point magicPosition)
editor
- the editor in which the vertical navigation occurredmagicPosition
- the new magic caret positionpublic static boolean isEditable(BasicEditorPane editor, boolean beepIfNotEditable)
editor
- the editor pane to check editabilitybeepIfNotEditable
- request a beep if the editor is not editablepublic static void beep(BasicEditorPane editor)
editor
- the editor panepublic static int getFontHeight(BasicEditorPane editor)
editor
- the editor pane
public static java.awt.Rectangle getVisibleRect(BasicEditorPane editor)
editor
- the editor pane
public static void showMessage(BasicEditorPane editor, java.lang.String message)
editor
- the editor to show the message formessage
- the message to displaypublic static int getTabSizeProperty(BasicEditorPane editor)
editor
- the editor pane
public static boolean getUseAutoIndentProperty(BasicEditorPane editor)
editor
- the editor pane
public static SmartIndentProvider getSmartIndentProvider(BasicEditorPane editor, BasicDocument document)
editor
- the editor panedocument
- the document being editedpublic static boolean getUseTabsProperty(BasicEditorPane editor)
editor
- the editor pane
public static java.lang.String getTab(boolean useTabs, int tabSize)
useTabs
- whether to use a tab charactertabSize
- the size of the tab stop (if using spaces)
public static java.lang.String buildIndent(boolean useTabs, int tabSize, int numColumns)
useTabs
- whether to use tab characterstabSize
- the size of a tab stopnumColumns
- the width of the indent in number of columnspublic static int skipLeadingIndent(TextBuffer textBuffer, int lineStart, int lineEnd)
textBuffer
- the text buffer to uselineStart
- the start of the linelineEnd
- the end of the linepublic static java.lang.String getSpaces(int numSpaces)
numSpaces
- the number of space characters
public static java.lang.String getTabs(int numTabs)
numTabs
- the number of tab characters
|
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.