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:
ImageObserver
,MenuContainer
,Serializable
,Accessible
- Direct Known Subclasses:
PerspectiveNodeEditor
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
The panel that is the main row of editing UI for this node (i.e.static class
static interface
Heads up! If you implement this, you also must be a JComponentNested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsFields 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
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorsConstructorDescriptionNodeEditor
(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
Modifier and TypeMethodDescriptionvoid
int
applyFilter
(com.jidesoft.filter.Filter<String> filter) Applies a string filter to this editor.protected void
changeNodeType
(NodeType type) void
void
protected KeyEditorField
createKeyEditor
(DocumentNode node) 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.final void
destroy()
Called when this UI is no longer used in order to remove any listeners from the underlying document node.protected String
getAddChildText
(DocumentNode parent) protected Optional<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
int
getDepth()
getNode()
protected Optional<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.protected String
getPath()
Shortcut to get the path to the node as a stringprotected 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.protected void
boolean
boolean
protected boolean
Whether or not this node can be altered by the userprotected void
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
Expands the node and if the key is editable, starts editing it.toString()
void
visit
(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
-
Field Details
-
GUTTER_BACKGROUND
-
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
Shortcut to get the path to the node as a string -
onInit
protected void onInit()Subclasses may override this to provide custom initialization. -
initContextMenu
Called to initialize the context menu at the very end (to add actions after the cut, copy, paste, delete, and type actions. -
initContextMenuAdditionalActions
-
isMutable
protected boolean isMutable()Whether or not this node can be altered by the user -
getMainEditor
-
getChildPanel
public com.inductiveautomation.ignition.client.jsonedit.NodeEditor.ChildEditors getChildPanel() -
getParentEditor
-
getNode
-
toString
-
isFullyLoaded
public boolean isFullyLoaded() -
startEditing
public void startEditing()Expands the node and if the key is editable, starts editing it. -
addAfterChildrenUpdateCallback
-
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
Calls the visitor for each node editor in the hierarchy. -
applyFilter
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
-
getObjectHelper
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
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
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
-
changeNodeType
-