Class AbstractNavTreeNode
java.lang.Object
com.inductiveautomation.ignition.designer.navtree.model.AbstractNavTreeNode
- All Implemented Interfaces:
Iterable<AbstractNavTreeNode>
,TreeNode
- Direct Known Subclasses:
AbstractResourceNavTreeNode
,ComponentNode
,ComponentNode
,MutableNavTreeNode
,PipeNode
,PipesFolderNode
,ShapeNode
public abstract class AbstractNavTreeNode
extends Object
implements TreeNode, 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 Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Semantically, the "delete" operation gets used for a variety of different reasons.protected static class
A BaseAction that gets set up with the node selection prior to being shown -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected List<AbstractNavTreeNode>
protected boolean
protected static final AbstractNavTreeNode.PopupAction
protected static final AbstractNavTreeNode.PopupAction
protected static final AbstractNavTreeNode.PopupAction
protected static final AbstractNavTreeNode.PopupAction
protected int
protected AbstractNavTreeNode.PopupAction
protected Icon
protected boolean
protected LoggerEx
protected NavTreePanel.EditableTreeModel
protected String
protected AbstractNavTreeNode
protected static final AbstractNavTreeNode.PopupAction
protected static final AbstractNavTreeNode.PopupAction
protected TreeSelectionModel
protected String
protected BufferedImage
protected String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBadges
(BadgeTreeCellRenderer renderer, boolean selected) Add 'badges' to indicate meta information about this nodeprotected void
addEditActions
(JPopupMenu menu) protected void
addEditActions
(JPopupMenu menu, boolean excludeRenameAction) The standard edit popup menu includes the following: - Rename - Cut - Copy - Copy Path (Only for non TopLevel nodes - Paste - Delete / Discard Overrides (for overridden resources, Discard Overrides will appear in place of Delete) Overridden and Inherited resources (element of the subclassAbstractResourceNavTreeNode
can not be renamed, to accommodate that situation, the excludeRenameAction option can be use in those cases should these edit actions.boolean
canCopy
(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.boolean
canDelete
(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.boolean
canDrag
(List<AbstractNavTreeNode> draggedChildren) Can the nodes controlled by this action handling node be dragged?boolean
canDrop
(AbstractNavTreeNode dropTarget, List<DataFlavor> flavors) boolean
canPaste
(List<AbstractNavTreeNode> selectedChildren, Transferable data) Can this action handler handle a paste given the data flavors currently available in the clipboard? data may be null.protected void
Checks to see if the children have been loaded, and if not, loads them.children()
boolean
confirmDelete
(List<? extends AbstractNavTreeNode> selectedChildren) Used to confirm the delete.protected Transferable
createResourceCopy
(List<ProjectResource> resources) Creates a Transferable that will just be a JSON string containing an array of project resourcesprotected void
debug()
protected void
final void
dispatchSelectionEvent
(List<TreePath> selection) Not part of the public API.doCopy
(List<? extends AbstractNavTreeNode> selectedChildren) Called when the copy action is performed.doCut
(List<? extends AbstractNavTreeNode> selectedChildren) Called when the cut action is performed.void
doDelete
(List<? extends AbstractNavTreeNode> selectedChildren, AbstractNavTreeNode.DeleteReason reason) Called when the delete action is performed, if confirmDelete returned trueboolean
doPaste
(List<? extends AbstractNavTreeNode> selectedChildren, Transferable clipboardContents, boolean isDrop) Called when the paste action is performedvoid
expand()
void
Looks through the node's children (if any) for a node with the given namestatic AbstractNavTreeNode
findCommonEditActionHandler
(TreePath[] paths) static AbstractNavTreeNode
findDropHandler
(TreePath path) Finds the closest edit action handling node in the hierarchy of the given path, including the last path component itself.static AbstractNavTreeNode
Finds the closest edit action handling node in the hierarchy of the given path, not including the last path component itself.void
Will force child nodes to reload the next time checkChildren() is called.boolean
final AbstractNavTreeNode
getChildAt
(int idx) final int
protected Clipboard
protected AbstractNavTreeNode.PopupAction
int
getDepth()
Returns this node's depth in the tree.Returns an alternate icon for when this node is expanded, if applicable.getIcon()
final int
getModel()
getName()
Overridden to narrow the return typeprotected Iterable<AbstractNavTreeNode.PopupAction>
Provide a list ofPopupAction
s 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.selection
andAbstractNavTreeNode.PopupAction.actionHandler
set.int
Returns the relative sort order for peers.getText()
The text that will be used to render the nodeReturns the name of the desired workspace for this node.protected void
initPopupMenu
(JPopupMenu menu, TreePath[] paths, List<AbstractNavTreeNode> selection, int modifiers) Default implementation calls setupEditActions(), and then addEditActions()void
install
(AbstractNavTreeNode parent) boolean
isBold()
boolean
Override this and return true if you want your node's text to be editable.boolean
Override to return true if you want this node to be an edit action handler for its children.boolean
isItalic()
boolean
isLeaf()
boolean
boolean
Used to display protected Icon for project resources that are able to be protected.boolean
protected boolean
Indicates whether this node is the "root" of a given tree; primarily used to offer different edit optionsprotected boolean
isValidName
(String aName) iterator()
protected List<AbstractNavTreeNode>
Called before this node responds from any of the children-related TreeNode functions, if a list of children wasn't already set.protected LoggerEx
protected void
Called back by {setName(String)
so the parent can re-sort its children if necessary.void
onChildrenSelected
(List<TreePath> paths) Called when child nodes (deep) are selected under this node.void
Called when this node is double-clicked on.void
Called after this node has been edited in the tree.void
Called when this node is selected in the treestatic void
performOnAllChildren
(AbstractNavTreeNode node, Consumer<AbstractNavTreeNode> action) protected void
recreate()
Asks the node to create its child list again, and reloads the structureprotected void
recreate
(boolean keepSelection) void
refresh()
Tells the model that this node's representation has changed, but not its structure.void
reload()
Tells the model that this node and its child structure have changed.void
select()
Causes this tree node to become selected, clearing the current selectionvoid
select
(boolean append) Causes this tree node to become selected.void
setBold
(boolean bold) protected void
setChildren
(List<AbstractNavTreeNode> children, boolean notify) protected void
void
setItalic
(boolean italic) protected void
protected void
protected void
setThumbnail
(BufferedImage thumbnail) protected void
setTooltip
(String tooltip) protected void
setupEditActions
(TreePath[] paths, List<AbstractNavTreeNode> selection) Searches for a common edit action handling parent, and initializes each popup action by callingAbstractNavTreeNode.PopupAction.setSelection(AbstractNavTreeNode, AbstractNavTreeNode, List)
void
showPopupMenu
(Component source, int x, int y, int modifiers, TreePath[] paths, List<AbstractNavTreeNode> selection) Called when a popup triggering event (right click) occurs over this node.toString()
protected void
Called when the node is removed from the tree.protected void
boolean
void
visitIfLoaded
(Consumer<AbstractNavTreeNode> visitor) Visits children first if they have been loadedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
children
-
childrenLoaded
protected boolean childrenLoaded -
parent
-
model
-
selectionModel
-
name
-
text
-
tooltip
-
thumbnail
-
icon
-
italic
protected boolean italic -
bold
protected boolean bold -
log
-
depth
protected int depth -
cutAction
-
copyAction
-
pasteAction
-
deleteAction
-
discardOverridesAction
-
renameAction
-
copyPathAction
-
-
Constructor Details
-
AbstractNavTreeNode
protected AbstractNavTreeNode() -
AbstractNavTreeNode
protected AbstractNavTreeNode(boolean isModuleNode)
-
-
Method Details
-
newLogger
-
toString
-
getSortOrder
public 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
-
debug
-
debug
protected void debug() -
getDepth
public int getDepth()Returns this node's depth in the tree. Will be -1 when the node is not installed. -
uninstall
protected void uninstall()Called when the node is removed from the tree. Override to provide meaningful implementation. -
uninstallChildren
protected void uninstallChildren() -
useThumbnailTooltip
public boolean useThumbnailTooltip() -
children
-
iterator
- Specified by:
iterator
in interfaceIterable<AbstractNavTreeNode>
-
getAllowsChildren
public boolean getAllowsChildren()- Specified by:
getAllowsChildren
in interfaceTreeNode
-
checkChildren
protected void checkChildren()Checks to see if the children have been loaded, and if not, loads them. -
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. -
showPopupMenu
public void showPopupMenu(Component source, int x, int y, int modifiers, TreePath[] paths, 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 valuey
- popup location y valuemodifiers
- 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 inInputEvent.getModifiers()
)}selection
- The list of currently selected nodes.
-
initPopupMenu
protected void initPopupMenu(JPopupMenu menu, TreePath[] paths, List<AbstractNavTreeNode> selection, int modifiers) Default implementation calls setupEditActions(), and then addEditActions() -
addEditActions
-
addEditActions
The standard edit popup menu includes the following: - Rename - Cut - Copy - Copy Path (Only for non TopLevel nodes - Paste - Delete / Discard Overrides (for overridden resources, Discard Overrides will appear in place of Delete) Overridden and Inherited resources (element of the subclassAbstractResourceNavTreeNode
can not be renamed, to accommodate that situation, the excludeRenameAction option can be use in those cases should these edit actions.- Parameters:
menu
- The popup menu that the edit actions will be added to.excludeRenameAction
- Set to true to exclude "Rename" as an option.
-
getPopupActions
Provide a list ofPopupAction
s 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.selection
andAbstractNavTreeNode.PopupAction.actionHandler
set. -
getDeleteAction
-
setupEditActions
Searches for a common edit action handling parent, and initializes each popup action by callingAbstractNavTreeNode.PopupAction.setSelection(AbstractNavTreeNode, AbstractNavTreeNode, List)
-
isRestricted
public 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. -
isTopLevelNode
protected boolean isTopLevelNode()Indicates whether this node is the "root" of a given tree; primarily used to offer different edit options -
findCommonEditActionHandler
-
findEditActionHandler
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
Finds the closest edit action handling node in the hierarchy of the given path, including the last path component itself. -
isEditable
public boolean isEditable()Override this and return true if you want your node's text to be editable. SeeonEdit(String)
-
isValidName
-
onEdit
Called after this node has been edited in the tree. -
onDoubleClick
public void onDoubleClick()Called when this node is double-clicked on. -
onSelected
public void onSelected()Called when this node is selected in the tree -
onChildrenSelected
Called when child nodes (deep) are selected under this node.- Parameters:
paths
- the children selected when the parent node is selected
-
select
public void select()Causes this tree node to become selected, clearing the current selection -
select
public 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?
-
expand
public void expand() -
expandAndSelect
public void expandAndSelect() -
pathToRoot
-
getChildAt
- Specified by:
getChildAt
in interfaceTreeNode
-
getChildCount
public final int getChildCount()- Specified by:
getChildCount
in interfaceTreeNode
-
getIndex
-
isLeaf
public boolean isLeaf() -
setChildren
-
getParent
Overridden to narrow the return type -
refresh
public void refresh()Tells the model that this node's representation has changed, but not its structure. -
reload
public void reload()Tells the model that this node and its child structure have changed. -
recreate
protected void recreate()Asks the node to create its child list again, and reloads the structure -
recreate
protected void recreate(boolean keepSelection) -
findChild
Looks through the node's children (if any) for a node with the given name -
visitIfLoaded
Visits children first if they have been loaded -
getModel
-
getSelectionModel
-
isSelected
public boolean isSelected() -
getText
The text that will be used to render the node -
getTooltip
-
getThumbnail
-
getIcon
-
getExpandedIcon
Returns an alternate icon for when this node is expanded, if applicable. Default implementation simply returns getIcon() -
getName
-
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. -
dispatchSelectionEvent
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
-
setName
-
setText
-
isItalic
public boolean isItalic() -
setItalic
public void setItalic(boolean italic) -
isBold
public boolean isBold() -
setBold
public void setBold(boolean bold) -
setTooltip
-
setThumbnail
-
setIcon
-
isEditActionHandler
public boolean isEditActionHandler()Override to return true if you want this node to be an edit action handler for its children. -
canDelete
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. -
canCopy
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. -
canPaste
Can this action handler handle a paste given the data flavors currently available in the clipboard? data may be null. -
canDrag
Can the nodes controlled by this action handling node be dragged? -
confirmDelete
Used to confirm the delete. If true is returned, doDelete will be called. -
doCopy
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.
-
createResourceCopy
Creates a Transferable that will just be a JSON string containing an array of project resources -
doCut
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.
-
doPaste
public boolean doPaste(List<? extends AbstractNavTreeNode> selectedChildren, 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.
-
getClipboard
-
forceChildrenReload
public void forceChildrenReload()Will force child nodes to reload the next time checkChildren() is called. -
isModuleNode
public boolean isModuleNode()
-