- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xo::OrderedComposite
::xo::OrderedComposite create ...
Defined in
Class Relations
- class: ::xotcl::Class
- superclass: ::xotcl::Object
- subclass: ::xo::tdom::Object, ::xowiki::Tree, ::ListWidget, ::xo::Chat, ::xo::Table
::xotcl::Class create ::xo::OrderedComposite \ -superclass ::xotcl::ObjectMethods (to be applied on instances)
__compare (scripted)
<instance of xo::OrderedComposite> __compare
- Testcases:
- includelet_childresources, xowiki
set by ${:__orderby} set x [$a set $by] set y [$b set $by] return [ns_strcoll $x $y]__compare_tcl (scripted)
# # Comparison based on plain Tcl compare. This behaves reasonable # on numbers (integer or real) and in mixed cases of numbers and # strings. # set by ${:__orderby} set x [$a set $by] set y [$b set $by] if {$x < $y} { return -1 } elseif {$x > $y} { return 1 } else { return 0 }add (scripted)
lappend :__children $obj $obj set __parent [self] #:log "-- adding __parent [self] to $obj -- calling after_insert" #$obj __after_insertchildren (scripted)
if {![info exists :__children]} { return "" } if {[info exists :__orderby] && [llength ${:__children}] > 0} { set firstChild [lindex ${:__children} 0] if {[$firstChild exists ${:__orderby}]} { set order [expr {[info exists :__order] ? ${:__order} : "increasing"}] set compare [expr {[info exists :__ordercompare] ? ${:__ordercompare} : "__compare"}] #ns_log notice SORT=[list lsort -command :$compare -$order ${:__children}] return [lsort -command :$compare -$order ${:__children}] } else { ad_log warning "ignore invalid sorting criterion '${:__orderby}'" } } return ${:__children}contains (scripted)
:requireNamespace ;# legacy for older XOTcl versions set m [Object info instmixin] if {"[self class]::ChildManager" ni $m} { set insert 1 Object instmixin add [self class]::ChildManager } else { set insert 0 } # [self class]::ChildManager instvar composite # push the active composite lappend composite [self] set errorOccurred 0 # check, if we have Tcl's apply available if {[info procs ::apply] eq ""} { set applyCmd [list ::apply [list {} $cmds [self]]] } else { set applyCmd [list namespace eval [self] $cmds] } try { {*}$applyCmd } on error {errorMsg} { set errorOccurred 1 } finally { # pop the last active composite set composite [lrange $composite 0 end-1] if {$insert} { Object instmixin delete [self class]::ChildManager } } if {$errorOccurred} {error $errorMsg}deep_copy (scripted)
set copy [:copy [::xotcl::Object new]] if {[info exists :__children]} { $copy set __children {} foreach c ${:__children} { $copy add [$c copy [::xotcl::Object new]] } } return $copydelete (scripted)
set p [lsearch -exact ${:__children} $obj] if {$p == -1} {error "can't delete '$obj' from ${:__children}"} set :__children [lreplace ${:__children} $p $p] $obj destroydestroy (scripted)
# destroy all children of the ordered composite if {[info exists :__children]} { #:log "--W destroying children ${:__children}" foreach c ${:__children} { if {[nsf::is object $c]} {$c destroy} } } #show_stack;:log "--W children murdered, now next, chlds=[:info children]" #namespace eval [self] {namespace forget *} ;# for pre 1.4.0 versions nextlast_child (scripted)
lindex ${:__children} endorderby (scripted)
# # Specify the sorting properties order in OrderedComposites. The # sorting is defined via sorting attribute, sorting order and the # sorting type (defining the comparison operators). # # @param order one of "increasing" or "decreasing" # @param type one of "integer", "real", "index" or "dictionary" (default "dictionary") # #ns_log notice "OrderedComposite called with order '$order' type '$type' attribute '$attribute'" set :__order $order set :__orderby $attribute set :__ordercompare [ad_decode $type real __compare_tcl integer __compare_tcl __compare] if {$type eq "index"} { :mixin add ::xo::OrderedComposite::IndexCompare }show (scripted)
next foreach child [:children] { $child show }
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables