Package org.moeaframework.util.mvc
Class Controller
java.lang.Object
org.moeaframework.util.mvc.Controller
- Direct Known Subclasses:
DiagnosticToolController
,RuntimeController
An abstract controller that manages the underlying data model, settings, and events for a GUI.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addControllerListener
(ControllerListener listener) Adds the specified listener to receive all subsequent controller events.void
addShutdownHook
(Runnable hook) Adds a shutdown hook that is called duringshutdown()
.void
displayError
(String message) Displays a dialog box with the given error message.void
Fires the specified controller event.void
handleException
(Exception exception) Displays a dialog box with the given exception.void
loadPreferences
(Preferences preferences) Called during startup to load persisted settings.void
removeControllerListener
(ControllerListener listener) Removes the specified listener so it no longer receives controller events.void
savePreferences
(Preferences preferences) Called during shutdown to save persisted settings.protected void
shutdown()
Shuts down this controller by calling all shutdown hooks andsavePreferences(Preferences)
.protected void
startup()
Starts up this controller.
-
Constructor Details
-
Controller
Constructs a new MVC controller.- Parameters:
window
- the parent window
-
-
Method Details
-
loadPreferences
Called during startup to load persisted settings.- Parameters:
preferences
- the persisted preferences
-
savePreferences
Called during shutdown to save persisted settings.- Parameters:
preferences
- the persisted preferences
-
addControllerListener
Adds the specified listener to receive all subsequent controller events.- Parameters:
listener
- the listener to receive controller events
-
removeControllerListener
Removes the specified listener so it no longer receives controller events.- Parameters:
listener
- the listener to no longer receive controller events
-
addShutdownHook
Adds a shutdown hook that is called duringshutdown()
.- Parameters:
hook
- the shutdown hook
-
startup
protected void startup()Starts up this controller. This is called once before the GUI is displayed. -
shutdown
protected void shutdown()Shuts down this controller by calling all shutdown hooks andsavePreferences(Preferences)
. This is called once before the GUI is disposed. -
fireEvent
Fires the specified controller event. All listeners will receive this event on the event dispatch thread.- Parameters:
eventType
- identifies the type of event
-
displayError
Displays a dialog box with the given error message.- Parameters:
message
- the error message
-
handleException
Displays a dialog box with the given exception.- Parameters:
exception
- the exception
-