Class TaskAction
- java.lang.Object
-
- ca.cgjennings.apps.arkham.project.TaskAction
-
- All Implemented Interfaces:
IconProvider
- Direct Known Subclasses:
AddLocale
,AddTask
,Browse
,ChangeIcon
,Clean
,CompareFiles
,Compile
,CompileAll
,ConvertSpellingDictionary.Converter
,Copy
,Cut
,DrawRegion
,Export
,MakeBundle
,MakeDeck
,New.NewAction
,New.NewGameComponent
,Open
,Packaging
,Paste
,PluginImportAction
,PublishBundle
,RasterizeImage
,Rename
,Run
,ScriptedFactoryBuild
,ShowFolder
,SpecializedAction
,TaskActionTree
,TestBundle
,Translate
,View
,VirtualDeck
public abstract class TaskAction extends java.lang.Object implements IconProvider
An action that can be performed on a member of project.- Author:
- Chris Jennings
-
-
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)
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.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, ornull
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()
-
-
-
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, ornull
if the action should not be associated with an icon.- Specified by:
getIcon
in interfaceIconProvider
- 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 classjava.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
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.- 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
-
appliesTo
public abstract 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. 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.- 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
-
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 ofmember
,task
, orproject
that is non-null
.- Parameters:
project
- the project passed in to the actiontask
- the task passed in to the actionmember
- 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)
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.- 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
-
-
-