portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r895864 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src: main/java/org/apache/jetspeed/services/rest/PageLayoutService.java test/java/org/apache/jetspeed/services/rest/TestPageLayoutService.java
Date Tue, 05 Jan 2010 02:25:42 GMT
Author: taylor
Date: Tue Jan  5 02:25:37 2010
New Revision: 895864

URL: http://svn.apache.org/viewvc?rev=895864&view=rev
Log:
JS2-1084
on detach, reorganize existing grid-bound windows by shifting all portlets up and moving detached
to end of container

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/services/rest/TestPageLayoutService.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java?rev=895864&r1=895863&r2=895864&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
Tue Jan  5 02:25:37 2010
@@ -381,12 +381,23 @@
             
             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"))
                 {
-                    //pageLayoutComponent.moveFragment(contentPage, layoutFragmentId, fromFragmentId,
toFragmentId)
+                    // first time detach, reallocate column and move it to the back
+                    ContentFragment layoutFragment = getParentFragment(pageLayoutComponent.getUnlockedRootFragment(contentPage),
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);
                 }
-                pageLayoutComponent.updatePosition(contentFragment, posX, posY, posZ, posWidth,
posHeight, PageLayoutComponent.USER_PROPERTY_SCOPE, null);
-                pageLayoutComponent.updateStateMode(contentFragment, JetspeedActions.DETACH,
null, PageLayoutComponent.USER_PROPERTY_SCOPE, null);
             }
             catch (Exception e)
             {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/services/rest/TestPageLayoutService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/services/rest/TestPageLayoutService.java?rev=895864&r1=895863&r2=895864&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/services/rest/TestPageLayoutService.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/services/rest/TestPageLayoutService.java
Tue Jan  5 02:25:37 2010
@@ -24,6 +24,7 @@
 import javax.security.auth.Subject;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.components.ComponentManager;
 import org.apache.jetspeed.components.SpringComponentManager;
 import org.apache.jetspeed.components.factorybeans.ServletConfigFactoryBean;
@@ -31,6 +32,7 @@
 import org.apache.jetspeed.layout.PageLayoutComponent;
 import org.apache.jetspeed.layout.impl.LayoutValve;
 import org.apache.jetspeed.mocks.ResourceLocatingServletContext;
+import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.page.ContentPage;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.om.portlet.InitParam;
@@ -150,7 +152,8 @@
                     {
                         try
                         {
-                            executeGridMoves(request, rc);                 
+                            executeGridMoves(request, rc);     
+                            executeDetachedMoves(request, rc);
                             return null;
                         }
                         catch (Exception e)
@@ -165,9 +168,11 @@
     
     private void executeGridMoves(HttpServletRequest request, RequestContext rc) throws Exception
     {
-        Page grid = pageManager.getPage("grid.psml");
-        assertNotNull("default page not found", grid);
-        
+        Page src = pageManager.getPage("grid.psml");
+        assertNotNull("default page not found", src);
+        Page grid = pageManager.copyPage(src, "grid-1.psml", true);
+        pageManager.updatePage(grid);
+       
         ContentPage page = layoutManager.newContentPage(grid, null, null);
         rc.setPage(page);
         
@@ -195,6 +200,45 @@
         assertEquals(cfb.getId(), "dp-0.dp-02");
         assertEquals(cfb.getProperties().get("column"), "0");
         assertEquals(cfb.getProperties().get("row"), "2");
+        
+        pageManager.removePage(grid);
+    }
+
+    private void executeDetachedMoves(HttpServletRequest request, RequestContext rc) throws
Exception
+    {
+        Page src = pageManager.getPage("grid.psml");
+        assertNotNull("default page not found", src);
+        Page grid = pageManager.copyPage(src, "grid-2.psml", true);
+        pageManager.updatePage(grid);
+       
+        ContentPage page = layoutManager.newContentPage(grid, null, null);
+        rc.setPage(page);
+
+        ContentFragmentBean cfb = pageLayoutService.moveContentFragment(request, null, "dp-0.dp-10",
"detach", null, null, null, "491.0", "14.0", null, null, null);
+        assertEquals(cfb.getId(), "dp-0.dp-10");
+        assertEquals(cfb.getProperties().get("column"), "1");
+        assertEquals(cfb.getProperties().get("row"), "3");
+        assertEquals(cfb.getProperties().get("x"), "491.0");
+        assertEquals(cfb.getProperties().get("y"), "14.0");
+        assertEquals(cfb.getState(), JetspeedActions.DETACH);
+        ContentFragment dp10 = page.getFragmentByFragmentId("dp-10");
+        assertNotNull(dp10);
+        assertEquals(dp10.getLayoutRow(), 3);
+        assertEquals(dp10.getLayoutX(), (float)491.0);
+        assertEquals(dp10.getLayoutY(), (float)14.0);
+        assertEquals(dp10.getState(), JetspeedActions.DETACH);
+        // test shift up of all rows not detached
+        ContentFragment dp11 = page.getFragmentByFragmentId("dp-11");
+        assertNotNull(dp11);
+        assertEquals(dp11.getLayoutRow(), 0);
+        ContentFragment dp12 = page.getFragmentByFragmentId("dp-12");
+        assertNotNull(dp12);
+        assertEquals(dp12.getLayoutRow(), 1);
+        ContentFragment dp13 = page.getFragmentByFragmentId("dp-13");
+        assertNotNull(dp13);
+        assertEquals(dp13.getLayoutRow(), 2);
+        
+        pageManager.removePage(grid);        
     }
     
     private PortletRegistry createMockPortletRegistry()



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message