Class | Tk::BLT::Tree::Node |
In: |
tk/lib/tkextlib/blt/tree.rb
|
Parent: | TkObject |
TreeNodeID_TBL | = | TkCore::INTERP.create_table |
# File tk/lib/tkextlib/blt/tree.rb, line 19 def self.id2obj(tree, id) tpath = tree.path return id unless TreeNodeID_TBL[tpath] if TreeNodeID_TBL[tpath][id] TreeNodeID_TBL[tpath][id] else begin self.new(tree, nil, 'node'=>Integer(id)) rescue id end end end
# File tk/lib/tkextlib/blt/tree.rb, line 46 def initialize(tree, parent, keys={}) @parent = @tree = tree @tpath = @parent.path parent = tk_call(@tpath, 'root') unless parent if (id = keys['node']) && bool(tk_call(@tpath, 'exists', id)) @path = @id = id keys.delete('node') tk_call(@tpath, 'move', @id, parent, keys) if parent else @path = @id = tk_call(@tpath, 'insert', parent, keys) end TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath] TreeNodeID_TBL[@tpath][@id] = self end
# File tk/lib/tkextlib/blt/tree.rb, line 33 def self.new(tree, parent, keys={}) keys = _symbolkey2str(keys) tpath = tree.path if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id]) keys.delete('node') tk_call(tree.path, 'move', id, parent, keys) if parent return obj end super(tree, parent, keys) end
# File tk/lib/tkextlib/blt/tree.rb, line 77 def copy(parent, keys={}) @tree.copy(@id, parent, keys) end
# File tk/lib/tkextlib/blt/tree.rb, line 80 def copy_to(dest_tree, parent, keys={}) @tree.copy_to(@id, dest_tree, parent, keys) end
# File tk/lib/tkextlib/blt/tree.rb, line 101 def dump_to_file(file) @tree.dump_to_file(@id, file) self end
# File tk/lib/tkextlib/blt/tree.rb, line 125 def get_value(key, default_val=None) @tree.get_value(@id, key, default_val) end
# File tk/lib/tkextlib/blt/tree.rb, line 158 def move(dest, keys={}) @tree.keys(@id, dest, keys) self end
# File tk/lib/tkextlib/blt/tree.rb, line 191 def restore(str, keys={}) @tree.restore(@id, str, keys) self end
# File tk/lib/tkextlib/blt/tree.rb, line 200 def restore_from_file(file, keys={}) @tree.restore_from_file(@id, file, keys) self end
# File tk/lib/tkextlib/blt/tree.rb, line 195 def restore_overwrite(str, keys={}) @tree.restore_overwrite(@id, str, keys) self end
# File tk/lib/tkextlib/blt/tree.rb, line 204 def restore_overwrite_from_file(file, keys={}) @tree.restore_overwrite_from_file(@id, file, keys) self end