portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r881419 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java webapp/WEB-INF/view/toolbox/toolbox-portlets.jsp webapp/WEB-INF/view/toolbox/toolbox.jsp
Date Tue, 17 Nov 2009 18:08:40 GMT
Author: woonsan
Date: Tue Nov 17 18:08:40 2009
New Revision: 881419

URL: http://svn.apache.org/viewvc?rev=881419&view=rev
Log:
JS2-1057: Initial clean up for collaborative works.

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox-portlets.jsp
  (with props)
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java?rev=881419&r1=881418&r2=881419&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java
Tue Nov 17 18:08:40 2009
@@ -27,12 +27,11 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Random;
-import java.util.ResourceBundle;
-import java.util.Set;
 import java.util.StringTokenizer;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
+import javax.portlet.MimeResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
@@ -46,8 +45,6 @@
 import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.decoration.DecorationFactory;
-import org.apache.jetspeed.decoration.LayoutDecoration;
-import org.apache.jetspeed.decoration.Theme;
 import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.om.portlet.InitParam;
@@ -57,6 +54,7 @@
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.PageNotUpdatedException;
 import org.apache.jetspeed.page.document.NodeException;
+import org.apache.jetspeed.portlet.HeaderPhaseSupportConstants;
 import org.apache.jetspeed.portlets.PortletInfo;
 import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.request.RequestContext;
@@ -66,6 +64,7 @@
 import org.apache.portals.bridges.common.GenericServletPortlet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
 
 /**
  * Jetspeed Toolbox
@@ -84,6 +83,7 @@
     protected SecurityAccessController securityAccessController;
     protected DecorationFactory decorationFactory;    
     protected Random rand;
+    protected String yuiScriptPath = "/javascript/yui/build/yui/yui-min.js";
     
     public final String[] DEFAULT_IMAGES = new String[]
                                                       {
@@ -130,8 +130,28 @@
             throw new PortletException("Failed to find the Decoration Factory on portlet
initialization");
         }        
         rand = new Random( 19580427 );
+        
+        String param = config.getInitParameter("yuiScriptPath");
+        
+        if (param != null) {
+            yuiScriptPath = param;
+        }
     }
-
+    
+    @Override
+    protected void doHeaders(RenderRequest request, RenderResponse response) {
+        super.doHeaders(request, response);
+        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
+        Element headElem = response.createElement("script");
+        headElem.setAttribute("language", "javascript");
+        String scriptPath = rc.getRequest().getContextPath() + yuiScriptPath;
+        headElem.setAttribute("id", HeaderPhaseSupportConstants.HEAD_ELEMENT_CONTRIBUTION_ELEMENT_ID_YUI_LIBRARY_INCLUDE);
+        headElem.setAttribute("src", scriptPath);
+        headElem.setAttribute("type", "text/javascript");
+        response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, headElem);
+    }
+    
+    @Override
     @SuppressWarnings("unchecked")
     public void doView(RenderRequest request, RenderResponse response)
             throws PortletException, IOException
@@ -140,9 +160,13 @@
         String filter = request.getParameter("filter");
         if (filter == null ||  filter.equals("")) filter = null;       
         if (category == null || category.equals("")) category = "All";
-        RequestContext requestContext = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
           
+        RequestContext requestContext = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
+        
+        //TODO: The following two lines need to be move somewhere like 'serveResource()'
+        //      because portlets info should be retrieved from ajax calls.
         List<PortletInfo> portlets = retrievePortlets(request, null);
         request.setAttribute("portlets", portlets);
+        
         request.setAttribute("categories", retrieveCategories(request));
         request.setAttribute("layouts", LayoutBean.retrieveLayouts(request, decorationFactory));
         request.setAttribute("themes", ThemeBean.retrieveThemes(request, decorationFactory));
@@ -158,6 +182,7 @@
         super.doView(request, response);        
     }
     
+    @Override
     public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException,
     IOException
     {

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox-portlets.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox-portlets.jsp?rev=881419&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox-portlets.jsp
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox-portlets.jsp
Tue Nov 17 18:08:40 2009
@@ -0,0 +1,21 @@
+<%--
+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.
+
+--%>
+
+<%--
+portlet infos in json? or xml?
+--%>

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox-portlets.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox-portlets.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox-portlets.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp?rev=881419&r1=881418&r2=881419&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Tue Nov 17 18:08:40 2009
@@ -27,7 +27,7 @@
 <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c_rt"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
-<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
+<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
 
 <portlet:defineObjects/>
 <c_rt:set var="requestContext" value="<%=request.getAttribute(RequestContext.REQUEST_PORTALENV)%>"/>
@@ -54,6 +54,10 @@
         }
     }
 }
+function <portlet:namespace/>category_onchange(sel) {
+    var url = '<portlet:resourceURL id="/WEB-INF/view/toolbox/toolbox-portlets.jsp"/>';
+    // TODO: ajax call to retrieve portlets info
+}
 function <portlet:namespace/>toggleCategory(cat) {
     var div = document.getElementById('<portlet:namespace/>PortletsOf' + cat);
     if (div) {
@@ -87,66 +91,23 @@
             <input type="submit" value="search" />
         </td>
     </tr>
-
+    
     <tr>
         <td class="portlet-section-subheader" colspan='10'>
-            <div>
-                <a href="javascript:<portlet:namespace/>toggleCategory('All');">All</a>
-            </div>
-            <c:choose>
-              <c:when test="${fn:length(portlets) gt 10}">
-                <c:set var="divStyleHeight" value="height: 400px;"/>
-              </c:when>
-              <c:otherwise>
-                <c:set var="divStyleHeight" value=""/>
-              </c:otherwise>
-            </c:choose>
-            <div id="<portlet:namespace/>PortletsOfAll" style="${divStyleHeight}
overflow: auto;">
-                <table style="border-collapse: collapse; width: 100%; margin-top: 0px;
margin-bottom: 0px; float: left;">
-                    <c:forEach var="portletInfo" items="${portlets}">
-                        <tr>
-                            <td class="portlet-section-body" style='background: #fff'>
-                                <table style="border-collapse: collapse; width: 100%;
margin-top: 0px; margin-bottom: 0px; float: left;">
-	                                <tr>
-	                                   <td rowspan="2" width="20%" class="portlet-section-body">
-	                                       <img src='<c:url context="${portalContextPath}"
value="${portletInfo.image}"/>'/>
-	                                   </td>
-	                                   <td width="80%" class="portlet-section-body">${portletInfo.displayName}</td>
-	                                </tr>       
-	                                <tr>
-	                                   <td class="portlet-section-body">
-	                                       <a href="<portlet:actionURL><portlet:param
name='portletPreview' value='${portletInfo.name}'/></portlet:actionURL>">Preview</a>
-											<c:if test="${editAccess}">
-    	                                       <a href="<portlet:actionURL><portlet:param
name='portletAdd' value='${portletInfo.name}'/></portlet:actionURL>">Add</a>
-    	                                   </c:if>
-	                                   </td>
-	                                </tr>
-                                </table>
-                            </td>
-                        </tr>
-                    </c:forEach>
-                </table>
-            </div>
+            <select onchange="return <portlet:namespace/>category_onchange(this);">
+                <option value="">All categories</option>
+                <c:forEach var="category" items="${categories}">
+                    <option value="${category.name}">${category.name}</option>
+                </c:forEach>
+            </select>
         </td>
     </tr>
     
-    <c:forEach var="category" items="${categories}">
-		<tr>
-		    <td class="portlet-section-subheader" colspan='10'>
-		        <div>
-	    	        <a href="javascript:<portlet:namespace/>toggleCategory('${category.name}');">${category.name}</a>
-	    	    </div>
-	    	    <c:choose>
-	              <c:when test="${fn:length(category.portlets) gt 10}">
-	                <c:set var="divStyleHeight" value="height: 400px;"/>
-	              </c:when>
-	              <c:otherwise>
-	                <c:set var="divStyleHeight" value=""/>
-	              </c:otherwise>
-	            </c:choose>
-		        <div id="<portlet:namespace/>PortletsOf${category.name}" style="display:
none; ${divStyleHeight} overflow: auto;">
-		            <table style="border-collapse: collapse; width: 100%; margin-top: 0px; margin-bottom:
0px; float: left;">
-		                <c:forEach var="portletInfo" items="${category.portlets}">
+    <tr>
+        <td>
+            <div style="height: 400px; overflow: auto;">
+                <table style="border-collapse: collapse; width: 100%; margin-top: 0px;
margin-bottom: 0px; float: left;">
+                    <c:forEach var="portletInfo" items="${portlets}">
                         <tr>
                             <td class="portlet-section-body" style='background: #fff'>
                                 <table style="border-collapse: collapse; width: 100%;
margin-top: 0px; margin-bottom: 0px; float: left;">
@@ -155,24 +116,23 @@
                                            <img src='<c:url context="${portalContextPath}"
value="${portletInfo.image}"/>'/>
                                        </td>
                                        <td width="80%" class="portlet-section-body">${portletInfo.displayName}</td>
-                                    </tr>
+                                    </tr>       
                                     <tr>
                                        <td class="portlet-section-body">
                                            <a href="<portlet:actionURL><portlet:param
name='portletPreview' value='${portletInfo.name}'/></portlet:actionURL>">Preview</a>
-                                           <c:if test="${not empty renderRequest.userPrincipal}">
-	                                           <a href="<portlet:actionURL><portlet:param
name='portletAdd' value='${portletInfo.name}'/></portlet:actionURL>">Add</a>
-	                                       </c:if>
+                                            <c:if test="${editAccess}">
+                                               <a href="<portlet:actionURL><portlet:param
name='portletAdd' value='${portletInfo.name}'/></portlet:actionURL>">Add</a>
+                                           </c:if>
                                        </td>
                                     </tr>
                                 </table>
                             </td>
                         </tr>
-		                </c:forEach>
-		            </table>
-		        </div>
-		    </td>
-		</tr>
-    </c:forEach>
+                    </c:forEach>
+                </table>
+            </div>
+        </td>
+    </tr>
 
     <tr>
         <th class="portlet-section-header" colspan="2"></th>



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