portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r1089711 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/clone/ resources/org/apache/jetspeed/portlets/clone/ resources/org/apache/jetspeed/portlets/clone/resources/ webapp/WEB-INF/ webapp/WE...
Date Thu, 07 Apr 2011 02:36:58 GMT
Author: woonsan
Date: Thu Apr  7 02:36:57 2011
New Revision: 1089711

URL: http://svn.apache.org/viewvc?rev=1089711&view=rev
Log:
JS2-1247: Implementing portlet clone popup window UI

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/clone/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/clone/resources/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/clone/resources/PortletCloneManagerResources.properties
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java?rev=1089711&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java
Thu Apr  7 02:36:57 2011
@@ -0,0 +1,93 @@
+/*
+ * 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.clone;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+public class ClonePortletInfo implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+    
+    private String portletName;
+    private String portletDisplayName;
+    private String portletTitle;
+    private String portletShortTitle;
+    private String portletKeywords;
+    private Map<String, List<String>> portletPreferences;
+    
+    public String getPortletName()
+    {
+        return portletName;
+    }
+    
+    public void setPortletName(String portletName)
+    {
+        this.portletName = portletName;
+    }
+    
+    public String getPortletDisplayName()
+    {
+        return portletDisplayName;
+    }
+    
+    public void setPortletDisplayName(String portletDisplayName)
+    {
+        this.portletDisplayName = portletDisplayName;
+    }
+    
+    public String getPortletTitle()
+    {
+        return portletTitle;
+    }
+    
+    public void setPortletTitle(String portletTitle)
+    {
+        this.portletTitle = portletTitle;
+    }
+    
+    public String getPortletShortTitle()
+    {
+        return portletShortTitle;
+    }
+    
+    public void setPortletShortTitle(String portletShortTitle)
+    {
+        this.portletShortTitle = portletShortTitle;
+    }
+    
+    public String getPortletKeywords()
+    {
+        return portletKeywords;
+    }
+    
+    public void setPortletKeywords(String portletKeywords)
+    {
+        this.portletKeywords = portletKeywords;
+    }
+    
+    public Map<String, List<String>> getPortletPreferences()
+    {
+        return portletPreferences;
+    }
+    
+    public void setPortletPreferences(Map<String, List<String>> portletPreferences)
+    {
+        this.portletPreferences = portletPreferences;
+    }
+}

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java?rev=1089711&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
Thu Apr  7 02:36:57 2011
@@ -0,0 +1,153 @@
+/*
+ * 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.clone;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.Preference;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.portals.bridges.common.GenericServletPortlet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Portlet Clone Manager Portlet
+ * 
+ * @version $Id$
+ */
+public class PortletCloneManagerPortlet extends GenericServletPortlet
+{
+    private static Logger log = LoggerFactory.getLogger(PortletCloneManagerPortlet.class);
+    
+    private PortletRegistry registry;
+    
+    @Override
+    public void init(PortletConfig config) throws PortletException
+    {
+        super.init(config);
+        registry = (PortletRegistry) config.getPortletContext().getAttribute(CommonPortletServices.CPS_REGISTRY_COMPONENT);
+    }
+    
+    @Override
+    public void doView(RenderRequest request, RenderResponse response) throws PortletException,
IOException
+    {
+        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
+        String portletUniqueId = rc.getRequestParameter("portlet");
+        PortletDefinition def = null;
+        
+        if (!StringUtils.isBlank(portletUniqueId))
+        {
+            def = registry.getPortletDefinitionByUniqueName(portletUniqueId);
+        }
+        
+        if (def == null)
+        {
+            log.error("Cannot find the portlet or clone: {}", portletUniqueId);
+        }
+        else
+        {
+            ClonePortletInfo clonePortletInfo = new ClonePortletInfo();
+            clonePortletInfo.setPortletName(def.getPortletName());
+            clonePortletInfo.setPortletDisplayName(def.getDisplayNameText(Locale.getDefault()));
+            clonePortletInfo.setPortletTitle(def.getPortletInfo().getTitle());
+            clonePortletInfo.setPortletShortTitle(def.getPortletInfo().getShortTitle());
+            clonePortletInfo.setPortletKeywords(def.getPortletInfo().getKeywords());
+            Map<String, List<String>> prefsMap = new HashMap<String, List<String>>();
+            
+            for (Preference pref : def.getPortletPreferences().getPortletPreferences())
+            {
+                String prefName = pref.getName();
+                List<String> prefValues = new ArrayList<String>(pref.getValues());
+                prefsMap.put(prefName, prefValues);
+            }
+            
+            clonePortletInfo.setPortletPreferences(prefsMap);
+            request.setAttribute("clonePortletInfo", clonePortletInfo);
+        }
+        
+        super.doView(request, response);
+    }
+    
+    @Override
+    public void processAction(ActionRequest request, ActionResponse response) throws PortletException,
IOException
+    {
+        String action = request.getParameter("action");
+        
+        if ("clone".equals(action))
+        {
+            ClonePortletInfo clonePortletInfo = readClonePortletInfoFromRequest(request);
+        }
+    }
+    
+    private ClonePortletInfo readClonePortletInfoFromRequest(ActionRequest request)
+    {
+        ClonePortletInfo clonePortletInfo = new ClonePortletInfo();
+        clonePortletInfo.setPortletName(request.getParameter("portlet_name"));
+        clonePortletInfo.setPortletDisplayName(request.getParameter("portlet_displayName"));
+        clonePortletInfo.setPortletTitle(request.getParameter("portlet_title"));
+        clonePortletInfo.setPortletShortTitle(request.getParameter("portlet_shortTitle"));
+        clonePortletInfo.setPortletKeywords(request.getParameter("portlet_keywords"));
+        
+        Map<String, List<String>> prefsMap = new HashMap<String, List<String>>();
+        
+        for (Enumeration<String> paramNames = request.getParameterNames(); paramNames.hasMoreElements();
)
+        {
+            String paramName = paramNames.nextElement();
+            
+            if (paramName.startsWith("prefs_"))
+            {
+                String prefName = paramName.substring("prefs_".length());
+                String [] prefValues = request.getParameterValues(paramName);
+                List<String> prefValueList = null;
+                if (prefValues == null)
+                {
+                    prefValueList = Collections.emptyList();
+                }
+                else
+                {
+                    prefValueList = Arrays.asList(prefValues);
+                }
+                prefsMap.put(prefName, prefValueList);
+            }
+        }
+        
+        clonePortletInfo.setPortletPreferences(prefsMap);
+        
+        return clonePortletInfo;
+    }
+    
+}
+

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/clone/resources/PortletCloneManagerResources.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/clone/resources/PortletCloneManagerResources.properties?rev=1089711&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/clone/resources/PortletCloneManagerResources.properties
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/clone/resources/PortletCloneManagerResources.properties
Thu Apr  7 02:36:57 2011
@@ -0,0 +1,27 @@
+# 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.
+#
+# $Id: PortletCloneManagerResources.properties 1089286 2011-04-06 00:38:56Z woonsan $
+#
+
+portlet.clone.label.portlet_info=Portlet Information
+portlet.clone.label.name=Name
+portlet.clone.label.display_name=Display Name
+portlet.clone.label.preferences=Preferences
+portlet.clone.label.title=Title
+portlet.clone.label.short_title=Short Title
+portlet.clone.label.keywords=Keywords
+portlet.clone.label.action.clone = Clone
+portlet.clone.label.action.cancel = Cancel

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=1089711&r1=1089710&r2=1089711&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml Thu
Apr  7 02:36:57 2011
@@ -2705,7 +2705,7 @@
     <description>Create Portlet Clone</description>
     <portlet-name>PortletCloneManager</portlet-name>
     <display-name>Portlet Clone Manager</display-name>
-    <portlet-class>org.apache.portals.bridges.common.GenericServletPortlet</portlet-class>
+    <portlet-class>org.apache.jetspeed.portlets.clone.PortletCloneManagerPortlet</portlet-class>
     <init-param>
       <name>ViewPage</name>
       <value>/WEB-INF/view/prm/portlet-clone-manager-view.jsp</value>
@@ -2717,7 +2717,7 @@
     </supports>
     <supported-locale>en</supported-locale>
     <supported-locale>ja</supported-locale>
-    <resource-bundle>org.apache.jetspeed.portlets.prm.resources.PRMResources</resource-bundle>
+    <resource-bundle>org.apache.jetspeed.portlets.clone.resources.PortletCloneManagerResources</resource-bundle>
     <portlet-info>
       <title>Create Portlet Clone</title>
       <short-title>Portlet Clone Manager</short-title>

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp?rev=1089711&r1=1089710&r2=1089711&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp
Thu Apr  7 02:36:57 2011
@@ -23,8 +23,93 @@ limitations under the License.
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 <portlet:defineObjects/>
-<fmt:setBundle basename="org.apache.jetspeed.portlets.prm.resources.PRMResources" />
+<fmt:setBundle basename="org.apache.jetspeed.portlets.clone.resources.PortletCloneManagerResources"
/>
 
-<h2>Portlet Clone Manager</h2>
-<hr/>
-TODO
\ No newline at end of file
+<br/>
+
+<form method="POST" action="<portlet:actionURL/>">
+  <table cellpadding="0" cellspacing="1" border="0" width="100%">
+    <tbody>
+      <tr>
+        <td class="portlet-section-header" colspan="2">
+          <fmt:message key="portlet.clone.label.portlet_info"/>
+        </td>
+      </tr>
+      <tr>
+        <td class="portlet-section-alternate" width="20%" nowrap="true">
+          <fmt:message key="portlet.clone.label.name"/>
+        </td>
+        <td class="portlet-section-body">
+          <input type="text" name="portlet_name" size="40" value="<c:out value='${clonePortletInfo.portletName}'/>"/>
+        </td>
+      </tr>
+      <tr>
+        <td class="portlet-section-alternate" width="20%" nowrap="true">
+          <fmt:message key="portlet.clone.label.display_name"/>
+        </td>
+        <td class="portlet-section-body">
+          <input type="text" name="portlet_displayName" size="40" value="<c:out value='${clonePortletInfo.portletDisplayName}'/>"/>
+        </td>
+      </tr>
+      <tr>
+        <td class="portlet-section-alternate" width="20%" nowrap="true">
+          <fmt:message key="portlet.clone.label.title"/>
+        </td>
+        <td class="portlet-section-body">
+          <input type="text" name="portlet_title" size="40" value="<c:out value='${clonePortletInfo.portletTitle}'/>"/>
+        </td>
+      </tr>
+      <tr>
+        <td class="portlet-section-alternate" width="20%" nowrap="true">
+          <fmt:message key="portlet.clone.label.short_title"/>
+        </td>
+        <td class="portlet-section-body">
+          <input type="text" name="portlet_shortTitle" size="40" value="<c:out value='${clonePortletInfo.portletShortTitle}'/>"/>
+        </td>
+      </tr>
+      <tr>
+        <td class="portlet-section-alternate" width="20%" nowrap="true">
+          <fmt:message key="portlet.clone.label.keywords"/>
+        </td>
+        <td class="portlet-section-body">
+          <input type="text" name="portlet_keywords" size="40" value="<c:out value='${clonePortletInfo.portletKeywords}'/>"/>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+  <c:if test="${not empty clonePortletInfo.portletPreferences}">
+    <table cellpadding="0" cellspacing="1" border="0" width="100%">
+      <tbody>
+        <tr>
+          <td class="portlet-section-header" colspan="2">
+            <fmt:message key="portlet.clone.label.preferences"/>
+          </td>
+        </tr>
+        <c:forEach var="item" items="${clonePortletInfo.portletPreferences}">
+          <tr>
+            <td class="portlet-section-alternate" width="20%" nowrap="true">
+              <c:out value='${item.key}'/>
+            </td>
+            <td class="portlet-section-body">
+              <c:forEach var="valItem" items="${item.value}">
+                <input type="text" name="prefs_<c:out value='${item.key}'/>" size="40"
value="<c:out value='${valItem}'/>"/>
+              </c:forEach>
+            </td>
+          </tr>
+        </c:forEach>
+      </tbody>
+    </table>
+  </c:if>
+  <table cellpadding="0" cellspacing="1" border="0" width="100%">
+    <tbody>
+      <tr>
+        <th class="portlet-section-alternate" colspan="2">
+          <input type="submit" value="<fmt:message key='portlet.clone.label.action.clone'/>"
/>
+          <input type="hidden" name="action" value="clone" />
+        </th>
+      </tr>
+    </tbody>
+  </table>
+</form>
+
+<br/>



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