Author: julien(a)jboss.com
Date: 2007-01-18 18:00:28 -0500 (Thu, 18 Jan 2007)
New Revision: 6040
Added:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowContext.java
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/ContentEditor.java
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletContentEditor.java
Removed:
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/plugin/
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
started content editor plugin
Added: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowContext.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowContext.java 2007-01-18
23:00:28 UTC (rev 6040)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.portlet.dashboard;
+
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.theme.ThemeConstants;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AddWindowContext
+{
+
+ /** . */
+ private final Page page;
+
+ /** . */
+ private final String toRegion;
+
+ public AddWindowContext(Page page, String toRegion)
+ {
+ this.page = page;
+ this.toRegion = toRegion;
+ }
+
+ public Content createWindow(ContentType contentType)
+ {
+ try
+ {
+ String windowName = "" + doWindowNaming();
+ while (page.getWindow(windowName) != null)
+ {
+ windowName = "" + doWindowNaming();
+ }
+ Window window = page.createWindow(windowName, ContentType.PORTLET);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" +
Integer.MAX_VALUE);
+ return window.getContent();
+ }
+ catch (DuplicatePortalObjectException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private int doWindowNaming()
+ {
+ return (int)(100 * Math.random());
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2007-01-18
22:18:50 UTC (rev 6039)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2007-01-18
23:00:28 UTC (rev 6040)
@@ -30,8 +30,6 @@
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.impl.model.content.portlet.PortletContent;
-import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PortalTheme;
@@ -226,33 +224,11 @@
if ("copy".equals(op))
{
String toRegion = actionRequest.getParameter("toRegion");
- String[] copyInstance =
actionRequest.getParameterValues("available_instances");
- try
- {
- for (int i = 0; i < copyInstance.length; i++)
- {
- String windowName = "" + doWindowNaming();
- while (page.getWindow(windowName) != null)
- {
- windowName = "" + doWindowNaming();
- }
+ AddWindowContext ctx = new AddWindowContext(page, toRegion);
+ PortletContentEditor editor = new PortletContentEditor();
+ editor.add(actionRequest, ctx);
- //
- Window window = page.createWindow(windowName, ContentType.PORTLET);
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, ""
+ Integer.MAX_VALUE);
-
- //
- PortletContent content = (PortletContent)window.getContent();
- content.setInstanceRef(copyInstance[i]);
- }
- }
- catch (Exception e)
- {
- errorMessage = "Error adding window to region";
- log.error(errorMessage, e);
- }
actionResponse.setRenderParameter("editPageSelect", editPage);
}
else if ("remove".equals(op))
@@ -419,11 +395,6 @@
actionResponse.setRenderParameter("errorMsg", errorMessage);
}
- private int doWindowNaming()
- {
- return (int)(100 * Math.random());
- }
-
/** Returns a <Region,<Window>SortedSet>Map. */
private Map getWindows(Page page) throws Exception
{
Added: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/ContentEditor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/ContentEditor.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/ContentEditor.java 2007-01-18
23:00:28 UTC (rev 6040)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.portlet.dashboard;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.ActionRequest;
+import java.io.PrintWriter;
+
+/**
+ * Content editor plugin.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentEditor
+{
+ void show(RenderRequest req, PrintWriter writer);
+ void add(ActionRequest req, AddWindowContext ctx);
+}
Added:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletContentEditor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletContentEditor.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletContentEditor.java 2007-01-18
23:00:28 UTC (rev 6040)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.portlet.dashboard;
+
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.impl.model.content.portlet.PortletContent;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.ActionRequest;
+import java.util.List;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletContentEditor implements ContentEditor
+{
+
+ public void show(RenderRequest req, PrintWriter writer)
+ {
+ List available_instances =
(List)req.getAttribute("available_instances");
+ writer.println("<select name=\"available_instances\"
multiple=\"true\" size=\"20\">\n");
+ for (int i = 0; i < available_instances.size(); i++)
+ {
+ Instance instance = (Instance)available_instances.get(i);
+ writer.println("<option value=\"");
+ writer.println(instance.getId());
+ writer.println("\">");
+ writer.println(instance.getId());
+ writer.println("</option>\n");
+ }
+ writer.println("</select>");
+ }
+
+ public void add(ActionRequest req, AddWindowContext ctx)
+ {
+ String[] copyInstance = req.getParameterValues("available_instances");
+ try
+ {
+ for (int i = 0; i < copyInstance.length; i++)
+ {
+ PortletContent content =
(PortletContent)ctx.createWindow(ContentType.PORTLET);
+ content.setInstanceRef(copyInstance[i]);
+ }
+ }
+ catch (Exception e)
+ {
+// errorMessage = "Error adding window to region";
+// log.error(errorMessage, e);
+ }
+ }
+}
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2007-01-18
22:18:50 UTC (rev 6039)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2007-01-18
23:00:28 UTC (rev 6040)
@@ -9,6 +9,8 @@
<%@ page import="java.util.TreeSet" %>
<%@ page import="org.jboss.portal.core.model.content.ContentType" %>
<%@ page
import="org.jboss.portal.core.impl.model.content.portlet.PortletContent" %>
+<%@ page
import="org.jboss.portal.core.portlet.dashboard.PortletContentEditor" %>
+<%@ page import="java.io.PrintWriter" %>
<%@ page language="java"
extends="org.jboss.portal.core.servlet.jsp.PortalJsp" %>
<%@ taglib
uri="http://java.sun.com/portlet" prefix="portlet"
%>
<%@ taglib uri="/WEB-INF/portal-lib.tld" prefix="n" %>
@@ -219,7 +221,12 @@
</table>
</td>
<td class="portlet-section-body" valign="top"
align="right"><b>Available Content</b><br/>
- <jsp:include page="plugin/portlet/show.jsp"/>
+<%
+ PortletContentEditor editor = new PortletContentEditor();
+ PrintWriter writer = new PrintWriter(out);
+ editor.show(renderRequest, writer);
+ writer.flush();
+%>
</td>
<td>
<table>