Author: julien(a)jboss.com
Date: 2007-06-25 20:20:41 -0400 (Mon, 25 Jun 2007)
New Revision: 7543
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
trunk/core/src/resources/portal-core-war/WEB-INF/portlet.xml
trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
trunk/widget/src/resources/widget-war/WEB-INF/portlet.xml
Log:
filter instances in portlet content editor portlet to not show portlet which are them
selves content editors based on their portlet mode declarations
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-25
23:46:58 UTC (rev 7542)
+++
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java 2007-06-26
00:20:41 UTC (rev 7543)
@@ -26,7 +26,9 @@
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.ModeInfo;
+import org.jboss.portal.Mode;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletMode;
@@ -43,6 +45,8 @@
import java.util.List;
import java.util.Comparator;
import java.util.Collections;
+import java.util.Iterator;
+import java.util.ArrayList;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -54,7 +58,8 @@
/** . */
private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
- private final PortletMode SELECT_CONTENT = new
PortletMode("select_content");
+ /** . */
+ private final Mode INTERNAL_EDIT_CONTENT = Mode.create("edit_content");
/** . */
private InstanceContainer instanceContainer;
@@ -66,7 +71,7 @@
public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
{
- if ((req.getPortletMode().equals(EDIT_CONTENT)) ||
(req.getPortletMode().equals(SELECT_CONTENT)))
+ if ((req.getPortletMode().equals(EDIT_CONTENT)))
{
String uri = req.getParameter("content.uri");
if (uri != null)
@@ -82,27 +87,17 @@
{
doEditContent(req, resp);
}
- else if (SELECT_CONTENT.equals(req.getPortletMode()))
- {
- doCreateContent(req, resp);
- }
else
{
super.doDispatch(req, resp);
}
}
- protected void doCreateContent(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
- {
- getContent(req, resp, true);
- }
-
-
protected void doEditContent(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
{
getContent(req, resp, false);
}
-
+
protected void getContent(RenderRequest req, RenderResponse resp, boolean newContent)
throws PortletException, PortletSecurityException, IOException
{
String selectedURI = req.getParameter("content.uri");
@@ -114,9 +109,38 @@
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
- // load insances this user has access to.
- List available_instances = (List)instanceContainer.getDefinitions();
+ // load instances this user has access to.
+ // Remove content editors
+ List available_instances = new ArrayList();
+ nextInstance:
+ for (Iterator i = instanceContainer.getDefinitions().iterator();i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+
+ //
+ try
+ {
+ // Filter portlets that are editors
+ Portlet portlet = instance.getPortlet();
+ PortletInfo info = portlet.getInfo();
+ for (Iterator j =
info.getCapabilities().getAllModes().iterator();j.hasNext();)
+ {
+ ModeInfo modeInfo = (ModeInfo)j.next();
+ if (modeInfo.getMode().equals(INTERNAL_EDIT_CONTENT))
+ {
+ continue nextInstance;
+ }
+ }
+
+ //
+ available_instances.add(instance);
+ }
+ catch (PortletInvokerException ignore)
+ {
+ }
+ }
+
// Sort alphabetically
Comparator simpleComparator = new Comparator()
{
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/portlet.xml 2007-06-25 23:46:58 UTC
(rev 7542)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/portlet.xml 2007-06-26 00:20:41 UTC
(rev 7543)
@@ -118,6 +118,7 @@
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
+ <portlet-mode>EDIT_CONTENT</portlet-mode>
</supports>
<portlet-info>
<title>Portlet Content Portlet</title>
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-25
23:46:58 UTC (rev 7542)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editPageLayout.xhtml 2007-06-26
00:20:41 UTC (rev 7543)
@@ -61,9 +61,9 @@
portletId="#{pageManager.selectedEditorPortletId}"
portletInvoker="#{pageManager.portletInvoker}"
actionListener="#{pageManager.assignWindow}"
- supportedModes="select_content"
+ supportedModes="edit_content"
supportedWindowStates="normal"
- initialMode="select_content"
+ initialMode="edit_content"
initialWindowState="normal"
renderParameters="#{pageManager.selectedRenderParameters}"
onClick="url.setParameter('windowName',
document.getElementById('windowForm:windowName').value);"/>
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-06-25
23:46:58 UTC (rev 7542)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-06-26
00:20:41 UTC (rev 7543)
@@ -135,9 +135,6 @@
private static final PortletMode EDIT_CONTENT = new
PortletMode("edit_content");
/** . */
- private static final PortletMode SELECT_CONTENT = new
PortletMode("select_content");
-
- /** . */
private CMS CMSService;
/** . */
@@ -307,7 +304,7 @@
protected void doDispatch(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
{
- if (EDIT_CONTENT.equals(req.getPortletMode()) ||
SELECT_CONTENT.equals(req.getPortletMode()))
+ if (EDIT_CONTENT.equals(req.getPortletMode()))
{
doEditContent(req, resp);
}
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml 2007-06-25 23:46:58
UTC (rev 7542)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml 2007-06-26 00:20:41
UTC (rev 7543)
@@ -36,6 +36,7 @@
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
+ <portlet-mode>EDIT_CONTENT</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<supported-locale>fr</supported-locale>
Modified:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java
===================================================================
---
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java 2007-06-25
23:46:58 UTC (rev 7542)
+++
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java 2007-06-26
00:20:41 UTC (rev 7543)
@@ -56,15 +56,12 @@
/** The edit_content mode. */
public static final PortletMode EDIT_CONTENT_MODE = new
PortletMode("edit_content");
- private final PortletMode SELECT_CONTENT = new
PortletMode("select_content");
-
-
/**
* Additional dispatch that will call the
<code>doEditContent(RenderRequest,RenderResponse)</code> method.
*/
protected void doDispatch(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
{
- if (EDIT_CONTENT_MODE.equals(req.getPortletMode()) ||
SELECT_CONTENT.equals(req.getPortletMode()))
+ if (EDIT_CONTENT_MODE.equals(req.getPortletMode()))
{
doEditContent(req, resp);
}
@@ -197,7 +194,7 @@
public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
{
- if (EDIT_CONTENT_MODE.equals(req.getPortletMode()) ||
SELECT_CONTENT.equals(req.getPortletMode()))
+ if (EDIT_CONTENT_MODE.equals(req.getPortletMode()))
{
String contentURI = req.getParameter("content.uri");
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml 2007-06-25
23:46:58 UTC (rev 7542)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml 2007-06-26
00:20:41 UTC (rev 7543)
@@ -369,6 +369,8 @@
<portlet-class>org.jboss.portal.core.portlet.test.FSContentDrivenPortlet</portlet-class>
<supports>
<mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ <portlet-mode>EDIT_CONTENT</portlet-mode>
</supports>
<portlet-info>
<title>File Portlet</title>
Modified: trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-06-25 23:46:58
UTC (rev 7542)
+++ trunk/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-06-26 00:20:41
UTC (rev 7543)
@@ -52,8 +52,6 @@
/** . */
private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
- private final PortletMode SELECT_CONTENT = new
PortletMode("select_content");
-
/** . */
private GGProvider provider = new GGProvider();
@@ -128,7 +126,7 @@
protected void doDispatch(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
{
- if (EDIT_CONTENT.equals(req.getPortletMode()) ||
SELECT_CONTENT.equals(req.getPortletMode()))
+ if (EDIT_CONTENT.equals(req.getPortletMode()))
{
doEditContent(req, resp);
}
Modified: trunk/widget/src/resources/widget-war/WEB-INF/portlet.xml
===================================================================
--- trunk/widget/src/resources/widget-war/WEB-INF/portlet.xml 2007-06-25 23:46:58 UTC (rev
7542)
+++ trunk/widget/src/resources/widget-war/WEB-INF/portlet.xml 2007-06-26 00:20:41 UTC (rev
7543)
@@ -35,6 +35,7 @@
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
+ <portlet-mode>EDIT_CONTENT</portlet-mode>
</supports>
<portlet-info>
<title>Google Widget</title>