java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.inductiveautomation.ignition.client.jsonedit.NodeEditor
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
PerspectiveNodeEditor

public class NodeEditor extends JPanel
This UI does the heavy lifting for the json editor. Consists of a "main editor" which has the drag handle, the options menu, the collapse control, key editor, and value editor, and a collection of child editors which are the editors for the node's children (if any)
See Also:
  • Field Details

    • GUTTER_BACKGROUND

      public static final Color GUTTER_BACKGROUND
    • GUTTER_BORDER

      public static final Color GUTTER_BORDER
  • Constructor Details

    • NodeEditor

      public NodeEditor(JsonEditor jsonEditor, int depth, @Nullable NodeEditor parentEditor, @Nullable DocumentNode node)
      This constructor can be used for a normal node editor or a special empty version. Exactly one of node _or_ message must be non-null.
      Parameters:
      depth - This defines the depth of this node within the document. If the root node is given a depth of zero, then controls for the root object will be visible. If the root node is given a depth of -1, then the root node controls will be hidden (useful when the document should always be an object at the root and you don't want to give the user the ability to change the root node type)
  • Method Details

    • destroy

      public final void destroy()
      Called when this UI is no longer used in order to remove any listeners from the underlying document node.
    • onDestroy

      protected void onDestroy()
      Subclasses may override this to do something when the editor is being destroyed
    • getPath

      protected String getPath()
      Shortcut to get the path to the node as a string
    • onInit

      protected void onInit()
      Subclasses may override this to provide custom initialization.
    • initContextMenu

      protected void initContextMenu(JPopupMenu menu)
      Called to initialize the context menu at the very end (to add actions after the cut, copy, paste, delete, and type actions.
    • initContextMenuAdditionalActions

      protected void initContextMenuAdditionalActions(JPopupMenu menu)
    • isMutable

      protected boolean isMutable()
      Whether or not this node can be altered by the user
    • getMainEditor

      public NodeEditor.MainEditor getMainEditor()
    • getChildPanel

      public com.inductiveautomation.ignition.client.jsonedit.NodeEditor.ChildEditors getChildPanel()
    • getParentEditor

      public NodeEditor getParentEditor()
    • getNode

      public DocumentNode getNode()
    • toString

      public String toString()
      Overrides:
      toString in class Component
    • isFullyLoaded

      public boolean isFullyLoaded()
    • startEditing

      public void startEditing()
      Expands the node and if the key is editable, starts editing it.
    • addAfterChildrenUpdateCallback

      public void addAfterChildrenUpdateCallback(Runnable r)
    • getDepth

      public int getDepth()
      Returns:
      the depth of this node in the hierarchy. Note that the "root" node will be at depth -1 if the node editor was configured to hide the root.
    • visit

      public void visit(Consumer<NodeEditor> visitor, boolean load)
      Calls the visitor for each node editor in the hierarchy.
    • applyFilter

      public int applyFilter(com.jidesoft.filter.Filter<String> filter)
      Applies a string filter to this editor. This will do a few things:

      1. Test the filter against this node's key and value (if applicable) 2. Highlight they key and/or value fields if they match the filter 3. Apply the filter to all children. 4. If this node or any children matched the filter, will set expanded=true

      Returns:
      number of matches found
    • clearFilter

      public void clearFilter()
    • commitEdit

      public void commitEdit()
    • isExpanded

      public boolean isExpanded()
    • setExpanded

      public void setExpanded(boolean expanded)
    • getAddChildText

      protected String getAddChildText(DocumentNode parent)
    • getObjectHelper

      protected Optional<JComponent> getObjectHelper(@Nullable JsonSchema schema)
      Called for object-typed nodes, in order to optionally create a helper component that will be added to the right of the object size indicator.
    • getArrayHelper

      protected Optional<JComponent> getArrayHelper(@Nullable JsonSchema schema)
      Called for array-typed nodes, in order to optionally create a helper component that will be added to the right of the object size indicator.
    • createValueEditor

      protected JComponent createValueEditor(DocumentNode node, MouseListener popupListener)
      Called for "value" nodes, that is, nodes that are not objects or arrays, in order to create an editor for them.

      If your editor happens to implement NodeEditor.ValueEditorComponent, you'll get additional functionality like schema and ui lifecycle support

      Parameters:
      popupListener - Mouse listener to add to any interior components in order for the context menu to work correctly
      Returns:
      A component to use as the editor
    • createKeyEditor

      protected KeyEditorField createKeyEditor(DocumentNode node)
    • changeNodeType

      protected void changeNodeType(NodeType type)