Class NodeActions

java.lang.Object
uk.theretiredprogrammer.actionssupport.NodeActions

public class NodeActions extends Object
NodeActions creates DynamicAsyncActions for a node, using a properties file to define these actions. In many cases the node will be the project node. NodeActions observes the node folder containing the properties file, ensuring the actions are updated whenever changes to the properties file occur. Additional files within the node folder can be observed, so that changes can trigger updates to any associated objects. It provides a method for assembling node actions, combining various sources of actions to create the Actions array required by a node definition. Structure of the Properties file. The properties file must include a property _COMMANDCOUNT_ which indicates the number of actions being defined in this file. Each action definition must have two or more property lines defined: n.label - defines the label displayed in the popup list (required), n.command - defines the CLI command to be executed when the action is selected (required), n.tabname - defines the tab name to be used in the Output Window. Optional, if not defined then the label property will be used. n.inputfrom - defines the source for the STDIN stream (optional). Value is one of: "file" a file is to be used as the STDIN stream (see inputfile), "ui" the Output window is to be the STDIN stream, providing keyboard input or "noinput" no input is provided for STDIN (default). n.inputfile - defines the input file for STDIN (required if inputfrom is set to "file"), n.needscancel = yes - adds a cancel button to the Output Window sidebar. This allows a user to cancel the Process created by the DynamicAsyncAction. Note that n must be an integer between 1 and _COMMANDCOUNT_.
  • Constructor Details

    • NodeActions

      public NodeActions(org.openide.filesystems.FileObject filefolder, String actionpropertiesfilename)
      Constructor Defines the actions property file and its location.
      Parameters:
      filefolder - the node folder (which contains the actions property file)
      actionpropertiesfilename - the filename (no extension) of the actions property file.
  • Method Details

    • registerFile

      public final void registerFile(String filename, String fileext, Consumer<NodeActions.FileChangeType> callback)
      Register an addition file to be observed. This file is expected to be present (when existing) in the same folder as the actions properties file.
      Parameters:
      filename - The filename of the file to be observed
      fileext - The file extension of the file to be observed
      callback - The method to be called when a change is observed on this file
    • setNodeBasicActions

      public void setNodeBasicActions(Action... actions)
      Define the set of basic actions which are to be included in the Node's actions popup.
      Parameters:
      actions - set of Actions.
    • setNodeActions

      public void setNodeActions(DynamicAsyncAction... actions)
      Define the set of actions which are particular to all projects of this Node's project type.
      Parameters:
      actions - set of Actions.
    • getAllNodeActions

      public Action[] getAllNodeActions()
      Get the array of enabled actions for this node. This includes the basicNodeActions, the NodeActions and any DynamicAsyncActions that were defined by the properties file. Separators are included to split the three groups.
      Returns:
      Array of actions;