Author: taylor
Date: Thu Nov 12 03:18:22 2009
New Revision: 835210

URL: http://svn.apache.org/viewvc?rev=835210&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-1059
started reworking the actions, and discovered I was in over my head for my 
alloted time
still managed to keep some work on enhancing decorations, so im going to check 
that in under the actions issue
portlet decorators now support 3 new properties:

# option.actions valid values are: show | hide | dropdown | hover (default=show)
option.actions=hide

# option.title valid values are: show | hide (default=show)
option.title=hide

# option.draghandle valid values are: a CSS selector | none (default: ".PTitle" 
selector)

haven't implemented all action modes yet, only show and hide

Added:
    
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/ClearDecoratorActionsFactory.java
   (with props)
Modified:
    
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
    
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/css/styles.css
    
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/decorator.properties
    
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/BaseDecoration.java
    
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/decoration/Decoration.java

Modified: 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp?rev=835210&r1=835209&r2=835210&view=diff
==============================================================================
--- 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
 (original)
+++ 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/jetui-portlet.jsp
 Thu Nov 12 03:18:22 2009
@@ -26,6 +26,7 @@
 <%@ page import="org.apache.jetspeed.portlets.layout.ColumnLayout" %>
 <%@ page import="org.apache.jetspeed.portlets.layout.LayoutCoordinate" %>
 <%@ page import="org.apache.jetspeed.om.page.ContentFragment" %>
+<%@ page import="org.apache.jetspeed.decoration.Decoration" %>
 <%@ page import="org.apache.jetspeed.decoration.DecoratorAction" %>
 <%@ page import="org.apache.jetspeed.PortalReservedParameters" %>
 <%
@@ -34,28 +35,33 @@
        ContentFragment fragment = 
(ContentFragment)request.getAttribute("fragment");
        LayoutCoordinate coordinate = 
(LayoutCoordinate)request.getAttribute("coordinate");
        String title = "";
-       if (fragment.getPortletContent() != null)
+       boolean showTitle = fragment.getDecoration().getTitleOption() == 
Decoration.TitleOption.SHOW;   
+       if (showTitle && fragment.getPortletContent() != null)
            title = fragment.getPortletContent().getTitle();
 %>
        <div class="portal-layout-cell" id="<%=fragment.getId()%>" 
name="<%=fragment.getName()%>" column="<%=coordinate.getX()%>" 
row="<%=coordinate.getY()%>">
                <div class="portlet <%=decorator%>">
                    <div class="PTitle" >
-                 <div class="PTitleContent"><%=title%></div>               
+                 <div class="PTitleContent"><%=title%></div>
                            <div class="PActionBar">
 <%
-                                   for(DecoratorAction action : 
(List<DecoratorAction>)fragment.getDecoration().getActions())
-                                   {                           
-                                       String target = "target='"+ 
action.getTarget() + "'";
-                                       if (action.getTarget() == null)
-                                           target = "";
+                                       Decoration.ActionsOption option = 
fragment.getDecoration().getActionsOption();  
+                                       if (option != 
Decoration.ActionsOption.HIDE) // TODO: HOVER, DROP DOWN not yet implemented
+                                       {
+                                               for(DecoratorAction action : 
(List<DecoratorAction>)fragment.getDecoration().getActions())
+                                           {                           
+                                               String target = "target='"+ 
action.getTarget() + "'";
+                                               if (action.getTarget() == null)
+                                                   target = "";
  %>                        
                             <a href="<%=action.getAction()%>" 
title="<%=action.getName()%>" class="action portlet-action" <%=target%>><img 
src="<%=request.getContextPath()%>/<%=action.getLink()%>" 
alt="<%=action.getAlt()%>" border="0" /></a>
-<% } 
-if (request.getUserPrincipal() != null)
+<%                  } // for loop                              
+// FIXME: integrate close into standard actions, use security constraints on 
close action
+if (request.getUserPrincipal() != null && 
fragment.getDecoration().getActions().size() > 0)
 {
 %>
                                 <span style='cursor: pointer; z-index: 1000;' 
id='jetspeed-close-<%=fragment.getId()%>' title="close" 
class="portlet-action-close"><img 
src="<%=request.getContextPath()%>/decorations/portlet/jetspeed/images/close.gif"
 alt="Close" border="0" /></span>                              
-<% } %>
+<% }  } %>
                            </div>
                      </div>
                       <div class="PContentBorder">

Modified: 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/css/styles.css
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/css/styles.css?rev=835210&r1=835209&r2=835210&view=diff
==============================================================================
--- 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/css/styles.css
 (original)
+++ 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/css/styles.css
 Thu Nov 12 03:18:22 2009
@@ -14,3 +14,9 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 */
+.clear .PActionBar
+{
+   float: right;
+   display: inline;
+   padding:4px;
+}

Modified: 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/decorator.properties
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/decorator.properties?rev=835210&r1=835209&r2=835210&view=diff
==============================================================================
--- 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/decorator.properties
 (original)
+++ 
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/decorations/portlet/clear/decorator.properties
 Thu Nov 12 03:18:22 2009
@@ -16,4 +16,11 @@
 id=clear
 template.type=velocity
 template.extension=.vm
-decorates=any
\ No newline at end of file
+decorates=any
+actions.factory=org.apache.jetspeed.decoration.ClearDecoratorActionsFactory
+# option.actions valid values are: show | hide | dropdown | hover 
(default=show)
+option.actions=hide
+# option.title valid values are: show | hide (default=show)
+option.title=hide
+# option.draghandle valid values are: a CSS selector | none (default: 
".PTitle" selector)
+

Modified: 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/BaseDecoration.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/BaseDecoration.java?rev=835210&r1=835209&r2=835210&view=diff
==============================================================================
--- 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/BaseDecoration.java
 (original)
+++ 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/BaseDecoration.java
 Thu Nov 12 03:18:22 2009
@@ -30,6 +30,8 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.jetspeed.decoration.Decoration.ActionsOption;
+import org.apache.jetspeed.decoration.Decoration.TitleOption;
 import org.apache.jetspeed.util.Path;
 
 /**
@@ -63,6 +65,26 @@
     private String currentModeAction;
     private String currentStateAction;
     private boolean supportsDesktop;
+    private Decoration.ActionsOption actionsOption = ActionsOption.SHOW;
+    private Decoration.TitleOption titleOption = TitleOption.SHOW;
+    private String dragHandleOption;
+    
+    static final String[] ACTIONS_NAMES = 
+    {
+        "show", "hide", "dropdown", "hover"    
+    };
+    static final ActionsOption[] ACTIONS_VALUES = 
+    {
+        ActionsOption.SHOW, ActionsOption.HIDE, ActionsOption.DROPDOWN, 
ActionsOption.HOVER     
+    };
+    static final String[] TITLE_NAMES = 
+    {
+        "show", "hide"    
+    };
+    static final TitleOption[] TITLE_VALUES = 
+    {
+        TitleOption.SHOW, TitleOption.HIDE     
+    };
     
     /**
      * 
@@ -81,8 +103,34 @@
         this.baseClientPath= baseClientPath;
         this.cache = cache;
         
-        this.name = config.getProperty( "name" );      
-        
+        this.name = config.getProperty( "name" );
+        String temp = config.getProperty(Decoration.OPTION_ACTIONS);
+        if (temp != null)
+        {
+            for (int ix = 0; ix < ACTIONS_NAMES.length; ix++)
+            {
+                if (temp.equalsIgnoreCase(ACTIONS_NAMES[ix]))
+                {
+                    this.actionsOption = ACTIONS_VALUES[ix];
+                    break;
+                }
+            }
+        }
+        temp = config.getProperty(Decoration.OPTION_TITLE);
+        if (temp != null)
+        {
+            for (int ix = 0; ix < TITLE_NAMES.length; ix++)
+            {
+                if (temp.equalsIgnoreCase(TITLE_NAMES[ix]))
+                {
+                    this.titleOption = TITLE_VALUES[ix];
+                    break;
+                }
+            }
+        }        
+        this.dragHandleOption = 
config.getProperty(Decoration.OPTION_DRAGHANDLE, ".PTitle");
+        if (dragHandleOption.equalsIgnoreCase("none"))
+            dragHandleOption = null;
         this.commonStylesheet = config.getProperty( "stylesheet", 
DEFAULT_COMMON_STYLE_SHEET );
         
         this.supportsDesktop = "true".equalsIgnoreCase( config.getProperty( 
Decoration.DESKTOP_SUPPORTED_PROPERTY ) );
@@ -293,4 +341,18 @@
     {
         return this.supportsDesktop;
     }
+    
+    public ActionsOption getActionsOption()
+    {
+        return this.actionsOption;
+    }
+    public TitleOption getTitleOption()
+    {
+        return this.titleOption;
+    }
+    public String getDragHandle() // returns null for not supported
+    {
+        return this.getDragHandle();
+    }
+    
 }

Added: 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/ClearDecoratorActionsFactory.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/ClearDecoratorActionsFactory.java?rev=835210&view=auto
==============================================================================
--- 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/ClearDecoratorActionsFactory.java
 (added)
+++ 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/ClearDecoratorActionsFactory.java
 Thu Nov 12 03:18:22 2009
@@ -0,0 +1,55 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.jetspeed.decoration;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.om.page.ContentFragment;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.SecurityAccessController;
+import org.apache.jetspeed.container.PortletWindow;
+
+public class ClearDecoratorActionsFactory extends 
AbstractDecoratorActionsFactory
+{
+    private static final DecoratorActionTemplate PRINT_MODE_TEMPLATE = new 
DecoratorActionTemplate(JetspeedActions.PRINT_MODE);
+    private static final DecoratorActionTemplate SOLO_ACTION_TEMPLATE = new 
DecoratorActionTemplate(JetspeedActions.SOLO_STATE);
+    
+    private final List supportedActions;
+    private final List supportedSoloActions;
+    
+    public ClearDecoratorActionsFactory()
+    {
+        ArrayList list = new ArrayList();
+        supportedActions = Collections.unmodifiableList(list);
+        supportedSoloActions = Collections.unmodifiableList(list);
+    }
+
+    public List getSupportedActions(RequestContext rc, PortletApplication pa, 
PortletWindow pw, PortletMode cm,
+                    WindowState ws, Decoration decoration)
+    {
+        // don't support any window state actions when in "solo" state
+        return JetspeedActions.SOLO_STATE.equals(ws) ? supportedSoloActions : 
supportedActions;
+    }
+}

Propchange: 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/ClearDecoratorActionsFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/ClearDecoratorActionsFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/decoration/Decoration.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/decoration/Decoration.java?rev=835210&r1=835209&r2=835210&view=diff
==============================================================================
--- 
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/decoration/Decoration.java
 (original)
+++ 
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/decoration/Decoration.java
 Thu Nov 12 03:18:22 2009
@@ -53,6 +53,22 @@
     /** Property which specifies the directory name for resource bundle */
     String RESOURCES_DIRECTORY_NAME = "resources";
 
+    String OPTION_TITLE = "option.title";
+    String OPTION_ACTIONS = "option.actions";
+    String OPTION_DRAGHANDLE = "option.draghandle";
+    
+    enum ActionsOption 
+    {
+        SHOW, HIDE, DROPDOWN, HOVER
+    };
+    enum TitleOption 
+    {
+        SHOW, HIDE
+    };
+
+    ActionsOption getActionsOption();
+    TitleOption getTitleOption();
+    String getDragHandle(); // returns null for not supported
     
     /**
      * The name of this Decoration.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to