Class AbstractNavTreeNode
- java.lang.Object
- 
- com.inductiveautomation.ignition.designer.navtree.model.AbstractNavTreeNode
 
- 
- All Implemented Interfaces:
- java.lang.Iterable<AbstractNavTreeNode>,- javax.swing.tree.TreeNode
 - Direct Known Subclasses:
- AbstractResourceNavTreeNode,- ComponentNode,- ComponentNode,- MutableNavTreeNode,- PipeNode,- PipesFolderNode,- ShapeNode
 
 public abstract class AbstractNavTreeNode extends java.lang.Object implements javax.swing.tree.TreeNode, java.lang.Iterable<AbstractNavTreeNode> Base TreeNode for the Designer's Project Browser tree. Supports a number of project-browser features, such as:- lazy (but synchronous) loading
- badges for rendering
- selection delegation
- cut/copy/paste handling.
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classAbstractNavTreeNode.DeleteReasonSemantically, the "delete" operation gets used for a variety of different reasons.protected static classAbstractNavTreeNode.PopupActionA BaseAction that gets set up with the node selection prior to being shown
 - 
Field SummaryFields Modifier and Type Field Description protected booleanboldprotected java.util.List<AbstractNavTreeNode>childrenprotected booleanchildrenLoadedprotected static AbstractNavTreeNode.PopupActioncopyActionprotected static AbstractNavTreeNode.PopupActioncopyPathActionprotected static AbstractNavTreeNode.PopupActioncutActionprotected static AbstractNavTreeNode.PopupActiondeleteActionprotected intdepthprotected javax.swing.Iconiconprotected booleanitalicprotected LoggerExlogprotected NavTreePanel.EditableTreeModelmodelprotected java.lang.Stringnameprotected AbstractNavTreeNodeparentprotected static AbstractNavTreeNode.PopupActionpasteActionprotected static AbstractNavTreeNode.PopupActionrenameActionprotected javax.swing.tree.TreeSelectionModelselectionModelprotected java.lang.Stringtextprotected java.awt.image.BufferedImagethumbnailprotected java.lang.Stringtooltip
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractNavTreeNode()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBadges(BadgeTreeCellRenderer renderer, boolean selected)Add 'badges' to indicate meta information about this nodeprotected voidaddEditActions(javax.swing.JPopupMenu menu)booleancanCopy(java.util.List<AbstractNavTreeNode> selectedChildren)Can this edit action handler handle the copy action, given its current selection? Note that if this andcanDelete(java.util.List)both return true, the cut action will also be enabled.booleancanDelete(java.util.List<AbstractNavTreeNode> selectedChildren)Can this edit action handler handle the delete action, given its current selection? Note that if this andcanCopy(java.util.List)both return true, the cut action will also be enabled.booleancanDrag(java.util.List<AbstractNavTreeNode> draggedChildren)Can the nodes controlled by this action handling node be dragged?booleancanDrop(AbstractNavTreeNode dropTarget, java.util.List<java.awt.datatransfer.DataFlavor> flavors)booleancanPaste(java.util.List<AbstractNavTreeNode> selectedChildren, java.awt.datatransfer.Transferable data)Can this action handler handle a paste given the data flavors currently available in the clipboard? data may be null.protected voidcheckChildren()Checks to see if the children have been loaded, and if not, loads them.java.util.Enumerationchildren()booleanconfirmDelete(java.util.List<? extends AbstractNavTreeNode> selectedChildren)Used to confirm the delete.protected java.awt.datatransfer.TransferablecreateResourceCopy(java.util.List<ProjectResource> resources)Creates a Transferable that will just be a JSON string containing an array of project resourcesprotected voiddebug()protected voiddebug(java.lang.String str)voiddispatchSelectionEvent(java.util.List<javax.swing.tree.TreePath> selection)Not part of the public API.java.awt.datatransfer.TransferabledoCopy(java.util.List<? extends AbstractNavTreeNode> selectedChildren)Called when the copy action is performed.java.awt.datatransfer.TransferabledoCut(java.util.List<? extends AbstractNavTreeNode> selectedChildren)Called when the cut action is performed.voiddoDelete(java.util.List<? extends AbstractNavTreeNode> selectedChildren, AbstractNavTreeNode.DeleteReason reason)Called when the delete action is performed, if confirmDelete returned truebooleandoPaste(java.util.List<? extends AbstractNavTreeNode> selectedChildren, java.awt.datatransfer.Transferable clipboardContents, boolean isDrop)Called when the paste action is performedvoidexpand()voidexpandAndSelect()AbstractNavTreeNodefindChild(java.lang.String name)Looks through the node's children (if any) for a node with the given namestatic AbstractNavTreeNodefindCommonEditActionHandler(javax.swing.tree.TreePath[] paths)static AbstractNavTreeNodefindDropHandler(javax.swing.tree.TreePath path)Finds the closest edit action handling node in the hierarchy of the given path, including the last path component itself.static AbstractNavTreeNodefindEditActionHandler(javax.swing.tree.TreePath path)Finds the closest edit action handling node in the hierarchy of the given path, not including the last path component itself.voidforceChildrenReload()Will force child nodes to reload the next time checkChildren() is called.booleangetAllowsChildren()AbstractNavTreeNodegetChildAt(int idx)intgetChildCount()protected java.awt.datatransfer.ClipboardgetClipboard()protected AbstractNavTreeNode.PopupActiongetDeleteAction()intgetDepth()Returns this node's depth in the tree.javax.swing.IcongetExpandedIcon()Returns an alternate icon for when this node is expanded, if applicable.javax.swing.IcongetIcon()intgetIndex(javax.swing.tree.TreeNode node)NavTreePanel.EditableTreeModelgetModel()java.lang.StringgetName()AbstractNavTreeNodegetParent()Overridden to narrow the return typeprotected java.lang.Iterable<AbstractNavTreeNode.PopupAction>getPopupActions()Provide a list ofPopupActions that will be set up bysetupEditActions(javax.swing.tree.TreePath[], java.util.List<com.inductiveautomation.ignition.designer.navtree.model.AbstractNavTreeNode>); that is, will have theirAbstractNavTreeNode.PopupAction.selectionandAbstractNavTreeNode.PopupAction.actionHandlerset.javax.swing.tree.TreeSelectionModelgetSelectionModel()intgetSortOrder()Returns the relative sort order for peers.java.lang.StringgetText()The text that will be used to render the nodejava.awt.image.BufferedImagegetThumbnail()java.lang.StringgetTooltip()java.lang.StringgetWorkspaceName()Returns the name of the desired workspace for this node.protected voidinitPopupMenu(javax.swing.JPopupMenu menu, javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection, int modifiers)Default implementation calls setupEditActions(), and then addEditActions()voidinstall(AbstractNavTreeNode parent)booleanisBold()booleanisEditable()Override this and return true if you want your node's text to be editable.booleanisEditActionHandler()Override to return true if you want this node to be an edit action handler for its children.booleanisItalic()booleanisLeaf()booleanisRestricted()Used to display protected Icon for project resources that are able to be protected.booleanisSelected()protected booleanisTopLevelNode()Indicates whether this node is the "root" of a given tree; primarily used to offer different edit optionsprotected booleanisValidName(java.lang.String aName)java.util.Iterator<AbstractNavTreeNode>iterator()protected java.util.List<AbstractNavTreeNode>loadChildren()Called before this node responds from any of the children-related TreeNode functions, if a list of children wasn't already set.protected LoggerExnewLogger()protected voidnotifyChildNameChanged(AbstractNavTreeNode child)Called back by {setName(String)so the parent can re-sort its children if necessary.voidonChildrenSelected(java.util.List<javax.swing.tree.TreePath> paths)Called when child nodes (deep) are selected under this node.voidonDoubleClick()Called when this node is double-clicked on.voidonEdit(java.lang.String newTextValue)Called after this node has been edited in the tree.voidonSelected()Called when this node is selected in the treejavax.swing.tree.TreePathpathToRoot()protected voidrecreate()Asks the node to create its child list again, and reloads the structureprotected voidrecreate(boolean keepSelection)voidrefresh()Tells the model that this node's representation has changed, but not its structure.voidreload()Tells the model that this node and its child structure have changed.voidselect()Causes this tree node to become selected, clearing the current selectionvoidselect(boolean append)Causes this tree node to become selected.voidsetBold(boolean bold)protected voidsetChildren(java.util.List<AbstractNavTreeNode> children, boolean notify)protected voidsetIcon(javax.swing.Icon icon)voidsetItalic(boolean italic)protected voidsetName(java.lang.String name)protected voidsetText(java.lang.String text)protected voidsetThumbnail(java.awt.image.BufferedImage thumbnail)protected voidsetTooltip(java.lang.String tooltip)protected voidsetupEditActions(javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection)Searches for a common edit action handling parent, and initializes each popup action by callingAbstractNavTreeNode.PopupAction.setSelection(AbstractNavTreeNode, AbstractNavTreeNode, List)voidshowPopupMenu(java.awt.Component source, int x, int y, int modifiers, javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection)Called when a popup triggering event (right click) occurs over this node.java.lang.StringtoString()protected voiduninstall()Called when the node is removed from the tree.protected voiduninstallChildren()booleanuseThumbnailTooltip()voidvisitIfLoaded(java.util.function.Consumer<AbstractNavTreeNode> visitor)Visits children first if they have been loaded
 
- 
- 
- 
Field Detail- 
childrenprotected java.util.List<AbstractNavTreeNode> children 
 - 
childrenLoadedprotected boolean childrenLoaded 
 - 
parentprotected AbstractNavTreeNode parent 
 - 
modelprotected NavTreePanel.EditableTreeModel model 
 - 
selectionModelprotected javax.swing.tree.TreeSelectionModel selectionModel 
 - 
nameprotected java.lang.String name 
 - 
textprotected java.lang.String text 
 - 
tooltipprotected java.lang.String tooltip 
 - 
thumbnailprotected java.awt.image.BufferedImage thumbnail 
 - 
iconprotected javax.swing.Icon icon 
 - 
italicprotected boolean italic 
 - 
boldprotected boolean bold 
 - 
logprotected LoggerEx log 
 - 
depthprotected int depth 
 - 
cutActionprotected static final AbstractNavTreeNode.PopupAction cutAction 
 - 
copyActionprotected static final AbstractNavTreeNode.PopupAction copyAction 
 - 
pasteActionprotected static final AbstractNavTreeNode.PopupAction pasteAction 
 - 
deleteActionprotected static final AbstractNavTreeNode.PopupAction deleteAction 
 - 
renameActionprotected static final AbstractNavTreeNode.PopupAction renameAction 
 - 
copyPathActionprotected static final AbstractNavTreeNode.PopupAction copyPathAction 
 
- 
 - 
Method Detail- 
newLoggerprotected LoggerEx newLogger() 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
getSortOrderpublic int getSortOrder() Returns the relative sort order for peers. Not all nav tree node parents will use this sort order, but the root node does. Nodes with equal sort orders will then be sorted by their titles. The default return value here is 0. The config menu node returns Integer.MIN_VALUE.- Returns:
- relative sort order for peers
 
 - 
debugprotected void debug(java.lang.String str) 
 - 
debugprotected void debug() 
 - 
getDepthpublic int getDepth() Returns this node's depth in the tree. Will be -1 when the node is not installed.
 - 
installpublic void install(AbstractNavTreeNode parent) 
 - 
uninstallprotected void uninstall() Called when the node is removed from the tree. Override to provide meaningful implementation.
 - 
uninstallChildrenprotected void uninstallChildren() 
 - 
useThumbnailTooltippublic boolean useThumbnailTooltip() 
 - 
childrenpublic java.util.Enumeration children() - Specified by:
- childrenin interface- javax.swing.tree.TreeNode
 
 - 
iteratorpublic java.util.Iterator<AbstractNavTreeNode> iterator() - Specified by:
- iteratorin interface- java.lang.Iterable<AbstractNavTreeNode>
 
 - 
getAllowsChildrenpublic boolean getAllowsChildren() - Specified by:
- getAllowsChildrenin interface- javax.swing.tree.TreeNode
 
 - 
checkChildrenprotected void checkChildren() Checks to see if the children have been loaded, and if not, loads them.
 - 
loadChildrenprotected java.util.List<AbstractNavTreeNode> loadChildren() Called before this node responds from any of the children-related TreeNode functions, if a list of children wasn't already set. Override to use lazy child loading.
 - 
showPopupMenupublic void showPopupMenu(java.awt.Component source, int x, int y, int modifiers, javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection)Called when a popup triggering event (right click) occurs over this node.- Parameters:
- source- The component to use as the invoker for the popup menu.
- x- popup location x value
- y- popup location y value
- modifiers- extended modifier mask for this event, e.g. this which end with the _DOWN_MASK suffix, such as ALT_DOWN_MASK, BUTTON1_DOWN_MASK, and others, as defined in- InputEvent.getModifiers())}
- selection- The list of currently selected nodes.
 
 - 
initPopupMenuprotected void initPopupMenu(javax.swing.JPopupMenu menu, javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection, int modifiers)Default implementation calls setupEditActions(), and then addEditActions()
 - 
addEditActionsprotected void addEditActions(javax.swing.JPopupMenu menu) 
 - 
getPopupActionsprotected java.lang.Iterable<AbstractNavTreeNode.PopupAction> getPopupActions() Provide a list ofPopupActions that will be set up bysetupEditActions(javax.swing.tree.TreePath[], java.util.List<com.inductiveautomation.ignition.designer.navtree.model.AbstractNavTreeNode>); that is, will have theirAbstractNavTreeNode.PopupAction.selectionandAbstractNavTreeNode.PopupAction.actionHandlerset.
 - 
getDeleteAction@Nonnull protected AbstractNavTreeNode.PopupAction getDeleteAction() 
 - 
setupEditActionsprotected void setupEditActions(javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection)Searches for a common edit action handling parent, and initializes each popup action by callingAbstractNavTreeNode.PopupAction.setSelection(AbstractNavTreeNode, AbstractNavTreeNode, List)
 - 
isRestrictedpublic boolean isRestricted() Used to display protected Icon for project resources that are able to be protected. This method is overridden in AbstractProtectableResource to return if the the project resource it contains is actually.
 - 
isTopLevelNodeprotected boolean isTopLevelNode() Indicates whether this node is the "root" of a given tree; primarily used to offer different edit options
 - 
findCommonEditActionHandler@Nullable public static AbstractNavTreeNode findCommonEditActionHandler(javax.swing.tree.TreePath[] paths) 
 - 
findEditActionHandler@Nullable public static AbstractNavTreeNode findEditActionHandler(javax.swing.tree.TreePath path) Finds the closest edit action handling node in the hierarchy of the given path, not including the last path component itself. (unless no other is found)
 - 
findDropHandler@Nullable public static AbstractNavTreeNode findDropHandler(javax.swing.tree.TreePath path) Finds the closest edit action handling node in the hierarchy of the given path, including the last path component itself.
 - 
isEditablepublic boolean isEditable() Override this and return true if you want your node's text to be editable. SeeonEdit(String)
 - 
isValidNameprotected boolean isValidName(@Nonnull java.lang.String aName)
 - 
onEditpublic void onEdit(java.lang.String newTextValue) Called after this node has been edited in the tree.
 - 
onDoubleClickpublic void onDoubleClick() Called when this node is double-clicked on.
 - 
onSelectedpublic void onSelected() Called when this node is selected in the tree
 - 
onChildrenSelectedpublic void onChildrenSelected(java.util.List<javax.swing.tree.TreePath> paths) Called when child nodes (deep) are selected under this node.- Parameters:
- paths- the children selected when the parent node is selected
 
 - 
selectpublic void select() Causes this tree node to become selected, clearing the current selection
 - 
selectpublic void select(boolean append) Causes this tree node to become selected.- Parameters:
- append- Should this node be appended to the current selection, or be selected by itself?
 
 - 
expandpublic void expand() 
 - 
expandAndSelectpublic void expandAndSelect() 
 - 
pathToRootpublic javax.swing.tree.TreePath pathToRoot() 
 - 
getChildAtpublic final AbstractNavTreeNode getChildAt(int idx) - Specified by:
- getChildAtin interface- javax.swing.tree.TreeNode
 
 - 
getChildCountpublic final int getChildCount() - Specified by:
- getChildCountin interface- javax.swing.tree.TreeNode
 
 - 
getIndexpublic final int getIndex(javax.swing.tree.TreeNode node) - Specified by:
- getIndexin interface- javax.swing.tree.TreeNode
 
 - 
isLeafpublic boolean isLeaf() - Specified by:
- isLeafin interface- javax.swing.tree.TreeNode
 
 - 
setChildrenprotected final void setChildren(java.util.List<AbstractNavTreeNode> children, boolean notify) 
 - 
getParentpublic AbstractNavTreeNode getParent() Overridden to narrow the return type- Specified by:
- getParentin interface- javax.swing.tree.TreeNode
 
 - 
refreshpublic void refresh() Tells the model that this node's representation has changed, but not its structure.
 - 
reloadpublic void reload() Tells the model that this node and its child structure have changed.
 - 
recreateprotected void recreate() Asks the node to create its child list again, and reloads the structure
 - 
recreateprotected void recreate(boolean keepSelection) 
 - 
notifyChildNameChangedprotected void notifyChildNameChanged(AbstractNavTreeNode child) Called back by {setName(String)so the parent can re-sort its children if necessary. Simply calls recreate() by default assuming theloadChildren()call sorts alphabetically.
 - 
findChildpublic AbstractNavTreeNode findChild(java.lang.String name) Looks through the node's children (if any) for a node with the given name
 - 
visitIfLoadedpublic void visitIfLoaded(java.util.function.Consumer<AbstractNavTreeNode> visitor) Visits children first if they have been loaded
 - 
getModelpublic NavTreePanel.EditableTreeModel getModel() 
 - 
getSelectionModelpublic javax.swing.tree.TreeSelectionModel getSelectionModel() 
 - 
isSelectedpublic boolean isSelected() 
 - 
getTextpublic java.lang.String getText() The text that will be used to render the node
 - 
getTooltippublic java.lang.String getTooltip() 
 - 
getThumbnailpublic java.awt.image.BufferedImage getThumbnail() 
 - 
getIconpublic javax.swing.Icon getIcon() 
 - 
getExpandedIconpublic javax.swing.Icon getExpandedIcon() Returns an alternate icon for when this node is expanded, if applicable. Default implementation simply returns getIcon()
 - 
addBadgespublic void addBadges(BadgeTreeCellRenderer renderer, boolean selected) Add 'badges' to indicate meta information about this node- Parameters:
- renderer- the renderer; call- BadgeTreeCellRenderer.addBadge(Badge)to add your badge(s)
- selected- the state of this node
- Since:
- 8.0 removed the single-arg variant that did not pass selection status
 
 - 
getNamepublic java.lang.String getName() 
 - 
getWorkspaceNamepublic java.lang.String getWorkspaceName() Returns the name of the desired workspace for this node. Default behavior is to delegate to the parent. null mean's don't affect workspace selection.
 - 
dispatchSelectionEventpublic final void dispatchSelectionEvent(java.util.List<javax.swing.tree.TreePath> selection) Not part of the public API. Used by the nav tree to dispatch a selection event to the nodes. This function take a list of selected paths, which are paths to the children of this node. It then calls onSelected() for any direct children, and calls dispatchSelectionEvent with a sublist to any child folders. Lastly, it will call onChildrenSelected for this node.- Parameters:
- selection- the selected paths
 
 - 
setNameprotected void setName(java.lang.String name) 
 - 
setTextprotected void setText(java.lang.String text) 
 - 
isItalicpublic boolean isItalic() 
 - 
setItalicpublic void setItalic(boolean italic) 
 - 
isBoldpublic boolean isBold() 
 - 
setBoldpublic void setBold(boolean bold) 
 - 
setTooltipprotected void setTooltip(java.lang.String tooltip) 
 - 
setThumbnailprotected void setThumbnail(java.awt.image.BufferedImage thumbnail) 
 - 
setIconprotected void setIcon(javax.swing.Icon icon) 
 - 
isEditActionHandlerpublic boolean isEditActionHandler() Override to return true if you want this node to be an edit action handler for its children.
 - 
canDeletepublic boolean canDelete(java.util.List<AbstractNavTreeNode> selectedChildren) Can this edit action handler handle the delete action, given its current selection? Note that if this andcanCopy(java.util.List)both return true, the cut action will also be enabled.
 - 
canCopypublic boolean canCopy(java.util.List<AbstractNavTreeNode> selectedChildren) Can this edit action handler handle the copy action, given its current selection? Note that if this andcanDelete(java.util.List)both return true, the cut action will also be enabled.
 - 
canPastepublic boolean canPaste(java.util.List<AbstractNavTreeNode> selectedChildren, @Nullable java.awt.datatransfer.Transferable data) Can this action handler handle a paste given the data flavors currently available in the clipboard? data may be null.
 - 
canDroppublic boolean canDrop(AbstractNavTreeNode dropTarget, java.util.List<java.awt.datatransfer.DataFlavor> flavors) 
 - 
canDragpublic boolean canDrag(java.util.List<AbstractNavTreeNode> draggedChildren) Can the nodes controlled by this action handling node be dragged?
 - 
doDeletepublic void doDelete(java.util.List<? extends AbstractNavTreeNode> selectedChildren, AbstractNavTreeNode.DeleteReason reason) Called when the delete action is performed, if confirmDelete returned true
 - 
confirmDeletepublic boolean confirmDelete(java.util.List<? extends AbstractNavTreeNode> selectedChildren) Used to confirm the delete. If true is returned, doDelete will be called.
 - 
doCopy@Nullable public java.awt.datatransfer.Transferable doCopy(java.util.List<? extends AbstractNavTreeNode> selectedChildren) Called when the copy action is performed.- Returns:
- the current selection as a Transferable, or null if the copy failed. Will be added to the system clipboard.
 
 - 
createResourceCopyprotected java.awt.datatransfer.Transferable createResourceCopy(@Nonnull java.util.List<ProjectResource> resources)Creates a Transferable that will just be a JSON string containing an array of project resources
 - 
doCutpublic java.awt.datatransfer.Transferable doCut(java.util.List<? extends AbstractNavTreeNode> selectedChildren) Called when the cut action is performed.- Returns:
- the current selection as a Transferable, or null if the cut failed. Will be added to the system clipboard.
 
 - 
doPastepublic boolean doPaste(java.util.List<? extends AbstractNavTreeNode> selectedChildren, java.awt.datatransfer.Transferable clipboardContents, boolean isDrop) Called when the paste action is performed- Parameters:
- clipboardContents- The current contents of the clipboard to paste.
- isDrop- Indicates whether this paste originated from a drop action. If false, originated from a keyboard or menu paste shortcut.
- Returns:
- whether or not the paste successfully completed.
 
 - 
getClipboardprotected java.awt.datatransfer.Clipboard getClipboard() 
 - 
forceChildrenReloadpublic void forceChildrenReload() Will force child nodes to reload the next time checkChildren() is called.
 
- 
 
-