portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r893685 - in /portals/jetspeed-2/portal/trunk: applications/jetspeed/src/main/webapp/WEB-INF/pages/default-page.psml components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java
Date Thu, 24 Dec 2009 02:39:18 GMT
Author: taylor
Date: Thu Dec 24 02:39:17 2009
New Revision: 893685

URL: http://svn.apache.org/viewvc?rev=893685&view=rev
Log:
bug fix. move portlets was kinda (sick) broken. This patch seems to get back to respectable
column up,down and cross moves. sorry charjie
we are running all the new rest actions without a single unit test safety net. maybe the portletplacement
was a fat beast, but at least it had unit tests....

Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/default-page.psml
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/PageLayoutService.java

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/default-page.psml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/default-page.psml?rev=893685&r1=893684&r2=893685&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/default-page.psml
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/default-page.psml
Thu Dec 24 02:39:17 2009
@@ -45,37 +45,36 @@
     <fragment id="dp-23" type="portlet" name="j2-admin::UserRegistrationPortlet">
       <property layout="TwoColumns" name="row" value="3" />
       <property layout="TwoColumns" name="column" value="1" />
-    </fragment>                                
+    </fragment>                                    
     <fragment-reference id="dp-24-wp-reference" refid="wp-definition">
         <property name="row" value="4"/>
         <property name="column" value="1"/>
-    </fragment-reference>
-    
+    </fragment-reference>       
     <fragment id="dp-7" type="portlet" name="demo::PickANumberPortlet" >
-      <property layout="TwoColumns" name="row" value="1" />
+      <property layout="TwoColumns" name="row" value="0" />
       <property layout="TwoColumns" name="column" value="0" />
     </fragment>        
     <fragment id="dp-16" type="portlet" name="demo::RoleSecurityTest">
-      <property layout="TwoColumns" name="row" value="2" />
+      <property layout="TwoColumns" name="row" value="1" />
       <property layout="TwoColumns" name="column" value="0" />
     </fragment>
     <fragment id="dp-9" type="portlet" name="webcontent::ReverseProxyIFramePortlet" decorator="gray-gradient-noborder">
-      <property layout="TwoColumns" name="row" value="3" />
+      <property layout="TwoColumns" name="row" value="2" />
       <property layout="TwoColumns" name="column" value="0" />
     </fragment>
     <fragment id="dp-10" type="portlet" name="webcontent::IFramePortlet" decorator="gray-gradient-noborder">
-      <property layout="TwoColumns" name="row" value="4" />
+      <property layout="TwoColumns" name="row" value="3" />
       <property layout="TwoColumns" name="column" value="0" />
       <preference name="SRC">
         <value>http://www.apache.org/</value>
       </preference>
     </fragment>
     <fragment id="dp-17" type="portlet" name="demo::UserInfoTest">
-      <property layout="TwoColumns" name="row" value="5" />
+      <property layout="TwoColumns" name="row" value="4" />
       <property layout="TwoColumns" name="column" value="0" />
     </fragment>
     <fragment id="dp-18" type="portlet" name="demo::BookmarkPortlet">
-      <property layout="TwoColumns" name="row" value="6" />
+      <property layout="TwoColumns" name="row" value="5" />
       <property layout="TwoColumns" name="column" value="0" />
     </fragment>
   </fragment>

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=893685&r1=893684&r2=893685&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
Thu Dec 24 02:39:17 2009
@@ -432,23 +432,39 @@
                         {
                             row = set.size();
                         }
-                        
+  
+                        int prevRow = contentFragment.getLayoutRow();
+                        boolean movingDown = (prevRow < row);
                         pageLayoutComponent.updateRowColumn(contentFragment, row, col);
-                        
-                        SortedSet<ContentFragment> tailSet = set.tailSet(contentFragment);
-                        
-                        for (ContentFragment f : tailSet)
+                        SortedSet<ContentFragment> sscf = this.getSortedChildFragmentSet(set,
movingDown, contentFragment);
+                        int rowCount = 0;
+                        for (ContentFragment f : sscf)
                         {
-                            if (!f.getId().equals(contentFragment.getId()))
+                            if (f != contentFragment)
                             {
-                                ++row;
-                                
-                                if (row != f.getLayoutRow())
-                                {
-                                    pageLayoutComponent.updateRowColumn(f, row, col);
-                                }
+                                if (rowCount != f.getLayoutRow())
+                                    pageLayoutComponent.updateRowColumn(f, rowCount, col);
                                   
                             }
+                            rowCount++;
+                            
                         }
+                        
+//                        pageLayoutComponent.updateRowColumn(contentFragment, row, col);
+                        
+//                        SortedSet<ContentFragment> tailSet = set.tailSet(contentFragment);
+//                        
+//                        for (ContentFragment f : tailSet)
+//                        {
+//                            if (!f.getId().equals(contentFragment.getId()))
+//                            {
+//                                ++row;
+//                                
+//                                if (row != f.getLayoutRow())
+//                                {
+//                                    pageLayoutComponent.updateRowColumn(f, row, col);
+//                                }
+//                            }
+//                        }
                     }
                 }
                 catch (Exception e)
@@ -719,5 +735,66 @@
             }
         }
     }
+
+    private class ExtendedContentFragmentRowComparator implements Comparator<ContentFragment>
+    {
+        private boolean movingDown;
+        private ContentFragment movingFragment;        
+        public ExtendedContentFragmentRowComparator(boolean movingDown, ContentFragment movingFragment)
+        {
+            this.movingDown = movingDown;
+            this.movingFragment = movingFragment;
+        }
+        public int compare(ContentFragment f1, ContentFragment f2)
+        {
+            int r1 = f1.getLayoutRow();
+            int r2 = f2.getLayoutRow();
+            
+            if (r1 == r2)
+            {
+                if (f1 == movingFragment)
+                {
+                    return (movingDown) ? 1: -1;
+                }
+                else if (f2 == movingFragment)
+                {
+                    return (movingDown) ? -1: 1;
+                }
+                return 0;
+            }
+            else if (r1 != -1 && r2 == -1)
+            {
+                return -1;
+            }
+            else if (r1 == -1 && r2 != -1)
+            {
+                return 1;
+            }
+            else if (r1 > r2)
+            {
+                return 1;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+    }
+
+    /**
+     * Returns child content fragment set array ordered by the column index from the layout
content fragment.
+     * @param layoutFragment
+     * @param columnCount
+     * @return
+     */
+    private SortedSet<ContentFragment> getSortedChildFragmentSet(SortedSet<ContentFragment>
layoutFragments, boolean movingDown, ContentFragment movedFragment)
+    {
+        SortedSet<ContentFragment> set = new TreeSet<ContentFragment>(new ExtendedContentFragmentRowComparator(movingDown,
movedFragment));
+        for (ContentFragment child : layoutFragments)
+        {
+            set.add(child);
+        }        
+        return set;
+    }
     
 }



---------------------------------------------------------------------
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