Author: julien(a)jboss.com
Date: 2007-06-14 16:16:25 -0400 (Thu, 14 Jun 2007)
New Revision: 7418
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
Log:
page layout editor improvements:
- workflow for content configuration simplified
- removed the target region combo box
- auto submit of content editor selection
- switched region / content selection left<->right
Modified:
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java 2007-06-14
19:54:35 UTC (rev 7417)
+++
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java 2007-06-14
20:16:25 UTC (rev 7418)
@@ -85,7 +85,6 @@
{
doCreateContent(req, resp);
}
-
else
{
super.doDispatch(req, resp);
@@ -139,8 +138,9 @@
{
writer.print("<span class=\"portlet-font\">Select a portlet
instance to associate to this window:</span>");
}
-
- writer.print("<form action=\"");
+
+ //
+ writer.print("<form id=\"portlet_selection_form\"
action=\"");
writer.print(actionURL);
writer.print("\" method=\"post\">\n");
writer.println("<select
name=\"content.uri\"size=\"20\">\n");
@@ -166,10 +166,9 @@
writer.println("</option>\n");
}
writer.println("</select><br />");
-
+
String buttonText = (newContent) ? "Select" : "Update";
writer.println("<input type=\"submit\"
name=\"content.action.select\" value=\"" + buttonText + "\"
class=\"portlet-form-button\"/>");
- writer.println("<input type=\"submit\" value=\"Info\"
class=\"portlet-form-button\"/>");
writer.print("</form>");
//
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-06-14
19:54:35 UTC (rev 7417)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-06-14
20:16:25 UTC (rev 7418)
@@ -85,6 +85,9 @@
/** . */
private static final int MOVE_LEFT = 'l';
+ /** . */
+ private static final int ADD_ACTION = 'a';
+
public PageManagerBean(LayoutService layoutService, PortletInvoker portletInvoker)
{
this.layoutService = layoutService;
@@ -107,6 +110,12 @@
/** . */
public DynamicMap assignedWindows = new DynamicMap();
+ /** . */
+ public String selectedContentURI;
+
+ /** . */
+ public Map selectedContentParams;
+
public List getContentTypeItems()
{
LinkedList types = new LinkedList();
@@ -185,6 +194,79 @@
index += step;
}
}
+ else if (direction == ADD_ACTION)
+ {
+ if (selectedContentURI != null)
+ {
+ //
+ String selectedContentURI = this.selectedContentURI;
+ Map selectedContentParams = this.selectedContentParams;
+ this.selectedContentURI = null;
+ this.selectedContentParams = null;
+
+ // Obtain a window name
+ String windowName =
(String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("blah");
+ if (windowName.trim().length() == 0)
+ {
+ windowName = createWindowName();
+ while (page.getWindow(windowName) != null)
+ {
+ windowName = "" + createWindowName();
+ }
+ }
+
+ // Check for duplicate window name
+ if (page.getWindow(windowName) != null)
+ {
+ FacesContext faces = FacesContext.getCurrentInstance();
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Duplicate window name found on this page!", null);
+ faces.addMessage("windowName", message);
+ throw new AbortProcessingException();
+ }
+
+ //
+ try
+ {
+ Window window = page.createWindow(windowName, selectedContentType,
selectedContentURI);
+ Content content = window.getContent();
+ for (Iterator i =
selectedContentParams.entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String paramName = (String)entry.getKey();
+ String paramValue = (String)entry.getValue();
+ content.setParameter(paramName, paramValue);
+ }
+
+ //
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION,
regionName);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, ""
+ Integer.MAX_VALUE);
+
+ // Sort windows
+ Collections.sort(windows, new WindowComparator());
+
+ // Add the created one
+ windows.add(window);
+
+ // Update the order states
+ for (int i = 0;i < windows.size();i++)
+ {
+ Window tmp = (Window)windows.get(i);
+ tmp.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, ""
+ i);
+ }
+ }
+ catch (DuplicatePortalObjectException unexpected)
+ {
+ unexpected.printStackTrace();
+ }
+ }
+ else
+ {
+ FacesContext faces = FacesContext.getCurrentInstance();
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "No
content was selected!", null);
+ faces.addMessage("layoutForm", message);
+ throw new AbortProcessingException();
+ }
+ }
else if (direction == MOVE_LEFT)
{
for (Iterator i = windows.iterator();i.hasNext();)
@@ -217,8 +299,7 @@
}
private String windowName;
- private String targetRegion;
-
+
public String getWindowName()
{
return windowName;
@@ -228,18 +309,7 @@
{
this.windowName = windowName;
}
-
- public String getTargetRegion()
- {
- return targetRegion;
- }
- public void setTargetRegion(String targetRegion)
- {
- this.targetRegion = targetRegion;
- }
-
-
/**
* Portlet event
*/
@@ -252,18 +322,18 @@
// Keep window name and region defined
setWindowName(((String[])renderParams.get("windowName"))[0]);
- setTargetRegion(((String[])renderParams.get("targetRegion"))[0]);
}
else if (event instanceof PortletActionEvent)
{
-
PortletActionEvent actionEvent = (PortletActionEvent)event;
Map actionParams = actionEvent.getParameterMap();
+ System.out.println("actionParams = " + actionParams);
+
// Keep window name and region defined
setWindowName(((String[])actionParams.get("windowName"))[0]);
- setTargetRegion(((String[])actionParams.get("targetRegion"))[0]);
+ //
if (actionParams.get(CONTENT_ACTION_SELECT) != null)
{
String[] uris = (String[])actionParams.get(CONTENT_URI);
@@ -271,29 +341,6 @@
{
String uri = uris[0];
- // Obtain a window name
- String windowName =
((String[])actionParams.get("windowName"))[0];
- if (windowName.trim().length() == 0)
- {
- windowName = createWindowName();
- while (page.getWindow(windowName) != null)
- {
- windowName = "" + createWindowName();
- }
- }
-
- // Check for duplicate window name
- if (page.getWindow(windowName) != null)
- {
- FacesContext faces = FacesContext.getCurrentInstance();
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Duplicate window name found on this page!", null);
- faces.addMessage("windowName", message);
- throw new AbortProcessingException();
- }
-
- // Get the target region
- String targetRegion =
((String[])actionParams.get("targetRegion"))[0];
-
//
Map params = new HashMap();
for (Iterator i = actionParams.entrySet().iterator();i.hasNext();)
@@ -308,50 +355,9 @@
}
}
- try
- {
- Window window = page.createWindow(windowName, selectedContentType,
uri);
- Content content = window.getContent();
- for (Iterator i = params.entrySet().iterator();i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String paramName = (String)entry.getKey();
- String paramValue = (String)entry.getValue();
- content.setParameter(paramName, paramValue);
- }
-
- //
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION,
targetRegion);
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER,
"" + Integer.MAX_VALUE);
-
- // Get the windows belonging to the selected region sorted by order
- List windows = new ArrayList();
- for (Iterator i =
page.getChildren(PortalObject.WINDOW_MASK).iterator();i.hasNext();)
- {
- Window tmp = (Window)i.next();
- if
(targetRegion.equals(tmp.getProperty(ThemeConstants.PORTAL_PROP_REGION)))
- {
- windows.add(tmp);
- }
- }
-
- // Sort windows
- Collections.sort(windows, new WindowComparator());
-
- // Add the created one
- windows.add(window);
-
- // Update the order states
- for (int i = 0;i < windows.size();i++)
- {
- Window tmp = (Window)windows.get(i);
- tmp.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER,
"" + i);
- }
- }
- catch (DuplicatePortalObjectException unexpected)
- {
- unexpected.printStackTrace();
- }
+ //
+ this.selectedContentURI = uri;
+ this.selectedContentParams = params;
}
}
}
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml
===================================================================
---
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml 2007-06-14
19:54:35 UTC (rev 7417)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml 2007-06-14
20:16:25 UTC (rev 7418)
@@ -6,149 +6,147 @@
xmlns:jbp="http://www.jboss.org/portal"
xmlns:c="http://java.sun.com/jstl/core">
-<div style="float:left; padding:0 2em 0 2em">
- <h:form id="layoutForm">
- <table>
- <c:forEach items="#{pageManager.regionNames}"
var="regionName" varStatus="status">
- <tbody>
- <tr>
- <td colspan="2"
class="portlet-form-field-label"><hr/> #{regionName} Region
</td>
- </tr>
- <tr>
- <td>
- <div>
- <h:commandButton
- value="Up" id="u_#{regionName}"
- actionListener="#{pageManager.assignWindows}"
- styleClass="portlet-form-button"/>
- </div>
- <div>
- <h:commandButton
- value="Down" id="d_#{regionName}"
- actionListener="#{pageManager.assignWindows}"
- styleClass="portlet-form-button"/>
- </div>
- <div style="margin-top: 1em">
- <h:commandButton
- value="Delete" id="l_#{regionName}"
- actionListener="#{pageManager.assignWindows}"
- styleClass="portlet-form-button"/>
- </div>
- </td>
- <td>
- <h:selectManyListbox
- value="#{pageManager.assignedWindows[regionName]}"
- size="7" styleClass="windowList
portlet-form-field">
- <f:selectItems
-
value="#{pageManager.windowItemsMap[regionName]}"/>
- </h:selectManyListbox>
- </td>
- </tr>
- </tbody>
- </c:forEach>
- <tbody>
+<table class="form">
+ <tr>
+ <td valign="top">
+ <table class="form">
<tr>
- <td colspan="2" class="portlet-form-field-label"
- style="border-width:0px;border-top:1px dashed
#d5d5d5">Unassigned
- windows
+ <td colspan="2"><hr/>You can choose among several
types of content to assign on the page:
</td>
</tr>
<tr>
- <td>
- <div style="margin-top: 1em">
- <h:commandButton value="Delete"
- id="l_unknown"
actionListener="#{pageManager.assignWindows}"
- styleClass="portlet-form-button"/>
- </div>
+ <td class="label">
+ <span class="portlet-form-field-label">Content
type:</span>
</td>
- <td>
- <h:selectManyListbox
- value="#{pageManager.assignedWindows['unknown']}"
- size="7" styleClass="windowList
portlet-form-field">
- <f:selectItems
-
value="#{pageManager.windowItemsMap['unknown']}"/>
- </h:selectManyListbox>
+ <td class="widget">
+ <h:form id="abc">
+ <h:selectOneMenu
+ id="instanceId"
+ value="#{pageManager.selectedContentType}"
+ styleClass="portlet-form-field contentType"
+
onclick="document.getElementById('abc').submit()">
+ <f:selectItems
value="#{pageManager.contentTypeItems}"/>
+ </h:selectOneMenu>
+ <h:message for="instanceId"
errorClass="portlet-msg-error"/>
+ </h:form>
</td>
</tr>
- </tbody>
- </table>
- </h:form>
-</div>
-<div style="float:left">
- <table class="form">
- <tr>
- <td colspan="2"><hr/>You can choose among several types of
content to assign on the page:
- </td>
- </tr>
- <tr>
- <td class="label">
- <span class="portlet-form-field-label">Content
type:</span>
- </td>
- <td class="widget">
- <h:form id="abc">
- <h:selectOneMenu
- id="instanceId"
- value="#{pageManager.selectedContentType}"
- styleClass="portlet-form-field contentType">
- <f:selectItems
value="#{pageManager.contentTypeItems}"/>
- </h:selectOneMenu>
- <h:commandButton value="Change"
styleClass="portlet-form-button"/>
- <h:message for="instanceId"
errorClass="portlet-msg-error"/>
- </h:form>
- </td>
- </tr>
- <tr>
- <td colspan="2"><hr/>You can enter a window name used
during content selection (optional):
- </td>
- </tr>
- <tr>
- <td class="label">
- <span class="portlet-form-field-label">Window
Name:</span>
- </td>
- <td class="widget">
- <h:form id="windowForm">
- <h:inputText id="windowName"
value="#{pageManager.windowName}"
styleClass="portlet-form-input-field"/>
- <h:message for="windowName"
errorClass="portlet-msg-error"/>
- </h:form>
- </td>
- </tr>
- <tr>
- <td colspan="2"><hr/>The page region will contain the
selected content:
- </td>
- </tr>
- <tr>
- <td class="label">
- <span class="portlet-form-field-label">Target
Region:</span>
- </td>
- <td class="widget">
- <h:form id="regionForm">
- <h:selectOneMenu id="targetRegion"
value="#{pageManager.targetRegion}"
styleClass="portlet-form-input-field">
- <f:selectItems value="#{pageManager.regionItems}"/>
- </h:selectOneMenu>
- <h:message for="targetRegion"
errorClass="portlet-msg-error"/>
- </h:form>
- </td>
- </tr>
- <tr>
- <td colspan="2"><hr/>Select content that will be added to
the page:
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <div style="margin:3em;">
- <jbp:portlet
- portletId="#{pageManager.selectedEditorPortletId}"
- portletInvoker="#{pageManager.portletInvoker}"
- actionListener="#{pageManager.assignWindow}"
- supportedModes="select_content"
- supportedWindowStates="normal"
- initialMode="select_content"
- initialWindowState="normal"
- onClick="url.setParameter('windowName',
document.getElementById('windowForm:windowName').value).setParameter('targetRegion',
document.getElementById('regionForm:targetRegion').value);"/>
- </div>
- </td>
- </tr>
- </table>
-</div>
+ <tr>
+ <td colspan="2"><hr/>You can enter a window name
used during content selection (optional):
+ </td>
+ </tr>
+ <tr>
+ <td class="label">
+ <span class="portlet-form-field-label">Window
Name:</span>
+ </td>
+ <td class="widget">
+ <h:form id="windowForm">
+ <h:inputText id="windowName"
value="#{pageManager.windowName}"
styleClass="portlet-form-input-field"/>
+ <h:message for="windowName"
errorClass="portlet-msg-error"/>
+ </h:form>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><hr/>Select content that will be
added to the page:
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <div style="margin:3em;">
+ <jbp:portlet
+ portletId="#{pageManager.selectedEditorPortletId}"
+ portletInvoker="#{pageManager.portletInvoker}"
+ actionListener="#{pageManager.assignWindow}"
+ supportedModes="select_content"
+ supportedWindowStates="normal"
+ initialMode="select_content"
+ initialWindowState="normal"
+ onClick="url.setParameter('windowName',
document.getElementById('windowForm:windowName').value);"/>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td valign="top">
+ <h:form id="layoutForm">
+ <h:message for="layoutForm"
errorClass="portlet-msg-error"/>
+ <input id="blah" type="hidden" name="blah"
value=""/>
+ <table>
+ <c:forEach items="#{pageManager.regionNames}"
var="regionName" varStatus="status">
+ <tbody>
+ <tr>
+ <td colspan="2"
class="portlet-form-field-label"><hr/> #{regionName} Region
</td>
+ </tr>
+ <tr>
+ <td>
+ <div>
+ <h:commandButton
+
onclick="document.getElementById('blah').value=document.getElementById('windowForm:windowName').value"
+ value="Add" id="a_#{regionName}"
+ actionListener="#{pageManager.assignWindows}"
+ styleClass="portlet-form-button"/>
+ </div>
+ </td>
+ <td>
+ <h:selectManyListbox
+
value="#{pageManager.assignedWindows[regionName]}"
+ size="7" styleClass="windowList
portlet-form-field">
+ <f:selectItems
+
value="#{pageManager.windowItemsMap[regionName]}"/>
+ </h:selectManyListbox>
+ </td>
+ <td>
+ <div>
+ <h:commandButton
+ value="Up" id="u_#{regionName}"
+ actionListener="#{pageManager.assignWindows}"
+ styleClass="portlet-form-button"/>
+ </div>
+ <div>
+ <h:commandButton
+ value="Down" id="d_#{regionName}"
+ actionListener="#{pageManager.assignWindows}"
+ styleClass="portlet-form-button"/>
+ </div>
+ <div style="margin-top: 1em">
+ <h:commandButton
+ value="Delete" id="l_#{regionName}"
+ actionListener="#{pageManager.assignWindows}"
+ styleClass="portlet-form-button"/>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </c:forEach>
+ <tbody>
+ <tr>
+ <td colspan="2"
class="portlet-form-field-label"
+ style="border-width:0px;border-top:1px dashed
#d5d5d5">Unassigned
+ windows
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div style="margin-top: 1em">
+ <h:commandButton value="Delete"
+ id="l_unknown"
actionListener="#{pageManager.assignWindows}"
+
styleClass="portlet-form-button"/>
+ </div>
+ </td>
+ <td>
+ <h:selectManyListbox
+
value="#{pageManager.assignedWindows['unknown']}"
+ size="7" styleClass="windowList
portlet-form-field">
+ <f:selectItems
+
value="#{pageManager.windowItemsMap['unknown']}"/>
+ </h:selectManyListbox>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </h:form>
+ </td>
+ </tr>
+</table>
</div>
\ No newline at end of file