org.viewaframework.controller
Class AbstractViewController<EL extends EventListener,EO extends EventObject>

java.lang.Object
  extended by org.viewaframework.controller.AbstractViewController<EL,EO>
All Implemented Interfaces:
InvocationHandler, ListenerProxy<EL,EO>, ViewController<EL,EO>, ViewContainerLocatorAware
Direct Known Subclasses:
AbstractActionController, AbstractMouseClickController, AbstractOpenerController, DefaultWindowController, LoginViewController

public abstract class AbstractViewController<EL extends EventListener,EO extends EventObject>
extends Object
implements ViewController<EL,EO>, ViewContainerLocatorAware

This is the default implementation of the ViewController concept. The main entrance for the event is the executeHandler(ViewContainer vc,EventObject eo) which executes the following methods sequentially:

1) preHandlingView(...): It should be use to establish a initial visual state of the view. For example you can disable some buttons when executing a long task 2) handleView(...): Here you have to program those non visual actions which could last a while. It's executed in a new Thread. 3) postHandlingView(...): It should be use to recover the final state of the view once the logic programmed in the handleView(...) method has finished.

Since:
1.0
Author:
Mario Garcia

Constructor Summary
AbstractViewController()
           
 
Method Summary
 void executeHandler(ViewContainer view, EO eventObject)
          Its the callback method.
 ViewController<EL,EO> getTargetController()
          Returns the listener the proxy is carrying.
 ViewManager getViewManager()
          Returns the application's current view manager
 void handleView(ViewContainer view, EO eventObject)
          This is the method where the logical handling of the data should be called.
 Object invoke(Object proxy, Method method, Object[] args)
           
<U extends ViewContainer>
ViewContainerLocator<U>
locate(Class<U> clazz)
          This method should return a ViewContainerLocator
 ViewContainer locate(String name)
          This method should return a ViewContainer with the name passed as parameter
 ViewContainerFrame locateRootView()
          This method should return the current root view
 void postHandlingView(ViewContainer view, EO eventObject)
          Used for some UI updating before the logical code has been called.
 void preHandlingView(ViewContainer view, EO eventObject)
          Used for some UI updating once the logical code has been called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.viewaframework.controller.ViewController
getSupportedClass
 

Constructor Detail

AbstractViewController

public AbstractViewController()
Method Detail

executeHandler

public void executeHandler(ViewContainer view,
                           EO eventObject)
Description copied from interface: ViewController
Its the callback method. It is called from a given component of the view in order to perform some action. It should call first to preHandlingView() for cleaning up some information data then it calls to handleView(..) and finally calls to postHandlingView(...).

Notice that depending on the listener proxied the EventObject should be casted in order to get the desired information from it.

Specified by:
executeHandler in interface ViewController<EL extends EventListener,EO extends EventObject>
Parameters:
view - The view where this listener belongs
eventObject - The event fired by the proxied listener.

getViewManager

public ViewManager getViewManager()
Description copied from interface: ViewController
Returns the application's current view manager

Specified by:
getViewManager in interface ViewController<EL extends EventListener,EO extends EventObject>
Returns:
The current view manager

handleView

public void handleView(ViewContainer view,
                       EO eventObject)
Description copied from interface: ViewController
This is the method where the logical handling of the data should be called. Any UI call should be done in post/pre-handling methods. It is important to notice that the code executed within this method should be running in other thread than EventDispathThread.

Specified by:
handleView in interface ViewController<EL extends EventListener,EO extends EventObject>

postHandlingView

public void postHandlingView(ViewContainer view,
                             EO eventObject)
                      throws ViewException
Description copied from interface: ViewController
Used for some UI updating before the logical code has been called.

Specified by:
postHandlingView in interface ViewController<EL extends EventListener,EO extends EventObject>
Throws:
ViewException

preHandlingView

public void preHandlingView(ViewContainer view,
                            EO eventObject)
Description copied from interface: ViewController
Used for some UI updating once the logical code has been called.

Specified by:
preHandlingView in interface ViewController<EL extends EventListener,EO extends EventObject>

getTargetController

public ViewController<EL,EO> getTargetController()
Description copied from interface: ListenerProxy
Returns the listener the proxy is carrying.

Specified by:
getTargetController in interface ListenerProxy<EL extends EventListener,EO extends EventObject>
Returns:

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
Specified by:
invoke in interface InvocationHandler

locate

public <U extends ViewContainer> ViewContainerLocator<U> locate(Class<U> clazz)
Description copied from interface: ViewContainerLocatorAware
This method should return a ViewContainerLocator

Specified by:
locate in interface ViewContainerLocatorAware
Returns:

locate

public ViewContainer locate(String name)
Description copied from interface: ViewContainerLocatorAware
This method should return a ViewContainer with the name passed as parameter

Specified by:
locate in interface ViewContainerLocatorAware
Returns:

locateRootView

public ViewContainerFrame locateRootView()
Description copied from interface: ViewContainerLocatorAware
This method should return the current root view

Specified by:
locateRootView in interface ViewContainerLocatorAware
Returns:


Copyright © 2010. All Rights Reserved.