org.viewaframework.view
Class AbstractViewContainer

java.lang.Object
  extended by org.viewaframework.view.AbstractViewContainer
All Implemented Interfaces:
RootPaneContainer, ViewControllerAware, ApplicationAware, MessageAware, ViewModelAware, ComponentsAware, DelegatorAware, ViewContainerEventAware, ViewContainerEventControllerAware, ViewContainer
Direct Known Subclasses:
AbstractViewContainerDialog, AbstractViewContainerFrame, DefaultViewContainer

public abstract class AbstractViewContainer
extends Object
implements ViewContainer

This is a default abstract implementation of a ViewContainer. The lifecycle implementation is far to be optimal but is pretty closed from the concept.

The view should execute the following methods in order:

1) injectListeners() This method should be hidden from the user. This method will be declared in the interface in future releases, because it will be moved from the application context to the view context.

2) viewInitUIState() This method should be used by the programmer in order to initialize some visual components before the viewInitBackActions() is called. For example disable some components while the viewInitBackActions() is reading some information from the database.

3) viewInitBackActions(): Used to perform some non visual actions before the final state of the view has been set.

4) viewFinalUIState(): Once the viewInitBackActions() has finished this method could be used to establish the final state of the view before the UI user will begin to interactwith it. For example enabling the components previously disabled by the viewInitUIState() method.

Since:
1.0
Author:
Mario Garcia

Field Summary
 
Fields inherited from interface org.viewaframework.view.ViewContainer
CONTENTPANE, FRAME, MENUBAR, ROOTPANE, TOOLBAR
 
Constructor Summary
AbstractViewContainer()
           
AbstractViewContainer(String id)
           
 
Method Summary
 void addDelegator(Delegator delegator)
           
 void addModelValue(String alias, Object object)
           
 void addViewContainerListener(ViewContainerEventController listener)
           
 void fireViewClose(ViewContainerEvent event)
           
 void fireViewFinalUIState(ViewContainerEvent event)
           
 void fireViewInit(ViewContainerEvent event)
           
 void fireViewInitBackActions(ViewContainerEvent event)
           
 void fireViewInitUIState(ViewContainerEvent event)
           
 List<ViewActionDescriptor> getActionDescriptors()
           
 Application getApplication()
          Returns the instance of the current application
 Component getComponentByName(String name)
          This method retrieves components by its name.
 List<Component> getComponentsByName(String name)
          This method retrieves components by its name.
 Container getContainer()
           
 Container getContentPane()
           
 List<Delegator> getDelegators()
           
 Component getGlassPane()
           
 Image getIconImage()
          Returns the image that represents this view
 String getId()
          Returns the id of the view
 JToolBar getJToolBar()
           
 JLayeredPane getLayeredPane()
           
 String getMessage(String key)
           
 ResourceBundle getMessageBundle()
           
 Object getModelValue(String alias)
           
 Map<String,List<Component>> getNamedComponents()
          It retrieves all the named components within the main Container returned by this view.
 JRootPane getRootPane()
           
 String getTitle()
          Returns the title of the view
 List<ViewContainerEventController> getViewContainerListeners()
           
 Map<String,List<ViewController<? extends EventListener,? extends EventObject>>> getViewControllerMap()
           
 Map<String,ViewModel> getViewModelMap()
           
 void removeDelegator(Delegator delegator)
           
 void removeViewContainerListener(ViewContainerEventController listener)
           
 void setActionDescriptors(List<ViewActionDescriptor> descriptors)
           
 void setApplication(Application application)
          Sets the application instance
 void setContentPane(Container contentPane)
           
 void setDelegators(List<Delegator> delegators)
           
 void setGlassPane(Component glassPane)
           
 void setIconImage(Image iconImage)
          Sets a representative image for this view
 void setId(String id)
          Sets the name view.
 void setJToolbar(JToolBar toolBar)
           
 void setLayeredPane(JLayeredPane layeredPane)
           
 void setMessageBundle(ResourceBundle messageBundle)
           
 void setNamedComponents(Map<String,List<Component>> namedComponents)
          NamedComponents should be filled by an external delegator.
 void setTitle(String title)
          Sets the title of the view
 void setViewContainerListeners(List<ViewContainerEventController> listeners)
           
 void setViewControllerMap(Map<String,List<ViewController<? extends EventListener,? extends EventObject>>> viewControllerMap)
           
 void setViewModelMap(Map<String,ViewModel> viewModelMap)
           
 void viewClose()
          Closes the view
 void viewFinalUIState()
          Once background actions has been performed we can establish the final aspect of the view within this method.
 void viewInit()
          Initializes the view.
 void viewInitBackActions()
          Background actions affecting the final view.
 void viewInitUIState()
          How the view is visualized before background actions are performed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractViewContainer

public AbstractViewContainer()

AbstractViewContainer

public AbstractViewContainer(String id)
Parameters:
id -
Method Detail

addDelegator

public void addDelegator(Delegator delegator)
Specified by:
addDelegator in interface DelegatorAware

addModelValue

public void addModelValue(String alias,
                          Object object)
Specified by:
addModelValue in interface ViewModelAware

addViewContainerListener

public void addViewContainerListener(ViewContainerEventController listener)
Specified by:
addViewContainerListener in interface ViewContainerEventControllerAware

fireViewClose

public void fireViewClose(ViewContainerEvent event)
Specified by:
fireViewClose in interface ViewContainerEventAware

fireViewFinalUIState

public void fireViewFinalUIState(ViewContainerEvent event)
Specified by:
fireViewFinalUIState in interface ViewContainerEventAware

fireViewInit

public void fireViewInit(ViewContainerEvent event)
Specified by:
fireViewInit in interface ViewContainerEventAware

fireViewInitBackActions

public void fireViewInitBackActions(ViewContainerEvent event)
Specified by:
fireViewInitBackActions in interface ViewContainerEventAware

fireViewInitUIState

public void fireViewInitUIState(ViewContainerEvent event)
Specified by:
fireViewInitUIState in interface ViewContainerEventAware

getActionDescriptors

public List<ViewActionDescriptor> getActionDescriptors()
Specified by:
getActionDescriptors in interface ViewContainer
Returns:

getApplication

public Application getApplication()
Description copied from interface: ApplicationAware
Returns the instance of the current application

Specified by:
getApplication in interface ApplicationAware
Returns:

getComponentByName

public Component getComponentByName(String name)
Description copied from interface: ComponentsAware
This method retrieves components by its name. If the component doesn't exist it returns null.

Specified by:
getComponentByName in interface ComponentsAware
Parameters:
name - The name of the component we want to retrieve
Returns:
The Component

getComponentsByName

public List<Component> getComponentsByName(String name)
Description copied from interface: ComponentsAware
This method retrieves components by its name. If the component doesn't exist it returns an empty List.

Specified by:
getComponentsByName in interface ComponentsAware
Parameters:
name - The name of the component we want to retrieve
Returns:
The Component

getContainer

public Container getContainer()

getContentPane

public Container getContentPane()
Specified by:
getContentPane in interface RootPaneContainer

getDelegators

public List<Delegator> getDelegators()
Specified by:
getDelegators in interface DelegatorAware

getGlassPane

public Component getGlassPane()
Specified by:
getGlassPane in interface RootPaneContainer

getIconImage

public Image getIconImage()
Description copied from interface: ViewContainer
Returns the image that represents this view

Specified by:
getIconImage in interface ViewContainer
Returns:

getId

public String getId()
Description copied from interface: ViewContainer
Returns the id of the view

Specified by:
getId in interface ViewContainer
Returns:
the name

getJToolBar

public JToolBar getJToolBar()
Specified by:
getJToolBar in interface ViewContainer
Returns:

getLayeredPane

public JLayeredPane getLayeredPane()
Specified by:
getLayeredPane in interface RootPaneContainer

getMessage

public String getMessage(String key)
Specified by:
getMessage in interface MessageAware
Returns:

getMessageBundle

public ResourceBundle getMessageBundle()
Specified by:
getMessageBundle in interface MessageAware
Returns:

getModelValue

public Object getModelValue(String alias)
Specified by:
getModelValue in interface ViewModelAware
Returns:

getNamedComponents

public Map<String,List<Component>> getNamedComponents()
Description copied from interface: ComponentsAware
It retrieves all the named components within the main Container returned by this view.

Specified by:
getNamedComponents in interface ComponentsAware
Returns:
A map with all the named components

getRootPane

public JRootPane getRootPane()
Specified by:
getRootPane in interface RootPaneContainer

getTitle

public String getTitle()
Description copied from interface: ViewContainer
Returns the title of the view

Specified by:
getTitle in interface ViewContainer
Returns:

getViewContainerListeners

public List<ViewContainerEventController> getViewContainerListeners()
Specified by:
getViewContainerListeners in interface ViewContainerEventControllerAware

getViewControllerMap

public Map<String,List<ViewController<? extends EventListener,? extends EventObject>>> getViewControllerMap()
Specified by:
getViewControllerMap in interface ViewControllerAware
Returns:

getViewModelMap

public Map<String,ViewModel> getViewModelMap()
Specified by:
getViewModelMap in interface ViewModelAware
Returns:

removeDelegator

public void removeDelegator(Delegator delegator)
Specified by:
removeDelegator in interface DelegatorAware

removeViewContainerListener

public void removeViewContainerListener(ViewContainerEventController listener)
Specified by:
removeViewContainerListener in interface ViewContainerEventControllerAware

setActionDescriptors

public void setActionDescriptors(List<ViewActionDescriptor> descriptors)
Specified by:
setActionDescriptors in interface ViewContainer

setApplication

public void setApplication(Application application)
Description copied from interface: ApplicationAware
Sets the application instance

Specified by:
setApplication in interface ApplicationAware

setContentPane

public void setContentPane(Container contentPane)
Specified by:
setContentPane in interface RootPaneContainer

setDelegators

public void setDelegators(List<Delegator> delegators)
Specified by:
setDelegators in interface DelegatorAware

setGlassPane

public void setGlassPane(Component glassPane)
Specified by:
setGlassPane in interface RootPaneContainer

setIconImage

public void setIconImage(Image iconImage)
Description copied from interface: ViewContainer
Sets a representative image for this view

Specified by:
setIconImage in interface ViewContainer

setId

public void setId(String id)
Description copied from interface: ViewContainer
Sets the name view.

Specified by:
setId in interface ViewContainer
Parameters:
id - the id to set

setJToolbar

public void setJToolbar(JToolBar toolBar)
Specified by:
setJToolbar in interface ViewContainer

setLayeredPane

public void setLayeredPane(JLayeredPane layeredPane)
Specified by:
setLayeredPane in interface RootPaneContainer

setMessageBundle

public void setMessageBundle(ResourceBundle messageBundle)
Specified by:
setMessageBundle in interface MessageAware

setNamedComponents

public void setNamedComponents(Map<String,List<Component>> namedComponents)
Description copied from interface: ComponentsAware
NamedComponents should be filled by an external delegator. It should inspect the rootPane of the view and retrieve all named java.awt.Component components.

Specified by:
setNamedComponents in interface ComponentsAware
Parameters:
namedComponents -

setTitle

public void setTitle(String title)
Description copied from interface: ViewContainer
Sets the title of the view

Specified by:
setTitle in interface ViewContainer

setViewContainerListeners

public void setViewContainerListeners(List<ViewContainerEventController> listeners)
Specified by:
setViewContainerListeners in interface ViewContainerEventControllerAware

setViewControllerMap

public void setViewControllerMap(Map<String,List<ViewController<? extends EventListener,? extends EventObject>>> viewControllerMap)
Specified by:
setViewControllerMap in interface ViewControllerAware

setViewModelMap

public void setViewModelMap(Map<String,ViewModel> viewModelMap)
Specified by:
setViewModelMap in interface ViewModelAware

viewClose

public void viewClose()
               throws ViewException
Description copied from interface: ViewContainer
Closes the view

Specified by:
viewClose in interface ViewContainer
Throws:
ViewException

viewFinalUIState

public void viewFinalUIState()
                      throws ViewException
Description copied from interface: ViewContainer
Once background actions has been performed we can establish the final aspect of the view within this method.

Specified by:
viewFinalUIState in interface ViewContainer
Throws:
ViewException

viewInit

public void viewInit()
              throws ViewException
Description copied from interface: ViewContainer
Initializes the view. It should be implemented by an abstract class and it should call sequentially to the following methods.

viewInitUIState();
viewInitBackActions();
viewFinalUIState();

Specified by:
viewInit in interface ViewContainer
Throws:
ViewException

viewInitBackActions

public void viewInitBackActions()
                         throws ViewException
Description copied from interface: ViewContainer
Background actions affecting the final view. Actions that could freeze the UI, should be done here.

Specified by:
viewInitBackActions in interface ViewContainer
Throws:
ViewException

viewInitUIState

public void viewInitUIState()
                     throws ViewException
Description copied from interface: ViewContainer
How the view is visualized before background actions are performed. For example, if we want to keep disabled the UI until some database actions finished we should do it here.

Specified by:
viewInitUIState in interface ViewContainer
Throws:
ViewException


Copyright © 2010. All Rights Reserved.