[jboss-cvs] jboss-portal/portlet/src/main/org/jboss/portal/portlet ...

Chris Laprun chris.laprun at jboss.com
Tue Jul 18 18:29:27 EDT 2006


  User: claprun 
  Date: 06/07/18 18:29:27

  Modified:    portlet/src/main/org/jboss/portal/portlet     Mode.java
                        WindowState.java
  Added:       portlet/src/main/org/jboss/portal/portlet    
                        Actionable.java BaseActionable.java
  Log:
  JBPORTAL-958:
  - Added Actionable and BaseActionable which WindowState and Mode extend.
  - Added support for Actions ordering so that buttons in decoration are always at the same spot.
  - Minor code improvements.
  
  Revision  Changes    Path
  1.2       +27 -43    jboss-portal/portlet/src/main/org/jboss/portal/portlet/Mode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Mode.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/portlet/Mode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- Mode.java	9 Jul 2006 12:04:15 -0000	1.1
  +++ Mode.java	18 Jul 2006 22:29:27 -0000	1.2
  @@ -25,55 +25,39 @@
   
   /**
    * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
  -public class Mode implements Serializable
  +public class Mode extends BaseActionable implements Serializable
   {
   
  -   /** The serialVersionUID. */
  +   /**
  +    * The serialVersionUID.
  +    */
      private static final long serialVersionUID = 6033765240710422050L;
   
  -   /** . */
  -   public static final Mode EDIT = new Mode("edit");
  -
  -   /** . */
  -   public static final Mode HELP = new Mode("help");
  -
  -   /** . */
  -   public static final Mode VIEW = new Mode("view");
  -
  -   /** . */
  -   public static final Mode EDIT_DEFAULTS = new Mode("edit_defaults");
  -
  -   /** . */
  -   private String name;
  +   /**
  +    * .
  +    */
  +   public static final Mode EDIT = new Mode("edit", 101);
   
  -   public Mode(String name)
  -   {
  -      if (name == null)
  -      {
  -         throw new NullPointerException();
  -      }
  -      this.name = name;
  -   }
  +   /**
  +    * .
  +    */
  +   public static final Mode HELP = new Mode("help", 102);
   
  -   public boolean equals(Object o)
  -   {
  -      if (o instanceof Mode)
  -      {
  -         return o == this || name.equalsIgnoreCase(((Mode)o).name);
  -      }
  -      return false;
  -   }
  +   /**
  +    * .
  +    */
  +   public static final Mode VIEW = new Mode("view", 103);
   
  -   public int hashCode()
  -   {
  -      return name.hashCode();
  -   }
  +   /**
  +    * .
  +    */
  +   public static final Mode EDIT_DEFAULTS = new Mode("edit_defaults", 100);
   
  -   public String toString()
  +   protected Mode(String name, int index)
      {
  -      return name;
  +      super(name, index);
      }
   
      private Object readResolve()
  @@ -120,7 +104,7 @@
         }
         else
         {
  -         return new Mode(s);
  +         return new Mode(s, lastUsedIndex++);
         }
      }
   }
  
  
  
  1.2       +11 -33    jboss-portal/portlet/src/main/org/jboss/portal/portlet/WindowState.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WindowState.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/portlet/WindowState.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- WindowState.java	9 Jul 2006 12:04:15 -0000	1.1
  +++ WindowState.java	18 Jul 2006 22:29:27 -0000	1.2
  @@ -25,45 +25,23 @@
   
   /**
    * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
  -public class WindowState implements Serializable
  +public class WindowState extends BaseActionable implements Serializable
   {
   
  -   /** The serialVersionUID */
  +   /**
  +    * The serialVersionUID
  +    */
      private static final long serialVersionUID = -6305311518934458562L;
  -   public static final WindowState NORMAL = new WindowState("normal");
  -   public static final WindowState MINIMIZED = new WindowState("minimized");
  -   public static final WindowState MAXIMIZED = new WindowState("maximized");
  -
  -   private String name;
  -
  -   public WindowState(String name)
  -   {
  -      if (name == null)
  -      {
  -         throw new IllegalArgumentException("Window state name cannot be null.");
  -      }
  -      this.name = name;
  -   }
   
  -   public boolean equals(Object o)
  -   {
  -      if (o instanceof WindowState)
  -      {
  -         return o == this || name.equalsIgnoreCase(((WindowState)o).name);
  -      }
  -      return false;
  -   }
  -
  -   public int hashCode()
  -   {
  -      return name.hashCode();
  -   }
  +   public static final WindowState NORMAL = new WindowState("normal", 101);
  +   public static final WindowState MINIMIZED = new WindowState("minimized", 100);
  +   public static final WindowState MAXIMIZED = new WindowState("maximized", 102);
   
  -   public String toString()
  +   protected WindowState(String name, int index)
      {
  -      return name;
  +      super(name, index);
      }
   
      private Object readResolve()
  @@ -102,7 +80,7 @@
         }
         else
         {
  -         return new WindowState(s);
  +         return new WindowState(s, lastUsedIndex++);
         }
      }
   }
  
  
  
  1.1      date: 2006/07/18 22:29:27;  author: claprun;  state: Exp;jboss-portal/portlet/src/main/org/jboss/portal/portlet/Actionable.java
  
  Index: Actionable.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  
  package org.jboss.portal.portlet;
  
  /**
   * An interface describing the behavior of origin of actions (e.g. WindowState or Mode) for Portlets.
   *
   * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
   * @version $Revision: 1.1 $
   * @see org.jboss.portal.theme.page.WindowResult.Action
   * @since 2.4
   */
  public interface Actionable extends Comparable
  {
     String MODES_KEY = "mode";
     String WINDOWSTATES_KEY = "windowstate";
  
     /**
      * Returns the displayable name of this Actionable.
      */
     String getName();
  
     /**
      * Returns the absolute order index of this Actionable.
      */
     int getIndex();
  }
  
  
  
  1.1      date: 2006/07/18 22:29:27;  author: claprun;  state: Exp;jboss-portal/portlet/src/main/org/jboss/portal/portlet/BaseActionable.java
  
  Index: BaseActionable.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  
  package org.jboss.portal.portlet;
  
  /**
   * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
   * @version $Revision: 1.1 $
   * @since 2.4
   */
  public class BaseActionable implements Actionable
  {
     /**
      * Records the last index used to compare Actionables.
      */
     protected static int lastUsedIndex = 0;
  
     /**
      * The display name of this Actionable.
      */
     protected final String name;
  
     /**
      * An index indicating the order of this Actionable with respect to others. Used to order buttons on portlet
      * decoration.
      */
     protected final int index;
  
     protected BaseActionable(String name, int index)
     {
        if (name == null)
        {
           throw new IllegalArgumentException("Name cannot be null.");
        }
        this.name = name;
        this.index = index;
     }
  
     public int hashCode()
     {
        return name.hashCode();
     }
  
     public String toString()
     {
        return name;
     }
  
     public String getName()
     {
        return name;
     }
  
     public int getIndex()
     {
        return index;
     }
  
     public boolean equals(Object o)
     {
        if (this == o)
        {
           return true;
        }
        if (o == null || getClass() != o.getClass())
        {
           return false;
        }
  
        final BaseActionable that = (BaseActionable)o;
  
        return name.equalsIgnoreCase(that.name);
  
     }
  
     public int compareTo(Object o)
     {
        Actionable actionable = (Actionable)o;
        if (equals(actionable))
        {
           return 0;
        }
        if (index < actionable.getIndex())
        {
           return -1;
        }
        return 1;
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list