Interface FormAction


  • public interface FormAction

    An interface describing an action.

    An action in terms of this framework is a piece of code that must be executed in reaction of a user action. Actions are associated with GUI controls like menu items or toolbar buttons.

    This definition of an action is compatible with similar concepts in typical GUI libraries like Swing or SWT (jface). The purpose of this interface is to provide an abstraction for specific action classes and/or interfaces used in different GUI libraries. There will be adapter implementations for the supported libraries.

    From this framework's point of view an action has the following characteristics:

    • It has a unique name by which it can be identified.
    • It can be disabled if the corresponding GUI controls should not be available for the user because of the actual state of the application.
    • It has a task, which is an arbitrary object. This task will be invoked when the action is executed. It is possible to set the task at runtime.
    • It has an execute() method for invoking the action.

    Note: Concrete implementations cannot be expected to be thread-safe; the manipulation of an action's properties is only safe in the UI thread of the platform in use.

    Version:
    $Id: FormAction.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Method Detail

      • getName

        String getName()
        Returns the name of this action.
        Returns:
        this action's name
      • isEnabled

        boolean isEnabled()
        Returns a flag whether this action is enabled at the moment.
        Returns:
        the enabled flag
      • setEnabled

        void setEnabled​(boolean f)
        Allows to set this action's enabled flag. If set to false, the user is not allowed to do something with the associated GUI controls.
        Parameters:
        f - the value of the enabled flag
      • isChecked

        boolean isChecked()
        Returns a flag whether this action is checked at the moment.
        Returns:
        the checked flag
      • setChecked

        void setChecked​(boolean f)
        Allows to set this action's checked flag. The checked flag is important for actions only if they are represented as checked menu items or toggle buttons in a toolbar. They then act as a kind of switch.
        Parameters:
        f - the value of the checked flag
      • execute

        void execute​(BuilderEvent event)
        Executes this action. The corresponding code will be invoked. The event that caused the action to be executed is passed as parameter. Note that depending on the information available at the time the action is invoked, some properties of the event may be undefined.
        Parameters:
        event - the event that caused the execution of this action
      • getTask

        Object getTask()
        Returns the task of this action.
        Returns:
        the task of this action
      • setTask

        void setTask​(Object task)
        Sets the task of this action. The task will be executed when this action is triggered. It can be changed at runtime to assign the action a different behavior (however this feature should be used with care). Which tasks an action supports, is up to a concrete implementation. Every FormAction implementation should support objects implementing one of these interfaces: Runnable, ActionTask.
        Parameters:
        task - the task for this action
        Throws:
        IllegalArgumentException - if the task is not supported by this action