com.sencha.gxt.widget.core.client.container
Class PortalLayoutContainer

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.sencha.gxt.widget.core.client.Component
              extended by com.sencha.gxt.widget.core.client.container.Container
                  extended by com.sencha.gxt.widget.core.client.container.ResizeContainer
                      extended by com.sencha.gxt.widget.core.client.container.InsertResizeContainer
                          extended by com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer
                              extended by com.sencha.gxt.widget.core.client.container.PortalLayoutContainer
All Implemented Interfaces:
HasScrollHandlers, HasAttachHandlers, HasResizeHandlers, HasHandlers, EventListener, HasEnabled, HasVisibility, HasWidgets, HasWidgets.ForIsWidget, IndexedPanel, IndexedPanel.ForIsWidget, InsertPanel, InsertPanel.ForIsWidget, IsWidget, ProvidesResize, RequiresResize, HasScrollSupport, HasLayout, AddEvent.HasAddHandlers, BeforeAddEvent.HasBeforeAddHandlers, BeforeHideEvent.HasBeforeHideHandlers, BeforeRemoveEvent.HasBeforeRemoveHandlers, BeforeShowContextMenuEvent.HasBeforeShowContextMenuHandler, BeforeShowEvent.HasBeforeShowHandlers, BlurEvent.HasBlurHandlers, ContainerHandler.HasContainerHandlers, DisableEvent.HasDisableHandlers, EnableEvent.HasEnableHandlers, FocusEvent.HasFocusHandlers, HideEvent.HasHideHandlers, MoveEvent.HasMoveHandlers, PortalDropEvent.HasPortalDropHandlers, PortalValidateDropEvent.HasPortalValidateDropHandlers, RemoveEvent.HasRemoveHandlers, ShowContextMenuEvent.HasShowContextMenuHandler, ShowEvent.HasShowHandlers, HasFocusSupport, HasItemId, java.lang.Iterable<Widget>

public class PortalLayoutContainer
extends CssFloatLayoutContainer
implements PortalValidateDropEvent.HasPortalValidateDropHandlers, PortalDropEvent.HasPortalDropHandlers

A layout container that lays out its children in in multiple columns, each containing zero or more Portlets. Supports drag and drop of child Portlets between columns as well as modifying the order within columns.

PortalLayoutContainer internally creates a VerticalLayoutContainer for each column. The add, insert, remove methods work against these internal containers, getWidget(int) returns the internal containers. The portlets are children of the internal containers, not the portlet container itself.

Code Snippet:

  public void onModuleLoad() {
    PortalLayoutContainer c = new PortalLayoutContainer(3);
    c.add(createPortlet("Portlet 1", "Content 1"), 0);
    c.add(createPortlet("Portlet 2", "Content 2"), 1);
    c.add(createPortlet("Portlet 3", "Content 3"), 2);
    Viewport v = new Viewport();
    v.add(c);
    RootPanel.get().add(v);
  }

  private Portlet createPortlet(String h, String l) {
    Portlet p = new Portlet();
    p.setHeadingText(h);
    p.setWidget(new Label(l));
    p.setPixelSize(200, 200);
    return p;
  }
 


Nested Class Summary
static interface PortalLayoutContainer.PortalLayoutAppearance
           
 
Nested classes/interfaces inherited from class com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer
CssFloatLayoutContainer.CssFloatData, CssFloatLayoutContainer.CssFloatLayoutAppearance
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.InsertPanel
InsertPanel.ForIsWidget
 
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets
HasWidgets.ForIsWidget
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
PortalLayoutContainer(int numColumns)
          Creates a portal layout container with the default appearance and the specified number of columns.
PortalLayoutContainer(PortalLayoutContainer.PortalLayoutAppearance appearance, int numColumns)
          Creates a portal layout container with the specified appearance and number of columns.
 
Method Summary
 void add(IsWidget child)
          Adds a widget to this panel.
 void add(IsWidget w, int column)
          Adds a portlet to the portal.
 void add(Portlet portlet, int column)
          Adds a portlet to the portal.
 void add(Widget child)
          Adds the specified widget to the container.
 HandlerRegistration addDropHandler(PortalDropEvent.PortalDropHandler handler)
          Adds a PortalDropEvent.PortalDropHandler handler for PortalDropEvent events.
 HandlerRegistration addValidateDropHandler(PortalValidateDropEvent.PortalValidateDropHandler handler)
          Adds a PortalValidateDropEvent.PortalValidateDropHandler handler for PortalValidateDropEvent events.
 AutoScrollSupport getAutoScrollSupport()
          Returns the scroll support instance.
 int getColumnCount()
          Returns the number of columns.
 int getPortletColumn(Portlet portlet)
          Returns the column of the given porlet.
 int getPortletIndex(Portlet portlet)
          Returns the index of the column for the given portlet.
 int getSpacing()
          Returns the spacing between portlets.
 VerticalLayoutContainer getWidget(int index)
           
 void insert(IsWidget w, int beforeIndex)
           
 void insert(IsWidget w, int beforeIndex, CssFloatLayoutContainer.CssFloatData layoutData)
          Inserts the widget at the specified index in the CSS float layout container.
 void insert(IsWidget w, int index, int column)
          Inserts a portlet.
 void insert(Portlet portlet, int index, int column)
          Inserts a portlet.
 boolean isAutoScroll()
          Returns true if auto scroll is enabled (defaults to true).
 boolean remove(int index)
           
 boolean remove(IsWidget child)
           
 void remove(IsWidget w, int column)
          Removes a portlet from the portal.
 void remove(Portlet portlet, int column)
          Removes a portlet from the portal.
 void setAutoScroll(boolean autoScroll)
          True to automatically scroll the portal container when the user hovers over the top and bottom of the container (defaults to true).
 void setColumnWidth(int colIndex, double width)
          Sets the column's width.
 void setSpacing(int spacing)
          Sets the spacing between portlets (defaults to 10).
 
Methods inherited from class com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer
add, addScrollHandler, getScrollMode, getScrollSupport, getStyleFloat, isAdjustForScroll, setAdjustForScroll, setScrollMode, setScrollSupport, setStyleFloat
 
Methods inherited from class com.sencha.gxt.widget.core.client.container.InsertResizeContainer
insert
 
Methods inherited from class com.sencha.gxt.widget.core.client.container.ResizeContainer
forceLayout, isLayoutRunning, isOrWasLayoutRunning, onResize
 
Methods inherited from class com.sencha.gxt.widget.core.client.container.Container
addAddHandler, addBeforeAddHandler, addBeforeRemoveHandler, addContainerHandler, addRemoveHandler, clear, disable, enable, findWidget, getItemByItemId, getWidgetCount, getWidgetIndex, getWidgetIndex, iterator, remove
 
Methods inherited from class com.sencha.gxt.widget.core.client.Component
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleOnOver, clearSizeCache, disableEvents, enableEvents, fireEvent, focus, getData, getElement, getFocusSupport, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getShadow, getStateId, getToolTip, hide, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isRendered, isStateful, isVisible, isVisible, mask, mask, onBrowserEvent, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setPagePosition, setPixelSize, setPosition, setShadow, setSize, setStateful, setStateId, setTabIndex, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, getLayoutData, getParent, isAttached, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, removeStyleName, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, sinkBitlessEvent, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget
getWidgetIndex
 
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel
getWidgetCount, getWidgetIndex
 

Constructor Detail

PortalLayoutContainer

@UiConstructor
public PortalLayoutContainer(int numColumns)
Creates a portal layout container with the default appearance and the specified number of columns.

Parameters:
numColumns - the number of columns managed by this portal

PortalLayoutContainer

public PortalLayoutContainer(PortalLayoutContainer.PortalLayoutAppearance appearance,
                             int numColumns)
Creates a portal layout container with the specified appearance and number of columns.

Parameters:
appearance - the portal layout appearance
numColumns - the number of columns managed by this portal
Method Detail

add

public void add(IsWidget child)
Description copied from class: Container
Adds a widget to this panel.

Specified by:
add in interface HasWidgets.ForIsWidget
Specified by:
add in interface InsertPanel.ForIsWidget
Overrides:
add in class Container
Parameters:
child - the child widget to be added

add

public void add(IsWidget w,
                int column)
Adds a portlet to the portal.

Parameters:
w - the portlet
column - the column to add to

add

@UiChild(tagname="portlet")
public void add(Portlet portlet,
                               int column)
Adds a portlet to the portal.

Parameters:
portlet - the portlet to add
column - the column to add to

add

public void add(Widget child)
Description copied from class: Container
Adds the specified widget to the container.

If you override this method, please see Panel.add(Widget) for a number of things you must take into consideration.

Specified by:
add in interface HasWidgets
Specified by:
add in interface InsertPanel
Overrides:
add in class Container
Parameters:
child - the child widget to be added.

addDropHandler

public HandlerRegistration addDropHandler(PortalDropEvent.PortalDropHandler handler)
Description copied from interface: PortalDropEvent.HasPortalDropHandlers
Adds a PortalDropEvent.PortalDropHandler handler for PortalDropEvent events.

Specified by:
addDropHandler in interface PortalDropEvent.HasPortalDropHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

addValidateDropHandler

public HandlerRegistration addValidateDropHandler(PortalValidateDropEvent.PortalValidateDropHandler handler)
Description copied from interface: PortalValidateDropEvent.HasPortalValidateDropHandlers
Adds a PortalValidateDropEvent.PortalValidateDropHandler handler for PortalValidateDropEvent events.

Specified by:
addValidateDropHandler in interface PortalValidateDropEvent.HasPortalValidateDropHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

getAutoScrollSupport

public AutoScrollSupport getAutoScrollSupport()
Returns the scroll support instance.

Returns:
the scroll support

getColumnCount

public int getColumnCount()
Returns the number of columns.

Returns:
the number of columns

getPortletColumn

public int getPortletColumn(Portlet portlet)
Returns the column of the given porlet.

Parameters:
portlet - the portlet
Returns:
the column or -1 if not found

getPortletIndex

public int getPortletIndex(Portlet portlet)
Returns the index of the column for the given portlet.

Parameters:
portlet - the portlet
Returns:
the index or -1 if not found

getSpacing

public int getSpacing()
Returns the spacing between portlets.

Returns:
the spacing the spacing in pixels

getWidget

public VerticalLayoutContainer getWidget(int index)
Specified by:
getWidget in interface IndexedPanel
Overrides:
getWidget in class Container

insert

public void insert(IsWidget w,
                   int beforeIndex)
Specified by:
insert in interface InsertPanel.ForIsWidget
Overrides:
insert in class InsertResizeContainer

insert

public void insert(IsWidget w,
                   int beforeIndex,
                   CssFloatLayoutContainer.CssFloatData layoutData)
Description copied from class: CssFloatLayoutContainer
Inserts the widget at the specified index in the CSS float layout container.

Overrides:
insert in class CssFloatLayoutContainer
Parameters:
w - the widget to insert in the layout container
beforeIndex - the insert index
layoutData - the parameters that describe how to lay out the widget

insert

public void insert(IsWidget w,
                   int index,
                   int column)
Inserts a portlet.

Parameters:
w - the portlet to added
index - the insert index
column - the column to insert into

insert

public void insert(Portlet portlet,
                   int index,
                   int column)
Inserts a portlet.

Parameters:
portlet - the portlet to add
index - the insert index
column - the column to insert into

isAutoScroll

public boolean isAutoScroll()
Returns true if auto scroll is enabled (defaults to true).

Returns:
true if auto scroll enabled

remove

public boolean remove(int index)
Specified by:
remove in interface IndexedPanel
Overrides:
remove in class Container

remove

public boolean remove(IsWidget child)
Specified by:
remove in interface HasWidgets.ForIsWidget
Overrides:
remove in class Container

remove

public void remove(IsWidget w,
                   int column)
Removes a portlet from the portal.

Parameters:
w - the width
column - the column

remove

public void remove(Portlet portlet,
                   int column)
Removes a portlet from the portal.

Parameters:
portlet - the portlet to remove
column - the column

setAutoScroll

public void setAutoScroll(boolean autoScroll)
True to automatically scroll the portal container when the user hovers over the top and bottom of the container (defaults to true).

Parameters:
autoScroll - true to enable auto scroll
See Also:
AutoScrollSupport

setColumnWidth

public void setColumnWidth(int colIndex,
                           double width)
Sets the column's width.

Parameters:
colIndex - the column index
width - the column width

setSpacing

public void setSpacing(int spacing)
Sets the spacing between portlets (defaults to 10).

Parameters:
spacing - the spacing in pixels


Copyright © 2012. All Rights Reserved.