tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tsvete...@apache.org
Subject cvs commit: jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/table TreeTableDataView.java
Date Thu, 17 Jun 2004 14:39:07 GMT
tsvetelin    2004/06/17 07:39:07

  Modified:    contrib/src/org/apache/tapestry/contrib/tree/components
                        Tree.jwc TreeDataView.java TreeNodeView.jwc
                        TreeNodeView.html TreeNodeView.java
               contrib/src/org/apache/tapestry/contrib/tree/model
                        TreeRowObject.java ITreeRowSource.java
               contrib/src/org/apache/tapestry/contrib/tree/components/table
                        TreeTableDataView.java
  Added:       contrib/src/org/apache/tapestry/contrib/tree/components
                        MiddlePlus.gif BottomPlus.gif MiddleCrossLine.gif
                        TopMinus.gif TopLastMinus.gif MiddleMinus.gif
                        WhiteSpace.gif TopLine.gif TopPlus.gif
                        MiddleLine.gif BottomLine.gif BottomMinus.gif
                        TopLastPlus.gif
  Removed:     contrib/src/org/apache/tapestry/contrib/tree/components
                        plus.gif minus.gif
  Log:
  Tree compoment UI improvements
  
  Revision  Changes    Path
  1.5       +4 -8      jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/Tree.jwc
  
  Index: Tree.jwc
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/Tree.jwc,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Tree.jwc	8 Jun 2004 08:30:43 -0000	1.4
  +++ Tree.jwc	17 Jun 2004 14:39:06 -0000	1.5
  @@ -40,18 +40,16 @@
           direction="custom" required="no">
       </parameter>
   
  -    <parameter name="closeNodeImage" type="org.apache.tapestry.IAsset"
  -               required="no" direction="in"/>
  -    <parameter name="openNodeImage" type="org.apache.tapestry.IAsset"
  -               required="no" direction="in"/>
  -
       <parameter name="showNodeImages" type="boolean" required="no"
                  direction="custom"/>
  +    
       <parameter name="makeNodeDirect" type="boolean" required="no"
                  direction="custom"/>
  +    
       <parameter name="nodeRenderFactory"
                  type="org.apache.tapestry.contrib.tree.components.INodeRenderFactory"
                  required="no" direction="custom"/>
  +               
       <parameter name="showRootNode" type="boolean" required="no"
                  direction="custom"/>
       
  @@ -69,8 +67,6 @@
       </component>
   
       <component id="treeNodeValue" type="TreeNodeView">
  -        <inherited-binding name="closeNodeImage" parameter-name="closeNodeImage"/>
  -        <inherited-binding name="openNodeImage" parameter-name="openNodeImage"/>
           <inherited-binding name="showNodeImages" parameter-name="showNodeImages"/>
           <inherited-binding name="makeNodeDirect" parameter-name="makeNodeDirect"/>
           <inherited-binding name="nodeRenderFactory" parameter-name="nodeRenderFactory"/>
  
  
  
  1.7       +34 -6     jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TreeDataView.java
  
  Index: TreeDataView.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TreeDataView.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TreeDataView.java	8 Jun 2004 08:30:43 -0000	1.6
  +++ TreeDataView.java	17 Jun 2004 14:39:06 -0000	1.7
  @@ -76,12 +76,25 @@
           Object objRoot = objTreeDataModel.getRoot();
           Object objRootUID = objTreeDataModel.getUniqueKey(objRoot, null);
           if(getShowRootNode()){
  -            walkTree(objRoot, objRootUID, 0, objTreeModel, writer, cycle);
  +            walkTree(objRoot, objRootUID, 0, objTreeModel, writer, cycle, TreeRowObject.FIRST_LAST_ROW,
new int[0], true);
           }else{
  +        	boolean bFirst = true;
  +        	int nChildenCount = objTreeModel.getTreeDataModel().getChildCount(objRoot);
  +        	int nRowPossiotionType = nChildenCount == 1 ? TreeRowObject.FIRST_LAST_ROW : TreeRowObject.FIRST_ROW;
               for (Iterator iter = objTreeModel.getTreeDataModel().getChildren(objRoot);
iter.hasNext();) {
                   Object objChild = iter.next();
                   Object objChildUID = objTreeModel.getTreeDataModel().getUniqueKey(objChild,
objRoot);
  -                walkTree(objChild, objChildUID, 0, objTreeModel, writer, cycle);
  +                boolean bChildLast = !iter.hasNext();
  +                if( !bFirst){
  +                    if(bChildLast)
  +                		nRowPossiotionType = TreeRowObject.LAST_ROW;
  +                	else
  +                    	nRowPossiotionType = TreeRowObject.MIDDLE_ROW;
  +                }
  +
  +                walkTree(objChild, objChildUID, 0, objTreeModel, writer, cycle, nRowPossiotionType,
new int[0], bChildLast);
  +
  +                bFirst = false;
               }
           }        
   
  @@ -90,18 +103,32 @@
   
       public void walkTree(Object objParent, Object objParentUID, int nDepth,
                            ITreeModel objTreeModel, IMarkupWriter writer,
  -                         IRequestCycle cycle) {
  -		m_objTreeRowObject = new TreeRowObject(objParent, objParentUID, nDepth);
  +                         IRequestCycle cycle, int nRowPossiotionType, int[] arrConnectImages,
boolean bLast) {
  +    	int nNumberOfChildren = objTreeModel.getTreeDataModel().getChildCount(objParent);
  +    	boolean bLeaf = (nNumberOfChildren == 0) ? true : false;
  +		m_objTreeRowObject = new TreeRowObject(objParent, objParentUID, nDepth, bLeaf, nRowPossiotionType,
arrConnectImages);
           m_nTreeDeep = nDepth;
   
           super.renderComponent(writer, cycle);
   
           boolean bContain = objTreeModel.getTreeStateModel().isUniqueKeyExpanded(objParentUID);
           if (bContain) {
  +        	int[] arrConnectImagesNew = new int[arrConnectImages.length+1];
  +        	System.arraycopy(arrConnectImages, 0, arrConnectImagesNew, 0, arrConnectImages.length);
  +        	if(bLast)
  +        		arrConnectImagesNew[arrConnectImagesNew.length-1] = TreeRowObject.EMPTY_CONN_IMG;
  +        	else
  +        		arrConnectImagesNew[arrConnectImagesNew.length-1] = TreeRowObject.LINE_CONN_IMG;
  +        	
               for (Iterator iter = objTreeModel.getTreeDataModel().getChildren(objParent);
iter.hasNext();) {
                   Object objChild = iter.next();
                   Object objChildUID = objTreeModel.getTreeDataModel().getUniqueKey(objChild,
objParentUID);
  -                walkTree(objChild, objChildUID, nDepth+1, objTreeModel, writer, cycle);
  +                boolean bChildLast = !iter.hasNext();
  +                if(bChildLast)
  +            		nRowPossiotionType = TreeRowObject.LAST_ROW;
  +            	else
  +                	nRowPossiotionType = TreeRowObject.MIDDLE_ROW;
  +                walkTree(objChild, objChildUID, nDepth+1, objTreeModel, writer, cycle,
nRowPossiotionType, arrConnectImagesNew, bChildLast);
               }
           }
       }
  @@ -132,4 +159,5 @@
   		}
   		return bShowRootNode;
   	}
  +	
   }
  
  
  
  1.5       +35 -19    jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TreeNodeView.jwc
  
  Index: TreeNodeView.jwc
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TreeNodeView.jwc,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TreeNodeView.jwc	8 Jun 2004 08:30:43 -0000	1.4
  +++ TreeNodeView.jwc	17 Jun 2004 14:39:06 -0000	1.5
  @@ -23,11 +23,6 @@
       class="org.apache.tapestry.contrib.tree.components.TreeNodeView"
       allow-body="yes" allow-informal-parameters="yes">
   
  -    <parameter name="closeNodeImage" type="org.apache.tapestry.IAsset"
  -               required="no" direction="in"/>
  -    <parameter name="openNodeImage" type="org.apache.tapestry.IAsset"
  -               required="no" direction="in"/>
  -
       <parameter name="showNodeImages" type="boolean" required="no"
                  direction="custom"/>
       <parameter name="makeNodeDirect" type="boolean" required="no"
  @@ -37,14 +32,7 @@
                  type="org.apache.tapestry.contrib.tree.components.INodeRenderFactory"
                  required="no" direction="custom"/>
   
  -    <!--parameter name="treeStateListener"
  -        type="org.apache.tapestry.contrib.tree.model.ITreeStateListener"
  -        direction="custom" required="no">
  -    </parameter-->
  -
  -    <reserved-parameter name="opennodeimage"/>
       <reserved-parameter name="treedataview"/>
  -    <reserved-parameter name="closenodeimage"/>
       <reserved-parameter name="nodeviewdirect"/>
   
       <component id="expandCollapsDirect" type="DirectLink">
  @@ -53,6 +41,7 @@
           <binding name="stateful" expression="false"/>
           <binding name="name" expression="selectedID"/>
           <binding name="anchor" expression="cleanSelectedID"/>
  +        <binding name="disabled" expression="disableLink"/>
       </component>
   
       <component id="nodeDirect" type="DirectLink">
  @@ -87,12 +76,39 @@
       </component>
       <component id="insertValue2" copy-of="insertValue"/>
   
  -    <component id="offset" type="Any">
  -        <static-binding name="element">span</static-binding>
  -        <binding name="style" expression="offsetStyle"/>
  +    <component id="class" type="Any">
  +        <static-binding name="element">div</static-binding>
           <binding name="class" expression="nodeStyleClass"/>
       </component>
  -
  -    <private-asset name="_closeNodeImage" resource-path="plus.gif"/>
  -    <private-asset name="_openNodeImage" resource-path="minus.gif"/>
  +    
  +    <private-asset name="_topCloseNodeImage" resource-path="TopPlus.gif"/>
  +    <private-asset name="_topOpenNodeImage" resource-path="TopMinus.gif"/>
  +    <private-asset name="_topLineImage" resource-path="TopLine.gif"/>
  +    
  +    <private-asset name="_topLastOpenNodeImage" resource-path="TopLastMinus.gif"/>
  +    <private-asset name="_topLastCloseNodeImage" resource-path="TopLastPlus.gif"/>
  +    
  +    <private-asset name="_middleCloseNodeImage" resource-path="MiddlePlus.gif"/>
  +    <private-asset name="_middleOpenNodeImage" resource-path="MiddleMinus.gif"/>
  +    <private-asset name="_middleCrossLineImage" resource-path="MiddleCrossLine.gif"/>
  +    <private-asset name="_middleLineImage" resource-path="MiddleLine.gif"/>
  +    
  +    <private-asset name="_bottomCloseNodeImage" resource-path="BottomPlus.gif"/>
  +    <private-asset name="_bottomOpenNodeImage" resource-path="BottomMinus.gif"/>
  +    <private-asset name="_bottomLineImage" resource-path="BottomLine.gif"/>
  +    
  +    <private-asset name="_whiteSpaceImage" resource-path="WhiteSpace.gif"/>
  +    
  +    <component id="showConnectImage" type="Conditional">
  +        <binding name="condition" expression="showConnectImage"/>
  +    </component>
  +    <component id="connectImage" type="Image">
  +        <binding name="image" expression="connectImage"/>
  +    </component>
  +    <component id="foreachConnectImage" type="Foreach">
  +        <binding name="source" expression="foreachConnectImageList"/>
  +        <binding name="value" expression="currentForeachConnectImageValue"/>
  +    </component>
  +    
  +    
   </component-specification>
  
  
  
  1.3       +1 -19     jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TreeNodeView.html
  
  Index: TreeNodeView.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TreeNodeView.html,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TreeNodeView.html	8 Jun 2004 08:30:43 -0000	1.2
  +++ TreeNodeView.html	17 Jun 2004 14:39:06 -0000	1.3
  @@ -1,23 +1,5 @@
   <!-- generated by Spindle, http://spindle.sourceforge.net -->
   
   <span jwcid="$content$">
  -	<span jwcid="offset">
  -		<span jwcid="makeNodeDirect">
  -			<a jwcid="expandCollapsDirect">
  -				<span jwcid="showImages">
  -					<img jwcid="imageNode"/>
  -				</span>
  -            </a>
  -            <a jwcid="nodeDirect">
  -				<span jwcid="insertValue"/>
  -            </a>
  -           <br>
  -		</span>
  -		<span jwcid="makeNodeNoDirect">
  -			<span jwcid="showImages2">
  -				<img jwcid="imageNode2"/>
  -			</span>
  -			<span jwcid="insertValue2"/><br>
  -		</span>
  -	</span>
  +	    <span jwcid="class"><span jwcid="foreachConnectImage"><img jwcid="connectImage"
valign="top"/></span><span jwcid="makeNodeDirect"><a jwcid="expandCollapsDirect"><span
jwcid="showImages"><img jwcid="imageNode"/></span></a><a jwcid="nodeDirect"><span
jwcid="insertValue"/></a></span><span jwcid="makeNodeNoDirect"><span
jwcid="showImages2"><img jwcid="imageNode2"/></span><span jwcid="insertValue2"/></span></span>
   </span>
  
  
  
  1.7       +160 -4    jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TreeNodeView.java
  
  Index: TreeNodeView.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TreeNodeView.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TreeNodeView.java	8 Jun 2004 08:30:43 -0000	1.6
  +++ TreeNodeView.java	17 Jun 2004 14:39:06 -0000	1.7
  @@ -51,6 +51,8 @@
   
       private IAsset m_objOpenNodeImage;
       private IAsset m_objCloseNodeImage;
  +    
  +    private int m_CurrentForeachConnectImageValue = TreeRowObject.LINE_CONN_IMG;
   
       public TreeNodeView(){
           super();
  @@ -62,6 +64,7 @@
           m_objShowNodeImages = null;
           m_objNodeRenderFactory = null;
           m_objMakeNodeDirect = null;
  +        m_CurrentForeachConnectImageValue = TreeRowObject.LINE_CONN_IMG;
       }
   
       public IRender getCurrentRenderer(){
  @@ -205,6 +208,99 @@
        * @return IAsset
        */
       public IAsset getNodeImage() {
  +    	IAsset objResult = null;
  +    	ITreeRowSource objRowSource = getTreeRowSource();
  +    	boolean bLeaf = objRowSource.getTreeRow().getLeaf();
  +    	int nRowType = objRowSource.getTreeRow().getTreeRowPossiotionType();
  +    	if(!bLeaf){
  +	    	if(isNodeOpen()) {
  +	        	switch (nRowType) {
  +					case  TreeRowObject.FIRST_LAST_ROW:{
  +						objResult = getAsset("_topLastOpenNodeImage");
  +						break;
  +					}
  +					
  +					case  TreeRowObject.FIRST_ROW:{
  +						objResult = getAsset("_topOpenNodeImage");
  +						break;
  +					}
  +	
  +					case  TreeRowObject.MIDDLE_ROW:{
  +						objResult = getAsset("_middleOpenNodeImage");
  +						break;
  +					}
  +					
  +					case  TreeRowObject.LAST_ROW:{
  +						objResult = getAsset("_bottomOpenNodeImage");
  +						break;
  +					}
  +					
  +					default : {
  +						objResult = getAsset("_openNodeImage");
  +						break;
  +					}
  +				}
  +	        } else {
  +	        	switch (nRowType) {
  +					case  TreeRowObject.FIRST_LAST_ROW:{
  +						objResult = getAsset("_topLastCloseNodeImage");
  +						break;
  +					}
  +					
  +					case  TreeRowObject.FIRST_ROW:{
  +						objResult = getAsset("_topCloseNodeImage");
  +						break;
  +					}
  +	
  +					case  TreeRowObject.MIDDLE_ROW:{
  +						objResult = getAsset("_middleCloseNodeImage");
  +						break;
  +					}
  +					
  +					case  TreeRowObject.LAST_ROW:{
  +						objResult = getAsset("_bottomCloseNodeImage");
  +						break;
  +					}
  +					
  +					default : {
  +						objResult = getAsset("_closeNodeImage");
  +						break;
  +					}
  +	        	}
  +	        }
  +    	}else{
  +        	switch (nRowType) {
  +				case  TreeRowObject.FIRST_LAST_ROW:{
  +					objResult = getAsset("_topLineImage");
  +					break;
  +				}
  +				
  +				case  TreeRowObject.FIRST_ROW:{
  +					objResult = getAsset("_topLineImage");
  +					break;
  +				}
  +
  +				case  TreeRowObject.MIDDLE_ROW:{
  +					objResult = getAsset("_middleCrossLineImage");
  +					break;
  +				}
  +				
  +				case  TreeRowObject.LAST_ROW:{
  +					objResult = getAsset("_bottomLineImage");
  +					break;
  +				}
  +				
  +				default : {
  +					objResult = getAsset("_bottomLineImage");
  +					break;
  +				}
  +        	}
  +   		
  +    	}
  +    	return objResult;
  +    }
  +
  +    public IAsset getNodeImageOld() {
           if(isNodeOpen()) {
               if (m_objOpenNodeImage == null) {
                   m_objOpenNodeImage = getAsset("_openNodeImage");
  @@ -217,7 +313,7 @@
               return m_objCloseNodeImage;
           }
       }
  -
  +    
       /**
        * Returns the closeNodeImage.
        * @return IAsset
  @@ -307,14 +403,16 @@
       }
   
       public String getOffsetStyle() {
  -        //return "width: " + getTreeDataView().getTreeDeep() * 15;
  +       //return "width: " + getTreeDataView().getTreeDeep() * 15;
   		ITreeRowSource objTreeRowSource = getTreeRowSource();
   		TreeRowObject objTreeRowObject = objTreeRowSource.getTreeRow();
           int nTreeRowDepth = 0;
           if(objTreeRowObject != null){
   			nTreeRowDepth = objTreeRowObject.getTreeRowDepth();
  +			if(nTreeRowDepth != 0)
  +				nTreeRowDepth = nTreeRowDepth - 1;
           }
  -        return "padding-left: " + nTreeRowDepth * 15+"px";
  +        return "padding-left: " + nTreeRowDepth * 19+"px";
       }
   
       /**
  @@ -427,5 +525,63 @@
   	public ITreeModelSource getTreeModelSource(){
   		ITreeModelSource objSource = (ITreeModelSource)getPage().getRequestCycle().getAttribute(ITreeModelSource.TREE_MODEL_SOURCE_ATTRIBUTE);
   		return objSource;
  +	}
  +	
  +	public boolean getShowConnectImage(){
  +    	ITreeRowSource objRowSource = getTreeRowSource();
  +    	int nRowType = objRowSource.getTreeRow().getTreeRowPossiotionType();
  +    	if(TreeRowObject.MIDDLE_ROW == nRowType)
  +    		return true;
  +    	return false;
  +	}
  +	
  +	public int[] getForeachConnectImageList(){
  +		ITreeRowSource objTreeRowSource = getTreeRowSource();
  +		TreeRowObject objTreeRowObject = objTreeRowSource.getTreeRow();
  +		return objTreeRowObject.getLineConnImages();
  +	}
  +	
  +	public boolean getDisableLink(){
  +    	ITreeRowSource objRowSource = getTreeRowSource();
  +    	boolean bLeaf = objRowSource.getTreeRow().getLeaf();
  +    	return bLeaf;
  +	}
  +    /**
  +     * Returns the openNodeImage.
  +     * @return IAsset nevalidno neshto
  +     */
  +    public IAsset getConnectImage() {
  +    	IAsset objResult = null;
  +    	int nConnectImageType = getCurrentForeachConnectImageValue();
  +    	switch (nConnectImageType) {
  +			case  TreeRowObject.EMPTY_CONN_IMG:{
  +				objResult = getAsset("_whiteSpaceImage");
  +				break;
  +			}
  +
  +			case  TreeRowObject.LINE_CONN_IMG:{
  +				objResult = getAsset("_middleLineImage");
  +				break;
  +			}
  +			
  +			default : {
  +				objResult = getAsset("_whiteSpaceImage");
  +				break;
  +			}
  +		}
  +    	return objResult;
  +    }
  +	/**
  +	 * @return Returns the m_CurrentForeachConnectImageValue.
  +	 */
  +	public int getCurrentForeachConnectImageValue() {
  +		return m_CurrentForeachConnectImageValue;
  +	}
  +	/**
  +	 * @param currentForeachConnectImageValue The m_CurrentForeachConnectImageValue to set.
  +	 */
  +	public void setCurrentForeachConnectImageValue(
  +			int currentForeachConnectImageValue) {
  +		m_CurrentForeachConnectImageValue = currentForeachConnectImageValue;
   	}
   }
  
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/MiddlePlus.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/BottomPlus.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/MiddleCrossLine.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TopMinus.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TopLastMinus.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/MiddleMinus.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/WhiteSpace.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TopLine.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TopPlus.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/MiddleLine.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/BottomLine.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/BottomMinus.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/TopLastPlus.gif
  
  	<<Binary file>>
  
  
  1.5       +35 -3     jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/model/TreeRowObject.java
  
  Index: TreeRowObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/model/TreeRowObject.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TreeRowObject.java	19 Feb 2004 17:37:59 -0000	1.4
  +++ TreeRowObject.java	17 Jun 2004 14:39:07 -0000	1.5
  @@ -19,15 +19,29 @@
    * @version $Id$
    */
   public class TreeRowObject {
  -	private Object m_objTreeNode = null;
  +    public static final int FIRST_ROW		= 1;
  +    public static final int MIDDLE_ROW		= 2;
  +    public static final int LAST_ROW		= 3;
  +    public static final int FIRST_LAST_ROW	= 4;
  +
  +    public static final int EMPTY_CONN_IMG	= 1;
  +    public static final int LINE_CONN_IMG	= 2;
  +
  +    private Object m_objTreeNode = null;
   	private Object m_objTreeNodeUID = null;
   	private int m_nTreeRowDepth;
  +	private boolean m_bLeaf = false;
  +	private int m_nTreeRowPossiotionType = MIDDLE_ROW;
  +	private int[] m_nLineConnImages;
   
  -	public TreeRowObject(Object objTreeNode, Object objTreeNodeUID, int nTreeRowDepth) {
  +	public TreeRowObject(Object objTreeNode, Object objTreeNodeUID, int nTreeRowDepth, boolean
bLeaf, int nTreeRowPossiotionType, int[] nLineConnImages) {
   		super();
   		m_objTreeNode = objTreeNode;
   		m_objTreeNodeUID = objTreeNodeUID;
   		m_nTreeRowDepth = nTreeRowDepth;
  +		m_bLeaf = bLeaf;
  +		m_nTreeRowPossiotionType = nTreeRowPossiotionType;
  +		m_nLineConnImages = nLineConnImages;
   	}
   
   	public Object getTreeNode() {
  @@ -42,4 +56,22 @@
   		return m_nTreeRowDepth;
   	}
   
  +	/**
  +	 * @return Returns the leaf.
  +	 */
  +	public boolean getLeaf() {
  +		return m_bLeaf;
  +	}
  +	/**
  +	 * @return Returns the treeRowPossiotionType.
  +	 */
  +	public int getTreeRowPossiotionType() {
  +		return m_nTreeRowPossiotionType;
  +	}
  +	/**
  +	 * @return Returns the lineConnImages.
  +	 */
  +	public int[] getLineConnImages() {
  +		return m_nLineConnImages;
  +	}
   }
  
  
  
  1.4       +2 -2      jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/model/ITreeRowSource.java
  
  Index: ITreeRowSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/model/ITreeRowSource.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ITreeRowSource.java	19 Feb 2004 17:37:59 -0000	1.3
  +++ ITreeRowSource.java	17 Jun 2004 14:39:07 -0000	1.4
  @@ -25,7 +25,7 @@
   public interface ITreeRowSource
   {
       final static String TREE_ROW_SOURCE_ATTRIBUTE = "org.apache.tapestry.contrib.tree.model.ITreeRowSource";
  -
  +    
   	/**
   	 * Method getTreeRow
   	 * @return Object the current tree row object.
  
  
  
  1.7       +31 -5     jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/table/TreeTableDataView.java
  
  Index: TreeTableDataView.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/tree/components/table/TreeTableDataView.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TreeTableDataView.java	8 Jun 2004 08:30:43 -0000	1.6
  +++ TreeTableDataView.java	17 Jun 2004 14:39:07 -0000	1.7
  @@ -93,11 +93,23 @@
   	        Object objRoot = objTreeDataModel.getRoot();
   	        Object objRootUID = objTreeDataModel.getUniqueKey(objRoot, null);
   	        if(getShowRootNode()){
  +	            walkTree(arrAllExpandedNodes, objRoot, objRootUID, 0, objTreeModel, TreeRowObject.FIRST_LAST_ROW,
new int[0], true);
   	        }else{
  +	        	int nChildenCount = objTreeModel.getTreeDataModel().getChildCount(objRoot);
  +	        	int nRowPossiotionType = nChildenCount == 1 ? TreeRowObject.FIRST_LAST_ROW :
TreeRowObject.FIRST_ROW;
  +	        	boolean bFirst = true;
   	            for (Iterator iter = objTreeModel.getTreeDataModel().getChildren(objRoot);
iter.hasNext();) {
   	                Object objChild = iter.next();
   	                Object objChildUID = objTreeModel.getTreeDataModel().getUniqueKey(objChild,
objRoot);
  -					walkTree(arrAllExpandedNodes, objChild, objChildUID, 0, objTreeModel);
  +	                boolean bChildLast = !iter.hasNext();
  +	                if( !bFirst){
  +	                    if(bChildLast)
  +	                		nRowPossiotionType = TreeRowObject.LAST_ROW;
  +	                	else
  +	                    	nRowPossiotionType = TreeRowObject.MIDDLE_ROW;
  +	                }
  +					walkTree(arrAllExpandedNodes, objChild, objChildUID, 0, objTreeModel, nRowPossiotionType,
new int[0], bChildLast);
  +	                bFirst = false;
   	            }
   	        }			
   
  @@ -109,19 +121,32 @@
       }
   
       public void walkTree(ArrayList arrAllExpandedNodes, Object objParent, Object objParentUID,
int nDepth,
  -                         ITreeModel objTreeModel) {
  +                         ITreeModel objTreeModel, int nRowPossiotionType, int[] arrConnectImages,
boolean bLast) {
           m_nTreeDeep = nDepth;
   
  -		TreeRowObject objTreeRowObject = new TreeRowObject(objParent, objParentUID, nDepth);
  +    	int nNumberOfChildren = objTreeModel.getTreeDataModel().getChildCount(objParent);
  +    	boolean bLeaf = (nNumberOfChildren == 0) ? true : false;
  +		TreeRowObject objTreeRowObject = new TreeRowObject(objParent, objParentUID, nDepth, bLeaf,
nRowPossiotionType, arrConnectImages);
   		arrAllExpandedNodes.add(objTreeRowObject);
   
           boolean bContain = objTreeModel.getTreeStateModel().isUniqueKeyExpanded(objParentUID);
           if (bContain) {
  +        	int[] arrConnectImagesNew = new int[arrConnectImages.length+1];
  +        	System.arraycopy(arrConnectImages, 0, arrConnectImagesNew, 0, arrConnectImages.length);
  +        	if(bLast)
  +        		arrConnectImagesNew[arrConnectImagesNew.length-1] = TreeRowObject.EMPTY_CONN_IMG;
  +        	else
  +        		arrConnectImagesNew[arrConnectImagesNew.length-1] = TreeRowObject.LINE_CONN_IMG;
   			Iterator colChildren = objTreeModel.getTreeDataModel().getChildren(objParent);
               for (Iterator iter = colChildren; iter.hasNext();) {
                   Object objChild = iter.next();
                   Object objChildUID = objTreeModel.getTreeDataModel().getUniqueKey(objChild,
objParentUID);
  -                walkTree(arrAllExpandedNodes, objChild, objChildUID, nDepth+1, objTreeModel);
  +                boolean bChildLast = !iter.hasNext();
  +                if(!bChildLast)
  +            		nRowPossiotionType = TreeRowObject.LAST_ROW;
  +            	else
  +                	nRowPossiotionType = TreeRowObject.MIDDLE_ROW;
  +               walkTree(arrAllExpandedNodes, objChild, objChildUID, nDepth+1, objTreeModel,
nRowPossiotionType, arrConnectImagesNew, bChildLast);
               }
           }
       }
  @@ -241,4 +266,5 @@
   		}
   		return bShowRootNode;
   	}
  +	
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Mime
View raw message