insert_new_node (PopUpMenu)

         # File lib/json/editor.rb, line 418
    418:       def insert_new_node(item)
    419:         if current = selection.selected
    420:           parent = current.parent or return
    421:           parent_parent = parent.parent
    422:           parent_type = parent.type
    423:           if parent_type == 'Array'
    424:             selected_index = parent.each_with_index do |c, i|
    425:               break i if c == current
    426:             end
    427:             type, content = ask_for_element(parent)
    428:             type or return
    429:             iter = model.insert_before(parent, current)
    430:             iter.type, iter.content = type, content
    431:             toplevel.display_status("Inserted an element to " +
    432:               "'#{parent_type}' before index #{selected_index}.")
    433:             window.change
    434:           else
    435:             toplevel.display_status(
    436:               "Cannot insert node below '#{parent_type}'!")
    437:           end
    438:         else
    439:             toplevel.display_status("Append a node into the root first!")
    440:         end
    441:       end