Class Controller

java.lang.Object
org.moeaframework.util.mvc.Controller
Direct Known Subclasses:
DiagnosticToolController, RuntimeController

public abstract class Controller extends Object
An abstract controller that manages the underlying data model, settings, and events for a GUI.
  • Constructor Details

    • Controller

      public Controller(Window window)
      Constructs a new MVC controller.
      Parameters:
      window - the parent window
  • Method Details

    • loadPreferences

      public void loadPreferences(Preferences preferences)
      Called during startup to load persisted settings.
      Parameters:
      preferences - the persisted preferences
    • savePreferences

      public void savePreferences(Preferences preferences)
      Called during shutdown to save persisted settings.
      Parameters:
      preferences - the persisted preferences
    • addControllerListener

      public void addControllerListener(ControllerListener listener)
      Adds the specified listener to receive all subsequent controller events.
      Parameters:
      listener - the listener to receive controller events
    • removeControllerListener

      public void removeControllerListener(ControllerListener listener)
      Removes the specified listener so it no longer receives controller events.
      Parameters:
      listener - the listener to no longer receive controller events
    • addShutdownHook

      public void addShutdownHook(Runnable hook)
      Adds a shutdown hook that is called during shutdown().
      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 and savePreferences(Preferences). This is called once before the GUI is disposed.
    • fireEvent

      public void fireEvent(String eventType)
      Fires the specified controller event. All listeners will receive this event on the event dispatch thread.
      Parameters:
      eventType - identifies the type of event
    • displayError

      public void displayError(String message)
      Displays a dialog box with the given error message.
      Parameters:
      message - the error message
    • handleException

      public void handleException(Exception exception)
      Displays a dialog box with the given exception.
      Parameters:
      exception - the exception