Class SelectionPreCondition
java.lang.Object
com.j3d.engine.interact.cmd.base.conditions.SelectionPreCondition
- All Implemented Interfaces:
PreCommandExecution
A concrete implementation of
PreCommandExecution which forces the user to have made
a selection before the command can execute.
This implementation provides:
KeyEvent.VK_ENTERandKeyEvent.VK_ESCAPEto abort the selection requirement- a direct implementation of
getPassListener(),getFailListener(),getCondition(),getLogText()andgetEventEmitterToAttachTo() - a singleton
Runnablewhich executes the code when this passes - a singleton
commandEndCleanupRunnable to otherwise provide extra cleanup that is required by the command
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Runnableprivate final Runnableprivate final EventReactorprivate final EventReactorprivate String -
Constructor Summary
ConstructorsConstructorDescriptionSelectionPreCondition(Runnable success, Runnable extraCleanup) Constructs a newSelectionPreCondition.SelectionPreCondition(Runnable success, Runnable extraCleanup, String text) -
Method Summary
Modifier and TypeMethodDescriptionvoidFinalises the clean-up process by detaching the pass and fail listeners from the event emitter.The actual condition to check against wrapped around aSupplierTheEventEmitterInterfacewhich thePreCommandExecution.getPassListener()will attach to.The event to fire if the condition is false.The text to display to the user viaSafeJLabel.setText(String)when the condition is not met on startup.The main event reactor to run if the condition is met on startup or is later called by thePreCommandExecution.getEventEmitterToAttachTo().Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.j3d.engine.interact.cmd.base.PreCommandExecution
execute
-
Field Details
-
passListener
-
failListener
-
cleanup
-
commandEndCleanup
-
text
-
-
Constructor Details
-
Method Details
-
finaliseCleanup
public void finaliseCleanup()Finalises the clean-up process by detaching the pass and fail listeners from the event emitter. This should be called when the command has either successfully proceeded or been aborted. -
getPassListener
Description copied from interface:PreCommandExecutionThe main event reactor to run if the condition is met on startup or is later called by thePreCommandExecution.getEventEmitterToAttachTo().- Specified by:
getPassListenerin interfacePreCommandExecution- Returns:
- The event reactor to run.
-
getFailListener
Description copied from interface:PreCommandExecutionThe event to fire if the condition is false.- Specified by:
getFailListenerin interfacePreCommandExecution- Returns:
- The event reactor to run.
-
getEventEmitterToAttachTo
Description copied from interface:PreCommandExecutionTheEventEmitterInterfacewhich thePreCommandExecution.getPassListener()will attach to.- Specified by:
getEventEmitterToAttachToin interfacePreCommandExecution- Returns:
- The event emitter to attach to.
-
getLogText
Description copied from interface:PreCommandExecutionThe text to display to the user viaSafeJLabel.setText(String)when the condition is not met on startup. This is usually a friendly message requesting the user to interact with something before proceeding.- Specified by:
getLogTextin interfacePreCommandExecution- Returns:
- The text to display.
-
getCondition
Description copied from interface:PreCommandExecutionThe actual condition to check against wrapped around aSupplier- Specified by:
getConditionin interfacePreCommandExecution- Returns:
- The condition to check against.
-