Package ca.cgjennings.apps.arkham
Interface ContextBar.Button
-
- All Superinterfaces:
java.awt.event.ActionListener
,java.util.EventListener
,IconProvider
- All Known Implementing Classes:
ContextBar.AbstractButton
,ContextBar.CommandButton
- Enclosing class:
- ContextBar
public static interface ContextBar.Button extends java.awt.event.ActionListener, IconProvider
This class represents a buttons that can appear on the context bar. Plug-ins can register new kinds of buttons, and then the user can add these buttons to the context bar in the preferences dialog.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description javax.swing.Icon
getIcon()
Returns the button's icon.java.lang.String
getID()
Returns a unique ID for this button, such as "BOLD".java.lang.String
getName()
Returns the button's name, ornull
.boolean
isEnabledInCurrentContext(ContextBar.Context context)
Returnstrue
if the button should be enabled in the current context.boolean
isVisibleInCurrentContext(ContextBar.Context context)
Returnstrue
if the button should be visible in the current context.void
onAttach(ContextBar.Context context)
This method is called to notify the button when the tool bar is about to be attached to a new target component (the component that it floats over and that its commands normally apply to).void
onDetach(ContextBar.Context context)
This method is called to notify the button when the tool bar is about to be detached from the current target component (the component that it floats over and that its commands normally apply to).
-
-
-
Method Detail
-
getID
java.lang.String getID()
Returns a unique ID for this button, such as "BOLD". Only letters, digits, underscores, and currency symbols may appear in an ID.- Returns:
- a short ID that will identify this button in the application preferences
-
getName
java.lang.String getName()
Returns the button's name, ornull
.- Returns:
- a localized description of the button's function
-
getIcon
javax.swing.Icon getIcon()
Returns the button's icon.- Specified by:
getIcon
in interfaceIconProvider
- Returns:
- a small transparent icon used to represent the button
-
onAttach
void onAttach(ContextBar.Context context)
This method is called to notify the button when the tool bar is about to be attached to a new target component (the component that it floats over and that its commands normally apply to).- Parameters:
context
- information about the current context
-
onDetach
void onDetach(ContextBar.Context context)
This method is called to notify the button when the tool bar is about to be detached from the current target component (the component that it floats over and that its commands normally apply to).- Parameters:
context
- information about the current context
-
isEnabledInCurrentContext
boolean isEnabledInCurrentContext(ContextBar.Context context)
Returnstrue
if the button should be enabled in the current context.- Parameters:
context
- information about the current context- Returns:
true
if the button should be enabled (ignored if not visible)
-
isVisibleInCurrentContext
boolean isVisibleInCurrentContext(ContextBar.Context context)
Returnstrue
if the button should be visible in the current context. A button should be invisible if it can never be enabled in the current context, and disabled if it is not currently usable due to a temporary restriction. For example, any text field can be copied from if there is an active selection, so a copy button should always be visible but should be enabled only if there is a selection. On the other hand, a command that only works for script code should be visible only when editing a script.- Parameters:
context
- information about the current context- Returns:
true
if the button should be visible
-
-