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 abstractTaskAction
for actions that contain one or more child actions. The action is applicable if any of the children are applicable. ATaskActionTree
is never performed, but it's children can be. Adding anull
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 Summary
Constructors Constructor Description TaskActionTree()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, TaskAction ta)
void
add(TaskAction ta)
boolean
appliesTo(Project project, Task task, Member member)
Returnstrue
if this action can be performed on the specified member of a project, project or a task.boolean
appliesToSelection(Member[] members)
Returnstrue
if this action is applicable to any of the specifiedMember
s.TaskAction
findActionByName(java.lang.String name)
TaskAction
get(int index)
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.int
indexOf(TaskAction ta)
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.java.util.Iterator<TaskAction>
iterator()
boolean
perform(Project project, Task task, Member member)
Perform this action on a member of a project, a project or a task.TaskAction
remove(int index)
TaskAction
remove(TaskAction ta)
int
size()
-
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:TaskAction
Perform this action on a member of a project, a project or a task. If the project itself is the target,task
andmember
will benull
. If a task is the target, thenmember
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 returnfalse
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 classTaskAction
- Parameters:
project
- the project that is being acted upontask
- the task within the project that is being acted upon;null
if acting on a projectmember
- 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
Returnstrue
if this action is applicable to any of the specifiedMember
s. 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 ofmembers
and returningfalse
if it is not 1, and otherwise calling the super implementation.- Overrides:
appliesToSelection
in classTaskAction
- 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
Returnstrue
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
andmember
will benull
. If a task is the target, thenmember
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 returnfalse
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 classTaskAction
- Parameters:
project
- the project that is being acted upontask
- the task within the project that is being acted upon;null
if acting on a projectmember
- the specific member within the task to act upon;null
if 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 anull
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 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:
iterator
in 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:
true
if all children apply to exactly same set of members
-
-