org.apache.jetspeed.layout.impl
Class PortletPlacementContextImpl

java.lang.Object
  extended by org.apache.jetspeed.layout.impl.PortletPlacementContextImpl
All Implemented Interfaces:
PortletPlacementContext

public class PortletPlacementContextImpl
extends java.lang.Object
implements PortletPlacementContext

Portal Placement Context The purpose of the object is to provide an API that can be used to move a portlet fragment on the page. This includes moving, adding, removing and getting information about portlets that are on the page and portlets that are available to be added to the page. This object represents the fragment contents of a single layout fragment (i.e. nested depth cannot be captured by this object). An important note about this object: This object is really only intended to be used to do a single operation such as "moveabs" or "add". After performing the operation, the hashmap data structures are not correct and should not be used for subsequent operations. The reason they are incorrect is that when a fragment is moved, the coordinate of fragments below it are now different. These could be updated, but it really doesn't serve a purpose since this is a short lived object.

Version:
$Id: $
Author:
David Gurney, David Sean Taylor, Steve Milek

Field Summary
protected  java.util.ArrayList[] columnsList
           
protected static java.lang.String eol
           
protected  java.util.Map fragmentCoordinateMap
           
protected  java.util.Map fragmentMap
           
protected  Fragment layoutContainerFragment
           
protected  int numberOfColumns
           
protected  Page page
           
 
Constructor Summary
PortletPlacementContextImpl(Page page, PortletRegistry registry)
           
PortletPlacementContextImpl(Page page, PortletRegistry registry, Fragment container)
           
 
Method Summary
 Coordinate add(Fragment fragment, Coordinate coordinate)
          Add a portlet to its managed page.
 Fragment debugFragments(java.lang.String debug)
           
 java.lang.String dumpFragments(java.lang.String debug)
           
static int getColumnCountAndSizes(Fragment layoutFragment, PortletRegistry registry, java.util.Map fragSizes)
           
static int getColumnCountAndSizes(Fragment layoutFragment, PortletRegistry registry, java.util.Map fragSizes, boolean suppressErrorLogging)
           
 Fragment getFragment(java.lang.String fragmentId)
           
protected  Fragment getFragmentAtCoordinate(Coordinate coordinate, boolean useOldCoordinateValues, boolean suppressExceptions)
           
 Fragment getFragmentAtNewCoordinate(Coordinate coordinate)
          Retrieve a portlet fragment for the given coordinate.
 Fragment getFragmentAtOldCoordinate(Coordinate coordinate)
          Retrieve the old portlet fragment for the given coordinate (prior to placement).
 Fragment getFragmentById(java.lang.String fragmentId)
          Retrieve a fragment by fragment id.
 int getFragmentCol(Fragment fragment)
           
 int getFragmentRow(Fragment fragment)
           
protected  int getLatestColumn(Coordinate coordinate)
           
protected  int getLatestRow(Coordinate coordinate)
           
 int getNumberColumns()
          retrieve the number of columns for the managed layout.
 int getNumberRows(int col)
          retrieve the number of rows for the managed layout at the given column.
protected  void init(Fragment container)
           
 Coordinate moveAbsolute(Fragment fragment, Coordinate newCoordinate)
          Move a portlet fragment to a new absolute position as specified in the Coordinate parameter.
 Coordinate moveAbsolute(Fragment fragment, Coordinate newCoordinate, boolean okToAddFragment)
          Move a portlet fragment to a new absolute position as specified in the Coordinate parameter.
protected  Coordinate moveDirection(Fragment fragment, int deltaCol, int deltaRow)
           
 Coordinate moveDown(Fragment fragment)
          Move a portlet relative to its current position DOWN one row.
 Coordinate moveLeft(Fragment fragment)
          Move a portlet relative to its current position LEFT one column.
 Coordinate moveRight(Fragment fragment)
          Move a portlet relative to its current position RIGHT one column.
 Coordinate moveUp(Fragment fragment)
          Move a portlet relative to its current position UP one row.
 Coordinate remove(Fragment fragment)
          Remove the specified fragment.
protected  void syncFragments(boolean updateFragmentObjects, int onlyForColumnIndex)
           
 Page syncPageFragments()
          Takes the internal portlet placement state and stores back out to fragment state
protected  Fragment verifyFragmentAtExpectedCoordinate(int colIndex, int rowIndex, Fragment fragment, java.lang.String sourceDesc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eol

protected static final java.lang.String eol

columnsList

protected java.util.ArrayList[] columnsList

fragmentCoordinateMap

protected java.util.Map fragmentCoordinateMap

fragmentMap

protected java.util.Map fragmentMap

numberOfColumns

protected int numberOfColumns

page

protected Page page

layoutContainerFragment

protected Fragment layoutContainerFragment
Constructor Detail

PortletPlacementContextImpl

public PortletPlacementContextImpl(Page page,
                                   PortletRegistry registry)
                            throws PortletPlacementException
Throws:
PortletPlacementException

PortletPlacementContextImpl

public PortletPlacementContextImpl(Page page,
                                   PortletRegistry registry,
                                   Fragment container)
                            throws PortletPlacementException
Throws:
PortletPlacementException
Method Detail

init

protected void init(Fragment container)
             throws PortletPlacementException
Throws:
PortletPlacementException

dumpFragments

public java.lang.String dumpFragments(java.lang.String debug)

debugFragments

public Fragment debugFragments(java.lang.String debug)

syncPageFragments

public Page syncPageFragments()
Takes the internal portlet placement state and stores back out to fragment state

Specified by:
syncPageFragments in interface PortletPlacementContext
Returns:
the managed page layout with updated fragment state.

getLatestColumn

protected int getLatestColumn(Coordinate coordinate)

getLatestRow

protected int getLatestRow(Coordinate coordinate)

syncFragments

protected void syncFragments(boolean updateFragmentObjects,
                             int onlyForColumnIndex)

getFragmentRow

public int getFragmentRow(Fragment fragment)

getFragmentCol

public int getFragmentCol(Fragment fragment)

getFragment

public Fragment getFragment(java.lang.String fragmentId)
                     throws PortletPlacementException
Throws:
PortletPlacementException

getFragmentAtOldCoordinate

public Fragment getFragmentAtOldCoordinate(Coordinate coordinate)
                                    throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Retrieve the old portlet fragment for the given coordinate (prior to placement).

Specified by:
getFragmentAtOldCoordinate in interface PortletPlacementContext
Parameters:
coordinate - the coordinate associated to a fragment.
Returns:
the fragment associated to the given coordinate
Throws:
PortletPlacementException

getFragmentAtNewCoordinate

public Fragment getFragmentAtNewCoordinate(Coordinate coordinate)
                                    throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Retrieve a portlet fragment for the given coordinate.

Specified by:
getFragmentAtNewCoordinate in interface PortletPlacementContext
Parameters:
coordinate - the coordinate associated to a fragment.
Returns:
the fragment associated to the given coordinate
Throws:
PortletPlacementException

getFragmentAtCoordinate

protected Fragment getFragmentAtCoordinate(Coordinate coordinate,
                                           boolean useOldCoordinateValues,
                                           boolean suppressExceptions)
                                    throws PortletPlacementException
Throws:
PortletPlacementException

getFragmentById

public Fragment getFragmentById(java.lang.String fragmentId)
                         throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Retrieve a fragment by fragment id.

Specified by:
getFragmentById in interface PortletPlacementContext
Parameters:
fragmentId - a string key for a fragment managed on this layout.
Returns:
The fragment associated with the given fragment id.
Throws:
PortletPlacementException

getNumberColumns

public int getNumberColumns()
                     throws PortletPlacementException
Description copied from interface: PortletPlacementContext
retrieve the number of columns for the managed layout.

Specified by:
getNumberColumns in interface PortletPlacementContext
Returns:
the number of columns in the manged layout
Throws:
PortletPlacementException

getNumberRows

public int getNumberRows(int col)
                  throws PortletPlacementException
Description copied from interface: PortletPlacementContext
retrieve the number of rows for the managed layout at the given column.

Specified by:
getNumberRows in interface PortletPlacementContext
Parameters:
col - the column to retrieve the number of rows for
Returns:
the number of rows for the given column
Throws:
PortletPlacementException

add

public Coordinate add(Fragment fragment,
                      Coordinate coordinate)
               throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Add a portlet to its managed page.

Specified by:
add in interface PortletPlacementContext
Parameters:
fragment - The Fragment to add
coordinate - The coordinate where to place the new portlet
Returns:
Throws:
PortletPlacementException

moveAbsolute

public Coordinate moveAbsolute(Fragment fragment,
                               Coordinate newCoordinate)
                        throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Move a portlet fragment to a new absolute position as specified in the Coordinate parameter.

Specified by:
moveAbsolute in interface PortletPlacementContext
Parameters:
fragment - The fragment to be moved.
newCoordinate - The specification of the new absolute coordinate
Returns:
new coordinate location of the portlet
Throws:
PortletPlacementException

moveAbsolute

public Coordinate moveAbsolute(Fragment fragment,
                               Coordinate newCoordinate,
                               boolean okToAddFragment)
                        throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Move a portlet fragment to a new absolute position as specified in the Coordinate parameter.

Specified by:
moveAbsolute in interface PortletPlacementContext
Parameters:
fragment - The fragment to be moved.
newCoordinate - The specification of the new absolute coordinate
okToAddFragment - When true, the fragment is being added (i.e. it is not being moved within the column)
Returns:
new coordinate location of the portlet
Throws:
PortletPlacementException

moveDirection

protected Coordinate moveDirection(Fragment fragment,
                                   int deltaCol,
                                   int deltaRow)
                            throws PortletPlacementException
Throws:
PortletPlacementException

moveDown

public Coordinate moveDown(Fragment fragment)
                    throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Move a portlet relative to its current position DOWN one row.

Specified by:
moveDown in interface PortletPlacementContext
Parameters:
fragment - The fragment to be moved.
Returns:
new coordinate location of the portlet
Throws:
PortletPlacementException

moveUp

public Coordinate moveUp(Fragment fragment)
                  throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Move a portlet relative to its current position UP one row.

Specified by:
moveUp in interface PortletPlacementContext
Parameters:
fragment - The fragment to be moved.
Returns:
new coordinate location of the portlet
Throws:
PortletPlacementException

moveLeft

public Coordinate moveLeft(Fragment fragment)
                    throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Move a portlet relative to its current position LEFT one column.

Specified by:
moveLeft in interface PortletPlacementContext
Parameters:
fragment - The fragment to be moved.
Returns:
new coordinate location of the portlet
Throws:
PortletPlacementException

moveRight

public Coordinate moveRight(Fragment fragment)
                     throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Move a portlet relative to its current position RIGHT one column.

Specified by:
moveRight in interface PortletPlacementContext
Parameters:
fragment - The fragment to be moved.
Returns:
new coordinate location of the portlet
Throws:
PortletPlacementException

remove

public Coordinate remove(Fragment fragment)
                  throws PortletPlacementException
Description copied from interface: PortletPlacementContext
Remove the specified fragment.

Specified by:
remove in interface PortletPlacementContext
Returns:
Throws:
PortletPlacementException

verifyFragmentAtExpectedCoordinate

protected Fragment verifyFragmentAtExpectedCoordinate(int colIndex,
                                                      int rowIndex,
                                                      Fragment fragment,
                                                      java.lang.String sourceDesc)
                                               throws PortletPlacementException
Throws:
PortletPlacementException

getColumnCountAndSizes

public static int getColumnCountAndSizes(Fragment layoutFragment,
                                         PortletRegistry registry,
                                         java.util.Map fragSizes)

getColumnCountAndSizes

public static int getColumnCountAndSizes(Fragment layoutFragment,
                                         PortletRegistry registry,
                                         java.util.Map fragSizes,
                                         boolean suppressErrorLogging)


Copyright © 1999-2009 Apache Software Foundation. All Rights Reserved.