You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2004/09/07 05:58:46 UTC

cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity PortletWindowActionState.java JetspeedPowerTool.java

taylor      2004/09/06 20:58:46

  Modified:    portal/src/java/org/apache/jetspeed/velocity
                        PortletWindowActionState.java
                        JetspeedPowerTool.java
  Log:
  addied support to layout portlets for Help mode
  next step will be secure mode
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.2       +13 -1     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/PortletWindowActionState.java
  
  Index: PortletWindowActionState.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/PortletWindowActionState.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortletWindowActionState.java	3 Sep 2004 18:23:41 -0000	1.1
  +++ PortletWindowActionState.java	7 Sep 2004 03:58:46 -0000	1.2
  @@ -52,6 +52,12 @@
       {
           return portletMode;
       }
  +    
  +    public void setPortletMode(String mode)
  +    {
  +        this.portletMode = mode;
  +    }
  +    
       /**
        * @return Returns the windowState.
        */
  @@ -59,4 +65,10 @@
       {
           return windowState;
       }
  +    
  +    public void setWindowState(String state)
  +    {
  +        this.windowState = state;
  +    }
  +    
   }
  
  
  
  1.23      +93 -1     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java
  
  Index: JetspeedPowerTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JetspeedPowerTool.java	3 Sep 2004 22:51:56 -0000	1.22
  +++ JetspeedPowerTool.java	7 Sep 2004 03:58:46 -0000	1.23
  @@ -833,6 +833,14 @@
                       // nothing has changed
                       return actionState.getActions();
                   }                
  +                else
  +                {
  +                    actionState.setPortletMode(mode);                    
  +                }
  +            }
  +            else
  +            {
  +                actionState.setWindowState(state);
               }
               // something has changed, rebuild the list
           }
  @@ -866,6 +874,90 @@
               createAction(actions, JetspeedActions.INDEX_NORMAL, portlet);                        
           }
           
  +        if (mode.equals(PortletMode.VIEW.toString()))
  +        {
  +            if (content.supportsPortletMode(PortletMode.EDIT))
  +            {
  +                createAction(actions, JetspeedActions.INDEX_EDIT, portlet);
  +            }
  +            if (content.supportsPortletMode(PortletMode.HELP))
  +            {            
  +                createAction(actions, JetspeedActions.INDEX_HELP, portlet);
  +            }
  +        }
  +        else if (mode.equals(PortletMode.EDIT.toString()))
  +        {
  +            createAction(actions, JetspeedActions.INDEX_VIEW, portlet);
  +            if (content.supportsPortletMode(PortletMode.HELP))
  +            {                        
  +                createAction(actions, JetspeedActions.INDEX_HELP, portlet);
  +            }
  +        }
  +        else // help
  +        {
  +            createAction(actions, JetspeedActions.INDEX_VIEW, portlet);
  +            if (content.supportsPortletMode(PortletMode.EDIT))
  +            {            
  +                createAction(actions, JetspeedActions.INDEX_EDIT, portlet);
  +            }
  +        }
  +        return actions;
  +    }
  +
  +    /**
  +     * Gets the list of decorator actions for a page.
  +     * Each page has its own collection of actions associated with it.
  +     * The creation of the decorator action list per page will only be called once per session.
  +     * This optimization is to avoid the expensive operation of security checks and action object creation and logic
  +     * on a per request basis. 
  +     * 
  +     * @return A list of actions available to the current window, filtered by securty access and current state.
  +     * @throws Exception
  +     */
  +    public List getPageDecoratorActions() throws Exception
  +    {
  +        RequestContext context = Jetspeed.getCurrentRequestContext();
  +        String key = getPage().getId();
  +        Map sessionActions = (Map)context.getSessionAttribute(POWER_TOOL_SESSION_ACTIONS);
  +        if (null == sessionActions)
  +        {
  +            sessionActions = new HashMap();
  +            context.setSessionAttribute(POWER_TOOL_SESSION_ACTIONS, sessionActions);
  +        }        
  +        PortletWindowActionState actionState = (PortletWindowActionState)sessionActions.get(key);
  +        
  +        String state = getWindowState().toString();        
  +        String mode = getPortletMode().toString();
  +
  +        if (null == actionState)
  +        {
  +            actionState = new PortletWindowActionState(state, mode);   
  +            sessionActions.put(key, actionState);
  +        }
  +        else
  +        {
  +            if (actionState.getPortletMode().equals(mode))
  +            {
  +                // nothing has changed
  +                return actionState.getActions();
  +            }                
  +            // something has changed, rebuild the list
  +            actionState.setPortletMode(mode);
  +        }
  +        
  +                        
  +        List actions = actionState.getActions();
  +        actions.clear();
  +     
  +        PortletDefinitionComposite portlet = 
  +            (PortletDefinitionComposite) getCurrentPortletEntity().getPortletDefinition();
  +        if (null == portlet)
  +        {
  +            return actions; // allow nothing
  +        }        
  +                
  +        ContentTypeSet content = portlet.getContentTypeSet();
  +                
           if (mode.equals(PortletMode.VIEW.toString()))
           {
               if (content.supportsPortletMode(PortletMode.EDIT))
  
  
  

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