Class: Watobo::Gui::XmlTree

Inherits:
FXTreeList
  • Object
show all
Defined in:
lib/watobo/gui/xml_viewer_frame.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, xml_data = nil) ⇒ XmlTree

Returns a new instance of XmlTree.



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/watobo/gui/xml_viewer_frame.rb', line 47

def initialize(parent, xml_data=nil)
  super(parent, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_RIGHT|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|TREELIST_EXTENDEDSELECT)
  @xml_data = REXML::Document.new(xml_data)
  @root = @xml_data.root
#  @root.each_recursive { |x| 
 #puts x.name if x.has_text? and x.text == "?"
# puts x.name #unless x.has_elements?
 #}
  #puts @xml_data.root.methods.sort
  
 addTreeElement(nil, @root)
  
end

Instance Method Details

#addTreeElement(parent = nil, element = nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/watobo/gui/xml_viewer_frame.rb', line 34

def addTreeElement(parent=nil, element=nil)
  node = self.appendItem(parent, element.name)
  element.elements.each do |e|
    sn = self.appendItem(node, e.name)
    if e.has_elements?
      e.elements.each do |se|
        self.addTreeElement(sn, se)
      end
      
    end
  end
end