org.cruxframework.crux.core.client.screen.views
Class ViewContainer

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by org.cruxframework.crux.core.client.screen.views.ViewContainer
All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsRenderable, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
CrawlableViewContainer, ParameterizedViewContainer

public abstract class ViewContainer
extends com.google.gwt.user.client.ui.Composite

Author:
Thiago da Rosa de Bustamante

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
protected static Logger logger
           
protected  FastMap<View> views
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
ViewContainer(com.google.gwt.user.client.ui.Widget mainWidget)
          Constructor
ViewContainer(com.google.gwt.user.client.ui.Widget mainWidget, boolean clearPanelsForDeactivatedViews)
          Constructor
 
Method Summary
protected  boolean activate(View view, com.google.gwt.user.client.ui.Panel containerPanel, Object parameter)
          This method must be called by subclasses when any of your views is rendered.
 boolean add(View view)
          Loads a new view into the container
protected  boolean add(View view, boolean render, Object parameter)
          Loads a new view into the container
 boolean addLazy(View view)
          Adds a new view into the container, but does not load the view.
protected  boolean addView(View view, boolean lazy, Object parameter)
           
protected  void adoptView(View view)
           
protected  void bindToDOM()
          This method must be called by subclasses when the container is attached to DOM
 void clear()
          Remove all view inside this container
static void createView(String viewName, String viewId, ViewFactory.CreateCallback callback)
          Creates the view referenced by the given name and associate a custom identifier with the view created
static void createView(String viewName, ViewFactory.CreateCallback callback)
          Creates the view referenced by the given name
protected  boolean deactivate(View view, com.google.gwt.user.client.ui.Panel containerPanel, boolean skipEvent)
          This method must be called by subclasses when any of your views currently rendered is removed from view.
protected  boolean doAdd(View view, boolean lazy, Object parameter)
          Loads a new view into the container
protected  boolean doRemove(View view, boolean skipEvent)
           
protected abstract  com.google.gwt.user.client.ui.Panel getContainerPanel(View view)
           
protected
<T extends com.google.gwt.user.client.ui.Widget>
T
getMainWidget()
           
 View getView(String viewId)
          Retrieve the view associated to viewId
static ViewFactory getViewFactory()
          Retrieve the views factory associated with this screen.
protected abstract  void handleViewTitle(String title, com.google.gwt.user.client.ui.Panel containerPanel, String viewId)
           
protected abstract  boolean hasHistoryHandlers()
           
protected abstract  boolean hasOrientationChangeHandlers()
           
protected abstract  boolean hasResizeHandlers()
           
protected abstract  boolean hasWindowCloseHandlers()
           
protected abstract  boolean hasWindowClosingHandlers()
           
protected  void loadAndRenderView(String viewName, String viewId, Object parameter)
           
 void loadView(String viewName, boolean render)
          Loads a view into the current container
 void loadView(String viewName, String viewId, boolean render)
          Loads a view into the current container
protected  void loadView(String viewName, String viewId, boolean render, Object parameter)
          Loads a view into the current container
protected abstract  void notifyViewsAboutHistoryChange(com.google.gwt.event.logical.shared.ValueChangeEvent<String> event)
           
protected abstract  void notifyViewsAboutOrientationChange()
           
protected abstract  void notifyViewsAboutWindowClose(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.Window> event)
           
protected abstract  void notifyViewsAboutWindowClosing(com.google.gwt.user.client.Window.ClosingEvent event)
           
protected abstract  void notifyViewsAboutWindowResize(com.google.gwt.event.logical.shared.ResizeEvent event)
           
 boolean remove(View view)
          Remove the view from this container
 boolean remove(View view, boolean skipEvents)
          Remove the view from this container
protected  boolean renderView(View view, Object parameter)
          Render the view into the container
 void showView(String viewName)
          Render the requested view into the container.
 void showView(String viewName, String viewId)
          Render the requested view into the container.
protected  void showView(String viewName, String viewId, Object parameter)
          Render the requested view into the container.
protected  void unbindToDOM()
          This method must be called by subclasses when the container is detached from DOM
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static Logger logger

views

protected FastMap<View> views
Constructor Detail

ViewContainer

public ViewContainer(com.google.gwt.user.client.ui.Widget mainWidget)
Constructor

Parameters:
mainWidget - main widget on this container

ViewContainer

public ViewContainer(com.google.gwt.user.client.ui.Widget mainWidget,
                     boolean clearPanelsForDeactivatedViews)
Constructor

Parameters:
mainWidget - Main widget on this container
clearPanelsForDeactivatedViews - If true, makes the container clear the container panel for a view, when the view is deactivated.
Method Detail

add

public boolean add(View view)
Loads a new view into the container

Parameters:
view - View to be added
Returns:

addLazy

public boolean addLazy(View view)
Adds a new view into the container, but does not load the view.

Parameters:
view - View to be added
Returns:

clear

public void clear()
Remove all view inside this container


remove

public boolean remove(View view)
Remove the view from this container

Parameters:
view - View to be removed
Returns:

remove

public boolean remove(View view,
                      boolean skipEvents)
Remove the view from this container

Parameters:
view - View to be removed
skipEvents - skip the events fired during view removal
Returns:

showView

public void showView(String viewName)
Render the requested view into the container.

Parameters:
viewName - View name

showView

public void showView(String viewName,
                     String viewId)
Render the requested view into the container.

Parameters:
viewId - View identifier
viewId - View name

getView

public View getView(String viewId)
Retrieve the view associated to viewId

Parameters:
viewId - View identifier
Returns:
The view

getViewFactory

public static ViewFactory getViewFactory()
Retrieve the views factory associated with this screen.

Returns:

createView

public static void createView(String viewName,
                              ViewFactory.CreateCallback callback)
Creates the view referenced by the given name

Parameters:
viewName - View name
callback - Called when the view creation is completed.

createView

public static void createView(String viewName,
                              String viewId,
                              ViewFactory.CreateCallback callback)
Creates the view referenced by the given name and associate a custom identifier with the view created

Parameters:
viewName - View name
viewId - View identifier
callback - Called when the view creation is completed.

loadView

public void loadView(String viewName,
                     boolean render)
Loads a view into the current container

Parameters:
viewName - View name
render - If true also render the view

loadView

public void loadView(String viewName,
                     String viewId,
                     boolean render)
Loads a view into the current container

Parameters:
viewName - View name
viewId - View identifier
render - If true also render the view

loadView

protected void loadView(String viewName,
                        String viewId,
                        boolean render,
                        Object parameter)
Loads a view into the current container

Parameters:
viewName - View name
viewId - View identifier
parameter - A parameter passed that will be bound to the view load and activate events
render - If true also render the view

add

protected boolean add(View view,
                      boolean render,
                      Object parameter)
Loads a new view into the container

Parameters:
view - View to be added
render - If true, call the render method
parameter - A parameter passed that will be bound to the view load and activate events
Returns:
true if the view is loaded into the container

showView

protected void showView(String viewName,
                        String viewId,
                        Object parameter)
Render the requested view into the container.

Parameters:
viewId - View identifier
viewId - View name
parameter - to be passed to activate event

loadAndRenderView

protected void loadAndRenderView(String viewName,
                                 String viewId,
                                 Object parameter)

getMainWidget

protected <T extends com.google.gwt.user.client.ui.Widget> T getMainWidget()

bindToDOM

protected void bindToDOM()
This method must be called by subclasses when the container is attached to DOM


unbindToDOM

protected void unbindToDOM()
This method must be called by subclasses when the container is detached from DOM


activate

protected boolean activate(View view,
                           com.google.gwt.user.client.ui.Panel containerPanel,
                           Object parameter)
This method must be called by subclasses when any of your views is rendered.

Parameters:
view -
containerPanel -
parameter -

deactivate

protected boolean deactivate(View view,
                             com.google.gwt.user.client.ui.Panel containerPanel,
                             boolean skipEvent)
This method must be called by subclasses when any of your views currently rendered is removed from view.

Parameters:
view -
containerPanel -
skipEvent -
Returns:
True if view is deactivated

doAdd

protected boolean doAdd(View view,
                        boolean lazy,
                        Object parameter)
Loads a new view into the container

Parameters:
view - View to be added
Returns:

doRemove

protected boolean doRemove(View view,
                           boolean skipEvent)
Parameters:
view -
skipEvent -
Returns:

renderView

protected boolean renderView(View view,
                             Object parameter)
Render the view into the container

Parameters:
view -
parameter -

addView

protected boolean addView(View view,
                          boolean lazy,
                          Object parameter)
Parameters:
view -
lazy -
Returns:

adoptView

protected void adoptView(View view)
Parameters:
view -

hasResizeHandlers

protected abstract boolean hasResizeHandlers()

hasWindowCloseHandlers

protected abstract boolean hasWindowCloseHandlers()

hasWindowClosingHandlers

protected abstract boolean hasWindowClosingHandlers()

hasOrientationChangeHandlers

protected abstract boolean hasOrientationChangeHandlers()

hasHistoryHandlers

protected abstract boolean hasHistoryHandlers()

notifyViewsAboutWindowResize

protected abstract void notifyViewsAboutWindowResize(com.google.gwt.event.logical.shared.ResizeEvent event)

notifyViewsAboutWindowClose

protected abstract void notifyViewsAboutWindowClose(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.Window> event)

notifyViewsAboutWindowClosing

protected abstract void notifyViewsAboutWindowClosing(com.google.gwt.user.client.Window.ClosingEvent event)

notifyViewsAboutOrientationChange

protected abstract void notifyViewsAboutOrientationChange()

notifyViewsAboutHistoryChange

protected abstract void notifyViewsAboutHistoryChange(com.google.gwt.event.logical.shared.ValueChangeEvent<String> event)

getContainerPanel

protected abstract com.google.gwt.user.client.ui.Panel getContainerPanel(View view)

handleViewTitle

protected abstract void handleViewTitle(String title,
                                        com.google.gwt.user.client.ui.Panel containerPanel,
                                        String viewId)


Copyright © 2014. All rights reserved.