[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util ...

Christian Bauer christian at hibernate.org
Thu Jun 21 02:06:15 EDT 2007


  User: cbauer  
  Date: 07/06/21 02:06:15

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/util 
                        WikiUtil.java
  Log:
  Drag and drop support for sorting menu items
  
  Revision  Changes    Path
  1.9       +18 -0     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WikiUtil.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- WikiUtil.java	12 Jun 2007 17:51:00 -0000	1.8
  +++ WikiUtil.java	21 Jun 2007 06:06:15 -0000	1.9
  @@ -12,6 +12,7 @@
   import javax.imageio.ImageIO;
   import java.util.Collection;
   import java.util.List;
  +import java.util.Collections;
   import java.math.BigDecimal;
   import java.awt.image.BufferedImage;
   import java.awt.*;
  @@ -192,6 +193,23 @@
       }
   
       /**
  +     * Moves the element at <tt>oldPosition</tt> to <tt>newPosition</tt>.
  +     * <p>
  +     * Correctly handles forward and backward shifting of previous or subsequent elements.
  +     *
  +     * @param list the list that is affected
  +     * @param oldPosition the position of the element to move
  +     * @param newPosition the new position of the element
  +     */
  +    public static void shiftListElement(List list, int oldPosition, int newPosition) {
  +        if (oldPosition> newPosition) {
  +            Collections.rotate(list.subList(newPosition, oldPosition+1), +1);
  +        } else if (oldPosition < newPosition) {
  +            Collections.rotate(list.subList(oldPosition, newPosition+1), -1);
  +        }
  +    }
  +
  +    /**
        * Need to bind UI components to non-conversational backing beans.
        * That this is even needed makes no sense. Why can't I call the UI components
        * in the EL directly? Don't try #{components['id']}, it won't work.
  
  
  



More information about the jboss-cvs-commits mailing list