Method: JSON::Editor::JSONTreeView#create_node

Defined in:
lib/json/editor.rb

#create_node(parent, type, content) ⇒ Object

Create a type node with content content, and add it to parent in the model. If parent is nil, create a new model and put it into the editor treeview.



816
817
818
819
820
821
822
823
824
825
826
827
# File 'lib/json/editor.rb', line 816

def create_node(parent, type, content)
  iter = if parent
    model.append(parent)
  else
    new_model = Editor.data2model(nil)
    toplevel.view_new_model(new_model)
    new_model.iter_first
  end
  iter.type, iter.content = type, content
  expand_collapse(parent) if parent
  iter
end