Author: julien(a)jboss.com
Date: 2007-01-20 20:18:15 -0500 (Sat, 20 Jan 2007)
New Revision: 6058
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/editor/CMSContentEditor.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowContext.java
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletContentEditor.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
- basic content editor for cms and dashboard is done
- added a couple of argument checks in the portal object impl
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-01-20
14:59:28 UTC (rev 6057)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-01-21
01:18:15 UTC (rev 6058)
@@ -110,7 +110,14 @@
this.object = object;
}
- /** Create the association. */
+ /**
+ * Create and persist the provided child object. The object also becomes of child of
this node.
+ *
+ * @param name the child name
+ * @param childObject the child object
+ * @throws DuplicatePortalObjectException if a child with such a name already exists
+ * @throws IllegalArgumentException if the name is null or zero length or the child
object is null
+ */
void addChild(String name, PortalObjectImpl childObject) throws
DuplicatePortalObjectException, IllegalArgumentException
{
if (name == null)
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-01-20
14:59:28 UTC (rev 6057)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-01-21
01:18:15 UTC (rev 6058)
@@ -58,11 +58,23 @@
this.contentType = null;
}
- public WindowImpl(ContentType contentType)
+ /**
+ * Creates a new window.
+ *
+ * @param contentType the window content type
+ * @throws IllegalArgumentException if the content type is null
+ */
+ public WindowImpl(ContentType contentType) throws IllegalArgumentException
{
super(false);
//
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException("No null content type accepted");
+ }
+
+ //
this.instanceRef = null;
this.contentType = contentType;
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowContext.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowContext.java 2007-01-20
14:59:28 UTC (rev 6057)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/AddWindowContext.java 2007-01-21
01:18:15 UTC (rev 6058)
@@ -57,7 +57,7 @@
{
windowName = "" + doWindowNaming();
}
- Window window = page.createWindow(windowName, ContentType.PORTLET);
+ Window window = page.createWindow(windowName, contentType);
window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" +
Integer.MAX_VALUE);
return window.getContent();
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-20
14:59:28 UTC (rev 6057)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2007-01-21
01:18:15 UTC (rev 6058)
@@ -219,11 +219,18 @@
if ("copy".equals(op))
{
String toRegion = actionRequest.getParameter("toRegion");
-
- AddWindowContext ctx = new AddWindowContext(page, toRegion);
- ContentEditor editor = contentEditorRegistry.getEditor(ContentType.PORTLET);
- editor.add(actionRequest, ctx);
-
+ String contentType = actionRequest.getParameter("contentType");
+ ContentEditor editor = null;
+ if (contentType != null)
+ {
+ ContentType ct = ContentType.create(contentType);
+ editor = contentEditorRegistry.getEditor(ct);
+ }
+ if (editor != null)
+ {
+ AddWindowContext ctx = new AddWindowContext(page, toRegion);
+ editor.add(actionRequest, ctx);
+ }
actionResponse.setRenderParameter("editPageSelect", editPage);
}
else if ("remove".equals(op))
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletContentEditor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletContentEditor.java 2007-01-20
14:59:28 UTC (rev 6057)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/PortletContentEditor.java 2007-01-21
01:18:15 UTC (rev 6058)
@@ -92,8 +92,7 @@
}
catch (Exception e)
{
-// errorMessage = "Error adding window to region";
-// log.error(errorMessage, e);
+ log.error("Error adding window to region", 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-20
14:59:28 UTC (rev 6057)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2007-01-21
01:18:15 UTC (rev 6058)
@@ -8,7 +8,6 @@
<%@ page import="java.util.Map" %>
<%@ 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="java.io.PrintWriter" %>
<%@ page
import="org.jboss.portal.core.portlet.dashboard.ContentEditorRegistry" %>
<%@ page import="org.jboss.portal.core.portlet.dashboard.ContentEditor"
%>
@@ -34,6 +33,8 @@
Collection layouts = (Collection)request.getAttribute("layouts");
Collection themes = (Collection)request.getAttribute("themes");
+
+ String contentType = request.getParameter("contentType");
%>
<script type="text/javascript" language="JavaScript">
@@ -155,6 +156,14 @@
<input type="hidden" name="toRegion" value=""/>
<input type="hidden" name="fromRegion" value=""/>
<input type="hidden" name="sortRegion" value=""/>
+<%
+ if (contentType != null)
+ {
+%>
+<input type="hidden" name="contentType" value="<%=
contentType %>"/>
+<%
+ }
+%>
<input type="hidden" name="editPageSelect" value="<%=
currentPage %>"/>
<table width="100%">
<tr>
@@ -225,7 +234,29 @@
<td class="portlet-section-body" valign="top"
align="right"><b>Available Content</b><br/>
<%
ContentEditorRegistry registry =
(ContentEditorRegistry)request.getAttribute("registry");
- ContentEditor editor = registry.getEditor(ContentType.PORTLET);
+%>
+<div>
+<%
+ for (Iterator i = registry.getRegisteredContentTypes().iterator();i.hasNext();)
+ {
+ ContentType ct = (ContentType)i.next();
+%>
+ <a href="<portlet:renderURL><portlet:param name="op"
value="editPage"/><portlet:param name="contentType"
value="<%= ct.toString() %>"/>
+ </portlet:renderURL>"><%= ct %></a>
+<%
+ }
+%>
+</div>
+<%
+ ContentEditor editor = null;
+ if (contentType != null)
+ {
+ editor = registry.getEditor(ContentType.create(contentType));
+ }
+ if (editor == null)
+ {
+ editor = registry.getEditor(ContentType.PORTLET);
+ }
PrintWriter writer = new PrintWriter(out);
editor.show(renderRequest, writer);
writer.flush();
@@ -252,7 +283,6 @@
for (Iterator j = windows.iterator(); j.hasNext();)
{
Window window = (Window)j.next();
- ContentType contentType = window.getContentType();
Content portletContent = window.getContent();
%>
<option value="<%= window.getName() %>"><%=
portletContent.getDisplayName().getDefaultString() %>
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/editor/CMSContentEditor.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/editor/CMSContentEditor.java 2007-01-20
14:59:28 UTC (rev 6057)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/editor/CMSContentEditor.java 2007-01-21
01:18:15 UTC (rev 6058)
@@ -24,9 +24,12 @@
import org.jboss.portal.core.portlet.dashboard.AddWindowContext;
import org.jboss.portal.core.portlet.dashboard.AbstractContentEditor;
+import org.jboss.portal.core.impl.model.content.cms.CMSContent;
+import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.cms.CMS;
import org.jboss.portal.cms.Command;
import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.model.Folder;
import javax.portlet.RenderRequest;
import javax.portlet.ActionRequest;
@@ -55,16 +58,17 @@
public void show(RenderRequest req, PrintWriter writer)
{
- Command cmd = cms.getCommandFactory().createFileGetListCommand("/");
- List list = (List)cms.execute(cmd);
+ Command listCMD =
cms.getCommandFactory().createFolderGetListCommand("/default");
+ Folder folder = (Folder)cms.execute(listCMD);
+ List list = folder.getFiles();
writer.println("<select name=\"available_instances\"
multiple=\"true\" size=\"20\">\n");
for (int i = 0; i < list.size(); i++)
{
- File instance = (File)list.get(i);
+ File file = (File)list.get(i);
writer.print("<option value=\"");
- writer.print(instance.getBaseUUID());
+ writer.print(file.getBasePath());
writer.print("\">");
- writer.print(instance.getName());
+ writer.print(file.getName());
writer.println("</option>\n");
}
writer.println("</select>");
@@ -72,6 +76,19 @@
public void add(ActionRequest req, AddWindowContext ctx)
{
- // todo
+ String[] files = req.getParameterValues("available_instances");
+ try
+ {
+ for (int i = 0; i < files.length; i++)
+ {
+ String file = files[i];
+ CMSContent content = (CMSContent)ctx.createWindow(ContentType.CMS);
+ content.setURI(file);
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Error adding window to region", e);
+ }
}
}