Class SwingShutDownTask
- All Implemented Interfaces:
PropertyChangeListener,Runnable,Callable<Boolean>,EventListener,ShutDownTask
Sequence:
- checkPromptNeeded determines if ready to shutdown. If so, return ready.
- Issue a prompt, asking if the user wants to continue or do something else
- Recheck until something decided.
If no "action" name is provided, only the continue and cancel options are shown.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSwingShutDownTask(String name, String warning, String action, Component component) Constructor specifies the warning message and action to take -
Method Summary
Modifier and TypeMethodDescriptionfinal Booleancall()Ask if shut down is allowed.protected booleanProvide a subclass-specific check as to whether it's OK to shutdown.protected voidHandle the request to address a potential blocker to stopping.protected booleandoPrompt()Handle the request to address a potential blocker to stopping.voidrun()Take the necessary action.Methods inherited from class jmri.implementation.AbstractShutDownTask
getName, isDoRun, propertyChange, setDoRun, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.ShutDownTask
runEarly
-
Field Details
-
warning
-
action
-
component
-
-
Constructor Details
-
SwingShutDownTask
Constructor specifies the warning message and action to take- Parameters:
name- the name of the task (used in logs)warning- the prompt to displayaction- the action button to displaycomponent- the parent component of the dialog
-
-
Method Details
-
call
Ask if shut down is allowed.The shut down manager calls this method first on all the tasks before starting to execute the method
ShutDownTask.run()on the tasks.If this method returns false on any task, the shut down process must be aborted. This implementation merely sets the "doRun" property to true, and should be overridden for any real checking. Note that overriding implementations should call
AbstractShutDownTask.setDoRun(boolean)correctly. This implementation displays a dialog allowing a user continue stopping the app, abort stopping the app, or take a custom action. Closing the dialog without choosing any button is treated as aborting stopping the app.- Specified by:
callin interfaceCallable<Boolean>- Specified by:
callin interfaceShutDownTask- Overrides:
callin classAbstractShutDownTask- Returns:
- true if it is OK to shut down, false to abort shut down.
- See Also:
-
run
Take the necessary action. This method cannot abort the shutdown, and must not require user interaction to complete successfully. This method will be run in parallel to other ShutDownTasks. This implementation callsdidPrompt()if the user took the prompt action. -
checkPromptNeeded
Provide a subclass-specific check as to whether it's OK to shutdown. If not, issue a prompt before continuing. Default implementation never passes, causing message to be emitted.- Returns:
- true if ready to shutdown, and no prompt needed. false to present dialog before shutdown proceeds
-
didPrompt
Handle the request to address a potential blocker to stopping. This method is called inrun()and must not interact with the user.This is a dummy implementation, intended to be overloaded.
-
doPrompt
Handle the request to address a potential blocker to stopping. This method is called incall()and can interact with the user.This is a dummy implementation, intended to be overloaded.
- Returns:
- true if ready to shutdown, false to end shutdown
-