Class NodeEditor
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- com.inductiveautomation.ignition.client.jsonedit.NodeEditor
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
- Direct Known Subclasses:
PerspectiveNodeEditor
public class NodeEditor extends javax.swing.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
NodeEditor.MainEditor
The panel that is the main row of editing UI for this node (i.e.static class
NodeEditor.MainEditorLayout
static interface
NodeEditor.ValueEditorComponent
Heads up! If you implement this, you also must be a JComponent-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description static java.awt.Color
GUTTER_BACKGROUND
static java.awt.Color
GUTTER_BORDER
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description NodeEditor(JsonEditor jsonEditor, int depth, NodeEditor parentEditor, DocumentNode node)
This constructor can be used for a normal node editor or a special empty version.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAfterChildrenUpdateCallback(java.lang.Runnable r)
int
applyFilter(com.jidesoft.filter.Filter<java.lang.String> filter)
Applies a string filter to this editor.protected void
changeNodeType(NodeType type)
void
clearFilter()
void
commitEdit()
protected KeyEditorField
createKeyEditor(DocumentNode node)
protected javax.swing.JComponent
createValueEditor(DocumentNode node, java.awt.event.MouseListener popupListener)
Called for "value" nodes, that is, nodes that are not objects or arrays, in order to create an editor for them.void
destroy()
Called when this UI is no longer used in order to remove any listeners from the underlying document node.protected java.lang.String
getAddChildText(DocumentNode parent)
protected java.util.Optional<javax.swing.JComponent>
getArrayHelper(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.com.inductiveautomation.ignition.client.jsonedit.NodeEditor.ChildEditors
getChildPanel()
int
getDepth()
NodeEditor.MainEditor
getMainEditor()
DocumentNode
getNode()
protected java.util.Optional<javax.swing.JComponent>
getObjectHelper(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.NodeEditor
getParentEditor()
protected java.lang.String
getPath()
Shortcut to get the path to the node as a stringprotected void
initContextMenu(javax.swing.JPopupMenu menu)
Called to initialize the context menu at the very end (to add actions after the cut, copy, paste, delete, and type actions.protected void
initContextMenuAdditionalActions(javax.swing.JPopupMenu menu)
boolean
isExpanded()
boolean
isFullyLoaded()
protected boolean
isMutable()
Whether or not this node can be altered by the userprotected void
onDestroy()
Subclasses may override this to do something when the editor is being destroyedprotected void
onInit()
Subclasses may override this to provide custom initialization.void
setExpanded(boolean expanded)
void
startEditing()
Expands the node and if the key is editable, starts editing it.java.lang.String
toString()
void
visit(java.util.function.Consumer<NodeEditor> visitor, boolean load)
Calls the visitor for each node editor in the hierarchy.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Constructor Detail
-
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 Detail
-
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 java.lang.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(javax.swing.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(javax.swing.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 java.lang.String toString()
- Overrides:
toString
in classjava.awt.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(java.lang.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(java.util.function.Consumer<NodeEditor> visitor, boolean load)
Calls the visitor for each node editor in the hierarchy.
-
applyFilter
public int applyFilter(com.jidesoft.filter.Filter<java.lang.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 java.lang.String getAddChildText(DocumentNode parent)
-
getObjectHelper
protected java.util.Optional<javax.swing.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 java.util.Optional<javax.swing.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 javax.swing.JComponent createValueEditor(DocumentNode node, java.awt.event.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)
-
-