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/05/07 04:40:36 UTC

cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl PageAggregatorImpl.java

taylor      2004/05/06 19:40:36

  Modified:    portal/src/java/org/apache/jetspeed/container/session
                        NavigationalStateComponent.java
               portal/src/java/org/apache/jetspeed/velocity
                        JetspeedPowerTool.java
               portal/src/java/org/apache/jetspeed/container/session/impl
                        JetspeedNavigationalStateComponent.java
               portal/src/java/org/apache/jetspeed/aggregator/impl
                        PageAggregatorImpl.java
  Added:       portal/src/java/org/apache/jetspeed/velocity
                        DecoratorAction.java
  Log:
  start of new feature (JS2-25): decorator actions
  added min, max, restore buttons
  implemented min, restore behavior
  max is not yet implemented
  
  NOTE: this code is not yet optimized (first pass)
  
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  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.5       +24 -1     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalStateComponent.java
  
  Index: NavigationalStateComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalStateComponent.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NavigationalStateComponent.java	4 May 2004 22:05:17 -0000	1.4
  +++ NavigationalStateComponent.java	7 May 2004 02:40:36 -0000	1.5
  @@ -15,6 +15,9 @@
    */
   package org.apache.jetspeed.container.session;
   
  +import javax.portlet.PortletMode;
  +import javax.portlet.WindowState;
  +
   import org.apache.jetspeed.container.url.PortalURL;
   import org.apache.jetspeed.request.RequestContext;
   
  @@ -92,5 +95,25 @@
        * @return The window id from the key
        */    
       String getWindowIdFromKey(String key);
  +    
  +    /**
  +     * Given a window state name, look up its object.
  +     * Ensures that we always use the same objects for WindowStates
  +     * allowing for comparison by value.
  +     * 
  +     * @param name The string representation of the window state.
  +     * @return The corresponding WindowState object
  +     */
  +    //WindowState lookupWindowState(String name);
  +
  +    /**
  +     * Given a portlet mode name, look up its object.
  +     * Ensures that we always use the same objects for Portlet Modes
  +     * allowing for comparison by value.
  +     * 
  +     * @param name The string representation of the portlet mode.
  +     * @return The corresponding PortletMode object
  +     */    
  +    //PortletMode lookupPortletMode(String name);
       
   }
  
  
  
  1.12      +64 -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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JetspeedPowerTool.java	4 May 2004 22:05:18 -0000	1.11
  +++ JetspeedPowerTool.java	7 May 2004 02:40:36 -0000	1.12
  @@ -21,6 +21,7 @@
   import java.util.List;
   import java.util.Locale;
   import java.util.Stack;
  +import java.util.Vector;
   
   import javax.portlet.PortletConfig;
   import javax.portlet.PortletException;
  @@ -50,6 +51,7 @@
   import org.apache.jetspeed.om.page.Fragment;
   import org.apache.jetspeed.om.page.Page;
   import org.apache.jetspeed.request.RequestContext;
  +import org.apache.jetspeed.services.information.PortletURLProviderImpl;
   import org.apache.jetspeed.util.JetspeedObjectID;
   import org.apache.pluto.Constants;
   import org.apache.pluto.om.entity.PortletEntity;
  @@ -583,4 +585,65 @@
           }
       }
   
  +    private static final int ACTION_MINIMIZE = 0;    
  +    private static final int ACTION_MAXIMIZE = 1;
  +    private static final int ACTION_NORMAL = 2;
  +    private static final int ACTION_VIEW = 3;
  +    private static final int ACTION_EDIT = 4;
  +    private static final int ACTION_HELP = 5;
  +        
  +    private static final String ACTION_STRINGS[] =
  +    {
  +            "minimize", "maximize", "restore", "view", "edit", "help"
  +    };
  +    
  +    public List getDecoratorActions()
  +    {
  +        List actions = new Vector();        
  +        WindowState state = getWindowState();
  +        String s = state.toString();
  +        if (s.equals(WindowState.NORMAL.toString()))
  +        {
  +            actions.add(createAction(ACTION_MINIMIZE));
  +            actions.add(createAction(ACTION_MAXIMIZE));
  +        }
  +        else if (s.equals(WindowState.MAXIMIZED.toString()))
  +        {
  +            actions.add(createAction(ACTION_MINIMIZE));
  +            actions.add(createAction(ACTION_NORMAL));            
  +        }
  +        else // minimized
  +        {
  +            actions.add(createAction(ACTION_MAXIMIZE));
  +            actions.add(createAction(ACTION_NORMAL));                        
  +        }
  +        return actions;
  +    }
  +    
  +    public DecoratorAction createAction(int kind)
  +    {
  +        DecoratorAction action = new DecoratorAction(ACTION_STRINGS[kind], ACTION_STRINGS[kind], "content/images/" + ACTION_STRINGS[kind] + ".gif");
  +        PortletEntity entity = getCurrentPortletEntity();
  +        
  +        // TODO: use a factory to create this object
  +        PortletURLProviderImpl url = new PortletURLProviderImpl(Jetspeed.getCurrentRequestContext(), 
  +                                                                windowAccess.getPortletWindow(getCurrentFragment()));
  +        switch (kind)
  +        {
  +            case ACTION_MAXIMIZE:
  +                url.setWindowState(WindowState.MAXIMIZED);
  +                break;
  +            case ACTION_MINIMIZE:
  +                url.setWindowState(WindowState.MINIMIZED);
  +                break;
  +            case ACTION_NORMAL:
  +                url.setWindowState(WindowState.NORMAL);
  +                break;
  +        }
  +        
  +        action.setAction(url.toString());
  +        return action;
  +        
  +    }
  +    
   }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/DecoratorAction.java
  
  Index: DecoratorAction.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed 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.velocity;
  
  /**
   * DecoratorAction
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: DecoratorAction.java,v 1.1 2004/05/07 02:40:36 taylor Exp $
   */
  public class DecoratorAction
  {
      String name = null;
      String link = null;
      String alt = null;
      String action = null;
  
      /**
       * Constructor
       * 
       * @param name   Name of the action
       * @param alt    Alternative text description (localized)
       */
      public DecoratorAction(String name, String alt, String link)
      {
          this.name = name;
          this.alt = alt;
          this.link = link;
      }
      
      public String getName()
      {
          return this.name;
      }
      
      public String getLink()
      {
          return this.link;
      }
      
      public void setLink(String link)
      {
          this.link = link;
      }
  
      public String getAlt()
      {
          return this.alt;
      }
  
      public String getAction()
      {
          return this.action;
      }
      
      public void setAction(String action)
      {
          this.action = action;
      }
      
  }
  
  
  
  1.6       +2 -1      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/JetspeedNavigationalStateComponent.java
  
  Index: JetspeedNavigationalStateComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/JetspeedNavigationalStateComponent.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JetspeedNavigationalStateComponent.java	4 May 2004 22:05:17 -0000	1.5
  +++ JetspeedNavigationalStateComponent.java	7 May 2004 02:40:36 -0000	1.6
  @@ -199,4 +199,5 @@
               return null;        
           return tokenizer.nextToken();                
       }
  +        
   }
  
  
  
  1.2       +10 -5     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
  
  Index: PageAggregatorImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PageAggregatorImpl.java	17 Mar 2004 22:19:53 -0000	1.1
  +++ PageAggregatorImpl.java	7 May 2004 02:40:36 -0000	1.2
  @@ -105,8 +105,12 @@
           {
               layoutDecorator = page.getDefaultDecorator(currentFragment.getType());
           }
  -        
  +       
  +        ///////////////////////////////////////////////////////////////////////////////////////////////
           //TODO: Remove hard coding of locations and use CM + TL
  +        //      DST: Im going to encapsulate this into a class, which can be accessed by 
  +        //           the PowerTool when aggregating content, and make sure to modify the search path
  +        //           according to the current decorator. Assigned issue to JiRa JS2-24        
           List contentPathes = (List) context.getSessionAttribute(ContentFilter.SESSION_CONTENT_PATH_ATTR);
           
           if(contentPathes == null)
  @@ -119,15 +123,16 @@
           {
               // define the lookup order
               contentPathes.add(currentFragment.getType()+"/html/"+layoutDecorator);
  -            contentPathes.add("portlet/html");
  +            contentPathes.add("portlet/html/jetspeed");
  +            contentPathes.add("portlet/html");            
               contentPathes.add("generic/html");
               contentPathes.add("/html");
           }
           else
           {
               contentPathes.set(0, currentFragment.getType()+"/html/"+layoutDecorator);
  -        }
  -        
  +        }        
  +        ///////////////////////////////////////////////////////////////////////////////////////////////
   
           if (checkAccess(context,(currentFragment.getAcl()!=null)?currentFragment.getAcl():acl, "render"))
           {
  
  
  

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