portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r831787 - in /portals/jetspeed-2/portal/trunk: applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/ applications/jetspeed/src/main/webapp/jetui/engine/ jetspeed-commons/src/main/java/org/apache/jetspeed/portlets/layout/
Date Mon, 02 Nov 2009 01:18:02 GMT
Author: taylor
Date: Mon Nov  2 01:18:02 2009
New Revision: 831787

URL: http://svn.apache.org/viewvc?rev=831787&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-1057
implementation of persistence of Move Absolute clientside logic in /ui pipeline. Webpage,
grid, non-nested PSML absolute move operations (only)
Refactored ColumnLayout to Java 5 to better communicate collection types

Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
    portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlets/layout/ColumnLayout.java

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp?rev=831787&r1=831786&r2=831787&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
Mon Nov  2 01:18:02 2009
@@ -24,6 +24,7 @@
 <%@ page import="org.apache.jetspeed.om.page.Page" %>
 <%@ page import="org.apache.jetspeed.om.page.ContentFragment" %>
 <%@ page import="org.apache.jetspeed.portlets.layout.ColumnLayout" %>
+<%@ page import="org.apache.jetspeed.portlets.layout.LayoutCoordinate" %>
 <%@ page import="org.apache.jetspeed.om.page.ContentFragment" %>
 <%@ page import="org.apache.jetspeed.decoration.DecoratorAction" %>
 <%@ page import="org.apache.jetspeed.PortalReservedParameters" %>
@@ -31,11 +32,12 @@
 	String content = (String)request.getAttribute("content");
 	String pageDec = (String)request.getAttribute("pageDec");
 	ContentFragment fragment = (ContentFragment)request.getAttribute("fragment");
+	LayoutCoordinate coordinate = (LayoutCoordinate)request.getAttribute("coordinate");
 	String title = "";
 	if (fragment.getPortletContent() != null)
 	    title = fragment.getPortletContent().getTitle();
 %>
-	<div class="portal-layout-cell" id="<%=fragment.getId()%>" name="<%=fragment.getName()%>">
+	<div class="portal-layout-cell" id="<%=fragment.getId()%>" name="<%=fragment.getName()%>"
column="<%=coordinate.getX()%>" row="<%=coordinate.getY()%>">
 		<div class="portlet <%=pageDec%>">
 		    <div class="PTitle" >
 	          <div class="PTitleContent"><%=title%></div>               

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp?rev=831787&r1=831786&r2=831787&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui.jsp
Mon Nov  2 01:18:02 2009
@@ -23,6 +23,7 @@
 <%@ page import="org.apache.jetspeed.request.RequestContext" %>
 <%@ page import="org.apache.jetspeed.om.page.Page" %>
 <%@ page import="org.apache.jetspeed.om.page.ContentFragment" %>
+<%@ page import="org.apache.jetspeed.om.page.Fragment" %>
 <%@ page import="org.apache.jetspeed.portlets.layout.ColumnLayout" %>
 <%@ page import="org.apache.jetspeed.om.page.ContentFragment" %>
 <%@ page import="org.apache.jetspeed.decoration.DecoratorAction" %>
@@ -115,28 +116,28 @@
 	else
 	{
 		int index = 0;
-		for (Object collections : columnLayout.getColumns())
+		for (Collection<Fragment> collections : columnLayout.getColumns())
 		{
 		    String columnFloat = columnLayout.getColumnFloat(index);
 		    String columnWidth = columnLayout.getColumnWidth(index);
 		// class="portal-layout-column portal-layout-column-${layoutType}-${columnIndex}"	    
   
 %>
 <div id="column_id_<%=index%>" 
-     class="portal-layout-column"
+     class="portal-layout-column" column='<%=index%>'
      style="float:<%=columnFloat%>; min-height: 100px; width:<%=columnWidth%>;
background-color: #ffffff;">
 
 <%	    
 			int subindex = 0;
-		    Collection<ContentFragment> columns = (Collection<ContentFragment>)collections;
-		    for (ContentFragment fragment : columns)
+		    for (Fragment fragment : collections)
 		    {
 		        if (!(fragment.getName().equals("j2-admin::JetspeedToolbox") || fragment.getName().equals("j2-admin::JetspeedNavigator")))
 		        {
 		    		//String content = jetui.renderPortletWindow(fragment.getId(), fragment.getName(),
rc);
-		    		String content = jetui.getRenderedContent(fragment, rc);
+		    		String content = jetui.getRenderedContent((ContentFragment)fragment, rc);
 		    		request.setAttribute("content", content);
 		    		request.setAttribute("pageDec", pageDec);
-		    		request.setAttribute("fragment", fragment);		    		
+		    		request.setAttribute("fragment", fragment);		 
+		    		request.setAttribute("coordinate", columnLayout.getCoordinate(fragment));
 %>
 <jsp:include page="jetui-portlet.jsp"/>
 <%	    	

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js?rev=831787&r1=831786&r2=831787&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/jetui/engine/portal.js
Mon Nov  2 01:18:02 2009
@@ -1,5 +1,5 @@
 //Use loader to grab the modules needed
-YUI(yuiConfig).use('console', 'dd', 'anim', 'io', 'cookie', 'json', 'node-base', function(Y)
{
+YUI(yuiConfig).use('console', 'dd', 'anim', 'io', 'datatype-xml', 'dataschema-xml', 'node-base',
function(Y) {
 	//new Y.Console().render(); 
     //Make this an Event Target so we can bubble to it
     var Portal = function() {
@@ -31,12 +31,15 @@
     	"name" : { value: "undefined" }, 
         "id" : { value: "0" },
         "toolbar" : { value : false },
-        "detached" : { value : false }
+        "detached" : { value : false },
+        "column" : { value : 0 },
+        "row" : { value : 0 }
     };
 	Portlet.prototype.info = function() {
 		Y.log("name: " + this.get("name"));
 		Y.log("id  : " + this.get("id"));		
 		Y.log("toolbar  : " + this.get("toolbar"));		
+		Y.log("col, row  : " + this.get("column") + "," + this.get("row"));		
 		Y.log("---------");
     };
 
@@ -55,12 +58,15 @@
     Layout.ATTRS = {
     	"name" : { value: "undefined" }, 
         "id" : { value: "0" },
-        "nested" : { value : false }
+        "nested" : { value : false },
+        "column" : { value : 0 },
+        "row" : { value : 0 }
     };
 	Layout.prototype.info = function() {
 		Y.log("name: " + this.get("name"));
 		Y.log("id  : " + this.get("id"));		
 		Y.log("nested  : " + this.get("nested"));		
+		Y.log("col, row  : " + this.get("column") + "," + this.get("row"));		
 		Y.log("---------");
     };
     
@@ -175,8 +181,9 @@
         portlet.set("id", v.getAttribute("id"));
         portlet.set("toolbar", false);
         portlet.set("detached", false);
+        portlet.set("column", v.getAttribute("column"));
+        portlet.set("row", v.getAttribute("row"));
         v.data = portlet;
-        //portlet.info();        
         var ddNav = new Y.DD.Drag({
             node: v,
             groups: ['portlets'],
@@ -189,6 +196,7 @@
             node: v,
             groups: ['portlets', 'toolbars']            
         });        
+    	//portlet.info();
     });
     
     var dropLayouts = Y.Node.all('.portal-layout-column');
@@ -197,6 +205,8 @@
         layout.set("name", v.getAttribute("name"));
         layout.set("id", v.getAttribute("id"));
         layout.set("nested", false);
+        layout.set("column", v.getAttribute("column"));        
+        layout.set("row", 0);
         v.data = layout;
         //layout.info();
         if (v.get('children').size() == 0)
@@ -208,11 +218,10 @@
         }
     });
 
-    var onComplete = function(id, o, args) { 
+    var onRemoveComplete = function(id, o, args) { 
     	var id = id; // Transaction ID. 
     	var data = o.responseText; // Response data. 
     	var widgetId = args[0];
-    	Y.log("widget removed = " + widgetId);
     	// now remove it from the dom
     	var widget = Y.one("#" + widgetId);
     	if (widget)
@@ -230,20 +239,19 @@
     	}
     };     
     
-    var onClickWindow = function(e) {
+    var onClickRemove = function(e) {
     	var uri = document.location.href;
     	uri = uri.replace("/ui", "/ajaxapi");
     	var windowId =  e.currentTarget.getAttribute('id');
     	windowId = windowId.replace("jetspeed-close-", "");
     	var uri = uri + "?action=remove&id=" + windowId;
-    	Y.log("delete uri = " + uri);    	
-        Y.on('io:complete', onComplete, this, [windowId]); 
+        Y.on('io:complete', onRemoveComplete, this, [windowId]); 
         var request = Y.io(uri); 
     };
-    
+
     var closeWindows = Y.Node.all('.portlet-action-close');    
     closeWindows.each(function(v, k) {
-        v.on('click', onClickWindow);
+        v.on('click', onClickRemove);
     });
         
     Portal.prototype.toggleToolbar = function(toolbar, toggler, compareStyle) {
@@ -261,11 +269,10 @@
         }	        
         toolbar.fx.set('reverse', !toolbar.fx.get('reverse')); // toggle reverse 
         toolbar.fx.run();
-	};
-	    
+	};	   
     
 	Y.DD.DDM.on('drag:drophit', function(e) {
-        var drop = e.drop.get('node'),
+		var drop = e.drop.get('node'),
             drag = e.drag.get('node');
         if (drag.data.get("toolbar"))
         {        	
@@ -294,6 +301,9 @@
 				}              				
             }
         }
+        else
+        {
+        }
     });
 	
     Portal.prototype.moveToLayout = function(e)
@@ -379,6 +389,17 @@
         }        
     };    
 
+    var onMoveComplete = function(id, o, args) { 
+    	var id = id; // Transaction ID. 
+    	var data = o.responseText; // Response data.
+    	Y.log("move result = " + data);
+    	var dataIn = Y.DataType.XML.parse(data),
+    		schema = {  resultListLocator: "status", resultFields: [{key:"status"}] },
+    		dataOut = Y.DataSchema.XML.apply(schema, dataIn);
+		Y.log("data = " + dataOut)                
+    	var widgetId = args[0];
+    };     
+    
     Y.DD.DDM.on('drag:end', function(e) {
         var drag = e.target;
         if (drag.target) {
@@ -399,8 +420,44 @@
         //drag.get('node').setStyle('border', '');                
         drag.get('node').removeClass('moving');
         drag.get('dragNode').set('innerHTML', '');
+
+        persistMove(drag.get('node'));
     });
     
+    var persistMove = function(drag) {
+        if (drag.data.get("toolbar") == false) {
+        	var uri = document.location.href;
+        	uri = uri.replace("/ui", "/ajaxapi");
+        	var windowId =  drag.getAttribute('id');
+        	var oldColumn = drag.data.get('column');
+        	var oldRow = drag.data.get('row');        	
+    		var dragParent = drag.get('parentNode');
+        	var parentColumn = dragParent.data.get('column');
+        	if (parentColumn != oldColumn)
+        	{
+        		reallocateColumn(oldColumn); // moved from different column
+        		drag.data.set('column', parentColumn);
+        	}
+        	reallocateColumn(parentColumn);
+        	var uri = uri + "?action=moveabs&id=" + windowId + "&col=" + drag.data.get('column')
+ "&row=" + drag.data.get('row');
+            Y.on('io:complete', onMoveComplete, this, [windowId]); 
+            var request = Y.io(uri);         	    	
+        }    	
+    };
+	var reallocateColumn = function(column) {
+	    var columns = Y.Node.all('.portal-layout-column');
+	    columns.each(function(v, k) {
+	    	if (v.data.get('column') == column)
+	    	{
+	    		var row = 0;
+    			v.get('children').each(function(v,k) {
+	    			v.data.set('row', row);
+	    			row++;
+	    		}, row);
+	    	}
+	    });
+	};    
+    
     Y.DD.DDM.on('drag:start', function(e) {
         var drag = e.target;
 //        if (drag.target) {

Modified: portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlets/layout/ColumnLayout.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlets/layout/ColumnLayout.java?rev=831787&r1=831786&r2=831787&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlets/layout/ColumnLayout.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlets/layout/ColumnLayout.java
Mon Nov  2 01:18:02 2009
@@ -69,6 +69,8 @@
  */
 public class ColumnLayout implements Serializable
 {
+    private static final long serialVersionUID = 1L;
+
     /** Percentage widths gutter width */
     private final static double PERCENTAGE_WIDTH_GUTTER = 0.01;
 
@@ -80,7 +82,7 @@
     private final int numberOfColumns;
     
     /** SortedMap of Columns (which are also sorted maps */
-    private final SortedMap columns;
+    private final SortedMap<Integer, SortedMap<Integer, Fragment>> columns;
     
     /** Width settings for eacah column */
     private final String[] columnWidths;
@@ -89,10 +91,10 @@
     private final int[] nextRowNumber;
     
     /** maps Fragments (key) to it's current LayoutCoordinate (value) in this layout */
-    private final Map coordinates;
+    private final Map<Fragment, LayoutCoordinate> coordinates;
     
     /** All of the LayoutEventListeners registered to this layout */
-    private final List eventListeners;
+    private final List<LayoutEventListener> eventListeners;
 
     /**
      * 
@@ -113,14 +115,14 @@
     {
         this.numberOfColumns = numberOfColumns;
         this.columnWidths = columnWidths;
-        eventListeners = new ArrayList();
+        eventListeners = new ArrayList<LayoutEventListener>();
 
-        columns = new TreeMap();
-        coordinates = new HashMap();
+        columns = new TreeMap<Integer, SortedMap<Integer, Fragment>>();
+        coordinates = new HashMap<Fragment, LayoutCoordinate>();
 
         for (int i = 0; i < numberOfColumns; i++)
         {
-            columns.put(new Integer(i), new TreeMap());
+            columns.put(new Integer(i), new TreeMap<Integer, Fragment>());
         }
 
         nextRowNumber = new int[numberOfColumns];
@@ -152,10 +154,10 @@
      *            are used.
      * @throws LayoutEventException
      */
-    public ColumnLayout(int numberOfColumns, String layoutType, Collection fragments, String[]
columnWidths) throws LayoutEventException
+    public ColumnLayout(int numberOfColumns, String layoutType, Collection<Fragment>
fragments, String[] columnWidths) throws LayoutEventException
     {
         this(numberOfColumns, layoutType, columnWidths);
-        Iterator fragmentsItr = fragments.iterator();
+        Iterator<Fragment> fragmentsItr = fragments.iterator();
         try
         {
             while (fragmentsItr.hasNext())
@@ -238,7 +240,7 @@
      * @throws InvalidLayoutLocationException
      *             if the column is outisde of the constraints of this layout
      */
-    public Collection getColumn(int columnNumber) throws InvalidLayoutLocationException
+    public Collection<Fragment> getColumn(int columnNumber) throws InvalidLayoutLocationException
     {
         return Collections.unmodifiableCollection(getColumnMap(columnNumber).values());
     }
@@ -312,15 +314,13 @@
      *         Collection objects) in order within this layout. All Collections
      *         are immutable.
      */
-    public Collection getColumns()
+    public Collection<Collection<Fragment>> getColumns()
     {
-        ArrayList columnList = new ArrayList(getNumberOfColumns());
-        Iterator itr = columns.values().iterator();
-        while (itr.hasNext())
+        ArrayList<Collection<Fragment>> columnList = new ArrayList<Collection<Fragment>>(getNumberOfColumns());
+        for (SortedMap<Integer, Fragment> map : columns.values())
         {
-            columnList.add(Collections.unmodifiableCollection(((Map) itr.next()).values()));
+            columnList.add(Collections.unmodifiableCollection(map.values()));
         }
-
         return Collections.unmodifiableCollection(columnList);
     }
     
@@ -342,7 +342,7 @@
      * this ColumnLayout in no sepcific order.
      * @return Immutable Collection of Fragments.
      */
-    public Collection getFragments()
+    public Collection<Fragment> getFragments()
     {
         return Collections.unmodifiableCollection(coordinates.keySet());
     }
@@ -360,7 +360,7 @@
     public Fragment getFragmentAt(int columnNumber, int rowNumber) throws EmptyLayoutLocationException,
             InvalidLayoutLocationException
     {
-        SortedMap column = getColumnMap(columnNumber);
+        SortedMap<Integer, Fragment> column = getColumnMap(columnNumber);
         Integer rowInteger = new Integer(rowNumber);
         if (column.containsKey(rowInteger))
         {
@@ -404,7 +404,7 @@
      * 
      * @return The last column in this layout.  The Collection is immutable.
      */
-    public Collection getLastColumn() 
+    public Collection<Fragment> getLastColumn() 
     {
         try
         {
@@ -422,7 +422,7 @@
      * 
      * @return The last column in this layout.  The Collection is immutable.
      */
-    public Collection getFirstColumn()
+    public Collection<Fragment> getFirstColumn()
     {
         try
         {
@@ -646,7 +646,7 @@
     protected void doMove(Fragment fragment, LayoutCoordinate oldCoordinate, LayoutCoordinate
newCoordinate)
             throws InvalidLayoutLocationException, LayoutEventException
     {
-        SortedMap oldColumn = getColumnMap(oldCoordinate.getX());
+        SortedMap<Integer, Fragment> oldColumn = getColumnMap(oldCoordinate.getX());
         oldColumn.remove(new Integer(oldCoordinate.getY()));
         coordinates.remove(fragment);
 
@@ -686,7 +686,7 @@
      */
     protected void doAdd(int columnNumber, int rowNumber, Fragment fragment) throws InvalidLayoutLocationException,
LayoutEventException
     {
-        SortedMap column = getColumnMap(columnNumber);
+        SortedMap<Integer, Fragment> column = getColumnMap(columnNumber);
     
         Integer rowInteger = new Integer(rowNumber);
         LayoutCoordinate targetCoordinate = new LayoutCoordinate(columnNumber, rowNumber);
@@ -719,17 +719,17 @@
      * SortedMap.
      * 
      * @param columnNumber
-     * @return
+     * @return SortedMap<Integer, Fragment>
      * @throws InvalidLayoutLocationException if the <code>columnNumber</code>
resides
      * outside the bounds of this layout.
      */
-    protected final SortedMap getColumnMap(int columnNumber) throws InvalidLayoutLocationException
+    protected final SortedMap<Integer, Fragment> getColumnMap(int columnNumber) throws
InvalidLayoutLocationException
     {
-        Integer columnNumberIneteger = new Integer(columnNumber);
+        Integer columnNumberInteger = new Integer(columnNumber);
 
-        if (columns.containsKey(columnNumberIneteger))
+        if (columns.containsKey(columnNumberInteger))
         {
-            return ((SortedMap) columns.get(columnNumberIneteger));
+            return columns.get(columnNumberInteger);
         }
         else
         {
@@ -807,10 +807,8 @@
      */
     protected final void processEvent(LayoutEvent event) throws LayoutEventException
     {
-        Iterator itr = eventListeners.iterator();
-        while(itr.hasNext())
+        for (LayoutEventListener eventListener : eventListeners)
         {
-            LayoutEventListener eventListener = (LayoutEventListener) itr.next();
             eventListener.handleEvent(event);
         }
         



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