Class TaskActionTree

  • All Implemented Interfaces:
    IconProvider, java.lang.Iterable<TaskAction>
    Direct Known Subclasses:
    ConvertImage, ConvertSpellingDictionary, MergeSettings, MergeStrings, New

    public abstract class TaskActionTree
    extends TaskAction
    implements java.lang.Iterable<TaskAction>
    An abstract TaskAction for actions that contain one or more child actions. The action is applicable if any of the children are applicable. A TaskActionTree is never performed, but it's children can be. Adding a null value as a child indicates logical separation between two groups of children. This may be manifested, for example, as a separator in a command menu.
    Author:
    Chris Jennings
    • Constructor Detail

      • TaskActionTree

        public TaskActionTree()
    • Method Detail

      • perform

        public boolean perform​(Project project,
                               Task task,
                               Member member)
        Description copied from class: TaskAction
        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.
        Specified by:
        perform in class TaskAction
        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
      • appliesToSelection

        public boolean appliesToSelection​(Member[] members)
        Description copied from class: TaskAction
        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.
        Overrides:
        appliesToSelection in class TaskAction
        Parameters:
        members - a list of zero or more members
        Returns:
        true is the action can be applied to at least one member
      • appliesTo

        public boolean appliesTo​(Project project,
                                 Task task,
                                 Member member)
        Description copied from class: TaskAction
        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.
        Specified by:
        appliesTo in class TaskAction
        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
      • add

        public void add​(int index,
                        TaskAction ta)
      • getSectionIndex

        public int getSectionIndex​(int section,
                                   boolean placeAtEndOfSection)
        Returns the index at which to add(int, ca.cgjennings.apps.arkham.project.TaskAction) an action in order to place it at the start or end of the numbered section. A new section begins whenever a null action (separator) appears in the list of actions; the first section (before any separator) is numbered 0. If the specified section number is higher than the actual number of sections, the returned index will append actions to the end of the list.
        Parameters:
        section - the section number
        placeAtEndOfSection - if true, the index will locate the action at the end of the section rather than the start
        Returns:
        the index at which to add an action to place it at the specified position in the specified section
        Throws:
        java.lang.IllegalArgumentException - if the section number is negative
      • remove

        public TaskAction remove​(int index)
      • size

        public int size()
      • findActionByName

        public TaskAction findActionByName​(java.lang.String name)
      • iterator

        public java.util.Iterator<TaskAction> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<TaskAction>