tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/contrib/src/net/sf/tapestry/contrib/palette Palette.html Palette.jwc Palette.java
Date Fri, 07 Feb 2003 04:13:10 GMT
hlship      2003/02/06 20:13:10

  Modified:    contrib/src/net/sf/tapestry/contrib/palette Palette.html
                        Palette.jwc Palette.java
  Log:
  Update the Palette component to take advantage of recent improvements in 2.4.
  
  Revision  Changes    Path
  1.9       +32 -15    jakarta-tapestry/contrib/src/net/sf/tapestry/contrib/palette/Palette.html
  
  Index: Palette.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/net/sf/tapestry/contrib/palette/Palette.html,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Palette.html	28 Aug 2001 20:33:41 -0000	1.8
  +++ Palette.html	7 Feb 2003 04:13:10 -0000	1.9
  @@ -1,33 +1,50 @@
   <!-- $Id$ -->
   
   <span jwcid="$content$">
  -<table jwcid="table">
  +<table jwcid="@Any" element="table" class="[[ tableClass ]]">
     <tr>
     	<th>
  - <span jwcid="insertAvailableTitle"/>
  - <span jwcid="defaultAvailableTitleBlock">Available</span>
  + <span jwcid="@RenderBlock" block="[[ availableTitleBlock ]]"/>
  + <span jwcid="defaultAvailableTitleBlock@Block">Available</span>
   </th>
     	<td class="controls" rowspan=2>
  -  	    <a jwcid="selectButton"><img jwcid="selectImage" alt="[Select]"/></a>
  +  	    <a jwcid="@Any" 
  +  	    	element="a" 
  +  	    	href="[[ symbols.selectOnClickScript ]]"><img jwcid="@Image"
  +  	    		image="[[ selectImage ]]"
  +  	    		name="[[ symbols.selectImageName ]]"
  +  	    		alt="[Select]"/></a>
       <br>
  -    <a jwcid="deselectButton"><img jwcid="deselectImage" alt="[Deselect]"/></a>
  +    <a jwcid="@Any" element="a"
  +    	href="[[ symbols.deselectOnClickScript ]]"><img jwcid="@Image"
  +    		image="[[ deselectImage ]]"
  +    		name="[[ symbols.deselectImageName ]]"
  +    		alt="[Deselect]"/></a>
       
  -    <span jwcid="ifSortUser">
  -    <br>
  -    <a jwcid="moveUpButton"><img jwcid="upImage" alt="[Move Up]"/></a>
  -    <br>
  -    <a jwcid="moveDownButton"><img jwcid="downImage" alt="[Move Down]"/></a>
  +    <span jwcid="@Conditional" condition="[[ sortUser ]]">
  +    <br/>
  +    <a jwcid="@Any" element="a"
  +    	href="[[ symbols.upOnClickScript ]]"><img jwcid="@Image" 
  +    		image="[[ upImage ]]"
  +    		name="[[ symbols.upImageName ]]"
  +    		alt="[Move Up]"/></a>
  +    <br/>
  +    <a jwcid="@Any" element="a"
  +    	href="[[ symbols.downOnClickScript ]]"><img jwcid="@Image"
  +    		image="[[ downImage ]]"
  +    		name="[[ symbols.downImageName ]]"
  +    		alt="[Move Down]"/></a>
       </span>
       
       </td>
     	<th>
  - <span jwcid="insertSelectedTitle"/>
  - <span jwcid="defaultSelectedTitleBlock">Selected</span>
  + <span jwcid="@RenderBlock" block="[[ selectedTitleBlock ]]"/>
  + <span jwcid="defaultSelectedTitleBlock@Block">Selected</span>
       </th>
     </tr>
     <tr>
  -    <td><select jwcid="availableSelect"/></td>
  -    <td><select jwcid="selectedSelect"/></td>
  +    <td><select jwcid="@Delegator" delegate="[[ availableSelectDelegate ]]"/></td>
  +    <td><select jwcid="@Delegator" delegate="[[ selectedSelectDelegate ]]"/></td>
     </tr>
   </table>
   </span>
  
  
  
  1.16      +16 -85    jakarta-tapestry/contrib/src/net/sf/tapestry/contrib/palette/Palette.jwc
  
  Index: Palette.jwc
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/net/sf/tapestry/contrib/palette/Palette.jwc,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Palette.jwc	26 Jan 2003 02:59:21 -0000	1.15
  +++ Palette.jwc	7 Feb 2003 04:13:10 -0000	1.16
  @@ -12,116 +12,47 @@
     </description>
     
     <parameter name="selectedTitleBlock" 
  -  	java-type="net.sf.tapestry.components.Block" 
  +  	type="net.sf.tapestry.components.Block" 
     	required="no"
     	direction="in"/>
     
     <parameter name="availableTitleBlock" 
  -   	java-type="net.sf.tapestry.components.Block" 
  +   	type="net.sf.tapestry.components.Block" 
      	required="no"
      	direction="in"/>
      	
     <parameter name="model" 
  -  	java-type="net.sf.tapestry.form.IPropertySelectionModel" 
  +  	type="net.sf.tapestry.form.IPropertySelectionModel" 
     	required="yes"
     	direction="in"/>
     
  -  <parameter name="selected" java-type="java.util.List" 
  +  <parameter name="selected" type="java.util.List" 
     	required="yes" direction="form"/>
     
     <parameter name="sort" 
  -  	java-type="net.sf.tapestry.contrib.palette.SortMode" 
  +  	type="net.sf.tapestry.contrib.palette.SortMode" 
     	required="no"
     	direction="in"/>
     
     <parameter name="rows" 
  -   	java-type="int" 
  +   	type="int" 
      	required="no"
      	direction="in"/>
     
     <parameter name="tableClass" 
  -  	java-type="java.lang.String" 
  +  	type="java.lang.String" 
     	required="no"
     	direction="in"/>
     
  -  <parameter name="selectImage" java-type="net.sf.tapestry.IAsset" direction="in"/>
  -  <parameter name="selectDisabledImage" java-type="net.sf.tapestry.IAsset" direction="in"/>
  -  <parameter name="deselectImage" java-type="net.sf.tapestry.IAsset" direction="in"/>
  -  <parameter name="deselectDisabledImage" java-type="net.sf.tapestry.IAsset" direction="in"/>
  -  <parameter name="upImage" java-type="net.sf.tapestry.IAsset" direction="in"/>
  -  <parameter name="upDisabledImage" java-type="net.sf.tapestry.IAsset" direction="in"/>
  -  <parameter name="downImage" java-type="net.sf.tapestry.IAsset" direction="in"/>
  -  <parameter name="downDisabledImage" java-type="net.sf.tapestry.IAsset" direction="in"/>
  -  
  -  <component id="table" type="Any">
  -    <static-binding name="element">table</static-binding>
  -    <binding name="class" expression="tableClass"/>
  -  </component>
  -  
  -  <component id="insertAvailableTitle" type="RenderBlock">
  -    <binding name="block" expression="availableTitleBlock"/>
  -  </component>
  +  <parameter name="selectImage" type="net.sf.tapestry.IAsset" direction="in"/>
  +  <parameter name="selectDisabledImage" type="net.sf.tapestry.IAsset" direction="in"/>
  +  <parameter name="deselectImage" type="net.sf.tapestry.IAsset" direction="in"/>
  +  <parameter name="deselectDisabledImage" type="net.sf.tapestry.IAsset" direction="in"/>
  +  <parameter name="upImage" type="net.sf.tapestry.IAsset" direction="in"/>
  +  <parameter name="upDisabledImage" type="net.sf.tapestry.IAsset" direction="in"/>
  +  <parameter name="downImage" type="net.sf.tapestry.IAsset" direction="in"/>
  +  <parameter name="downDisabledImage" type="net.sf.tapestry.IAsset" direction="in"/>
       
  -  <component id="defaultAvailableTitleBlock" type="Block"/>
  -  
  -  <component id="insertSelectedTitle" type="RenderBlock">
  -    <binding name="block" expression="selectedTitleBlock"/>
  -  </component>
  -
  -  <component id="defaultSelectedTitleBlock" type="Block"/>
  -    
  -  <component id="availableSelect" type="Delegator">
  -    <binding name="delegate" expression="availableSelectDelegate"/>
  -  </component>
  -  
  -  <component id="selectedSelect" type="Delegator">
  -    <binding name="delegate" expression="selectedSelectDelegate"/>
  -  </component>
  -  
  -  <component id="selectButton" type="Any">
  -    <static-binding name="element">a</static-binding>
  -    <binding name="href" expression="symbols.selectOnClickScript"/>
  -  </component>
  -
  -  <component id="selectImage" type="Image">
  -  	<binding name="image" expression="selectImage"/>
  -  	<binding name="name" expression="symbols.selectImageName"/>
  -  </component>
  -  	  
  -  <component id="deselectButton" type="Any">
  -    <static-binding name="element">a</static-binding>
  -    <binding name="href" expression="symbols.deselectOnClickScript"/>
  -  </component>
  -
  -  <component id="deselectImage" type="Image">
  -  	<binding name="image" expression="deselectImage"/>
  -  	<binding name="name" expression="symbols.deselectImageName"/>
  -  </component>
  -    
  -  <component id="ifSortUser" type="Conditional">
  -    <binding name="condition" expression="sortUser"/>
  -  </component>
  -  
  -  <component id="moveUpButton" type="Any">
  -  	<static-binding name="element">a</static-binding>
  -    <binding name="href" expression="symbols.upOnClickScript"/>
  -   </component>
  -
  -  <component id="upImage" type="Image">
  -    <binding name="image" expression="upImage"/>
  -    <binding name="name" expression="symbols.upImageName"/>
  -   </component>
  -  
  -  <component id="moveDownButton" type="Any">
  -    <static-binding name="element">a</static-binding>
  -    <binding name="href" expression="symbols.downOnClickScript"/>
  -  </component>
  -  
  -  <component id="downImage" type="Image">
  -    <binding name="image" expression="downImage"/>
  -    <binding name="name" expression="symbols.downImageName"/>
  -  </component>
  -
     <private-asset name="Select" resource-path="select_right.gif"/>
     <private-asset name="SelectDisabled" resource-path="select_right_off.gif"/>
     <private-asset name="Deselect" resource-path="deselect_left.gif"/>
  
  
  
  1.28      +79 -176   jakarta-tapestry/contrib/src/net/sf/tapestry/contrib/palette/Palette.java
  
  Index: Palette.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/net/sf/tapestry/contrib/palette/Palette.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Palette.java	17 Jan 2003 17:40:56 -0000	1.27
  +++ Palette.java	7 Feb 2003 04:13:10 -0000	1.28
  @@ -76,6 +76,7 @@
   import net.sf.tapestry.RequestCycleException;
   import net.sf.tapestry.ScriptException;
   import net.sf.tapestry.ScriptSession;
  +import net.sf.tapestry.Tapestry;
   import net.sf.tapestry.components.Block;
   import net.sf.tapestry.form.Form;
   import net.sf.tapestry.form.FormEventType;
  @@ -163,7 +164,7 @@
    * <tr>
    *  <td>selectedTitleBlock</td>
    *  <td>{@link Block}</td>
  - *  </td>in</td> 
  + *  <td>in</td> 
    *  <td>no</td> 
    *  <td>"Selected"</td>
    *  <td>If specified, allows a {@link Block} to be placed within
  @@ -175,7 +176,7 @@
    * <tr>
    *  <td>availableTitleBlock</td>
    *  <td>{@link Block}</td>
  - *  </td>in</td> 
  + *  <td>in</td> 
    *  <td>no</td> 
    *  <td>"Available"</td>
    *  <td>As with selectedTitleBlock, but for the left column, of items
  @@ -213,29 +214,12 @@
    * 
    **/
   
  -public class Palette extends BaseComponent implements IFormComponent
  +public abstract class Palette extends BaseComponent implements IFormComponent
   {
       private static final int DEFAULT_ROWS = 10;
       private static final int MAP_SIZE = 7;
       private static final String DEFAULT_TABLE_CLASS = "tapestry-palette";
   
  -    /** @since 2.2 **/
  -    private List _selected;
  -    private IPropertySelectionModel _model;
  -    private SortMode _sort = SortMode.NONE;
  -    private int _rows = DEFAULT_ROWS;
  -    private String _tableClass = DEFAULT_TABLE_CLASS;
  -    private Block _selectedTitleBlock;
  -    private Block _availableTitleBlock;
  -    private IAsset _selectImage;
  -    private IAsset _selectDisabledImage;
  -    private IAsset _deselectImage;
  -    private IAsset _deselectDisabledImage;
  -    private IAsset _upImage;
  -    private IAsset _upDisabledImage;
  -    private IAsset _downImage;
  -    private IAsset _downDisabledImage;
  -
       /**
        *  {@link IForm} which is currently wrapping the Palette.
        *
  @@ -284,17 +268,21 @@
   
       public void finishLoad()
       {
  -        _selectedTitleBlock = (Block) getComponent("defaultSelectedTitleBlock");
  -        _availableTitleBlock = (Block) getComponent("defaultAvailableTitleBlock");
  +        setSelectedTitleBlock((Block) getComponent("defaultSelectedTitleBlock"));
  +        setAvailableTitleBlock((Block) getComponent("defaultAvailableTitleBlock"));
   
  -        _selectImage = getAsset("Select");
  -        _selectDisabledImage = getAsset("SelectDisabled");
  -        _deselectImage = getAsset("Deselect");
  -        _deselectDisabledImage = getAsset("DeselectDisabled");
  -        _upImage = getAsset("Up");
  -        _upDisabledImage = getAsset("UpDisabled");
  -        _downImage = getAsset("Down");
  -        _downDisabledImage = getAsset("DownDisabled");
  +        setSelectImage(getAsset("Select"));
  +        setSelectDisabledImage(getAsset("SelectDisabled"));
  +        setDeselectImage(getAsset("Deselect"));
  +        setDeselectDisabledImage(getAsset("DeselectDisabled"));
  +        setUpImage(getAsset("Up"));
  +        setUpDisabledImage(getAsset("UpDisabled"));
  +        setDownImage(getAsset("Down"));
  +        setDownDisabledImage(getAsset("DownDisabled"));
  +
  +        setTableClass(DEFAULT_TABLE_CLASS);
  +        setRows(DEFAULT_ROWS);
  +        setSort(SortMode.NONE);
       }
   
       /**
  @@ -394,17 +382,17 @@
           if (body == null)
               throw new RequestCycleException("Palette component must be wrapped by a Body.",
this);
   
  -        setImage(body, cycle, "selectImage", _selectImage);
  -        setImage(body, cycle, "selectDisabledImage", _selectDisabledImage);
  -        setImage(body, cycle, "deselectImage", _deselectImage);
  -        setImage(body, cycle, "deselectDisabledImage", _deselectDisabledImage);
  +        setImage(body, cycle, "selectImage", getSelectImage());
  +        setImage(body, cycle, "selectDisabledImage", getSelectDisabledImage());
  +        setImage(body, cycle, "deselectImage", getDeselectImage());
  +        setImage(body, cycle, "deselectDisabledImage", getDeselectDisabledImage());
   
  -        if (_sort == SortMode.USER)
  +        if (isSortUser())
           {
  -            setImage(body, cycle, "upImage", _upImage);
  -            setImage(body, cycle, "upDisabledImage", _upDisabledImage);
  -            setImage(body, cycle, "downImage", _downImage);
  -            setImage(body, cycle, "downDisabledImage", _downDisabledImage);
  +            setImage(body, cycle, "upImage", getUpImage());
  +            setImage(body, cycle, "upDisabledImage", getUpDisabledImage());
  +            setImage(body, cycle, "downImage", getDownImage());
  +            setImage(body, cycle, "downDisabledImage", getDownDisabledImage());
           }
   
           _symbols.put("palette", this);
  @@ -452,39 +440,43 @@
       {
           // Build a Set around the list of selected items.
   
  -        Set selectedSet = _selected == null ? Collections.EMPTY_SET : new HashSet(_selected);
  +        List selected = getSelected();
  +
  +        Set selectedSet = selected == null ? Collections.EMPTY_SET : new HashSet(selected);
   
           _selectedWriter = writer.getNestedWriter();
           _availableWriter = writer.getNestedWriter();
   
           _selectedWriter.begin("select");
           _selectedWriter.attribute("multiple");
  -        _selectedWriter.attribute("size", _rows);
  +        _selectedWriter.attribute("size", getRows());
           _selectedWriter.attribute("name", _name);
           _selectedWriter.println();
   
           _availableWriter.begin("select");
           _availableWriter.attribute("multiple");
  -        _availableWriter.attribute("size", _rows);
  +        _availableWriter.attribute("size", getRows());
           _availableWriter.attribute("name", (String) _symbols.get("availableName"));
           _availableWriter.println();
   
           // Each value specified in the model will go into either the selected or available
           // lists.
   
  -        int count = _model.getOptionCount();
  +        IPropertySelectionModel model = getModel();
  +
  +        int count = model.getOptionCount();
           for (int i = 0; i < count; i++)
           {
               IMarkupWriter w = _availableWriter;
   
  -            Object optionValue = _model.getOption(i);
  +            Object optionValue = model.getOption(i);
   
               if (selectedSet.contains(optionValue))
                   w = _selectedWriter;
   
               w.beginEmpty("option");
  -            w.attribute("value", _model.getValue(i));
  -            w.print(_model.getLabel(i));
  +            w.attribute("value", model.getValue(i));
  +            w.print(model.getLabel(i));
               w.println();
           }
   
  @@ -537,23 +529,28 @@
           RequestContext context = cycle.getRequestContext();
           String[] values = context.getParameters(_name);
   
  -        if (values == null || values.length == 0)
  -            return;
  +        int count = Tapestry.size(values);
   
  -        _selected = new ArrayList(values.length);
  +        if (count == 0)
  +            return;
   
  -        for (int i = 0; i < values.length; i++)
  +        List selected = new ArrayList(count);
  +		IPropertySelectionModel model = getModel();
  +		
  +        for (int i = 0; i < count; i++)
           {
               String value = values[i];
  -            Object option = _model.translateValue(value);
  +            Object option = model.translateValue(value);
   
  -            _selected.add(option);
  +            selected.add(option);
           }
  +
  +        setSelected(selected);
       }
   
       public boolean isSortUser()
       {
  -        return _sort == SortMode.USER;
  +        return getSort() == SortMode.USER;
       }
   
       /**
  @@ -566,145 +563,57 @@
           return null;
       }
   
  -    public Block getAvailableTitleBlock()
  -    {
  -        return _availableTitleBlock;
  -    }
  -
  -    public void setAvailableTitleBlock(Block availableTitleBlock)
  -    {
  -        _availableTitleBlock = availableTitleBlock;
  -    }
  -
  -    public IAsset getDeselectDisabledImage()
  -    {
  -        return _deselectDisabledImage;
  -    }
  +    public abstract Block getAvailableTitleBlock();
   
  -    public void setDeselectDisabledImage(IAsset deselectDisabledImage)
  -    {
  -        _deselectDisabledImage = deselectDisabledImage;
  -    }
  +    public abstract void setAvailableTitleBlock(Block availableTitleBlock);
   
  -    public IAsset getDeselectImage()
  -    {
  -        return _deselectImage;
  -    }
  +    public abstract IAsset getDeselectDisabledImage();
   
  -    public void setDeselectImage(IAsset deselectImage)
  -    {
  -        _deselectImage = deselectImage;
  -    }
  +    public abstract void setDeselectDisabledImage(IAsset deselectDisabledImage);
   
  -    public IAsset getDownDisabledImage()
  -    {
  -        return _downDisabledImage;
  -    }
  +    public abstract IAsset getDeselectImage();
   
  -    public void setDownDisabledImage(IAsset downDisabledImage)
  -    {
  -        _downDisabledImage = downDisabledImage;
  -    }
  +    public abstract void setDeselectImage(IAsset deselectImage);
   
  -    public IAsset getDownImage()
  -    {
  -        return _downImage;
  -    }
  +    public abstract IAsset getDownDisabledImage();
   
  -    public void setDownImage(IAsset downImage)
  -    {
  -        _downImage = downImage;
  -    }
  +    public abstract void setDownDisabledImage(IAsset downDisabledImage);
   
  -    public IPropertySelectionModel getModel()
  -    {
  -        return _model;
  -    }
  +    public abstract IAsset getDownImage();
   
  -    public void setModel(IPropertySelectionModel model)
  -    {
  -        _model = model;
  -    }
  +    public abstract void setDownImage(IAsset downImage);
   
  -    public int getRows()
  -    {
  -        return _rows;
  -    }
  +    public abstract IPropertySelectionModel getModel();
   
  -    public void setRows(int rows)
  -    {
  -        _rows = rows;
  -    }
  +    public abstract int getRows();
   
  -    public IAsset getSelectDisabledImage()
  -    {
  -        return _selectDisabledImage;
  -    }
  +    public abstract void setRows(int rows);
   
  -    public void setSelectDisabledImage(IAsset selectDisabledImage)
  -    {
  -        _selectDisabledImage = selectDisabledImage;
  -    }
  +    public abstract IAsset getSelectDisabledImage();
   
  -    public Block getSelectedTitleBlock()
  -    {
  -        return _selectedTitleBlock;
  -    }
  +    public abstract void setSelectDisabledImage(IAsset selectDisabledImage);
   
  -    public void setSelectedTitleBlock(Block selectedTitleBlock)
  -    {
  -        _selectedTitleBlock = selectedTitleBlock;
  -    }
  +    public abstract Block getSelectedTitleBlock();
   
  -    public IAsset getSelectImage()
  -    {
  -        return _selectImage;
  -    }
  +    public abstract void setSelectedTitleBlock(Block selectedTitleBlock);
   
  -    public void setSelectImage(IAsset selectImage)
  -    {
  -        _selectImage = selectImage;
  -    }
  +    public abstract IAsset getSelectImage();
   
  -    public SortMode getSort()
  -    {
  -        return _sort;
  -    }
  +    public abstract void setSelectImage(IAsset selectImage);
   
  -    public void setSort(SortMode sort)
  -    {
  -        _sort = sort;
  -    }
  +    public abstract SortMode getSort();
   
  -    public String getTableClass()
  -    {
  -        return _tableClass;
  -    }
  +    public abstract void setSort(SortMode sort);
   
  -    public void setTableClass(String tableClass)
  -    {
  -        _tableClass = tableClass;
  -    }
  +    public abstract void setTableClass(String tableClass);
   
  -    public IAsset getUpDisabledImage()
  -    {
  -        return _upDisabledImage;
  -    }
  +    public abstract IAsset getUpDisabledImage();
   
  -    public void setUpDisabledImage(IAsset upDisabledImage)
  -    {
  -        _upDisabledImage = upDisabledImage;
  -    }
  +    public abstract void setUpDisabledImage(IAsset upDisabledImage);
   
  -    public IAsset getUpImage()
  -    {
  -        return _upImage;
  -    }
  +    public abstract IAsset getUpImage();
   
  -    public void setUpImage(IAsset upImage)
  -    {
  -        _upImage = upImage;
  -    }
  +    public abstract void setUpImage(IAsset upImage);
   
       /**
        *  Returns false.  Palette components are never disabled.
  @@ -720,16 +629,10 @@
   
       /** @since 2.2 **/
   
  -    public List getSelected()
  -    {
  -        return _selected;
  -    }
  +    public abstract List getSelected();
   
       /**  @since 2.2 **/
   
  -    public void setSelected(List selected)
  -    {
  -        _selected = selected;
  -    }
  +    public abstract void setSelected(List selected);
   
   }
  
  
  

Mime
View raw message