svn commit: r1662795 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src: main/java/org/apache/jetspeed/portlets/layout/ main/java/org/apache/jetspeed/portlets/layout/responsive/ test/java/org/apache/jetspeed/portlets/layout/

[email protected]
Newsgroups gmane.comp.jakarta.jetspeed.devel
Message-ID <[email protected]>
Author: taylor
Date: Fri Feb 27 18:58:06 2015
New Revision: 1662795

URL: http://svn.apache.org/r1662795
Log:
JS2-1315: responsive layout server side implementation

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/responsive/
    portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/responsive/ResponsiveLayoutPortlet.java
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/test/java/org/apache/jetspeed/portlets/layout/TestColumnLayout.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java?rev=1662795&r1=1662794&r2=1662795&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java Fri Feb 27 18:58:06 2015
@@ -16,25 +16,10 @@
  */
 package org.apache.jetspeed.portlets.layout;
 
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-
 import org.apache.jetspeed.CommonPortletServices;
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.cache.JetspeedContentCache;
+import org.apache.jetspeed.container.PortletWindow;
 import org.apache.jetspeed.decoration.DecorationFactory;
 import org.apache.jetspeed.decoration.PageEditAccess;
 import org.apache.jetspeed.desktop.JetspeedDesktop;
@@ -47,11 +32,24 @@ import org.apache.jetspeed.page.FolderNo
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.document.NodeException;
 import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.container.PortletWindow;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
 /**
  */
 public class MultiColumnPortlet extends LayoutPortlet
@@ -66,11 +64,11 @@ public class MultiColumnPortlet extends
     protected final static String DEFAULT_TWO_COLUMN_SIZES = "50%,50%";
     protected final static String DEFAULT_THREE_COLUMN_SIZES = "34%,33%,33%";
 
-    private int numColumns = 0;
-    private String columnSizes = null;
-    private String portletName = null;
-    private String layoutType;
-    private String editorType = null;
+    protected int numColumns = 0;
+    protected String columnSizes = null;
+    protected String portletName = null;
+    protected String layoutType;
+    protected String editorType = null;
     protected DecorationFactory decorators;
     protected JetspeedDesktop desktop;
     protected JetspeedContentCache decoratorCache;
@@ -169,16 +167,7 @@ public class MultiColumnPortlet extends
         }
 
         // construct layout object
-        ColumnLayout layout;
-        try
-        {
-            layout = new ColumnLayout(numColumns, layoutType, f.getFragments(), fragmentColumnSizesArray);
-            layout.addLayoutEventListener(new PageLayoutEventListener(layoutType));
-        }
-        catch (LayoutEventException e1)
-        {
-            throw new PortletException("Failed to build ColumnLayout "+e1.getMessage(), e1);
-        }
+        ColumnLayout layout = constructColumnLayout(f, layoutType, fragmentColumnSizesArray);
 
         // invoke the JSP associated with this portlet
         request.setAttribute("columnLayout", layout);
@@ -696,5 +685,25 @@ public class MultiColumnPortlet extends
            Folder ff = (Folder) userFoldersIter.next();
            applyStyle(ff,theme,theme_type);
        }
-    }    
+    }
+
+    public ColumnLayout constructColumnLayout(ContentFragment f, String layout, String[] fragmentColumnSizesArray)
+            throws PortletException
+    {
+        try
+        {
+            ColumnLayout columnLayout = new ColumnLayout(getNumColumns(f), layoutType, f.getFragments(), fragmentColumnSizesArray);
+            columnLayout.addLayoutEventListener(new PageLayoutEventListener(layoutType));
+            return columnLayout;
+        }
+        catch (LayoutEventException e1)
+        {
+            throw new PortletException("Failed to build ColumnLayout "+e1.getMessage(), e1);
+        }
+    }
+
+    public int getNumColumns(ContentFragment fragment) {
+        return numColumns;
+    }
+
 }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/responsive/ResponsiveLayoutPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/responsive/ResponsiveLayoutPortlet.java?rev=1662795&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/responsive/ResponsiveLayoutPortlet.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/main/java/org/apache/jetspeed/portlets/layout/responsive/ResponsiveLayoutPortlet.java Fri Feb 27 18:58:06 2015
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portlets.layout.responsive;
+
+import org.apache.jetspeed.om.page.ContentFragment;
+import org.apache.jetspeed.portlets.layout.MultiColumnPortlet;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+
+public class ResponsiveLayoutPortlet extends MultiColumnPortlet {
+
+    public int getNumColumns(ContentFragment fragment) {
+        int columns = 0;
+        for (ContentFragment cf : fragment.getFragments()) {
+            String propertyValue = cf.getProperty(ContentFragment.COLUMN_PROPERTY_NAME);
+            if (propertyValue != null) {
+                int columnProperty = Integer.parseInt(propertyValue);
+                if (columnProperty > columns)
+                    columns = columnProperty;
+            }
+        }
+        return columns + 1;
+    }
+
+    public void init( PortletConfig config ) throws PortletException {
+        super.init(config);
+    }
+
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/test/java/org/apache/jetspeed/portlets/layout/TestColumnLayout.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/test/java/org/apache/jetspeed/portlets/layout/TestColumnLayout.java?rev=1662795&r1=1662794&r2=1662795&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/test/java/org/apache/jetspeed/portlets/layout/TestColumnLayout.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-layout-portlets/src/test/java/org/apache/jetspeed/portlets/layout/TestColumnLayout.java Fri Feb 27 18:58:06 2015
@@ -16,13 +16,13 @@
  */
 package org.apache.jetspeed.portlets.layout;
 
-import java.util.Iterator;
-
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.page.impl.ContentFragmentImpl;
 import org.jmock.Mock;
 import org.jmock.MockObjectTestCase;
 
+import java.util.Iterator;
+
 public class TestColumnLayout extends MockObjectTestCase
 {
     private static final String[] widths=new String[]{"25%", "50%", "25%"};
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.