Method: JSON::Editor::PopUpMenu#change_node

Defined in:
lib/vendor/json_pure/lib/json/editor.rb

#change_node(item) ⇒ Object

Change the type or content of the selected node.



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/vendor/json_pure/lib/json/editor.rb', line 265

def change_node(item)
  if current = selection.selected
    parent = current.parent
    old_type, old_content = current.type, current.content
    if ALL_TYPES.include?(old_type)
      @clipboard_data = Editor.model2data(current)
      type, content = ask_for_element(parent, current.type,
        current.content)
      if type
        current.type, current.content = type, content
        current.remove_subtree(model)
        toplevel.display_status("Changed a node in tree.")
        window.change
      end
    else
      toplevel.display_status(
        "Cannot change node of type #{old_type} in tree!")
    end
  end
end