Package org.apache.jetspeed.layout

Examples of org.apache.jetspeed.layout.PortletPlacementContext


       
        try
        {
            pageLayoutComponent.removeFragment(contentPage, fragmentId);
           
            PortletPlacementContext ppc = new PortletPlacementContextImpl(contentPage, portletRegistry, layoutFragment);
            // synchronize back to the page layout root fragment
            contentPage = ppc.syncPageFragments();
        }
        catch (Exception e)
        {
            throw new WebApplicationException(e);
        }
View Full Code Here


                {
                    throw new WebApplicationException(new IllegalArgumentException("Layout fragment not found for the fragment: " + fragmentId));
                }
            }
           
            PortletPlacementContext ppc = null;
           
            try
            {
                ppc = new PortletPlacementContextImpl(contentPage, portletRegistry, layoutFragment);
               
                if ("left".equals(direction))
                {
                    ppc.moveLeft(contentFragment);
                }
                else if ("right".equals(direction))
                {
                    ppc.moveRight(contentFragment);
                }
                else if ("up".equals(direction))
                {
                    ppc.moveUp(contentFragment);
                }
                else if ("down".equals(direction))
                {
                    ppc.moveDown(contentFragment);
                }
                else
                {
                    throw new WebApplicationException(new IllegalArgumentException("Invalid direction: " + direction));
                }
               
                // synchronize back to the page layout root fragment
                contentPage = ppc.syncPageFragments(PageLayoutComponent.USER_PROPERTY_SCOPE, null);
            }
            catch (PortletPlacementException e)
            {
                throw new WebApplicationException(e);
            }
        }
        else if (!StringUtils.isBlank(rowParam) && !StringUtils.isBlank(colParam))
        {
            int row = NumberUtils.toInt(rowParam, -1);
            int col = NumberUtils.toInt(colParam, -1);
            float posHeight = NumberUtils.toFloat(posHeightParam, -1.0f);
           
            if (row != -1 && col != -1 && (contentFragment.getLayoutRow() != row || contentFragment.getLayoutColumn() != col))
            {
                try
                {
                    ContentFragment layoutFragment = null;
                    boolean attach = false;
                    if (!StringUtils.isBlank(layoutFragmentId) && layoutFragmentId.equals("attach"))
                    {
                      layoutFragmentId = null;
                      attach = true;
                    }
                    if (!StringUtils.isBlank(layoutFragmentId))
                    {
                        layoutFragment = contentPage.getFragmentByFragmentId(layoutFragmentId);
                       
                        if (layoutFragment == null)
                        {
                            throw new WebApplicationException(new IllegalArgumentException("Layout fragment not found with the specified id: " + layoutFragmentId));
                        }
                    }
                    else
                    {
                        layoutFragment = getParentFragment(contentPage.getNonTemplateRootFragment(), fragmentId);
                       
                        if (layoutFragment == null)
                        {
                            throw new WebApplicationException(new IllegalArgumentException("Layout fragment not found for the fragment: " + fragmentId));
                        }
                    }
                   
                    PortletPlacementContext ppc = new PortletPlacementContextImpl(contentPage, portletRegistry, layoutFragment);
                    Coordinate coordinate = new CoordinateImpl(0, 0, col, row);
                    ppc.moveAbsolute(contentFragment, coordinate);
                   
                    if (posHeight != -1.0f)
                    {
                        pageLayoutComponent.updatePosition(contentFragment, -1.0f, -1.0f, -1.0f, -1.0f, posHeight, PageLayoutComponent.USER_PROPERTY_SCOPE, null);
                    }
                   
                    // synchronize back to the page layout root fragment
                    contentPage = ppc.syncPageFragments(PageLayoutComponent.USER_PROPERTY_SCOPE, null);
                    if (attach)
                      pageLayoutComponent.updateStateMode(contentFragment, JetspeedActions.NORMAL, null, PageLayoutComponent.USER_PROPERTY_SCOPE, null);                   
                }
                catch (Exception e)
                {
                    throw new WebApplicationException(e);
                }
            }
            else if (!StringUtils.isBlank(layoutFragmentId) && layoutFragmentId.equals("attach"))
            {
                pageLayoutComponent.updateStateMode(contentFragment, JetspeedActions.NORMAL, null, PageLayoutComponent.USER_PROPERTY_SCOPE, null);                   
            }           
        }
        else
        {
            float posX = NumberUtils.toFloat(posXParam, -1.0f);
            float posY = NumberUtils.toFloat(posYParam, -1.0f);
            float posZ = NumberUtils.toFloat(posZParam, -1.0f);
            float posWidth = NumberUtils.toFloat(posWidthParam, -1.0f);
            float posHeight = NumberUtils.toFloat(posHeightParam, -1.0f);
           
            try
            {
                pageLayoutComponent.updatePosition(contentFragment, posX, posY, posZ, posWidth, posHeight, PageLayoutComponent.USER_PROPERTY_SCOPE, null);
                pageLayoutComponent.updateStateMode(contentFragment, JetspeedActions.DETACH, null, PageLayoutComponent.USER_PROPERTY_SCOPE, null);
                if (layoutFragmentId != null && layoutFragmentId.equals("detach"))
                {
                    // first time detach, reallocate column and move it to the back
                    ContentFragment layoutFragment = getParentFragment(contentPage.getNonTemplateRootFragment(), fragmentId);                   
                    if (layoutFragment == null)
                    {
                        throw new WebApplicationException(new IllegalArgumentException("Layout fragment not found for the fragment: " + fragmentId));
                    }                   
                    PortletPlacementContext ppc = new PortletPlacementContextImpl(contentPage, portletRegistry, layoutFragment);
                    int col = contentFragment.getLayoutColumn();
                    int row = ppc.getNumberRows((col <= 0) ? 0 : col - 1);
                    Coordinate coordinate = new CoordinateImpl(col, contentFragment.getLayoutRow(), col, row);
                    ppc.moveAbsolute(contentFragment, coordinate);
                    contentPage = ppc.syncPageFragments(PageLayoutComponent.USER_PROPERTY_SCOPE, null);
                }
            }
            catch (Exception e)
            {
                throw new WebApplicationException(e);
View Full Code Here

                                               moveToLayoutFragment,
                                               currentLayoutFragment ) ;
            }
            else
            {
              PortletPlacementContext placement = null;
              ContentPage page = requestContext.getPage();
             
              if ( currentLayoutFragment == null )
                currentLayoutFragment = getParentFragmentById( moveFragmentId, page.getRootFragment() );
             
                if ( currentLayoutFragment != null )
                    placement = new PortletPlacementContextImpl( page, registry, currentLayoutFragment );
                else
                    placement = new PortletPlacementContextImpl( page, registry );
               
                ContentFragment fragment = placement.getFragmentById(moveFragmentId);
                if ( fragment == null )
                {
                    success = false;
                    resultMap.put( REASON, "Failed to find fragment for portlet id: " + moveFragmentId );
                    return success;
View Full Code Here

        boolean success = true;
        ContentFragment placeFragment = null;
        if ( removeFromLayoutFragment != null )
        {
          ContentPage page = requestContext.getPage();
            PortletPlacementContext placement = new PortletPlacementContextImpl( page, registry, removeFromLayoutFragment );
       
            placeFragment = placement.getFragmentById( moveFragmentId );
            if ( placeFragment == null )
            {
                success = false;
                resultMap.put( REASON, "Failed to find fragment to move to another layout for fragment id: " + moveFragmentId );
                return success;
            }
            placement.remove( placeFragment );
            page = placement.syncPageFragments();
           
            page.moveFragment(placeFragment.getId(), removeFromLayoutFragment.getId(), moveToLayoutFragment.getId());
        }
        if ( placeFragment != null )
        {
View Full Code Here

            return success;
        }
       
        // add fragment
        ContentPage page = requestContext.getPage();
        PortletPlacementContext placement = new PortletPlacementContextImpl( page, registry, placeInLayoutFragment, placeFragment );
       
        success = moveInFragment( requestContext, placement, placeFragment, true, resultMap, batch );

        return success;
    }
View Full Code Here

           
            // Use the Portlet Placement Manager to accomplish the removal
            ContentPage page = requestContext.getPage();
            ContentFragment root = page.getRootFragment();
            ContentFragment layoutContainerFragment = getParentFragmentById( portletId, root );
            PortletPlacementContext placement = null;
            ContentFragment fragment = null;
            if ( layoutContainerFragment != null )
            {
              placement = new PortletPlacementContextImpl( page, registry, layoutContainerFragment );
              fragment = placement.getFragmentById( portletId );
            }
            if ( fragment == null )
            {
                success = false;
                resultMap.put( REASON, "Fragment not found" );
                return success;               
            }
            placement.remove(fragment);
            page = placement.syncPageFragments();
            page.removeFragment( fragment.getId() );

            // Build the results for the response
            resultMap.put( PORTLETID, portletId );           
            resultMap.put( STATUS, status );
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.layout.PortletPlacementContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.