org.eodisp.ui.common.base
Class EodispApplicationController

java.lang.Object
  extended by org.eodisp.ui.common.base.EodispApplicationController
Direct Known Subclasses:
MmAppController, RmAppController, SMAppController

public abstract class EodispApplicationController
extends java.lang.Object

The EodispApplicationController is the main controller for this application. It handles the creation of of other controllers for the application as well as the creation and management of frames.

This class should be sub-classed by a specific application controller for each application to provide an implementation of the abstract methods. The sub-class should also handle the actions that belong to the main application. That is, all actions that should always be available.

In the MVC (Model-View-Controller) pattern, the controller is responsible for handling events. This is done by using the delegation mechanism which is provided by EodispDelegate class. See the documentation of this calls for more information.

Version:
$Id: EodispApplicationController.java 1427 2006-01-04 07:57:54Z eglimi $
Author:
eglimi

Field Summary
(package private) static org.apache.log4j.Logger logger
          Log4J logger for this class
protected  net.infonode.docking.RootWindow rootWindow
          Holds the root windows in which all views are embedded.
protected  net.infonode.docking.util.ViewMap viewMap
          Holds a list of all static views in the application.
 
Constructor Summary
protected EodispApplicationController()
          Default constructor.
 
Method Summary
protected  void attachController(EodispController c)
          Attaches the given controller to the list of controllers for this application.
protected  boolean canExit()
          Checks in all currently active frames if there is a model which has been changed and therefore needs to save before exiting.
protected abstract  void createControllers()
          This constructs all frames included in the application.
protected  void createInitialLayout()
          This method can be used by sub-classes to create an initial layout.
protected abstract  EodispMainFrame createMainFrame()
          Creates the main frame of the application.
protected  net.infonode.docking.RootWindow createRootWindow()
          Adds all frames created by controllers to the main frame.
protected  void detachAllControllers()
          Removes all controllers from the list of controllers registered for this application.
protected  void detachController(EodispController c)
          Removes a controller from the list of controllers registered for this application.
 java.lang.String[] getChangedViewNames()
          Checks in all views if its model(s) have changes.
 EodispMainFrame getMainFrame()
          Returns the main frame of this application.
 net.infonode.docking.RootWindow getRootWindow()
          Returns the root window.
 void handleExit()
           
 boolean hasAppChanges()
           
 void initialize()
          Initialization of the application controller.
protected abstract  void registerActionHandler()
          Register this class as a target handler for certain actions used within the EODiSP simulation manager application.
 void saveAllChanges()
          Saves all changes in all models.
protected  void saveLayout()
          Save the layout, if this method is supported by the application.
protected  void showDynamicView(int viewId)
          Adds the dynamic view identified by the given ID.
protected  void updateAllActions()
          Update the state of all actions.
protected  void updateAllModels()
           
protected  void updateAllViewStates()
          Updates the state on each view by calling the EodispView.updateViewState() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger
Log4J logger for this class


rootWindow

protected net.infonode.docking.RootWindow rootWindow
Holds the root windows in which all views are embedded. This is the container which is added to the main frame.


viewMap

protected net.infonode.docking.util.ViewMap viewMap
Holds a list of all static views in the application.

Constructor Detail

EodispApplicationController

protected EodispApplicationController()
Default constructor.

Method Detail

registerActionHandler

protected abstract void registerActionHandler()
Register this class as a target handler for certain actions used within the EODiSP simulation manager application.

For the registration, the EODiSP delegation mechanism is used (see EodispDelegate. Such an instance can be registered in the action itself, causing the method to be called whenever the action is performed.


createMainFrame

protected abstract EodispMainFrame createMainFrame()
Creates the main frame of the application. This method must be implemented by a concrete application controller for each application.

Returns:
The main frame of this application.

createControllers

protected abstract void createControllers()
This constructs all frames included in the application. It must be implemented by the specific application main controller.


createInitialLayout

protected void createInitialLayout()
This method can be used by sub-classes to create an initial layout. It will be called only the first time when there is no ui state file, or if an error occurs when reading the ui state file.

You do not need to call super().


saveLayout

protected void saveLayout()
Save the layout, if this method is supported by the application. Behavior depends on the application. An implementation might save the layout to a file.

The default implementation saves the layout of the root window in a file specified by the UiConfiguration of this application. It only saves the layout, it does not save the views (and their states) itself. Also, it does not save the state of the tool bar.


getMainFrame

public EodispMainFrame getMainFrame()
                             throws java.lang.IllegalStateException
Returns the main frame of this application.

Returns:
The main frame.
Throws:
java.lang.IllegalStateException - Thrown if this method is called before the application controller has been initialized.

getRootWindow

public net.infonode.docking.RootWindow getRootWindow()
Returns the root window. This is the main container that holds all views. It is content pane of the main frame.

Returns:

initialize

public void initialize()
Initialization of the application controller. This initialization sequence can be override by subclasses.


handleExit

public void handleExit()

saveAllChanges

public void saveAllChanges()
                    throws java.io.IOException
Saves all changes in all models. It catches possible errors and shows an error message to the user. Indication if the operation succeeded is given by the return value.

Throws:
java.io.IOException - Rethrown if one of the models throws an exception during save.

hasAppChanges

public boolean hasAppChanges()

updateAllModels

protected void updateAllModels()

updateAllActions

protected void updateAllActions()
Update the state of all actions. This method can be called when something changed that really needs to update many actions. Otherwise, it is less overhead to update single actions as appropriate.


updateAllViewStates

protected void updateAllViewStates()
Updates the state on each view by calling the EodispView.updateViewState() method.


canExit

protected boolean canExit()
Checks in all currently active frames if there is a model which has been changed and therefore needs to save before exiting.

The method checks if the view and a model exists.

Returns:
True, if the application can exit, false otherwise.

getChangedViewNames

public java.lang.String[] getChangedViewNames()
Checks in all views if its model(s) have changes. Returns an array of strings with the name of all views whose model(s) have changes.

Returns:
An array of names of views whose model(s) have changes. Returns an empty array if no changes are found.

createRootWindow

protected net.infonode.docking.RootWindow createRootWindow()
Adds all frames created by controllers to the main frame. The main frame itself should take care of the layout.


showDynamicView

protected void showDynamicView(int viewId)
Adds the dynamic view identified by the given ID. A new view will be created if not yet done.

Parameters:
viewId - The Id of the view to be added.

attachController

protected void attachController(EodispController c)
Attaches the given controller to the list of controllers for this application. If the controller is already registered in the list, the operation is ignored.

Parameters:
c -

detachController

protected void detachController(EodispController c)
Removes a controller from the list of controllers registered for this application. It should free all resources currently held by this controller and it should also dispose all underlying frames and views that are connected to the controller.

Parameters:
c - The controller to be removed from the list of registered controllers.

detachAllControllers

protected void detachAllControllers()
Removes all controllers from the list of controllers registered for this application. It should free all resources currently held by the controllers and should also dispose all underlying frames and views.

This should be called before exit the application. It ensures a proper sequence of the exit process.