raphael     01/06/25 03:46:46

  Modified:    src/java/org/apache/jetspeed/portal BasePortletSet.java
  Log:
  add explicit sorting support to BasePortletSet implementation
  
  Revision  Changes    Path
  1.10      +28 -6     
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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BasePortletSet.java       2001/06/09 15:42:45     1.9
  +++ BasePortletSet.java       2001/06/25 10:46:35     1.10
  @@ -80,7 +80,7 @@
    *
    * @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.9 2001/06/09 15:42:45 raphael Exp $
  + * @version $Id: BasePortletSet.java,v 1.10 2001/06/25 10:46:35 raphael Exp $
    */
   public class BasePortletSet implements PortletSet, Portlet, PortletState
   {
  @@ -88,7 +88,7 @@
       /**
       Is this set sorted
       */
  -    private boolean sorted = true;
  +    private boolean dirty = false;
   
       /**
       The PortletConfig of this set
  @@ -234,7 +234,11 @@
               {
                   pc.setPortletSet(this);
                   if (constraints!=null) pc.setConstraints(constraints);
  -                if (position >=0) pc.setPosition(position);
  +                if (position >=0)
  +                {
  +                    pc.setPosition(position);
  +                    if (position < portlets.size()-1) this.dirty = true;
  +                }
               }
           }
       }
  @@ -420,10 +424,28 @@
       // private util methods
   
       /**
  -    Not implemented yet, will sort the portlets according to Layout position
  -    */
  -    final private void sortPortletSet()
  +     * Sort the portlets according to Layout position
  +     */
  +    final public void sortPortletSet()    
       {
  +        if (!this.dirty) return;
  +        
  +        synchronized(portlets)
  +        {
  +            for (int i=0; i < portlets.size(); i++)
  +            {
  +                
  +                Portlet p = (Portlet)portlets.elementAt(i);
  +                int pos = p.getPortletConfig().getPosition();
  +                if ( (pos>=0) && (pos!=i) )
  +                {
  +                    portlets.removeElementAt(i);
  +                    portlets.insertElementAt(p,pos);
  +                }
  +            }
  +                    
  +            this.dirty = false;   
  +        }        
       }
   
       /**
  
  
  

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

Reply via email to