Class TaskActionTree
- java.lang.Object
-
- ca.cgjennings.apps.arkham.project.TaskAction
-
- ca.cgjennings.apps.arkham.project.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 abstractTaskActionfor actions that contain one or more child actions. The action is applicable if any of the children are applicable. ATaskActionTreeis never performed, but it's children can be. Adding anullvalue 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 Summary
Constructors Constructor Description TaskActionTree()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, TaskAction ta)voidadd(TaskAction ta)booleanappliesTo(Project project, Task task, Member member)Returnstrueif this action can be performed on the specified member of a project, project or a task.booleanappliesToSelection(Member[] members)Returnstrueif this action is applicable to any of the specifiedMembers.TaskActionfindActionByName(java.lang.String name)TaskActionget(int index)intgetSectionIndex(int section, boolean placeAtEndOfSection)Returns the index at which toadd(int, ca.cgjennings.apps.arkham.project.TaskAction)an action in order to place it at the start or end of the numbered section.intindexOf(TaskAction ta)protected booleanisAppliesToShortCircuited()If this method returnstrue, then the evaluation ofappliesToSelection(ca.cgjennings.apps.arkham.project.Member[])andappliesTo(ca.cgjennings.apps.arkham.project.Project, ca.cgjennings.apps.arkham.project.Task, ca.cgjennings.apps.arkham.project.Member)will assume that every child action performs the same test.java.util.Iterator<TaskAction>iterator()booleanperform(Project project, Task task, Member member)Perform this action on a member of a project, a project or a task.TaskActionremove(int index)TaskActionremove(TaskAction ta)intsize()-
Methods inherited from class ca.cgjennings.apps.arkham.project.TaskAction
applyToChildren, getActionName, getDescription, getIcon, getLabel, performOnSelection, resolveTarget, toString
-
-
-
-
Method Detail
-
perform
public boolean perform(Project project, Task task, Member member)
Description copied from class:TaskActionPerform this action on a member of a project, a project or a task. If the project itself is the target,taskandmemberwill benull. If a task is the target, thenmemberwill be null. If an error occurs while executing the task, then it is the action's responsibility to inform the user. This method can returnfalseto indicate that if the action is being applied to multiple members, it should stop immediately rather than continue to the next member.- Specified by:
performin classTaskAction- Parameters:
project- the project that is being acted upontask- the task within the project that is being acted upon;nullif acting on a projectmember- the specific member within the task to act upon;nullif this is a project or task
-
appliesToSelection
public boolean appliesToSelection(Member[] members)
Description copied from class:TaskActionReturnstrueif this action is applicable to any of the specifiedMembers. 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 ofmembersand returningfalseif it is not 1, and otherwise calling the super implementation.- Overrides:
appliesToSelectionin classTaskAction- Parameters:
members- a list of zero or more members- Returns:
trueis the action can be applied to at least one member
-
appliesTo
public boolean appliesTo(Project project, Task task, Member member)
Description copied from class:TaskActionReturnstrueif this action can be performed on the specified member of a project, project or a task. If the project itself is the target,taskandmemberwill benull. If a task is the target, thenmemberwill be null. If an error occurs while executing the task, then it is the action's responsibility to inform the user. This method can returnfalseto indicate that if the action is being applied to multiple members, it should stop immediately rather than continue to the next member.- Specified by:
appliesToin classTaskAction- Parameters:
project- the project that is being acted upontask- the task within the project that is being acted upon;nullif acting on a projectmember- the specific member within the task to act upon;nullif this is a project or task
-
add
public final void add(TaskAction ta)
-
add
public void add(int index, TaskAction ta)
-
getSectionIndex
public int getSectionIndex(int section, boolean placeAtEndOfSection)Returns the index at which toadd(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 anullaction (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 numberplaceAtEndOfSection- iftrue, 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)
-
remove
public TaskAction remove(TaskAction ta)
-
get
public TaskAction get(int index)
-
size
public int size()
-
indexOf
public int indexOf(TaskAction ta)
-
findActionByName
public TaskAction findActionByName(java.lang.String name)
-
iterator
public java.util.Iterator<TaskAction> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<TaskAction>
-
isAppliesToShortCircuited
protected boolean isAppliesToShortCircuited()
If this method returnstrue, then the evaluation ofappliesToSelection(ca.cgjennings.apps.arkham.project.Member[])andappliesTo(ca.cgjennings.apps.arkham.project.Project, ca.cgjennings.apps.arkham.project.Task, ca.cgjennings.apps.arkham.project.Member)will assume that every child action performs the same test. Therefore, if the first child action tested does not apply, none of them can apply and the search ends immediately. Otherwise, every child action will be tested to see if it applies until at least one is found that does or they all fail.The base class returns
false.- Returns:
trueif all children apply to exactly same set of members
-
-