Author: thomas.heute(a)jboss.com
Date: 2007-10-09 06:00:46 -0400 (Tue, 09 Oct 2007)
New Revision: 8571
Added:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/info/PortletInfoInfoImpl.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/metadata/portlet/PortletInfoMetaData.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/portlet/info/PortletInfoInfo.java
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/deployment/JBossApplicationMetaDataFactory.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/info/CorePortletInfoImpl.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/metadata/portlet/JBossPortletMetaData.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/portlet/info/CorePortletInfo.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd
branches/JBoss_Portal_Branch_2_6/core/src/resources/test/deployment/jboss-portlet.xml
Log:
JBPORTAL-1735: Added metadata to include portlet's icons
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/deployment/JBossApplicationMetaDataFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/deployment/JBossApplicationMetaDataFactory.java 2007-10-08
21:54:32 UTC (rev 8570)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/deployment/JBossApplicationMetaDataFactory.java 2007-10-09
10:00:46 UTC (rev 8571)
@@ -28,6 +28,7 @@
import org.jboss.portal.core.metadata.portlet.JBossPortletMetaData;
import org.jboss.portal.core.metadata.portlet.ElementMetaData;
import org.jboss.portal.core.metadata.portlet.AjaxMetaData;
+import org.jboss.portal.core.metadata.portlet.PortletInfoMetaData;
import org.jboss.xb.binding.UnmarshallingContext;
import org.xml.sax.Attributes;
@@ -72,6 +73,10 @@
{
child = new AjaxMetaData();
}
+ else if ("portlet-info".equals(localName))
+ {
+ child = new PortletInfoMetaData();
+ }
}
else if (object instanceof HeaderContentMetaData)
{
@@ -130,6 +135,12 @@
JBossPortletMetaData portlet = (JBossPortletMetaData)parent;
portlet.setAjax(ajax);
}
+ else if (child instanceof PortletInfoMetaData)
+ {
+ PortletInfoMetaData portletInfo = (PortletInfoMetaData)child;
+ JBossPortletMetaData portlet = (JBossPortletMetaData)parent;
+ portlet.setPortletInfo(portletInfo);
+ }
else if (child instanceof ElementMetaData)
{
ElementMetaData element = (ElementMetaData)child;
@@ -177,6 +188,24 @@
ajax.setPartialRefresh(Boolean.valueOf(value));
}
}
+ else if (object instanceof PortletInfoMetaData)
+ {
+ if ("small-icon-location".equals(localName))
+ {
+ PortletInfoMetaData portletInfo = (PortletInfoMetaData)object;
+ portletInfo.setIconLocation(value, PortletInfoMetaData.SMALL);
+ }
+ else if ("medium-icon-location".equals(localName))
+ {
+ PortletInfoMetaData portletInfo = (PortletInfoMetaData)object;
+ portletInfo.setIconLocation(value, PortletInfoMetaData.MEDIUM);
+ }
+ else if ("large-icon-location".equals(localName))
+ {
+ PortletInfoMetaData portletInfo = (PortletInfoMetaData)object;
+ portletInfo.setIconLocation(value, PortletInfoMetaData.LARGE);
+ }
+ }
else
{
super.setValue(object, nav, nsURI, localName, value);
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/info/CorePortletInfoImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/info/CorePortletInfoImpl.java 2007-10-08
21:54:32 UTC (rev 8570)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/info/CorePortletInfoImpl.java 2007-10-09
10:00:46 UTC (rev 8571)
@@ -25,9 +25,11 @@
import org.jboss.portal.core.portlet.info.CorePortletInfo;
import org.jboss.portal.core.portlet.info.AjaxInfo;
import org.jboss.portal.core.portlet.info.MarkupHeaderInfo;
+import org.jboss.portal.core.portlet.info.PortletInfoInfo;
import org.jboss.portal.core.metadata.portlet.JBossPortletMetaData;
import org.jboss.portal.core.metadata.portlet.AjaxMetaData;
import org.jboss.portal.core.metadata.portlet.HeaderContentMetaData;
+import org.jboss.portal.core.metadata.portlet.PortletInfoMetaData;
import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
import org.jboss.portal.common.i18n.ResourceBundleManager;
@@ -49,6 +51,9 @@
/** . */
private final MarkupHeaderInfoImpl markupHeader;
+ /** . */
+ private final PortletInfoInfoImpl portletInfo;
+
public CorePortletInfoImpl(PortletMetaData portletMD,
org.jboss.portal.portlet.metadata.JBossPortletMetaData jbossPortletMD,
ResourceBundleManager bundleMgr)
{
super(portletMD, jbossPortletMD, bundleMgr);
@@ -56,11 +61,13 @@
//
AjaxMetaData ajaxMD = ((JBossPortletMetaData)jbossPortletMD).getAjax();
HeaderContentMetaData headerContentMD =
((JBossPortletMetaData)jbossPortletMD).getHeaderContent();
+ PortletInfoMetaData portletInfoMD =
((JBossPortletMetaData)jbossPortletMD).getPortletInfo();
//
this.txType = jbossPortletMD.getTxType();
this.ajax = ajaxMD != null ? new AjaxInfoImpl(ajaxMD) : null;
this.markupHeader = headerContentMD != null ? new
MarkupHeaderInfoImpl(headerContentMD) : null;
+ this.portletInfo = portletInfoMD != null ? new PortletInfoInfoImpl(portletInfoMD) :
null;
}
public Transactions.Type getTxType()
@@ -77,4 +84,9 @@
{
return markupHeader;
}
+
+ public PortletInfoInfo getPortletInfo()
+ {
+ return portletInfo;
+ }
}
Added:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/info/PortletInfoInfoImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/info/PortletInfoInfoImpl.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/info/PortletInfoInfoImpl.java 2007-10-09
10:00:46 UTC (rev 8571)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * 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.impl.portlet.info;
+
+import java.util.Map;
+
+import org.jboss.portal.core.metadata.portlet.PortletInfoMetaData;
+import org.jboss.portal.core.portlet.info.PortletInfoInfo;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PortletInfoInfoImpl implements PortletInfoInfo
+{
+ /** . */
+ private Map icons;
+
+ public PortletInfoInfoImpl(PortletInfoMetaData portletInfoMetaData)
+ {
+ icons = portletInfoMetaData.getIcons();
+ }
+
+ public String getIconLocation(String size)
+ {
+ return (String)icons.get(size);
+ }
+
+}
+
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/metadata/portlet/JBossPortletMetaData.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/metadata/portlet/JBossPortletMetaData.java 2007-10-08
21:54:32 UTC (rev 8570)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/metadata/portlet/JBossPortletMetaData.java 2007-10-09
10:00:46 UTC (rev 8571)
@@ -34,6 +34,9 @@
/** . */
private AjaxMetaData ajax;
+
+ /** . */
+ private PortletInfoMetaData portletInfo;
public HeaderContentMetaData getHeaderContent()
{
@@ -44,7 +47,7 @@
{
this.headerContent = headerContent;
}
-
+
public AjaxMetaData getAjax()
{
return ajax;
@@ -54,7 +57,17 @@
{
this.ajax = ajax;
}
+
+ public PortletInfoMetaData getPortletInfo()
+ {
+ return portletInfo;
+ }
+ public void setPortletInfo(PortletInfoMetaData portletInfo)
+ {
+ this.portletInfo = portletInfo;
+ }
+
public void merge(org.jboss.portal.portlet.metadata.JBossPortletMetaData portlet)
{
super.merge(portlet);
Added:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/metadata/portlet/PortletInfoMetaData.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/metadata/portlet/PortletInfoMetaData.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/metadata/portlet/PortletInfoMetaData.java 2007-10-09
10:00:46 UTC (rev 8571)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * 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.metadata.portlet;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PortletInfoMetaData
+{
+
+ /** . */
+ public static final String SMALL = "small";
+
+ /** . */
+ public static final String MEDIUM = "medium";
+
+ /** . */
+ public static final String LARGE = "large";
+
+ /** . */
+ private Map icons;
+
+ public PortletInfoMetaData()
+ {
+ icons = new HashMap();
+ }
+
+ public void setIconLocation(String iconLocation, String size)
+ {
+ icons.put(size, iconLocation);
+ }
+
+ public String getIconLocation(String size)
+ {
+ return (String)icons.get(size);
+ }
+
+ public Map getIcons()
+ {
+ return Collections.unmodifiableMap(icons);
+ }
+}
+
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/portlet/info/CorePortletInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/portlet/info/CorePortletInfo.java 2007-10-08
21:54:32 UTC (rev 8570)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/portlet/info/CorePortletInfo.java 2007-10-09
10:00:46 UTC (rev 8571)
@@ -47,4 +47,6 @@
* @return
*/
MarkupHeaderInfo getMarkupHeader();
+
+ PortletInfoInfo getPortletInfo();
}
Added:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/portlet/info/PortletInfoInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/portlet/info/PortletInfoInfo.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/portlet/info/PortletInfoInfo.java 2007-10-09
10:00:46 UTC (rev 8571)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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.info;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface PortletInfoInfo
+{
+ /** . */
+ public static final String SMALL = "small";
+
+ /** . */
+ public static final String MEDIUM = "medium";
+
+ /** . */
+ public static final String LARGE = "large";
+
+ String getIconLocation(String size);
+}
+
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java 2007-10-08
21:54:32 UTC (rev 8570)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java 2007-10-09
10:00:46 UTC (rev 8571)
@@ -31,6 +31,7 @@
import org.jboss.portal.core.metadata.portlet.JBossPortletMetaData;
import org.jboss.portal.core.metadata.portlet.LinkElementMetaData;
import org.jboss.portal.core.metadata.portlet.NamedMetaElementMetaData;
+import org.jboss.portal.core.metadata.portlet.PortletInfoMetaData;
import org.jboss.portal.core.metadata.portlet.ScriptElementMetaData;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
@@ -65,7 +66,7 @@
//
assertNotNull(app.getPortlets());
- assertEquals(3, app.getPortlets().size());
+ assertEquals(4, app.getPortlets().size());
//
JBossPortletMetaData portlet =
(JBossPortletMetaData)app.getPortlets().get("Portlet1");
@@ -132,5 +133,32 @@
assertEquals("foo", link.getTitleAttribute());
}
+
+ public void testPortletInfoMetadata() throws Exception
+ {
+ URL jbossPortletXML =
Thread.currentThread().getContextClassLoader().getResource("test/deployment/jboss-portlet.xml");
+ assertTrue(URLTools.exists(jbossPortletXML));
+ //
+ JBossApplicationMetaDataFactory factory = new JBossApplicationMetaDataFactory();
+
+ //
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ //
+ Object o = unmarshaller.unmarshal(jbossPortletXML.openStream(), factory, null);
+ assertNotNull(o);
+ assertTrue(o instanceof JBossApplicationMetaData);
+ JBossApplicationMetaData app = (JBossApplicationMetaData)o;
+
+ //
+ JBossPortletMetaData portlet =
(JBossPortletMetaData)app.getPortlets().get("Portlet4");
+ assertNotNull(portlet);
+ assertEquals("Portlet4", portlet.getName());
+
+ PortletInfoMetaData portletInfo = (PortletInfoMetaData)portlet.getPortletInfo();
+ assertEquals("/tmp/toto.png",
portletInfo.getIconLocation(PortletInfoMetaData.SMALL));
+
+ }
+
}
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd 2007-10-08
21:54:32 UTC (rev 8570)
+++
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd 2007-10-09
10:00:46 UTC (rev 8571)
@@ -68,7 +68,7 @@
</portlet>
-->
-<!ELEMENT portlet
(portlet-name,remotable?,ajax?,session-config?,transaction?,header-content?)>
+<!ELEMENT portlet
(portlet-name,remotable?,ajax?,session-config?,transaction?,header-content?,portlet-info?)>
<!--
The portlet name.
@@ -94,6 +94,12 @@
-->
<!ELEMENT partial-refresh (#PCDATA)>
+<!ELEMENT portlet-info (small-icon-location?, medium-icon-location?,
large-icon-location?)>
+
+<!ELEMENT small-icon-location (#PCDATA)>
+<!ELEMENT medium-icon-location (#PCDATA)>
+<!ELEMENT large-icon-location (#PCDATA)>
+
<!--
This element configure the portlet session of the portlet.
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/resources/test/deployment/jboss-portlet.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/resources/test/deployment/jboss-portlet.xml 2007-10-08
21:54:32 UTC (rev 8570)
+++
branches/JBoss_Portal_Branch_2_6/core/src/resources/test/deployment/jboss-portlet.xml 2007-10-09
10:00:46 UTC (rev 8571)
@@ -40,4 +40,13 @@
<link rel="stylesheet" type="text/css"
href="test.css" media="screen" title="foo"/>
</header-content>
</portlet>
+ <portlet>
+ <portlet-name>Portlet4</portlet-name>
+ <header-content>
+ <link rel="stylesheet" type="text/css"
href="test.css" media="screen" title="foo"/>
+ </header-content>
+ <portlet-info>
+ <small-icon-location>/tmp/toto.png</small-icon-location>
+ </portlet-info>
+ </portlet>
</portlet-app>
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml 2007-10-08
21:54:32 UTC (rev 8570)
+++
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml 2007-10-09
10:00:46 UTC (rev 8571)
@@ -42,6 +42,7 @@
<tr
class="#{portlet.context.id ==
portletmgr.selectedPortlet.context.id ? 'portlet-section-selected' : (status.index
% 2 == 0 ? 'portlet-section-body' :
'portlet-section-alternate')}">
<td>
+ <img src="#{portlet.iconLocation}"
width="30px" height="30px" align="middle"/>
<h:commandLink
action="#{portletmgr.selectPortlet}"
title="#{portlet.context.id}">