package Templates.API_Support.Actions_API;

import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.NodeAction;

/** Action sensitive to the node selection that does something useful.
 * Consider using a cookie action instead if you can define what the
 * action is applicable to in terms of cookies.
 * @author __USER__
 */
public class __Sample_node__Action extends NodeAction {

    protected void performAction(Node[] nodes) {
        // do work based on the current node selection, e.g.:
        MyKindOfNode node = (MyKindOfNode)nodes[0];
        // ...
        // Note that casting to a type of node is often not the right
        // solution; try using a CookieAction, unless it is really the
        // node itself and not the underlying data that needs to be
        // considered. Also remember that some tests on nodes (casts
        // as well as reorderability of children etc.) will not work
        // when applied to filter nodes, whereas cookies will.
    }

    protected boolean enable(Node[] nodes) {
        // e.g.:
        return nodes.length == 1 && nodes[0] instanceof MyKindOfNode;
    }

    public String getName() {
        return NbBundle.getMessage(__NAME__.class, "LBL_Action");
    }

    protected String iconResource() {
        return "__PACKAGE_AND_NAME_SLASHES__Icon.gif";
    }

    public HelpCtx getHelpCtx() {
        return HelpCtx.DEFAULT_HELP;
        // If you will provide context help then use:
        // return new HelpCtx(__NAME__.class);
    }

    protected boolean asynchronous() {
        // performAction(Node[]) should run in event thread
        return false;
    }

    /** Perform extra initialization of this action's singleton.
     * PLEASE do not use constructors for this purpose!
    protected void initialize() {
	super.initialize();
	putProperty(Action.SHORT_DESCRIPTION, NbBundle.getMessage(__NAME__.class, "HINT_Action"));
    }
    */

}
