Class AbstractCommandProcessor

    • Constructor Detail

      • AbstractCommandProcessor

        public AbstractCommandProcessor​(AbstractScriptingEngine owner)
        Initializes the processor.
        Parameters:
        owner - the owning scripting engine
    • Method Detail

      • initScriptlets

        protected void initScriptlets()
        Initializes all the available scriptlets.
      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Returns:
        a description suitable for displaying in the gui
      • setOwner

        public void setOwner​(AbstractScriptingEngine value)
        Sets the owner of this processor.
        Parameters:
        value - the owner
      • getDatabaseConnection

        public abstract AbstractDatabaseConnection getDatabaseConnection()
        Returns the currently used database connection object, can be null.
        Returns:
        the current object
      • setBasePanel

        public void setBasePanel​(BasePanel value)
        Sets the base panel.
        Parameters:
        value - the panel to use
      • getBasePanel

        public BasePanel getBasePanel()
        Returns the base panel.
        Returns:
        the base panel
      • getDataContainerPanel

        public DataContainerPanel getDataContainerPanel()
        Returns the DataContainer panel.
        Returns:
        the panel or null
      • getRequiredFlowClass

        protected Class getRequiredFlowClass()
        Returns the class that is required in the flow.
        Returns:
        the required class
      • setUndo

        public void setUndo​(Undo value)
        Sets the undo manager to use, can be null if no undo-support wanted.
        Specified by:
        setUndo in interface UndoHandler
        Parameters:
        value - the undo manager to use
      • getUndo

        public Undo getUndo()
        Returns the current undo manager, can be null.
        Specified by:
        getUndo in interface UndoHandler
        Returns:
        the undo manager, if any
      • isUndoSupported

        public boolean isUndoSupported()
        Returns whether an Undo manager is currently available.
        Specified by:
        isUndoSupported in interface UndoHandler
        Returns:
        true if an undo manager is set
      • getStatusMessageHandler

        public StatusMessageHandler getStatusMessageHandler()
        Returns the status message handler, if available.
        Returns:
        the handler
      • getUndoObject

        protected abstract Object getUndoObject()
        Returns the object that is to be used for the undo point.
        Returns:
        the object to store as undo point
        See Also:
        addUndoPoint(String, String)
      • addUndoPoint

        protected void addUndoPoint​(String statusMsg,
                                    String undoComment)
        Adds an undo point, if possible.
        Parameters:
        statusMsg - the status message to display while adding the undo point
        undoComment - the comment for the undo point
      • showStatus

        protected void showStatus​(String msg)
        Displays the status, if the owner is a StatusMessageHandler, otherwise it just prints the status on the commandline.
        Parameters:
        msg - the message to display
        See Also:
        StatusMessageHandler
      • findScriptlet

        protected AbstractScriptlet findScriptlet​(String action)
        Returns the scriptlet associated with the action.
        Parameters:
        action - the action to get the scriptlet for
        Returns:
        the scriptlet or null if none found
      • createRequirementError

        protected String createRequirementError​(Class requirement)
        Creates a default error message for the given requirement class.
        Parameters:
        requirement - the class to create the error message for
        Returns:
        the error message
      • checkRequirement

        protected String checkRequirement​(Class requirement)
        Checks the following requirement.

        Needs to be extended in derived classes.
        Parameters:
        requirement - the requirement class that needs to be present
        Returns:
        "" if met, error message if not met, null if not processed
      • checkRequirements

        protected String checkRequirements​(AbstractScriptlet scriplet)
        Checks whether all the requirements for the scriptlet have been met.

        Needs to be extended in derived classes.
        Parameters:
        scriplet - the scriplet to check
        Returns:
        "" if all requirements met, error message if not met, null if at least one requirement not processed
      • setupScriptlet

        protected void setupScriptlet​(AbstractScriptlet scriptlet)
        Performs further setups of the scriptlet.

        Default implementation does nothing.
        Parameters:
        scriptlet - the scriptlet to work on
      • process

        public String process​(ScriptingCommand command)
                       throws Exception
        processes the given command.
        Parameters:
        command - the command to execute
        Returns:
        null if no error generated, otherwise the error output
        Throws:
        Exception - if something goes wrong
      • stopExecution

        public void stopExecution()
        Stops the execution.
        Specified by:
        stopExecution in interface Stoppable