1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
public class MyTreeItemRenderer extends TreeItemRenderer {
public function MyTreeItemRenderer() {
super();
}
private var rootIcon:Image;
private var chargeIcon:Image;
//click sur icone pour recharger les données du concept
public function chargeToutClick(event:MouseEvent):void {
var e : TreeEvent = new TreeEvent(this.label.text, true, true, null, null, null);
dispatchEvent(e);
/*
if (this.parent.contains(this)) {
this.parent.removeChild(this);
}
*/
}
//Affiche le composant
override protected function createChildren():void {
super.createChildren();
chargeIcon = new Image();
chargeIcon.source="assets/images/x1.jpg";
chargeIcon.toolTip = "reload";
rootIcon = new Image();
chargeIcon.addEventListener(MouseEvent.CLICK, this.chargeToutClick);
this.addChild(rootIcon);
this.addChild(chargeIcon);
}
//paramétrage des nodes
override public function set data(value:Object):void {
super.data = value;
var node:XML = XML(TreeListData(super.listData).item);
var chaineRecherche:String = null;
if (node.localName() == "concept") {
chaineRecherche = ".....";
}
else {
chaineRecherche = node.@parent.toString();
}
switch (chaineRecherche) {
case "....":
[Embed("..")]
var iconClass:Class;
setStyle("textDecoration","normal");
setStyle("color","#006699");
break;
case "..":
[Embed("..")]
var iconClass:Class;
setStyle("color","#006699");
break;
case "..":
[Embed("..")]
var iconClass:Class;
setStyle("color","#006699");
break;
case "..":
[Embed("..")]
var iconClass:Class;
setStyle("color","#006699");
break;
case "..":
[Embed("..")]
var iconClass:Class;
setStyle("fontWeight", 'bold');
setStyle("color","#006699");
break;
}
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
var treeListData:TreeListData=TreeListData(listData);
super.updateDisplayList(unscaledWidth,unscaledHeight);
icon.visible=true;
if(treeListData.hasChildren) {
var tmp:XMLList = new XMLList(treeListData.item);
var myStr:int = tmp[0].children().length();
super.label.text =
treeListData.label + " (" + myStr + ")";
rootIcon.source="..";
// Image Properties
chargeIcon.source="assets/images/recharger.jpg";
// Position
//rootIcon.x = label.x -2;
//label.x = rootIcon.x + 40;
//label.y = label.y + 5;
chargeIcon.visible=true;
chargeIcon.width=20;
chargeIcon.height=20;
chargeIcon.x=label.textWidth+label.x+5;
}
else {
this.setStyle("fontWeight","normal");
rootIcon.source="....";
chargeIcon.visible=false;
}
}
}
} |
Partager