public interface IExtension
Extensions are the way in which plugins extend Andami. Every class
implementing this interface is an extension (although this class
should not be directly implemented, extending the Extension
abstract class is the preferred way). During startup,
Andami creates an instance from each extension. Extensions are able
to add controls (tools, toolbars and menus)
to the user interface (GUI); when these controls
are clicked or modified, Andami will call the execute()
method from the associated extension. Extensions will also control
whether their associated controls are enabled or not, and whether
they are visible or hidden.
Besides implementing this interface, extensions are required to have an empty constructor, because it will be invoked to create the extension's instance.
On correctly installed plugins, an instance of every plugin's
extension will be created. Then, the initialize()
method will be executed for each extension.
Each time the active window is switched and every time the execute
method is called, Andami checks the isEnabled()
and
isVisible()
for each extension, to decide whether
they will be enabled and visible.
The execute()
method will be called from the GUI
thread, so it will block the GUI until it finishes. Therefore,
execution must be fast. If long process must be started from
the execute
method, a new thread must be created.
Normally, extensions should not directly implement this interface,
but they should extend the Extension
abstract class.
Extension
Modifier and Type | Method and Description |
---|---|
void |
execute(java.lang.String actionCommand)
This method is executed when the user clicks on any of the
controls associated with this extension (menus, tools, etc).
|
IExtensionStatus |
getStatus()
Gets the status of the extension, which may be queried to check
if the extension has some unsaved data or some associated background
tasks.
|
IExtensionStatus |
getStatus(IExtension extension) |
void |
initialize()
Extension's initialization code should be here.
|
boolean |
isEnabled()
This method is invoked by Andami to check whether the extension
(and its associated controls) is enabled or disabled.
|
boolean |
isVisible()
This method is invoked by Andami to check whether the extension
(and its associated controls) is visible or hidden.
|
void |
postInitialize()
Extension's post-initialization code should be here.
|
void |
terminate()
Extension's termination code should be here.
|
void initialize()
void postInitialize()
initialize()
has been called for ALL the extensions.void terminate()
void execute(java.lang.String actionCommand)
actionCommand
- An String specifying the action to
execute. This is useful when there are different
controls associated with the same extension.boolean isEnabled()
boolean isVisible()
IExtensionStatus getStatus()
IExtensionStatus
IExtensionStatus getStatus(IExtension extension)