net.customware.gwt.presenter.client
Class BasicPresenter<D extends Display>

java.lang.Object
  extended by net.customware.gwt.presenter.client.BasicPresenter<D>
All Implemented Interfaces:
Presenter
Direct Known Subclasses:
WidgetPresenter

public abstract class BasicPresenter<D extends Display>
extends java.lang.Object
implements Presenter


Field Summary
protected  D display
          The display for the presenter.
protected  EventBus eventBus
          The EventBus for the application.
 
Constructor Summary
BasicPresenter(D display, EventBus eventBus)
           
 
Method Summary
 void bind()
          Called when the presenter is initialised.
protected  void firePresenterChangedEvent()
          Fires a PresenterChangedEvent to the EventBus.
protected  void firePresenterRevealedEvent(boolean originator)
          Fires a PresenterRevealedEvent to the EventBus.
 D getDisplay()
          Returns the display for the presenter.
 boolean isBound()
          Checks if the presenter has been bound.
protected abstract  void onBind()
          This method is called when binding the presenter.
protected abstract  void onRevealDisplay()
          Called before firing a PresenterRevealedEvent.
protected abstract  void onUnbind()
          This method is called when unbinding the presenter.
protected  void registerHandler(com.google.gwt.event.shared.HandlerRegistration handlerRegistration)
          Any HandlerRegistrations added will be removed when unbind() is called.
 void revealDisplay()
          Triggers a PresenterRevealedEvent.
 void unbind()
          Called after the presenter and display have been finished with for the moment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

display

protected final D extends Display display
The display for the presenter.


eventBus

protected final EventBus eventBus
The EventBus for the application.

Constructor Detail

BasicPresenter

public BasicPresenter(D display,
                      EventBus eventBus)
Method Detail

bind

public void bind()
Description copied from interface: Presenter
Called when the presenter is initialised. This is called before any other methods. Any event handlers and other setup should be done here rather than in the constructor.

Specified by:
bind in interface Presenter

registerHandler

protected void registerHandler(com.google.gwt.event.shared.HandlerRegistration handlerRegistration)
Any HandlerRegistrations added will be removed when unbind() is called. This provides a handy way to track event handler registrations when binding and unbinding.

Parameters:
handlerRegistration - The registration.

unbind

public void unbind()
Description copied from interface: Presenter
Called after the presenter and display have been finished with for the moment.

Specified by:
unbind in interface Presenter

onBind

protected abstract void onBind()
This method is called when binding the presenter. Any additional bindings should be done here.


onUnbind

protected abstract void onUnbind()
This method is called when unbinding the presenter. Any handler registrations recorded with registerHandler(HandlerRegistration) will have already been removed at this point.


isBound

public boolean isBound()
Checks if the presenter has been bound. Will be set to false after a call to unbind().

Specified by:
isBound in interface Presenter
Returns:
The current bound status.

getDisplay

public D getDisplay()
Returns the display for the presenter.

Specified by:
getDisplay in interface Presenter
Returns:
The display.

firePresenterChangedEvent

protected void firePresenterChangedEvent()
Fires a PresenterChangedEvent to the EventBus. Call this method any time the presenter's state has been modified.


firePresenterRevealedEvent

protected void firePresenterRevealedEvent(boolean originator)
Fires a PresenterRevealedEvent to the EventBus. Implementations should call this when the presenter has been revealed onscreen.

Parameters:
originator - If set to true, this specifies that this presenter was the originator of the 'revelation' request.

revealDisplay

public void revealDisplay()
Triggers a PresenterRevealedEvent. Subclasses should override this method and call super.revealDisplay() if they need to perform extra operations when being revealed.

Specified by:
revealDisplay in interface Presenter

onRevealDisplay

protected abstract void onRevealDisplay()
Called before firing a PresenterRevealedEvent.



Copyright © 2010 customware.net. All Rights Reserved.