|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ehsbe.commons.gui.wizard.TaskControl
public class TaskControl
The controller which manages the tasks, which need to be executed.
A task which gets executed, may change/influence the order of execution as
well as vizualization by using one of the TaskControl.Callback
annotated methods.
Nested Class Summary | |
---|---|
static interface |
TaskControl.Callback
Marks methods for primary use by the task being controlled by this instance. |
Field Summary | |
---|---|
protected EventListenerList |
listenerList
listener list |
Constructor Summary | |
---|---|
TaskControl(Task root)
Create a new controller which manages the given task. |
Method Summary | |
---|---|
void |
addPageListener(TaskControlListener listener)
Register the given listener so that it gets notified, if the state of a page or its controller changes. |
void |
allUniqueIDs()
Check the complete task tree starting at this instance' origin for duplicated IDs. |
void |
dispose()
Cleanup all resources. |
void |
finished(Task task)
Callback for the task being executed in response to its Task.finish(HashMap, TaskControl, NavMode) to indicate, that it
is ready and switching to the next action indicated by the user is ok. |
void |
finishTask(HashMap<Task,HashMap<? extends Object,? extends Object>> settings,
NavMode nextMode)
Usually called by the wizard to indicate, that it intents to switch to another state. |
protected void |
fireStateChange(TaskControlEvent.Type what,
EnumSet<NavMode> mode)
Fires a TaskControlEvent . |
Task |
get()
Get the current step excecuted. |
int |
getDepth()
Get the path length for the current task in action. |
static int |
getDepth(Task task,
Task origin)
Get the path lenght to the given task wrt. to its origin. |
Locale |
getLocale()
Get the locale, which should be used by all tasks. |
Task |
getOrigin()
Get the origin of all tasks, controlled by this instance. |
JComponent |
getPage(HashMap<Task,HashMap<? extends Object,? extends Object>> settings,
EnumSet<NavMode> initalMode)
Create the wizard page, which needs to be shown for the current task in action. |
List<Task> |
getPath()
Get the path from the root task aka origin down to the current active task. |
List<Task> |
getPath(Task task)
Get the path from the root task aka origin down to the given task. |
boolean |
isBusy()
Get the busy state of the task currently being executed. |
Task |
next(boolean forward)
Get the next task, which needs to be executed. |
static Task |
next(Task task,
Task stop)
Get the next task which needs to be executed wrt. the given task. |
void |
prepare(HashMap<Task,HashMap<? extends Object,? extends Object>> settings)
Prepare the task, so that it has all information required to create the UI for information gathering and execution. |
Task |
previous(boolean backward)
Get the task, which has been executed before this task. |
void |
removePageListener(TaskControlListener listener)
Unregisters listener so that it will no longer receive PageEvents. |
void |
setBusy(Task task,
boolean busy)
Callback for the task being executed to indicate its busyness. |
void |
setLocale(Locale locale)
Set the locale, which should be used by all panels. |
void |
setNavMode(Task task,
EnumSet<NavMode> mode)
Calback for the currently executing task to inform about state changes, which caused a change in currently allowed navigation modes. |
void |
showHelp(HashMap<Task,HashMap<? extends Object,? extends Object>> settings,
JComponent parent)
Shows the help for the current task in action, if its Task.hasHelp()
returns true . |
void |
taskListChanged(Task task)
Facility to let the task in action notify interested parties, that the task list to whom it belongs to, was modified. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected EventListenerList listenerList
Constructor Detail |
---|
public TaskControl(Task root)
root
- the mother of all tasks, which need to be executed.Method Detail |
---|
public Task getOrigin()
NOTE: The returned task may still have a none-null
parent!
null
if no tasks are controlled, the root of all tasks
otherwise.public Task get()
null
if no step is beeing executed, the current step
otherwise.public Task next(boolean forward)
true
is the only way to advance to the next task. However, for
obvious reasons this should be done by the Wizard Controller, only!
forward
- if true
, advance the internal cursor to the
task being returned, if the current one is not null
.
null
if there are no more task to be executed, the next
task otherwise.public Task previous(boolean backward)
true
is the only way to go back to the previous task. However, for
obvious reasons this should be done by the Wizard Controller, only!
backward
- if true
, set the internal cursor to the task
being returned, execept if there is no previous task.
null
.public static Task next(Task task, Task stop)
task
- target for which to get the next taskstop
- an ascent, where to stop searching for the next task. If
null
the tree gets traversed up to the task, which has no
parent if necessary.
null
if all task are finished.public int getDepth()
0
if the current task in action has no further parent,
-1
if no task has been set, the path length from its origin
otherwise.public static int getDepth(Task task, Task origin)
Task.getParent()
calls required to reach
the origin OR root node of the given task.
task
- target for which to get the path lengthorigin
- an ascent, where to stop searching for the next task. If
null
the tree gets traversed up to the task, which has no
parent if necessary.
0
for the
mother of all tasks (aka root nodes), -1
if the given task is
null
.public void setBusy(Task task, boolean busy)
Controller will notify all listeners about this state change, which in turn may visualize the busyness in an appropriate way.
task
- the notifying taskbusy
- If true
, the task does some background work in a
none-EDT thread. If false
, the task has finished its work in the
none-EDT thread.public boolean isBusy()
true
if busy with none-EDT thread(s).public void finished(Task task)
Task.finish(HashMap, TaskControl, NavMode)
to indicate, that it
is ready and switching to the next action indicated by the user is ok.
task
- the notifying task.public void finishTask(HashMap<Task,HashMap<? extends Object,? extends Object>> settings, NavMode nextMode)
settings
- all settings and collected data so far.nextMode
- what to do nextpublic void setNavMode(Task task, EnumSet<NavMode> mode)
task
- the notifying taskmode
- new navigation mode, which should be propagated to all
interested parties.public void prepare(HashMap<Task,HashMap<? extends Object,? extends Object>> settings)
It returns immediately and sends an appropriate state notification, when the task has been prepared.
settings
- all settings and collected data so far.#fireStateChange(Type, EnumSet)
public void setLocale(Locale locale)
locale
- locale to use.public Locale getLocale()
null
if not set, the locale to use otherwise.public JComponent getPage(HashMap<Task,HashMap<? extends Object,? extends Object>> settings, EnumSet<NavMode> initalMode)
Should be called by the controlling wizard, only.
It makes sure, that component gets created within the EDT.
settings
- all settings and collected data so far.initalMode
- the set of navigation buttons, which should initially
be enabled. All others should be disabled.
null
if the current task needs no extra page aka user
interaction, the not yet visible wizard page otherwise.public void showHelp(HashMap<Task,HashMap<? extends Object,? extends Object>> settings, JComponent parent)
Task.hasHelp()
returns true
.
settings
- all settings and collected data so far.parent
- where to anchor the help UI.
IllegalArgumentException
- if the given parent is null
.public void taskListChanged(Task task)
Per contract, as soon as a task or one of its ascents gets assigned to a task controller, it has to notify the controller about structure changes. Furthermore it is only allowed to change the structure of not yet executed tasks.
task
- the notifying task.public void addPageListener(TaskControlListener listener)
listener
- listener to register. Ignored if null
.public void removePageListener(TaskControlListener listener)
listener
- listener to unregister. Ignored if null
.public List<Task> getPath()
getPath(Task)
public List<Task> getPath(Task task)
task
- where to start going up.
public final void allUniqueIDs() throws javax.ejb.DuplicateKeyException
javax.ejb.DuplicateKeyException
- for the first duplicated ID foundprotected void fireStateChange(TaskControlEvent.Type what, EnumSet<NavMode> mode)
TaskControlEvent
. Since it gets usually called in response
to a task callback, listener notification happens in a separate none-EDT
thread to prevent task blocking.
what
- the state change occured.mode
- navigation mode to proagate.public void dispose()
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |