portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r475466 [1/3] - in /portals/jetspeed-2/trunk/applications/j2-admin/src: java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java webapp/WEB-INF/portlet.xml webapp/WEB-INF/view/selectors/category-portlet-selector.vm
Date Wed, 15 Nov 2006 22:19:38 GMT
Author: taylor
Date: Wed Nov 15 14:19:37 2006
New Revision: 475466

URL: http://svn.apache.org/viewvc?view=rev&rev=475466
Log:
https://issues.apache.org/jira/browse/JS2-610

This pretty much completes the initial development of the category portlet selector
There are few enhancements I still need to add such as:

1. Handle Session Timeouts
2. Better placement of portlets in columns
3. Localization

I get those in for the 2.1 final

Modified:
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java
    portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/selectors/category-portlet-selector.vm

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java?view=diff&rev=475466&r1=475465&r2=475466
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java
Wed Nov 15 14:19:37 2006
@@ -26,6 +26,7 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Random;
 import java.util.StringTokenizer;
 
 import javax.portlet.ActionRequest;
@@ -65,6 +66,13 @@
  */
 public class CategoryPortletSelector extends AbstractDojoVelocityPortlet implements Comparator
 {
+    public final String[] DEFAULT_IMAGES = new String[]
+    {
+            "images/portlets/applications-development.png",
+            "images/portlets/applications-system.png",
+            "images/portlets/applications-other.png",
+            "images/portlets/linux.png"
+    };
     protected final Log logger = LogFactory.getLog(this.getClass());
     public final static String PORTLET_ICON = "portlet-icon";
     protected final static String PORTLETS = "category.selector.portlets";
@@ -74,7 +82,8 @@
     
     protected PortletRegistry registry;
     protected SearchEngine searchEngine;
-       
+    protected Random rand;
+    
     public void init(PortletConfig config)
     throws PortletException 
     {
@@ -89,7 +98,8 @@
         if (null == searchEngine)
         {
             throw new PortletException("Failed to find the Search Engine on portlet initialization");
-        }                
+        }
+        rand = new Random( 19580427 );
     }
     
     public void doView(RenderRequest request, RenderResponse response)
@@ -212,6 +222,8 @@
         return list;
     }
 
+    
+    
     /**
      * Filters portlets being added to the based on security checks and layout criteria
      * 
@@ -236,23 +248,41 @@
             Parameter param = portlet.getInitParameterSet().get(PORTLET_ICON);
             String image;
             if (param != null)
-            {
-                String relativeImagePath = param.getValue();
-                String context = muta.getWebApplicationDefinition().getContextRoot();
-                image = context + relativeImagePath;
+            {                
+                //String relativeImagePath = param.getValue();
+                //String context = muta.getWebApplicationDefinition().getContextRoot();
+                // Have to use a supported icon in jetspeed, otherwise image can be out of
skew
+                String  imagePath = param.getValue();
+                if (imagePath == null)
+                {
+                    image = DEFAULT_IMAGES[rand.nextInt(DEFAULT_IMAGES.length)];
+                }
+                else
+                {
+                    if (-1 == imagePath.indexOf("/"))
+                        image = "images/portlets/" + param.getValue();
+                    else
+                        image = param.getValue();
+                }
             }
             else
             {
-                // default TODO: assign image by category
-                image = "images/portlets/preferences-desktop-locale.png";
+                image = DEFAULT_IMAGES[rand.nextInt(DEFAULT_IMAGES.length)];
             }
-            return new PortletInfo(uniqueName, portlet.getDisplayNameText(locale), portlet.getDescriptionText(locale),
image);
+            return new PortletInfo(uniqueName, cleanup(portlet.getDisplayNameText(locale)),
cleanup(portlet.getDescriptionText(locale)), image);
         }
         catch (AccessControlException ace)
         {
             return null;
         }
         
+    }
+    
+    protected String cleanup(String str)
+    {
+        if (str == null)
+            return str;
+        return str.replaceAll("\r|\n|\"|\'", "");
     }
     
     protected PortletDefinitionComposite getPortletFromParsedObject(ParsedObject po)



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message