|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.keridwen.core.messaging.AbstractCommand<ResultType,MessageType>
ResultType
- the return type of the commandMessageType
- the message type to be handled by the commandpublic abstract class AbstractCommand<ResultType,MessageType>
This class provides default implementations for methods common to most Command
s.
Constructor Summary | |
---|---|
AbstractCommand(String aLabel,
String aDescription,
boolean isInterruptible,
boolean isUndoable,
boolean isPausable,
boolean isProgressDetermined)
Builds a command with the given label, description and control properties. |
|
AbstractCommand(String aLabel,
String aDescription,
boolean isInterruptible,
boolean isUndoable,
boolean isPausable,
boolean isProgressDetermined,
CommandLogLevel aLogLevel)
Builds a command with the given label, description and control properties. |
Method Summary | |
---|---|
void |
addControllableListener(ControllableListener listener)
|
void |
addProgressableListener(ProgressableListener listener)
|
boolean |
checkPreConditions()
Check that the Command preconditions are fulfilled. |
void |
clearControllableListener()
|
void |
clearProgressableListener()
|
ResultType |
execute(MessageType message)
Executes the Command 's logic with a given message. |
DataModel |
getApplicationModel()
Gets the data model of the application. |
DataModel |
getBundleModel()
Gets the data model of the bundle. |
String |
getDescription()
Returns the localized Command description. |
String |
getLabel()
Returns the localized Command name. |
CommandLogLevel |
getLogLevel()
Gets the verbosity level at which this command should be logged. |
int |
getProgress()
|
ControllableState |
getState()
|
void |
interrupt()
|
boolean |
isDetermined()
|
boolean |
isInterrupted()
|
boolean |
isInterruptible()
|
boolean |
isPausable()
|
boolean |
isUndoable()
Checks whether the Command can be undone by the user. |
protected void |
notifyProgressChanged(int newProgress)
Method called when the command progress has changed. |
protected void |
notifyStatusChanged(ControllableState newStatus)
Method called when the command status has changed. |
abstract void |
pause()
|
void |
removeControllableListener(ControllableListener listener)
|
void |
removeProgressableListener(ProgressableListener listener)
|
abstract void |
resume()
|
abstract ResultType |
run(MessageType message)
This method is the concrete business implementation of what the command should do. |
protected void |
setCommandStatus(ControllableState newStatus)
Sets the command status to the provided value and notifies the listeners. |
void |
setModels(DataModel anApplicationModel,
DataModel aBundleModel)
Initializes the models of that the command can access. |
protected void |
setProgress(int newProgress)
Updates the value of the command progress and warns the listeners. |
abstract void |
undo()
Undo the Command actions. |
abstract boolean |
validatePostConditions()
Sets all postconditions to true if they have been validated by the Command . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractCommand(String aLabel, String aDescription, boolean isInterruptible, boolean isUndoable, boolean isPausable, boolean isProgressDetermined)
aLabel
- the localized name of the commandaDescription
- the localized description of the command.isInterruptible
- boolean indicating whether the command can be interrupted.isUndoable
- boolean indicating whether the command can be undone.public AbstractCommand(String aLabel, String aDescription, boolean isInterruptible, boolean isUndoable, boolean isPausable, boolean isProgressDetermined, CommandLogLevel aLogLevel)
aLabel
- aDescription
- isInterruptible
- isUndoable
- isPausable
- isProgressDetermined
- aLogLevel
- Method Detail |
---|
public abstract void undo()
Command
Command
actions.
undo
in interface Command<ResultType,MessageType>
public abstract void pause()
pause
in interface Controllable
public abstract void resume()
resume
in interface Controllable
public abstract boolean validatePostConditions()
Command
Command
.
validatePostConditions
in interface Command<ResultType,MessageType>
public abstract ResultType run(MessageType message) throws CommandException
message
- the input message of the command
CommandException
- any exception raised during executionprotected final void notifyStatusChanged(ControllableState newStatus)
newStatus
- the new command statusprotected final void notifyProgressChanged(int newProgress)
newProgress
- the new command progressprotected final void setProgress(int newProgress)
newProgress
- the new progress valuepublic final ResultType execute(MessageType message) throws CommandException
Command
Command
's logic with a given message.
execute
in interface Command<ResultType,MessageType>
message
- the message to use for the execution.
CommandException
- exceptions raised during the execution of the command.public void interrupt()
interrupt
in interface Controllable
public final boolean isInterrupted()
isInterrupted
in interface Controllable
public final boolean isInterruptible()
isInterruptible
in interface Controllable
public final boolean isUndoable()
Command
Command
can be undone by the user.
isUndoable
in interface Command<ResultType,MessageType>
Command
can be undone, false otherwisepublic final boolean isDetermined()
isDetermined
in interface Progressable
public final int getProgress()
getProgress
in interface Progressable
public final ControllableState getState()
getState
in interface Controllable
getState
in interface Progressable
protected final void setCommandStatus(ControllableState newStatus)
newStatus
- the command status to set.public final String getLabel()
Command
Command
name.
getLabel
in interface Command<ResultType,MessageType>
public final String getDescription()
Command
Command
description.
getDescription
in interface Command<ResultType,MessageType>
public final void addProgressableListener(ProgressableListener listener)
addProgressableListener
in interface Progressable
public final void removeProgressableListener(ProgressableListener listener)
removeProgressableListener
in interface Progressable
public final boolean isPausable()
isPausable
in interface Controllable
public final void addControllableListener(ControllableListener listener)
addControllableListener
in interface Controllable
public final void removeControllableListener(ControllableListener listener)
removeControllableListener
in interface Controllable
public final void clearControllableListener()
clearControllableListener
in interface Controllable
public final void clearProgressableListener()
clearProgressableListener
in interface Progressable
public final boolean checkPreConditions()
Command
Command
preconditions are fulfilled.
checkPreConditions
in interface Command<ResultType,MessageType>
public void setModels(DataModel anApplicationModel, DataModel aBundleModel)
Command
setModels
in interface Command<ResultType,MessageType>
anApplicationModel
- the model of the applicationaBundleModel
- the model of the command bundlepublic DataModel getApplicationModel()
Command
getApplicationModel
in interface Command<ResultType,MessageType>
public DataModel getBundleModel()
Command
getBundleModel
in interface Command<ResultType,MessageType>
public CommandLogLevel getLogLevel()
Command
getLogLevel
in interface Command<ResultType,MessageType>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |