org.apache.jetspeed.layout.impl
Class PortletPlacementContextImpl

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

public class PortletPlacementContextImpl
extends Object
implements org.apache.jetspeed.layout.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

Nested Class Summary
(package private)  class PortletPlacementContextImpl.FragmentLinkedListEntry
           
(package private)  class PortletPlacementContextImpl.FragmentLinkedListInfo
           
 
Field Summary
protected  ArrayList[] columnsList
           
protected static String eol
           
protected  Map fragmentCoordinateMap
           
protected  Map fragmentMap
           
protected  org.apache.jetspeed.om.page.Fragment layoutContainerFragment
           
private static org.apache.commons.logging.Log log
           
protected  int numberOfColumns
           
protected  org.apache.jetspeed.om.page.Page page
           
private  org.apache.jetspeed.components.portletregistry.PortletRegistry registry
           
 
Constructor Summary
PortletPlacementContextImpl(org.apache.jetspeed.om.page.Page page, org.apache.jetspeed.components.portletregistry.PortletRegistry registry)
           
PortletPlacementContextImpl(org.apache.jetspeed.om.page.Page page, org.apache.jetspeed.components.portletregistry.PortletRegistry registry, org.apache.jetspeed.om.page.Fragment container)
           
 
Method Summary
 org.apache.jetspeed.layout.Coordinate add(org.apache.jetspeed.om.page.Fragment fragment, org.apache.jetspeed.layout.Coordinate coordinate)
           
 org.apache.jetspeed.om.page.Fragment debugFragments(String debug)
           
 String dumpFragments(String debug)
           
static int getColumnCountAndSizes(org.apache.jetspeed.om.page.Fragment layoutFragment, org.apache.jetspeed.components.portletregistry.PortletRegistry registry, Map fragSizes)
           
static int getColumnCountAndSizes(org.apache.jetspeed.om.page.Fragment layoutFragment, org.apache.jetspeed.components.portletregistry.PortletRegistry registry, Map fragSizes, boolean suppressErrorLogging)
           
private  int getColumnFromFragment(org.apache.jetspeed.om.page.Fragment fragment)
           
 org.apache.jetspeed.om.page.Fragment getFragment(String fragmentId)
           
protected  org.apache.jetspeed.om.page.Fragment getFragmentAtCoordinate(org.apache.jetspeed.layout.Coordinate coordinate, boolean useOldCoordinateValues, boolean suppressExceptions)
           
 org.apache.jetspeed.om.page.Fragment getFragmentAtNewCoordinate(org.apache.jetspeed.layout.Coordinate coordinate)
           
 org.apache.jetspeed.om.page.Fragment getFragmentAtOldCoordinate(org.apache.jetspeed.layout.Coordinate coordinate)
           
 org.apache.jetspeed.om.page.Fragment getFragmentById(String fragmentId)
           
 int getFragmentCol(org.apache.jetspeed.om.page.Fragment fragment)
           
 int getFragmentRow(org.apache.jetspeed.om.page.Fragment fragment)
           
protected  int getLatestColumn(org.apache.jetspeed.layout.Coordinate coordinate)
           
protected  int getLatestRow(org.apache.jetspeed.layout.Coordinate coordinate)
           
 int getNumberColumns()
           
 int getNumberRows(int col)
           
private  Integer getRowFromFragment(org.apache.jetspeed.om.page.Fragment fragment)
           
protected  void init(org.apache.jetspeed.om.page.Fragment container)
           
private  void initProcessLayoutContainerFragment()
           
 org.apache.jetspeed.layout.Coordinate moveAbsolute(org.apache.jetspeed.om.page.Fragment fragment, org.apache.jetspeed.layout.Coordinate newCoordinate)
           
 org.apache.jetspeed.layout.Coordinate moveAbsolute(org.apache.jetspeed.om.page.Fragment fragment, org.apache.jetspeed.layout.Coordinate newCoordinate, boolean okToAddFragment)
           
protected  org.apache.jetspeed.layout.Coordinate moveDirection(org.apache.jetspeed.om.page.Fragment fragment, int deltaCol, int deltaRow)
           
 org.apache.jetspeed.layout.Coordinate moveDown(org.apache.jetspeed.om.page.Fragment fragment)
           
 org.apache.jetspeed.layout.Coordinate moveLeft(org.apache.jetspeed.om.page.Fragment fragment)
           
 org.apache.jetspeed.layout.Coordinate moveRight(org.apache.jetspeed.om.page.Fragment fragment)
           
 org.apache.jetspeed.layout.Coordinate moveUp(org.apache.jetspeed.om.page.Fragment fragment)
           
private  int normalizeColumnIndex(int col, ArrayList[] columnFragments, int defaultForUnspecifiedCol)
           
 org.apache.jetspeed.layout.Coordinate remove(org.apache.jetspeed.om.page.Fragment fragment)
           
protected  void syncFragments(boolean updateFragmentObjects, int onlyForColumnIndex)
           
 org.apache.jetspeed.om.page.Page syncPageFragments()
          Takes the internal portlet placement state and stores back out to fragment state
protected  org.apache.jetspeed.om.page.Fragment verifyFragmentAtExpectedCoordinate(int colIndex, int rowIndex, org.apache.jetspeed.om.page.Fragment fragment, String sourceDesc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

eol

protected static final String eol

columnsList

protected ArrayList[] columnsList

fragmentCoordinateMap

protected Map fragmentCoordinateMap

fragmentMap

protected Map fragmentMap

numberOfColumns

protected int numberOfColumns

page

protected org.apache.jetspeed.om.page.Page page

registry

private org.apache.jetspeed.components.portletregistry.PortletRegistry registry

layoutContainerFragment

protected org.apache.jetspeed.om.page.Fragment layoutContainerFragment
Constructor Detail

PortletPlacementContextImpl

public PortletPlacementContextImpl(org.apache.jetspeed.om.page.Page page,
                                   org.apache.jetspeed.components.portletregistry.PortletRegistry registry)
                            throws org.apache.jetspeed.layout.PortletPlacementException
Throws:
org.apache.jetspeed.layout.PortletPlacementException

PortletPlacementContextImpl

public PortletPlacementContextImpl(org.apache.jetspeed.om.page.Page page,
                                   org.apache.jetspeed.components.portletregistry.PortletRegistry registry,
                                   org.apache.jetspeed.om.page.Fragment container)
                            throws org.apache.jetspeed.layout.PortletPlacementException
Throws:
org.apache.jetspeed.layout.PortletPlacementException
Method Detail

init

protected void init(org.apache.jetspeed.om.page.Fragment container)
             throws org.apache.jetspeed.layout.PortletPlacementException
Throws:
org.apache.jetspeed.layout.PortletPlacementException

initProcessLayoutContainerFragment

private void initProcessLayoutContainerFragment()
                                         throws org.apache.jetspeed.layout.PortletPlacementException
Throws:
org.apache.jetspeed.layout.PortletPlacementException

getColumnFromFragment

private int getColumnFromFragment(org.apache.jetspeed.om.page.Fragment fragment)

getRowFromFragment

private Integer getRowFromFragment(org.apache.jetspeed.om.page.Fragment fragment)

normalizeColumnIndex

private int normalizeColumnIndex(int col,
                                 ArrayList[] columnFragments,
                                 int defaultForUnspecifiedCol)

dumpFragments

public String dumpFragments(String debug)

debugFragments

public org.apache.jetspeed.om.page.Fragment debugFragments(String debug)

syncPageFragments

public org.apache.jetspeed.om.page.Page syncPageFragments()
Takes the internal portlet placement state and stores back out to fragment state

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

getLatestColumn

protected int getLatestColumn(org.apache.jetspeed.layout.Coordinate coordinate)

getLatestRow

protected int getLatestRow(org.apache.jetspeed.layout.Coordinate coordinate)

syncFragments

protected void syncFragments(boolean updateFragmentObjects,
                             int onlyForColumnIndex)

getFragmentRow

public int getFragmentRow(org.apache.jetspeed.om.page.Fragment fragment)

getFragmentCol

public int getFragmentCol(org.apache.jetspeed.om.page.Fragment fragment)

getFragment

public org.apache.jetspeed.om.page.Fragment getFragment(String fragmentId)
                                                 throws org.apache.jetspeed.layout.PortletPlacementException
Throws:
org.apache.jetspeed.layout.PortletPlacementException

getFragmentAtOldCoordinate

public org.apache.jetspeed.om.page.Fragment getFragmentAtOldCoordinate(org.apache.jetspeed.layout.Coordinate coordinate)
                                                                throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
getFragmentAtOldCoordinate in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

getFragmentAtNewCoordinate

public org.apache.jetspeed.om.page.Fragment getFragmentAtNewCoordinate(org.apache.jetspeed.layout.Coordinate coordinate)
                                                                throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
getFragmentAtNewCoordinate in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

getFragmentAtCoordinate

protected org.apache.jetspeed.om.page.Fragment getFragmentAtCoordinate(org.apache.jetspeed.layout.Coordinate coordinate,
                                                                       boolean useOldCoordinateValues,
                                                                       boolean suppressExceptions)
                                                                throws org.apache.jetspeed.layout.PortletPlacementException
Throws:
org.apache.jetspeed.layout.PortletPlacementException

getFragmentById

public org.apache.jetspeed.om.page.Fragment getFragmentById(String fragmentId)
                                                     throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
getFragmentById in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

getNumberColumns

public int getNumberColumns()
                     throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
getNumberColumns in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

getNumberRows

public int getNumberRows(int col)
                  throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
getNumberRows in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

add

public org.apache.jetspeed.layout.Coordinate add(org.apache.jetspeed.om.page.Fragment fragment,
                                                 org.apache.jetspeed.layout.Coordinate coordinate)
                                          throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
add in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

moveAbsolute

public org.apache.jetspeed.layout.Coordinate moveAbsolute(org.apache.jetspeed.om.page.Fragment fragment,
                                                          org.apache.jetspeed.layout.Coordinate newCoordinate)
                                                   throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
moveAbsolute in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

moveAbsolute

public org.apache.jetspeed.layout.Coordinate moveAbsolute(org.apache.jetspeed.om.page.Fragment fragment,
                                                          org.apache.jetspeed.layout.Coordinate newCoordinate,
                                                          boolean okToAddFragment)
                                                   throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
moveAbsolute in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

moveDirection

protected org.apache.jetspeed.layout.Coordinate moveDirection(org.apache.jetspeed.om.page.Fragment fragment,
                                                              int deltaCol,
                                                              int deltaRow)
                                                       throws org.apache.jetspeed.layout.PortletPlacementException
Throws:
org.apache.jetspeed.layout.PortletPlacementException

moveDown

public org.apache.jetspeed.layout.Coordinate moveDown(org.apache.jetspeed.om.page.Fragment fragment)
                                               throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
moveDown in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

moveUp

public org.apache.jetspeed.layout.Coordinate moveUp(org.apache.jetspeed.om.page.Fragment fragment)
                                             throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
moveUp in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

moveLeft

public org.apache.jetspeed.layout.Coordinate moveLeft(org.apache.jetspeed.om.page.Fragment fragment)
                                               throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
moveLeft in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

moveRight

public org.apache.jetspeed.layout.Coordinate moveRight(org.apache.jetspeed.om.page.Fragment fragment)
                                                throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
moveRight in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

remove

public org.apache.jetspeed.layout.Coordinate remove(org.apache.jetspeed.om.page.Fragment fragment)
                                             throws org.apache.jetspeed.layout.PortletPlacementException
Specified by:
remove in interface org.apache.jetspeed.layout.PortletPlacementContext
Throws:
org.apache.jetspeed.layout.PortletPlacementException

verifyFragmentAtExpectedCoordinate

protected org.apache.jetspeed.om.page.Fragment verifyFragmentAtExpectedCoordinate(int colIndex,
                                                                                  int rowIndex,
                                                                                  org.apache.jetspeed.om.page.Fragment fragment,
                                                                                  String sourceDesc)
                                                                           throws org.apache.jetspeed.layout.PortletPlacementException
Throws:
org.apache.jetspeed.layout.PortletPlacementException

getColumnCountAndSizes

public static int getColumnCountAndSizes(org.apache.jetspeed.om.page.Fragment layoutFragment,
                                         org.apache.jetspeed.components.portletregistry.PortletRegistry registry,
                                         Map fragSizes)

getColumnCountAndSizes

public static int getColumnCountAndSizes(org.apache.jetspeed.om.page.Fragment layoutFragment,
                                         org.apache.jetspeed.components.portletregistry.PortletRegistry registry,
                                         Map fragSizes,
                                         boolean suppressErrorLogging)


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