Package org.apache.jetspeed.layout.impl

Examples of org.apache.jetspeed.layout.impl.PortletPlacementContextImpl


        // Build a request object and populate it with fragments
        RequestContext requestContext = FragmentUtil.buildFullRequestContext();

        try
        {
            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);
            int a_iNumCols = ppc.getNumberColumns();
            assertEquals(a_iNumCols, 2);

            int a_iNumRows = ppc.getNumberRows(0);
            assertEquals(a_iNumRows, 2);

            a_iNumRows = ppc.getNumberRows(1);
            assertEquals(a_iNumRows, 3);

            // Check the fragments
            Fragment a_oFrag = ppc
                    .getFragmentAtNewCoordinate(new CoordinateImpl(0, 0, 0, 0));
            assertNotNull("null fragment found at 0,0", a_oFrag);
            assertEquals(a_oFrag.getId(), "1");
            assertEquals(a_oFrag.getName(), "frag1");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
                    0, 1));
            assertNotNull("null fragment found at 0,0", a_oFrag);
            assertEquals(a_oFrag.getId(), "2");
            assertEquals(a_oFrag.getName(), "frag2");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
                    1, 0));
            assertNotNull("null fragment found at 0,0", a_oFrag);
            assertEquals(a_oFrag.getId(), "3");
            assertEquals(a_oFrag.getName(), "frag3");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
                    1, 1));
            assertNotNull("null fragment found at 0,0", a_oFrag);
            assertEquals(a_oFrag.getId(), "4");
            assertEquals(a_oFrag.getName(), "frag4");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
                    1, 2));
            assertNotNull("null fragment found at 0,0", a_oFrag);
            assertEquals(a_oFrag.getId(), "5");
            assertEquals(a_oFrag.getName(), "frag5");
View Full Code Here


        // Build a request object and populate it with fragments
        RequestContext requestContext = FragmentUtil.buildFullRequestContext();

        try
        {
            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);

            // Check the fragments
            Fragment a_oFrag = ppc.getFragmentById("1");
            assertNotNull("null fragment with id 1", a_oFrag);
            assertEquals(a_oFrag.getId(), "1");
            assertEquals(a_oFrag.getName(), "frag1");

            a_oFrag = ppc.getFragmentById("2");
            assertNotNull("null fragment with id 2", a_oFrag);
            assertEquals(a_oFrag.getId(), "2");
            assertEquals(a_oFrag.getName(), "frag2");

            a_oFrag = ppc.getFragmentById("3");
            assertNotNull("null fragment with id 3", a_oFrag);
            assertEquals(a_oFrag.getId(), "3");
            assertEquals(a_oFrag.getName(), "frag3");

            a_oFrag = ppc.getFragmentById("4");
            assertNotNull("null fragment with id 4", a_oFrag);
            assertEquals(a_oFrag.getId(), "4");
            assertEquals(a_oFrag.getName(), "frag4");

            a_oFrag = ppc.getFragmentById("5");
            assertNotNull("null fragment with id 5", a_oFrag);
            assertEquals(a_oFrag.getId(), "5");
            assertEquals(a_oFrag.getName(), "frag5");

        } catch (PortletPlacementException e)
View Full Code Here

    {
        RequestContext requestContext = FragmentUtil.buildFullRequestContext();

        try
        {
            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);

            Fragment a_oFrag = ppc
                    .getFragmentAtNewCoordinate(new CoordinateImpl(0, 0, 0, 0));

            Coordinate a_oCoordinate = ppc.remove(a_oFrag);

            assertEquals(a_oCoordinate.getOldCol(), 0);
            assertEquals(a_oCoordinate.getOldRow(), 0);

            // Should be the second fragment now that the first has been deleted
            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
                    0, 0));
            assertEquals(a_oFrag.getId(), "2");
            assertEquals(a_oFrag.getName(), "frag2");
        } catch (PortletPlacementException e)
        {
View Full Code Here

    {
        RequestContext requestContext = FragmentUtil.buildFullRequestContext();

        try
        {
            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);

            Fragment a_oFrag = ppc
                    .getFragmentAtNewCoordinate(new CoordinateImpl(0, 0, 0, 0));

            Coordinate a_oCoordinate = ppc.moveAbsolute(a_oFrag, new CoordinateImpl(
                    0, 0, 0, 1));

            assertEquals(a_oCoordinate.getOldCol(), 0);
            assertEquals(a_oCoordinate.getOldRow(), 0);
            assertEquals(a_oCoordinate.getNewCol(), 0);
            assertEquals(a_oCoordinate.getNewRow(), 1);

            // Should be the second fragment now that the first has been moved
            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
                    0, 0));
            assertEquals(a_oFrag.getId(), "2");
            assertEquals(a_oFrag.getName(), "frag2");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
                    0, 1));
            assertEquals(a_oFrag.getId(), "1");
            assertEquals(a_oFrag.getName(), "frag1");
        } catch (PortletPlacementException e)
        {
View Full Code Here

    {
        RequestContext requestContext = FragmentUtil.buildFullRequestContext();

        try
        {
            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext);

            Fragment a_oFrag = ppc
                    .getFragmentAtNewCoordinate(new CoordinateImpl(0, 0, 0, 1));

            Coordinate a_oCoordinate = ppc.moveUp(a_oFrag);

            assertEquals(a_oCoordinate.getOldCol(), 0);
            assertEquals(a_oCoordinate.getOldRow(), 1);
            assertEquals(a_oCoordinate.getNewCol(), 0);
            assertEquals(a_oCoordinate.getNewRow(), 0);

            // Should be the second fragment since it was moved up
            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
                    0, 0));
            assertEquals(a_oFrag.getId(), "2");
            assertEquals(a_oFrag.getName(), "frag2");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 0,
                    0, 1));
            assertEquals(a_oFrag.getId(), "1");
            assertEquals(a_oFrag.getName(), "frag1");
        } catch (PortletPlacementException e)
        {
View Full Code Here

            if (layoutFragment == null)
            {
                layoutFragment = getParentFragment(contentPage.getNonTemplateRootFragment(), addedContentFragmentId);
            }
           
            PortletPlacementContext ppc = new PortletPlacementContextImpl(contentPage, portletRegistry, layoutFragment);
            // synchronize back to the page layout root fragment
            contentPage = ppc.syncPageFragments();
           
            return new ContentFragmentBean(contentFragment);
        }
        catch (Exception e)
        {
View Full Code Here

       
        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

           
            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

        // Build a request object and populate it with fragments
        RequestContext requestContext = FragmentUtil.buildFullRequestContext();

        try
        {
            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext.getPage(),portletRegistry);
            int a_iNumCols = ppc.getNumberColumns();
            assertEquals(a_iNumCols, 2);

            int a_iNumRows = ppc.getNumberRows(0);
            assertEquals(a_iNumRows, 2);

            a_iNumRows = ppc.getNumberRows(1);
            assertEquals(a_iNumRows, 3);

            // Check the fragments
            ContentFragment a_oFrag = ppc
                    .getFragmentAtNewCoordinate(new CoordinateImpl(0, 0, 0, 0));
            assertNotNull("null fragment found at 0,0", a_oFrag);
            assertEquals(a_oFrag.getId(), "1");
            assertEquals(a_oFrag.getName(), "frag1");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(0, 1,
                    0, 1));
            assertNotNull("null fragment found at 0,1", a_oFrag);
            assertEquals(a_oFrag.getId(), "2");
            assertEquals(a_oFrag.getName(), "frag2");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(1, 0,
                    1, 0));
            assertNotNull("null fragment found at 1,0", a_oFrag);
            assertEquals(a_oFrag.getId(), "3");
            assertEquals(a_oFrag.getName(), "frag3");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(1, 1,
                    1, 1));
            assertNotNull("null fragment found at 1,1", a_oFrag);
            assertEquals(a_oFrag.getId(), "4");
            assertEquals(a_oFrag.getName(), "frag4");

            a_oFrag = ppc.getFragmentAtNewCoordinate(new CoordinateImpl(1, 2,
                    1, 2));
            assertNotNull("null fragment found at 1,2", a_oFrag);
            assertEquals(a_oFrag.getId(), "5");
            assertEquals(a_oFrag.getName(), "frag5");
View Full Code Here

        // Build a request object and populate it with fragments
        RequestContext requestContext = FragmentUtil.buildFullRequestContext();

        try
        {
            PortletPlacementContext ppc = new PortletPlacementContextImpl(requestContext.getPage(),portletRegistry);

            // Check the fragments
            ContentFragment a_oFrag = ppc.getFragmentById("1");
            assertNotNull("null fragment with id 1", a_oFrag);
            assertEquals(a_oFrag.getId(), "1");
            assertEquals(a_oFrag.getName(), "frag1");

            a_oFrag = ppc.getFragmentById("2");
            assertNotNull("null fragment with id 2", a_oFrag);
            assertEquals(a_oFrag.getId(), "2");
            assertEquals(a_oFrag.getName(), "frag2");

            a_oFrag = ppc.getFragmentById("3");
            assertNotNull("null fragment with id 3", a_oFrag);
            assertEquals(a_oFrag.getId(), "3");
            assertEquals(a_oFrag.getName(), "frag3");

            a_oFrag = ppc.getFragmentById("4");
            assertNotNull("null fragment with id 4", a_oFrag);
            assertEquals(a_oFrag.getId(), "4");
            assertEquals(a_oFrag.getName(), "frag4");

            a_oFrag = ppc.getFragmentById("5");
            assertNotNull("null fragment with id 5", a_oFrag);
            assertEquals(a_oFrag.getId(), "5");
            assertEquals(a_oFrag.getName(), "frag5");

        } catch (PortletPlacementException e)
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.layout.impl.PortletPlacementContextImpl

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.