Creates new action which is always enabled. Rather than using this method
directly, use
ActionRegistration annotation:
ActionRegistration(displayName="#key")
ActionID(id="your.pkg.action.id", category="Tools")
public final class Always implements
ActionListener {
public Always() {
}
public void actionPerformed(
ActionEvent e) {
// your code
}
}
This method can also be used from
XML Layer
directly by following XML definition:
<file name="your-pkg-action-id.instance">
<attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
<attr name="delegate" methodvalue="your.pkg.YourAction.factoryMethod"/>
<attr name="displayName" bundlevalue="your.pkg.Bundle#key"/>
<attr name="iconBase" stringvalue="your/pkg/YourImage.png"/>
<!-- if desired: <attr name="noIconInMenu" boolvalue="true"/> -->
<!-- if desired: <attr name="asynchronous" boolvalue="true"/> -->
</file>
In case the "delegate" is not just
ActionListener, but also
Action, the returned action acts as a lazy proxy - it defers initialization
of the action itself, but as soon as it is created, it delegates all queries
to it. This way one can create an action that looks statically enabled, and as soon
as user really uses it, it becomes active - it can change its name, it can
change its enabled state, etc.