Class JsonEditor
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- com.inductiveautomation.ignition.client.jsonedit.JsonEditor
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
public class JsonEditor extends javax.swing.JPanel
Created by carlg on 5/15/2017.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
JsonEditor.AddNodeMenu
static class
JsonEditor.HierarchyIcon
-
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 javax.swing.Icon
COLLAPSED
static javax.swing.Icon
EXPANDED
protected DocumentModel
model
static int
SCROLL_BLOCK_INCREMENT
static int
SCROLL_UNIT_INCREMENT
-
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 JsonEditor(DocumentModel model, boolean showRoot)
JsonEditor(java.lang.String json, boolean showRoot)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
applyFilter(com.jidesoft.filter.Filter<java.lang.String> filter)
void
clearFilter()
void
collapseAll()
void
expandAll()
java.lang.String
getJson()
Get the current state of the edited model as a json documentjava.lang.String
getJson(boolean prettyPrint)
com.inductiveautomation.ignition.common.gson.JsonElement
getJsonElement()
Get the current state of the edited model as a gson objectDocumentModel
getModel()
boolean
insertDefaultItem(DocumentNode parent, int index)
Insert a new node on the parent representing the default value as declared in it's schema.protected void
insertNewNode(DocumentNode parent, DocumentNode newNode, int insertionPoint)
protected boolean
isScrollable()
protected boolean
isToolbarVisible()
static void
main(java.lang.String[] args)
protected NodeEditor
newNodeEditor(int depth, NodeEditor parent, DocumentNode node)
protected java.lang.Object
newValueValue()
The actual value to use for new "Value" nodes.void
setModel(DocumentModel model)
Sets the model for this editor-
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, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
SCROLL_UNIT_INCREMENT
public static final int SCROLL_UNIT_INCREMENT
- See Also:
- Constant Field Values
-
SCROLL_BLOCK_INCREMENT
public static final int SCROLL_BLOCK_INCREMENT
- See Also:
- Constant Field Values
-
model
protected DocumentModel model
-
COLLAPSED
public static final javax.swing.Icon COLLAPSED
-
EXPANDED
public static final javax.swing.Icon EXPANDED
-
-
Constructor Detail
-
JsonEditor
public JsonEditor(java.lang.String json, boolean showRoot)
-
JsonEditor
public JsonEditor(DocumentModel model, boolean showRoot)
-
-
Method Detail
-
setModel
public void setModel(DocumentModel model)
Sets the model for this editor
-
newNodeEditor
protected NodeEditor newNodeEditor(int depth, NodeEditor parent, DocumentNode node)
-
insertDefaultItem
public boolean insertDefaultItem(DocumentNode parent, int index)
Insert a new node on the parent representing the default value as declared in it's schema.- Parameters:
parent
- The parent node to insert new node.index
- The index in which to add the new node.- Returns:
- {boolean} Returns true if a new default item node was inserted, false otherwise.
-
applyFilter
public int applyFilter(com.jidesoft.filter.Filter<java.lang.String> filter)
-
clearFilter
public void clearFilter()
-
isToolbarVisible
protected boolean isToolbarVisible()
-
isScrollable
protected boolean isScrollable()
-
getModel
public DocumentModel getModel()
-
expandAll
public void expandAll()
-
collapseAll
public void collapseAll()
-
getJsonElement
public com.inductiveautomation.ignition.common.gson.JsonElement getJsonElement()
Get the current state of the edited model as a gson object
-
getJson
public java.lang.String getJson()
Get the current state of the edited model as a json document
-
getJson
public java.lang.String getJson(boolean prettyPrint)
-
insertNewNode
protected void insertNewNode(DocumentNode parent, DocumentNode newNode, int insertionPoint)
-
newValueValue
protected java.lang.Object newValueValue()
The actual value to use for new "Value" nodes.
-
main
public static void main(java.lang.String[] args)
-
-