raphael     01/05/29 15:57:52

  Modified:    src/java/org/apache/jetspeed/portal BasePortletSet.java
                        PortletController.java PortletState.java
               src/java/org/apache/jetspeed/portal/controls
                        AbstractPortletControl.java
               src/java/org/apache/jetspeed/portal/portlets
                        AbstractPortlet.java
               src/java/org/apache/jetspeed/portal/portlets/customize
                        CustomizePortlet.java PSMLTemplateGenerator.java
  Added:       src/java/org/apache/jetspeed/portal PortalState.java
               src/java/org/apache/jetspeed/portal/portlets
                        VelocityPortlet.java
  Log:
  add support for :
  - close portlet
  - stateful maximize and customization support
    (ie correctly skinned...)
  
  Customization link only works with VelocityPortlets right now...
  
  Revision  Changes    Path
  1.3       +147 -21   
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java
  
  Index: BasePortletSet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasePortletSet.java       2001/05/27 11:07:31     1.2
  +++ BasePortletSet.java       2001/05/29 22:57:40     1.3
  @@ -82,9 +82,9 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Kevin A. Burton</a>
  - * @version $Id: BasePortletSet.java,v 1.2 2001/05/27 11:07:31 raphael Exp $
  + * @version $Id: BasePortletSet.java,v 1.3 2001/05/29 22:57:40 raphael Exp $
    */
  -public class BasePortletSet implements PortletSet, Portlet
  +public class BasePortletSet implements PortletSet, Portlet, PortletState
   {
   
       /**
  @@ -117,6 +117,21 @@
       */
       private long creationTime;
       
  +    /** 
  +    The name of the portlet being customized
  +    */
  +    private String customize;
  +    
  +    /** 
  +    The name of the portlet being maximized
  +    */
  +    private String maximize;
  +
  +    /** 
  +    The name of the portlet displaying info
  +    */
  +    private String info;
  +
       /**
       Builds a new empty set for storing portlets
       */
  @@ -269,32 +284,47 @@
       public ConcreteElement getContent(RunData rundata)
       {
   
  -        //since PortletSets have to run from the current HTTP user we must
  -        //use their associated metadata
  -            
  -        CapabilityMap map = CapabilityMapFactory.getCapabilityMap( rundata );
  -        PortletController controller = getController();
  -            
  -        if ( controller == null )
  +        ConcreteElement content = null;
  +        
  +        if (PortalState.hasCustomized(rundata))
           {
  -            Portlet p = getPortletAt(0);
  +            //handle the customize special case
  +            content = PortalState.getCustomizeContent( this, rundata );
  +        }
  +        else if (PortalState.hasMaximized(rundata))
  +        {
  +            //handle the maximize special case
  +            content = PortalState.getMaximizeContent( this, rundata );
  +        }
  +        
  +        if (content == null)
  +        {
  +            //process the normal rendering flow
               
  -            if (p!=null)
  +            CapabilityMap map = CapabilityMapFactory.getCapabilityMap( rundata );
  +            PortletController controller = getController();
  +            
  +            if ( controller == null )
               {
  -                return p.getContent( rundata );
  +                Portlet p = getPortletAt(0);
  +            
  +                if (p!=null)
  +                {
  +                    return p.getContent( rundata );
  +                }
               }
  -        }
  -        else
  -        {
  -            if ( ! controller.supportsType( map.getPreferredType() ) )
  +            else
               {
  -                setController( ControllerFactory.getPortletController("") );
  +                if ( ! controller.supportsType( map.getPreferredType() ) )
  +                {
  +                    setController( ControllerFactory.getPortletController("") );
  +                }
  +    
  +                return controller.getContent( rundata );
               }
  -
  -            return controller.getContent( rundata );
           }
   
  -        return null;
  +        return content;
       }
   
       /**
  @@ -455,6 +485,102 @@
               }
           }
   
  +        return false;
  +    }
  +
  +    // PortletState Interface implementation
  +    
  +    /**
  +     * Implements the default close behavior: any authenticated user may
  +     * remove a portlet from his page
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowClose( RunData rundata )
  +    {
  +        return false;
  +    }
  +
  +    /**
  +     * Returns true if this portlet is currently closed
  +     */
  +    public boolean isClosed(RunData data)
  +    {
  +        return false;
  +    }
  +
  +    /**
  +     * Toggles the portlet state between closed and normal
  +     *
  +     * @param minimized the new portlet state
  +     * @param data the RunData for this request
  +     */
  +    public void setClosed(boolean close, RunData data)
  +    {
  +        // empty
  +    }
  +
  +    /**
  +     * Implements the default info behavior: any authenticated user may
  +     * get information on a portlet
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowInfo( RunData rundata )
  +    {
  +        return false;
  +    }
  +
  +    /**
  +     * Implements the default customize behavior: any authenticated user may
  +     * customize a portlet
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowCustomize( RunData rundata )
  +    {
  +        return ( (rundata.getUser() != null) && rundata.getUser().hasLoggedIn() );
  +    }
  +
  +    /**
  +     * Implements the default maximize behavior: any authenticated user may
  +     * maximize a portlet
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowMaximize( RunData rundata )
  +    {
  +        return false;
  +    }
  +
  +    /**
  +     * Implements the default info behavior: any authenticated user may
  +     * minimize a portlet
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowMinimize( RunData rundata )
  +    {
  +        return false;
  +    }
  +
  +    /**
  +     * Returns true if this portlet is currently minimized
  +     */
  +    public boolean isMinimized(RunData rundata)
  +    {
           return false;
  -    }        
  +    }
  +
  +    /**
  +    Change the portlet visibility state ( minimized <-> normal )
  +
  +    @param minimize True if the portlet change to minimized
  +    @param rundata A RunData object
  +    */
  +    public void setMinimized( boolean minimize, RunData rundata )
  +    {
  +        // empty
  +    }
  +
   }
  
  
  
  1.50      +2 -15     
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletController.java
  
  Index: PortletController.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletController.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- PortletController.java    2001/05/07 20:48:29     1.49
  +++ PortletController.java    2001/05/29 22:57:41     1.50
  @@ -54,7 +54,6 @@
   
   package org.apache.jetspeed.portal;
   
  -import org.apache.jetspeed.services.portletcache.Cacheable;
   import org.apache.jetspeed.util.MimeType;
   import org.apache.turbine.util.RunData;
   import org.apache.ecs.ConcreteElement;
  @@ -69,9 +68,9 @@
      presentation such as Palm devices.
      
      @author <a href="mailto:[EMAIL PROTECTED]";>Kevin A. Burton</a>
  -   @version $Id: PortletController.java,v 1.49 2001/05/07 20:48:29 raphael Exp $
  +   @version $Id: PortletController.java,v 1.50 2001/05/29 22:57:41 raphael Exp $
   */
  -public interface PortletController extends Cacheable
  +public interface PortletController
   {
   
       /**
  @@ -79,18 +78,6 @@
       */
       public int DEFAULT_PADDING = 3;
   
  -    /**
  -       Used for identification within the Registry
  -    */
  -    public String getName();
  -
  -    /**
  -       Used for identification within the Registry
  -
  -       @see getName()
  -    */
  -    public void setName(String name);
  -    
       /**
          Allows the user to override the default set of portlets...
       */
  
  
  
  1.3       +13 -0     
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletState.java
  
  Index: PortletState.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletState.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PortletState.java 2001/05/28 15:16:10     1.2
  +++ PortletState.java 2001/05/29 22:57:41     1.3
  @@ -79,6 +79,19 @@
       public boolean allowClose( RunData rundata );
   
       /**
  +     * Returns true if this portlet is currently closed
  +     */
  +    public boolean isClosed(RunData data);
  +
  +    /**
  +     * Toggles the portlet state between closed and normal
  +     *
  +     * @param minimized the new portlet state
  +     * @param data the RunData for this request
  +     */
  +    public void setClosed(boolean closed, RunData data);
  +
  +    /**
        * Returns true if the portlet allows the manager to link to a information
        * page about this portlet
        *
  
  
  
  1.1                  
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortalState.java
  
  Index: PortalState.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jetspeed.portal;
  
  import org.apache.turbine.util.RunData;
  import org.apache.ecs.ConcreteElement;
  import java.util.Enumeration;
  
  /**
   * This facade class is used to keep track of the portal state 
   * for any given user session.
   *
   * <p>Portal state can currently be altered by 2 kinds of actions :
   * <ul>
   *   <li>maximizing a portlet
   *   <li>customizing a portlet
   * </ul>
   *
   * In both cases, the layout engine makes sure only the active portlet
   * is shown on screen.
   *
   * The state is not persisted between sessions.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</a>
   */
  public class PortalState
  {
      public static final String CUSTOMIZED = "state-customized";
      public static final String MAXIMIZED = "state-maximized";
      
      /**
       * Returns true if there is a maximized portlet in the current page.
       *
       * @param rundata the RunData object for the current request
       */
      public static boolean hasMaximized( RunData rundata )
      {
          return (rundata.getSession().getAttribute(MAXIMIZED)!=null);
      }
  
      /**
       * Returns the name of the portlet currently maximized for this page
       *
       * @param rundata the RunData object for the current request
       */
      public static String getMaximized( RunData rundata )
      {
          return (String)rundata.getSession().getAttribute(MAXIMIZED);
      }
  
      /**
       * Sets the maximized portlet for this page
       *
       * @param portlet the maximized portlet name
       * @param rundata the RunData object for the current request
       */
      public static void setMaximized( String portlet, RunData rundata )
      {
          rundata.getSession().setAttribute(MAXIMIZED, portlet);
      }
  
      /**
       * Handle the generation of content for the given page when an
       * element is maximized.
       *
       * @param set the PortletSet describing the current page
       * @param data the current request RunData
       * @return the content for the maximized portlet or null if content 
       * generation should proceed as normal.
       */
      public static ConcreteElement getMaximizeContent( PortletSet set, RunData data )
      {        
          String name = getMaximized( data );
          
          if (!set.getName().equals(name))
          {
              Enumeration en = set.getPortlets();
              while(en.hasMoreElements())
              {
                  Portlet p = (Portlet)en.nextElement();
  
                  // unstack the controls to find the real PortletSets
                  Portlet real = p;
                  while (real instanceof PortletControl) { real = 
((PortletControl)p).getPortlet(); }
                          
                  if ( (real instanceof PortletSet) || (p.getName().equals(name)) )
                  {
                      return p.getContent(data);
                  }
              }
          }
  
          return null;
      }
  
      /**
       * Removes any maximized reference
       *
       * @param rundata the RunData object for the current request
       */
      public static void clearMaximized( RunData rundata )
      {
          rundata.getSession().removeAttribute(MAXIMIZED);
      }
  
      /**
       * Returns true if there is a portlet being customized in the current page.
       *
       * @param rundata the RunData object for the current request
       */
      public static boolean hasCustomized( RunData rundata )
      {
          return (rundata.getSession().getAttribute(CUSTOMIZED)!=null);
      }
  
      /**
       * Returns the name of the portlet being customized for this page
       *
       * @param rundata the RunData object for the current request
       */
      public static String getCustomized( RunData rundata )
      {
          return (String)rundata.getSession().getAttribute(CUSTOMIZED);
      }
  
      /**
       * Sets the customized portlet for this page
       *
       * @param portlet the customized portlet name
       * @param rundata the RunData object for the current request
       */
      public static void setCustomized( String portlet, RunData rundata )
      {
          rundata.getSession().setAttribute(CUSTOMIZED, portlet);
      }
  
      /**
       * Handle the generation of content for the given page when an
       * element is customized.
       *
       * @param set the PortletSet describing the current page
       * @param data the current request RunData
       * @return the content for the customized portlet or null if content 
       * generation should proceed as normal.
       */
      public static ConcreteElement getCustomizeContent( PortletSet set, RunData data )
      {        
          String name = getCustomized( data );
          
          if (set.getName().equals(name))
          {
              // FIXME: we can't call getContent() because that would create
              // a loop, call the default customizer for this PortletSet
          }
          else
          {
              Enumeration en = set.getPortlets();
              while(en.hasMoreElements())
              {
                  Portlet p = (Portlet)en.nextElement();
                          
                  // unstack the controls to find the real PortletSets
                  Portlet real = p;
                  while (real instanceof PortletControl) { real = 
((PortletControl)p).getPortlet(); }
                          
                  if ( (real instanceof PortletSet) || (p.getName().equals(name)) )
                  {
                      return p.getContent(data);
                  }
              }
          }
  
          return null;
      }
  
      /**
       * Removes any customized reference
       *
       * @param rundata the RunData object for the current request
       */
      public static void clearCustomized( RunData rundata )
      {
          rundata.getSession().removeAttribute(CUSTOMIZED);
      }
  
      /**
       * Reset the state of the portal for the session
       *
       * @param rundata the RunData object for the current request
       */
      public static void reset( RunData rundata )
      {
          clearCustomized( rundata );
          clearMaximized( rundata );
      }
  
  }
  
  
  
  1.5       +157 -3    
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/AbstractPortletControl.java
  
  Index: AbstractPortletControl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/AbstractPortletControl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractPortletControl.java       2001/05/28 15:14:15     1.4
  +++ AbstractPortletControl.java       2001/05/29 22:57:45     1.5
  @@ -60,6 +60,7 @@
   import java.util.Vector;
   
   import org.apache.jetspeed.portal.Portlet;
  +import org.apache.jetspeed.portal.PortletState;
   import org.apache.jetspeed.portal.PortletConfig;
   import org.apache.jetspeed.portal.PortletSet;
   import org.apache.jetspeed.portal.BasePortletSet;
  @@ -88,7 +89,7 @@
    * a simple portlet wherever in a PSML object tree.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</a>
  - * @version $Id: AbstractPortletControl.java,v 1.4 2001/05/28 15:14:15 raphael Exp $
  + * @version $Id: AbstractPortletControl.java,v 1.5 2001/05/29 22:57:45 raphael Exp $
    */
   public abstract class AbstractPortletControl extends AbstractPortlet
       implements PortletControl
  @@ -389,7 +390,6 @@
                   (PortletControlEntry)Registry.getEntry(Registry.PORTLET_CONTROL,
                                                      getConfig().getName() );
               String baseType = mimeType.toString();
  -            Log.note("Checking type for "+getConfig().getName()+" / type 
"+baseType+" => entry "+entry);
   
               if (entry!=null)
               {
  @@ -399,7 +399,7 @@
                   {
                       String name = (String)i.next();
                       MediaTypeEntry media = 
(MediaTypeEntry)Registry.getEntry(Registry.MEDIA_TYPE, name);
  -                    Log.note(" Found type: "+media.getMimeType());
  +
                       if (media != null)
                       {
                           if (baseType.equals(media.getMimeType())) 
  @@ -551,6 +551,160 @@
       {
           if (getPortlet() instanceof PortletSet)
               ((PortletSet)getPortlet()).setController(controller);
  +    }
  +
  +    // Delegate PortletState Interface
  +    
  +    /**
  +     * Implements the default close behavior: any authenticated user may
  +     * remove a portlet from his page
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowClose( RunData rundata )
  +    {
  +        Portlet p = getPortlet();
  +        
  +        if ( (p!=null) && (p instanceof PortletState) )
  +        {
  +            return ((PortletState)p).allowClose(rundata);
  +        }
  +        
  +        return false;           
  +    }
  +
  +    /**
  +     * Returns true if this portlet is currently closed
  +     */
  +    public boolean isClosed(RunData rundata)
  +    {
  +        Portlet p = getPortlet();
  +        
  +        if ( (p!=null) && (p instanceof PortletState) )
  +        {
  +            return ((PortletState)p).isClosed(rundata);
  +        }
  +        
  +        return false;           
  +    }
  +
  +    /**
  +     * Toggles the portlet state between closed and normal
  +     *
  +     * @param minimized the new portlet state
  +     * @param data the RunData for this request
  +     */
  +    public void setClosed(boolean close, RunData rundata)
  +    {
  +        Portlet p = getPortlet();
  +        
  +        if ( (p!=null) && (p instanceof PortletState) )
  +        {
  +            ((PortletState)p).setClosed(close, rundata);
  +        }
  +    }
  +
  +    /**
  +     * Implements the default info behavior: any authenticated user may
  +     * get information on a portlet
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowInfo( RunData rundata )
  +    {
  +        Portlet p = getPortlet();
  +        
  +        if ( (p!=null) && (p instanceof PortletState) )
  +        {
  +            return ((PortletState)p).allowInfo(rundata);
  +        }
  +        
  +        return false;
  +    }
  +
  +    /**
  +     * Implements the default customize behavior: any authenticated user may
  +     * customize a portlet
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowCustomize( RunData rundata )
  +    {
  +        Portlet p = getPortlet();
  +        
  +        if ( (p!=null) && (p instanceof PortletState) )
  +        {
  +            return ((PortletState)p).allowCustomize(rundata);
  +        }
  +        
  +        return false;
  +    }
  +
  +    /**
  +     * Implements the default maximize behavior: any authenticated user may
  +     * maximize a portlet
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowMaximize( RunData rundata )
  +    {
  +        Portlet p = getPortlet();
  +        
  +        if ( (p!=null) && (p instanceof PortletState) )
  +        {
  +            return ((PortletState)p).allowMaximize(rundata);
  +        }
  +        
  +        return false;
  +    }
  +
  +    /**
  +     * Implements the default info behavior: any authenticated user may
  +     * minimize a portlet
  +     *
  +     * @param rundata the RunData object for the current request
  +     */
  +    public boolean allowMinimize( RunData rundata )
  +    {
  +        Portlet p = getPortlet();
  +        
  +        if ( (p!=null) && (p instanceof PortletState) )
  +        {
  +            return ((PortletState)p).allowMinimize(rundata);
  +        }
  +        
  +        return false;
  +    }
  +
  +    /**
  +     * Returns true if this portlet is currently minimized
  +     */
  +    public boolean isMinimized(RunData rundata)
  +    {
  +        Portlet p = getPortlet();
  +        
  +        if ( (p!=null) && (p instanceof PortletState) )
  +        {
  +            return ((PortletState)p).isMinimized(rundata);
  +        }
  +        
  +        return false;
  +    }
  +
  +    /**
  +    Change the portlet visibility state ( minimized <-> normal )
  +
  +    @param minimize True if the portlet change to minimized
  +    @param rundata A RunData object
  +    */
  +    public void setMinimized( boolean minimize, RunData rundata )
  +    {
  +        Portlet p = getPortlet();
  +        
  +        if ( (p!=null) && (p instanceof PortletState) )
  +        {
  +            ((PortletState)p).setMinimized( minimize, rundata);
  +        }
       }
   
   }
  
  
  
  1.38      +39 -28    
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java
  
  Index: AbstractPortlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- AbstractPortlet.java      2001/05/28 15:13:58     1.37
  +++ AbstractPortlet.java      2001/05/29 22:57:47     1.38
  @@ -93,7 +93,7 @@
   
   @author <A HREF="mailto:[EMAIL PROTECTED]";>Kevin A. Burton</A>
   @author <A HREF="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</A>
  -@version $Id: AbstractPortlet.java,v 1.37 2001/05/28 15:13:58 raphael Exp $
  +@version $Id: AbstractPortlet.java,v 1.38 2001/05/29 22:57:47 raphael Exp $
   */
   public abstract class AbstractPortlet implements Portlet, PortletState, Cacheable
   {
  @@ -125,10 +125,22 @@
       
       /**
       */
  -    public String getName() {
  +    public String getName()
  +    {
   
  -        if ( name == null ) {
  -            return this.getClass().getName();
  +        if ( name == null )
  +        {
  +            if (getPortletConfig()!=null)
  +            {
  +                if (getPortletConfig().getName()!=null)
  +                {
  +                    return getPortletConfig().getName();
  +                }
  +                else
  +                {
  +                    return this.getClass().getName();
  +                }
  +            }
           }
   
           return name;
  @@ -380,7 +392,6 @@
       */
       public boolean supportsType( MimeType mimeType )
       {
  -/*
           PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET, 
getName() );
           String baseType = mimeType.toString();
           if (entry!=null)
  @@ -397,7 +408,7 @@
                   }
               }
           }
  -*/
  +
           return MimeType.HTML.equals( mimeType );
       }
       
  @@ -415,6 +426,28 @@
       }
   
       /**
  +     * Returns true if this portlet is currently closed
  +     */
  +    public boolean isClosed(RunData rundata)
  +    {
  +        return this.getAttribute("_display", "normal", rundata ).equals("closed");
  +    }
  +
  +    /**
  +     * Toggles the portlet state between closed and normal
  +     *
  +     * @param minimized the new portlet state
  +     * @param data the RunData for this request
  +     */
  +    public void setClosed(boolean close, RunData rundata)
  +    {
  +        if( allowClose( rundata ) )
  +        {
  +            this.setAttribute("_display", close ? "closed" : "normal", rundata );
  +        }
  +    }
  +
  +    /**
        * Implements the default info behavior: any authenticated user may
        * get information on a portlet
        *
  @@ -456,28 +489,6 @@
       public boolean allowMinimize( RunData rundata )
       {
           return ( (rundata.getUser() != null) && rundata.getUser().hasLoggedIn() );
  -    }
  -
  -    /**
  -     * Returns true if this portlet is currently maximized
  -     */
  -    public boolean isMaximized(RunData rundata)
  -    {
  -        return this.getAttribute("_display", "normal", rundata 
).equals("maximized");
  -    }
  -
  -    /**
  -    Change the portlet visibility state ( maximized <-> normal )
  -
  -    @param minimize True if the portlet change to maximize
  -    @param rundata A RunData object
  -    */
  -    public void setMaximized( boolean maximize, RunData rundata )
  -    {
  -        if( allowMaximize( rundata ) )
  -        {
  -            this.setAttribute("_display", maximize ? "maximized" : "normal", 
rundata );
  -        }
       }
   
       /**
  
  
  
  1.1                  
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/VelocityPortlet.java
  
  Index: VelocityPortlet.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jetspeed.portal.portlets;
  
  // Turbine stuff
  import org.apache.turbine.util.RunData;
  import org.apache.turbine.services.velocity.TurbineVelocity;
  import org.apache.turbine.services.pull.TurbinePull;
  import org.apache.turbine.modules.ActionLoader;
  
  // Jetspeed stuff
  import org.apache.jetspeed.portal.Portlet;
  import org.apache.jetspeed.portal.portlets.AbstractPortlet;
  import org.apache.jetspeed.portal.PortletException;
  
  // Ecs stuff
  import org.apache.ecs.ConcreteElement;
  import org.apache.ecs.StringElement;
  
  // Velocity Stuff
  import org.apache.velocity.context.Context;
  import org.apache.turbine.util.Log;
  
  /**
   * A Velocity based portlet implementation
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]";>Roberto Carrasco</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</a>
   */
  public class VelocityPortlet extends AbstractPortlet
  {
      /**
      By default the data is non cacheable
      */
      public void init( ) throws PortletException
      {
          setCacheable( false );
      }
  
      public ConcreteElement getContent( RunData rundata )
      {
          // create a blank context and with all the global application
          // Pull Tools inside
          Context context = TurbineVelocity.getContext();
          context.put( "data", rundata );
          context.put( "portlet", this );
          context.put( "conf", this.getPortletConfig() );
          context.put( "skin", this.getPortletConfig().getPortletSkin() );
  
          // Put the request and session based contexts
          TurbinePull.populateContext(context, rundata);
          
          String actionName = getPortletConfig().getInitParameter("action");
          
          if (actionName != null)
          {
              // store the context so that the action can retrieve it
              Log.note("VelocityPortlet found action "+actionName);
              rundata.getTemplateInfo().setTemplateContext( "VelocityPortletContext", 
context );
  
              // if there is an action with the same name in modules/actions/portlets 
exec it
              try
              {
                  ActionLoader.getInstance().exec( rundata, actionName );
              }
              catch( Exception e)
              {
                 Log.error( e.toString() );
              }
          }
   
          // either the action selected the template, or use the default template 
          // defined in the registry
          String template = (String)context.get( "template" );
          
          if (template == null)
          {
              template = getPortletConfig().getInitParameter("template");
          }
  
          // generate the content
          String s = null;
  
          try
          {
              s = TurbineVelocity.handleRequest(context, "portlets/" + template + 
".vm");
          }
          catch( Exception e)
          {
              s= e.toString();
          }
  
          return new StringElement( s );
      }
  
  }
  
  
  
  
  1.10      +0 -4      
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/customize/CustomizePortlet.java
  
  Index: CustomizePortlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/customize/CustomizePortlet.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CustomizePortlet.java     2001/05/02 14:17:24     1.9
  +++ CustomizePortlet.java     2001/05/29 22:57:49     1.10
  @@ -357,7 +357,6 @@
                      {
                         Entry newEntry = new Entry( );
                         newEntry.setParent( name );
  -                      newEntry.setType( "ref" );
                         tempStorage.addElement( newEntry );
                      }
                   }
  @@ -382,7 +381,6 @@
          
                   Entry clearPortletEntry = new Entry( );
                   clearPortletEntry.setParent( "ClearPortlet" );
  -                clearPortletEntry.setType( "ref" );
                   Control clearPortletControl = new Control( );
                   clearPortletControl.setName( ClearPortletControl.class.getName( ) );
                   clearPortletEntry.setControl( clearPortletControl );
  @@ -457,7 +455,6 @@
                   {
                      Entry newEntry = new Entry( );
                      newEntry.setParent( name );
  -                   newEntry.setType( "ref" );
                      tempStorage.addElement( newEntry );
                   }
                }
  @@ -495,7 +492,6 @@
                {
                   Entry clearPortletEntry = new Entry( );
                   clearPortletEntry.setParent( "ClearPortlet" );
  -                clearPortletEntry.setType( "ref" );
                   Control c = new Control( );
                   c.setName( ClearPortletControl.class.getName( ) );
                   clearPortletEntry.setControl( c );
  
  
  
  1.5       +0 -2      
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/customize/PSMLTemplateGenerator.java
  
  Index: PSMLTemplateGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/customize/PSMLTemplateGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PSMLTemplateGenerator.java        2001/03/07 06:47:50     1.4
  +++ PSMLTemplateGenerator.java        2001/05/29 22:57:50     1.5
  @@ -75,7 +75,6 @@
       {
           // First set the root Portlets object with its controller and skin
           Portlets root = new Portlets();
  -        root.setUser( "default");
       
           // set the Controller with its needed parameters for the root object
           Controller rootController = new Controller();
  @@ -129,7 +128,6 @@
       {
           // First set the root Portlets object with its controller and skin
           Portlets root = new Portlets();
  -        root.setUser( "default");
           
           Controller rootController = new Controller();
           rootController.setName( 
org.apache.jetspeed.portal.controllers.WMLCardController.class.getName() );
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to