|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.intellij.openapi.actionSystem.AnAction
public abstract class AnAction
Represents an entity that has a state, a presentation and can be performed.
For an action to be useful, you need to implement actionPerformed(com.intellij.openapi.actionSystem.AnActionEvent)
and optionally to override update(com.intellij.openapi.actionSystem.AnActionEvent). By overriding the
update(com.intellij.openapi.actionSystem.AnActionEvent) method you can dynamically change action's presentation
depending on the place (for more information on places see ActionPlaces.
The same action can have various presentations.
public class MyAction extends AnAction {
public MyAction() {
// ...
}
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
if (e.getPlace().equals(ActionPlaces.MAIN_MENU)) {
presentation.setText("My Menu item name");
} else if (e.getPlace().equals(ActionPlaces.MAIN_TOOLBAR)) {
presentation.setText("My Toolbar item name");
}
}
public void actionPerformed(AnActionEvent e) { ... }
}
AnActionEvent,
Presentation,
ActionPlaces| Field Summary | |
|---|---|
static AnAction[] |
EMPTY_ARRAY
|
static java.lang.String |
ourClientProperty
|
| Constructor Summary | |
|---|---|
AnAction()
Creates a new action with its text, description and icon set to null. |
|
AnAction(java.lang.String text)
Creates a new action with the specified text. |
|
AnAction(java.lang.String text,
java.lang.String description,
javax.swing.Icon icon)
Constructs a new action with the specified text, description and icon. |
|
| Method Summary | |
|---|---|
abstract void |
actionPerformed(AnActionEvent e)
Implement this method to provide your action handler. |
void |
copyFrom(AnAction sourceAction)
Copies template presentation and shortcuts set from sourceAction. |
static java.lang.String |
createTooltipText(java.lang.String s,
AnAction action)
|
boolean |
displayTextInToolbar()
Override with true returned if your action has to display its text along with the icon when placed in the toolbar |
ShortcutSet |
getShortcutSet()
Returns the shortcut set associated with this action. |
Presentation |
getTemplatePresentation()
Returns a template presentation that will be used as a template for created presentations. |
boolean |
isDefaultIcon()
Returns true if the action has an internal, not user-customized icon. |
boolean |
isEnabledInModalContext()
|
void |
registerCustomShortcutSet(ShortcutSet shortcutSet,
javax.swing.JComponent component)
Registers a set of shortcuts that will be processed when the specified component is the ancestor of focused component. |
void |
setDefaultIcon(boolean isDefaultIconSet)
Sets the flag indicating whether the action has an internal or a user-customized icon. |
protected void |
setEnabledInModalContext(boolean enabledInModalContext)
|
protected void |
setShortcutSet(ShortcutSet shortcutSet)
|
void |
unregisterCustomShortcutSet(javax.swing.JComponent component)
|
void |
update(AnActionEvent e)
Updates the state of the action. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final AnAction[] EMPTY_ARRAY
public static final java.lang.String ourClientProperty
| Constructor Detail |
|---|
public AnAction()
null.
public AnAction(java.lang.String text)
null.
text - Serves as a tooltip when the presention is a button and the name of the
menu item when the presentation is a menu item.
public AnAction(java.lang.String text,
java.lang.String description,
javax.swing.Icon icon)
text - Serves as a tooltip when the presention is a button and the name of the
menu item when the presentation is a menu itemdescription - Describes current action, this description will appear on
the status bar when presentation has focusicon - Action's icon| Method Detail |
|---|
public final ShortcutSet getShortcutSet()
public final void registerCustomShortcutSet(ShortcutSet shortcutSet,
javax.swing.JComponent component)
shortcutSet - the shortcuts for the action.component - the component for which the shortcuts will be active.public final void unregisterCustomShortcutSet(javax.swing.JComponent component)
public final void copyFrom(AnAction sourceAction)
sourceAction.
sourceAction - cannot be nullpublic final boolean isEnabledInModalContext()
protected final void setEnabledInModalContext(boolean enabledInModalContext)
public boolean displayTextInToolbar()
public void update(AnActionEvent e)
e - Carries information on the invocation place and data availablepublic final Presentation getTemplatePresentation()
public abstract void actionPerformed(AnActionEvent e)
e - Carries information on the invocation placeprotected void setShortcutSet(ShortcutSet shortcutSet)
public static java.lang.String createTooltipText(java.lang.String s,
AnAction action)
public void setDefaultIcon(boolean isDefaultIconSet)
isDefaultIconSet - true if the icon is internal, false if the icon is customized by the user.public boolean isDefaultIcon()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||