opttreecontroller.lzx
<node name="opttreecontroller">
<attribute name="rootnode"/>
<attribute name="nodelist" value="$once{ [] }"/>
<datapointer name="dp"/>
<attribute name="changeDel" value="$once{ new lz.Delegate( this, 'checkDocChange' ) }"/>
<handler name="ondata" reference="parent">
//setup listener
this.changeDel.unregisterAll();
var pdata = parent.data;
this.setAttribute( "rootnode", pdata );
if ( pdata != null ) {
this.changeDel.register( pdata.ownerDocument , "onDocumentChange" );
}
this.rebuildList();
</handler>
<method name="checkDocChange" args="chgpkg">
this.rebuildList();
</method>
<attribute name="_running" value="false
"/>
<method name="rebuildList">
if ( _locked || _running ) return;
this._running = true;
this.nodelist = [ ];
var rnode = this.rootnode;
if ( rnode != null ) {
rnode.setAttr( parent.depthattr , "-1" );
this.addNodesToList( rnode );
}
this.setAttribute( "nodelist" , nodelist );
this._running = false;
</method>
<method name="addNodesToList" args="n">
var chil = getChildNodes( n );
if ( !chil ) return;
var nd = 1 + Number( n.attributes[ parent.depthattr ] );
for ( var i = 0 ; i < chil.length; i++ ){
var c = chil[ i ];
if ( !c.attributes[ parent.depthattr ] ||
c.attributes[ parent.depthattr ] != parent.depthattr ){
c.setAttr( parent.depthattr, nd.toString() );
}
this.nodelist.push( c );
if ( c.attributes[ parent.openattr ] == "true" ){
this.addNodesToList( c );
}
}
</method>
<method name="getChildNodes" args="p">
dp.setPointer( p );
var c = dp.xpathQuery( parent.nodepath );
if ( c == null ){
return null;
} else if ( ! ( c instanceof Array ) ){
c = [ c ];
}
return c;
</method>
<attribute name="_locked" value="false
"/>
<attribute name="_lockkey" value="null
"/>
<method name="lock" args="k">
if ( _locked ) return;
this._lockkey = k;
this._locked = true;
</method>
<method name="unlock" args="k">
if( _lockkey != k ) return;
this._locked = false;
this._lockkey = null;
this.rebuildList();
</method>
</node>
Cross References
Named Instances