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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddControllerListener(ControllerListener listener) Adds the specified listener to receive all subsequent controller events.voidaddShutdownHook(Runnable hook) Adds a shutdown hook that is called duringshutdown().voiddisplayError(String message) Displays a dialog box with the given error message.voidFires the specified controller event.voidhandleException(Exception exception) Displays a dialog box with the given exception.voidloadPreferences(Preferences preferences) Called during startup to load persisted settings.voidremoveControllerListener(ControllerListener listener) Removes the specified listener so it no longer receives controller events.voidsavePreferences(Preferences preferences) Called during shutdown to save persisted settings.protected voidshutdown()Shuts down this controller by calling all shutdown hooks andsavePreferences(Preferences).protected voidstartup()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
-