2 Replies Latest reply on Sep 27, 2009 5:22 PM by drillnaut

    Flex Tree Folder/File Leaf/Branch icons

    drillnaut Level 1

      Hello Everyone ,

        I have an object which implements ITreeDataDescriptor and I stuff the objects into a Tree.  The objects are being shown in the tree , however  , they are all shown with the folder icon.  Is there a way I can tell this tree that some things should be represented by folders and that others should be represented by files ?  I have attached the disastrous code.  It has everything you need to see the damage. In the xml , the nodes are either labeled "Directory" , "Topdirectory" or "File"

       

      P.S

      For some reason the adobe flex forum wont let me attach ... Flex files ?  Here is the FileModel that implements the ITreeDataDescriptor and the tree mxml

       

      Tree mxml

      <mx:Tree id="Tree" itemClick="{thingClicked(event)}" labelField="name" width="100%" height="100%" dataProvider="{collection}" />

       

       

      FileModel.as

      package {
          import flash.events.EventDispatcher;
          import flash.events.IEventDispatcher;
         
          import mx.collections.ArrayCollection;
          import mx.collections.ICollectionView;
          import mx.controls.treeClasses.ITreeDataDescriptor;
          import mx.core.IUID;

       

          public class FileModel extends EventDispatcher implements ITreeDataDescriptor, IUID
          {
              public var userId:String;
              public var name:String;
              public var fileId:String;
              public var parentId:String;
              public var modified:String;
              public var description:String;
              public var type:String;
              public var children:ArrayCollection;
             
              public function FileModel(target:IEventDispatcher=null)
              {
                  super(target);
                  children = new ArrayCollection();
              }
             
              public function getChildren(node:Object, model:Object=null):ICollectionView
              {
                  return children;
              }
             
              public function hasChildren(node:Object, model:Object=null):Boolean
              {
                  if(children.length > 0)
                  {return true;}
                  else
                  {return false;}
              }
             
              public function isBranch(node:Object, model:Object=null):Boolean
              {
                   if(type == "DIRECTORY" || type=="TOPDIRECTORY")
                  {return true;}
                  else
                  {return false;}
              }
             
              public function getData(node:Object, model:Object=null):Object
              {
                  return this;
              }
             
              public function addChildAt(parent:Object, newChild:Object, index:int, model:Object=null):Boolean
              {
                  return false;
              }
             
              public function removeChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean
              {
                  return false;
              }
             
              public function get uid():String
              {
                  return fileId;
              }
             
              public function set uid(value:String):void
              {
              }
             
              public function addChild(childModel:FileModel):void
              {
                  children.addItem(childModel);
              }
          }
      }