Package com.j3d.engine.interact.cmd.base
Interface PreCommandExecution
- All Known Implementing Classes:
SelectionPreCondition
public interface PreCommandExecution
A basic interface for providing safe guards before a command is executed. This is the bare bones
implementation of simply checking if it's true and attaching listeners. Concrete implementations
need to make their own clean-up or otherwise logging logic.
An example would be SelectionPreCondition, where it allows commands to require that a
selection is made before the command can execute. And if on run a selection was not made, it
queries the user for a selection.
- Author:
- Lehlogonolo Poole
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanexecute(SafeJLabel logLabel) Executes the pre-command condition check.The actual condition to check against wrapped around aSupplierTheEventEmitterInterfacewhich thegetPassListener()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 thegetEventEmitterToAttachTo().
-
Method Details
-
getPassListener
EventReactor getPassListener()The main event reactor to run if the condition is met on startup or is later called by thegetEventEmitterToAttachTo().- Returns:
- The event reactor to run.
-
getFailListener
EventReactor getFailListener()The event to fire if the condition is false.- Returns:
- The event reactor to run.
-
getEventEmitterToAttachTo
EventEmitterInterface getEventEmitterToAttachTo()TheEventEmitterInterfacewhich thegetPassListener()will attach to.- Returns:
- The event emitter to attach to.
-
getLogText
The 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.- Returns:
- The text to display.
-
getCondition
The actual condition to check against wrapped around aSupplier- Returns:
- The condition to check against.
-
execute
Executes the pre-command condition check. If the condition is not met, it displays a message to the user and attaches the pass listener to the appropriate event emitter, waiting for the condition to be met. If the condition is met, it immediately triggers the pass listener.- Parameters:
logLabel- TheSafeJLabelto display messages to the user.- Returns:
trueif the condition was met immediately,falseotherwise.
-