From portal-commits at lists.jboss.org Thu Jan 18 18:00:32 2007 Content-Type: multipart/mixed; boundary="===============4751036593433022286==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6040 - in trunk/core/src: resources/portal-core-war/WEB-INF/jsp/dashboard and 1 other directory. Date: Thu, 18 Jan 2007 18:00:29 -0500 Message-ID: --===============4751036593433022286== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/AddWindowCon= text.java trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/ContentEdito= r.java trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletConte= ntEditor.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/AddWindo= wContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowCo= ntext.java (rev 0) +++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowCo= ntext.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 Julien Viet + * @version $Revision: 1.1 $ + */ +public class AddWindowContext +{ + + /** . */ + private final Page page; + + /** . */ + private final String toRegion; + + public AddWindowContext(Page page, String toRegion) + { + this.page =3D page; + this.toRegion =3D toRegion; + } + + public Content createWindow(ContentType contentType) + { + try + { + String windowName =3D "" + doWindowNaming(); + while (page.getWindow(windowName) !=3D null) + { + windowName =3D "" + doWindowNaming(); + } + Window window =3D page.createWindow(windowName, ContentType.PORTL= ET); + window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toR= egion); + 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/Confi= gurator.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurato= r.java 2007-01-18 22:18:50 UTC (rev 6039) +++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurato= r.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 =3D actionRequest.getParameter("toRegion"); - String[] copyInstance =3D actionRequest.getParameterValues("avail= able_instances"); = - try - { - for (int i =3D 0; i < copyInstance.length; i++) - { - String windowName =3D "" + doWindowNaming(); - while (page.getWindow(windowName) !=3D null) - { - windowName =3D "" + doWindowNaming(); - } + AddWindowContext ctx =3D new AddWindowContext(page, toRegion); + PortletContentEditor editor =3D new PortletContentEditor(); + editor.add(actionRequest, ctx); = - // - Window window =3D page.createWindow(windowName, ContentType= .PORTLET); - window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGIO= N, toRegion); - window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER= , "" + Integer.MAX_VALUE); - - // - PortletContent content =3D (PortletContent)window.getConten= t(); - content.setInstanceRef(copyInstance[i]); - } - } - catch (Exception e) - { - errorMessage =3D "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 SortedSet>Map. */ private Map getWindows(Page page) throws Exception { Added: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/ContentE= ditor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/ContentEdit= or.java (rev 0) +++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/ContentEdit= or.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 Julien Viet + * @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/PortletC= ontentEditor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletCont= entEditor.java (rev 0) +++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletCont= entEditor.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 Julien Viet + * @version $Revision: 1.1 $ + */ +public class PortletContentEditor implements ContentEditor +{ + + public void show(RenderRequest req, PrintWriter writer) + { + List available_instances =3D (List)req.getAttribute("available_insta= nces"); + writer.println(""); + } + + public void add(ActionRequest req, AddWindowContext ctx) + { + String[] copyInstance =3D req.getParameterValues("available_instance= s"); + try + { + for (int i =3D 0; i < copyInstance.length; i++) + { + PortletContent content =3D (PortletContent)ctx.createWindow(Co= ntentType.PORTLET); + content.setInstanceRef(copyInstance[i]); + } + } + catch (Exception e) + { +// errorMessage =3D "Error adding window to region"; +// log.error(errorMessage, e); + } + } +} Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/ed= itpage.jsp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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=3D"java.util.TreeSet" %> <%@ page import=3D"org.jboss.portal.core.model.content.ContentType" %> <%@ page import=3D"org.jboss.portal.core.impl.model.content.portlet.Portle= tContent" %> +<%@ page import=3D"org.jboss.portal.core.portlet.dashboard.PortletContentE= ditor" %> +<%@ page import=3D"java.io.PrintWriter" %> <%@ page language=3D"java" extends=3D"org.jboss.portal.core.servlet.jsp.Po= rtalJsp" %> <%@ taglib uri=3D"http://java.sun.com/portlet" prefix=3D"portlet" %> <%@ taglib uri=3D"/WEB-INF/portal-lib.tld" prefix=3D"n" %> @@ -219,7 +221,12 @@ Avail= able Content
- +<% + PortletContentEditor editor =3D new PortletContentEditor(); + PrintWriter writer =3D new PrintWriter(out); + editor.show(renderRequest, writer); + writer.flush(); +%> --===============4751036593433022286==--