Class TaskAction

    • Constructor Summary

      Constructors 
      Constructor Description
      TaskAction()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract boolean appliesTo​(Project project, Task task, Member member)
      Returns true if this action can be performed on the specified member of a project, project or a task.
      boolean appliesToSelection​(Member[] members)
      Returns true if this action is applicable to any of the specified Members.
      void applyToChildren​(Project project, Task task, Member parent)
      Recursively apply a task action to all of the children of a member that that action applies to.
      java.lang.String getActionName()
      Returns a unique internal name for this action.
      java.lang.String getDescription()
      Returns a longer description of the action, suitable for use as a tool tip.
      javax.swing.Icon getIcon()
      Returns an icon for this action, or null if the action should not be associated with an icon.
      abstract java.lang.String getLabel()
      Returns the human-readable name of this action.
      abstract boolean perform​(Project project, Task task, Member member)
      Perform this action on a member of a project, a project or a task.
      boolean performOnSelection​(Member[] members)
      Applies this action to all of the specified project members.
      protected Member resolveTarget​(Project project, Task task, Member member)
      Returns the member being targeted by action regardless of whether it is a project, task, or task member.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TaskAction

        public TaskAction()
    • Method Detail

      • getLabel

        public abstract java.lang.String getLabel()
        Returns the human-readable name of this action.
        Returns:
        the name used to create menu items for this action, localized if possible
      • getActionName

        public java.lang.String getActionName()
        Returns a unique internal name for this action. Actions can be looked up by this name. The default implementation returns the class name, converted to lowercase.
        Returns:
        the internal name of this action
      • getIcon

        public javax.swing.Icon getIcon()
        Returns an icon for this action, or null if the action should not be associated with an icon.
        Specified by:
        getIcon in interface IconProvider
        Returns:
        an icon that represents the action
      • getDescription

        public java.lang.String getDescription()
        Returns a longer description of the action, suitable for use as a tool tip.
        Returns:
        a long description of the action, or null
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • perform

        public abstract boolean perform​(Project project,
                                        Task task,
                                        Member member)
        Perform this action on a member of a project, a project or a task. If the project itself is the target, task and member will be null. If a task is the target, then member will be null. If an error occurs while executing the task, then it is the action's responsibility to inform the user. This method can return false to indicate that if the action is being applied to multiple members, it should stop immediately rather than continue to the next member.
        Parameters:
        project - the project that is being acted upon
        task - the task within the project that is being acted upon; null if acting on a project
        member - the specific member within the task to act upon; null if this is a project or task
      • appliesTo

        public abstract boolean appliesTo​(Project project,
                                          Task task,
                                          Member member)
        Returns true if this action can be performed on the specified member of a project, project or a task. If the project itself is the target, task and member will be null. If a task is the target, then member will be null. If an error occurs while executing the task, then it is the action's responsibility to inform the user. This method can return false to indicate that if the action is being applied to multiple members, it should stop immediately rather than continue to the next member.
        Parameters:
        project - the project that is being acted upon
        task - the task within the project that is being acted upon; null if acting on a project
        member - the specific member within the task to act upon; null if this is a project or task
      • resolveTarget

        protected final Member resolveTarget​(Project project,
                                             Task task,
                                             Member member)
        Returns the member being targeted by action regardless of whether it is a project, task, or task member. If your action can be applied to any type of member, you can call this to simplify your handling code. It returns the first of member, task, or project that is non-null.
        Parameters:
        project - the project passed in to the action
        task - the task passed in to the action
        member - the member passed in to the action
        Returns:
        the member that the parameters refer to, regardless of whether it is a project, task, or task member
      • appliesToSelection

        public boolean appliesToSelection​(Member[] members)
        Returns true if this action is applicable to any of the specified Members. By overriding this, you can modify whether an action is listed depending on which other members are selected. For example, you could create a command that can only be applied to a singleton selection by checking the length of members and returning false if it is not 1, and otherwise calling the super implementation.
        Parameters:
        members - a list of zero or more members
        Returns:
        true is the action can be applied to at least one member
      • performOnSelection

        public boolean performOnSelection​(Member[] members)
        Applies this action to all of the specified project members. By overriding this, you can modify what happens when the user tries to initiate this action. For example, you could add a verification dialog and call the super implementation only if the user verifies the action.
        Parameters:
        members -
        Returns:
        true if and only if the action is successfully applied to all of the members
      • applyToChildren

        public void applyToChildren​(Project project,
                                    Task task,
                                    Member parent)
        Recursively apply a task action to all of the children of a member that that action applies to. The application is depth first---an action that would lead to deleting a tree can succeed because the children would be deleted first.
        Parameters:
        project -
        task -
        parent -