org.progeeks.util.swing
Class WindowManager

java.lang.Object
  extended by org.progeeks.util.swing.WindowManager
All Implemented Interfaces:
ViewManager

public class WindowManager
extends java.lang.Object
implements ViewManager

Manages a list of swing windows that are associated with specific ViewContexts from an ObservableList. When new contexts are added, an appropriate WindowFactory is found that can create the Window/ContextView for the specified context. It is expected that the ObservableList implementation is responsible for ensuring that contexts are not removed prematurely if that is a requirement. When the window is closed, the WindowManager will attempt to remove the window's context from the list. If that succeeds then the window will be closed and removed. ContextList can be used for CloseableContexts to be sure that their canClose() method is called.

Version:
$Revision: 1.13 $
Author:
Paul Speed

Field Summary
static WindowFactory NULL_FACTORY
          A factory that can be registered with types to define a no-op behavior.
 
Constructor Summary
WindowManager()
           
WindowManager(ObservableList contexts)
           
WindowManager(ObservableList contexts, ClassRegistry factories)
           
 
Method Summary
 void createInitialViews()
          Initializes any pre-existing windows that were in the context list before the window manager was created.
 boolean getCascade()
           
 ObservableList getContextList()
          Returns the observable list of contexts for which this manager is responsible.
 boolean getExitWhenLastViewRemoved()
           
 ClassRegistry getViewFactories()
          Returns the mapping of context classes to view factories.
 void registerWindowFactory(java.lang.Class contextType, WindowFactory factory)
          Registers the specified WindowFactory to handle the specified context class.
 void setCascade(boolean cascade)
           
 void setContextList(ObservableList contexts)
          Sets the observable list of contexts for which this manager is responsible.
 void setExitWhenLastViewRemoved(boolean exitWhenLastViewRemoved)
           
 void setViewFactories(ClassRegistry factories)
          Sets a mapping of context classes to view factories.
protected  void viewAdded(ViewContext context)
           
protected  void viewRemoved(ViewContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_FACTORY

public static final WindowFactory NULL_FACTORY
A factory that can be registered with types to define a no-op behavior. In other words, when the WindowManager comes across said type, it will do nothing.

Constructor Detail

WindowManager

public WindowManager()

WindowManager

public WindowManager(ObservableList contexts)

WindowManager

public WindowManager(ObservableList contexts,
                     ClassRegistry factories)
Method Detail

setContextList

public void setContextList(ObservableList contexts)
Sets the observable list of contexts for which this manager is responsible.

Specified by:
setContextList in interface ViewManager

getContextList

public ObservableList getContextList()
Returns the observable list of contexts for which this manager is responsible.

Specified by:
getContextList in interface ViewManager

setViewFactories

public void setViewFactories(ClassRegistry factories)
Sets a mapping of context classes to view factories. This is is used by the manager to create new views.

Specified by:
setViewFactories in interface ViewManager

getViewFactories

public ClassRegistry getViewFactories()
Returns the mapping of context classes to view factories. This is is used by the manager to create new views.

Specified by:
getViewFactories in interface ViewManager

setExitWhenLastViewRemoved

public void setExitWhenLastViewRemoved(boolean exitWhenLastViewRemoved)

getExitWhenLastViewRemoved

public boolean getExitWhenLastViewRemoved()

setCascade

public void setCascade(boolean cascade)

getCascade

public boolean getCascade()

createInitialViews

public void createInitialViews()
Initializes any pre-existing windows that were in the context list before the window manager was created.

Specified by:
createInitialViews in interface ViewManager

registerWindowFactory

public void registerWindowFactory(java.lang.Class contextType,
                                  WindowFactory factory)
Registers the specified WindowFactory to handle the specified context class.


viewAdded

protected void viewAdded(ViewContext context)

viewRemoved

protected void viewRemoved(ViewContext context)


Copyright © 2002-2003 Paul Speed. All Rights Reserved.