public abstract class AbstractNavTreeNode extends java.lang.Object implements javax.swing.tree.TreeNode, java.lang.Iterable<AbstractNavTreeNode>
Modifier and Type | Class and Description |
---|---|
static class |
AbstractNavTreeNode.DeleteReason
Semantically, the "delete" operation gets used for a variety of different reasons.
|
protected static class |
AbstractNavTreeNode.PopupAction
A BaseAction that gets set up with the node selection prior to being shown
|
protected class |
AbstractNavTreeNode.ResourceChangeListener
Listens to see if any matching resources change, and modifies the nav tree's font accordingly.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
bold |
protected java.util.List<AbstractNavTreeNode> |
children |
protected boolean |
childrenLoaded |
protected static AbstractNavTreeNode.PopupAction |
copyAction |
protected static AbstractNavTreeNode.PopupAction |
cutAction |
protected static AbstractNavTreeNode.PopupAction |
deleteAction |
protected int |
depth |
protected javax.swing.Icon |
icon |
protected boolean |
italic |
protected LoggerEx |
log |
protected NavTreePanel.EditableTreeModel |
model |
protected java.lang.String |
name |
static java.util.regex.Pattern |
NAME_PATTERN
A basic name validation pattern that needs a character, underscore, or digit to start with, and then will also
accept spaces and parens afterwards.
|
protected AbstractNavTreeNode |
parent |
protected static AbstractNavTreeNode.PopupAction |
pasteAction |
protected static AbstractNavTreeNode.PopupAction |
protectedAction |
protected static javax.swing.JCheckBoxMenuItem |
protectedMenuItem |
protected static AbstractNavTreeNode.PopupAction |
renameAction |
protected javax.swing.tree.TreeSelectionModel |
selectionModel |
protected java.lang.String |
text |
protected java.awt.image.BufferedImage |
thumbnail |
protected java.lang.String |
tooltip |
Modifier | Constructor and Description |
---|---|
protected |
AbstractNavTreeNode() |
Modifier and Type | Method and Description |
---|---|
void |
addBadges(BadgeTreeCellRenderer renderer) |
protected void |
addEditActions(javax.swing.JPopupMenu menu) |
boolean |
canCopy(java.util.List<AbstractNavTreeNode> selectedChildren)
Can this edit action handler handle the copy action, given its current selection? Note that if this and
canDelete(java.util.List) both return true, the cut action will also be enabled. |
boolean |
canDelete(java.util.List<AbstractNavTreeNode> selectedChildren)
Can this edit action handler handle the delete action, given its current selection? Note that if this and
canCopy(java.util.List) both return true, the cut action will also be enabled. |
boolean |
canDrag(java.util.List<AbstractNavTreeNode> draggedChildren)
Can the nodes controlled by this action handling node be dragged?
|
boolean |
canDrop(AbstractNavTreeNode dropTarget,
java.util.List<java.awt.datatransfer.DataFlavor> flavors) |
boolean |
canPaste(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 void |
checkChildren()
Checks to see if the children have been loaded, and if not, loads them.
|
java.util.Enumeration |
children() |
boolean |
confirmDelete(java.util.List<? extends AbstractNavTreeNode> selectedChildren)
Used to confirm the delete.
|
protected void |
debug() |
protected void |
debug(java.lang.String str) |
void |
dispatchSelectionEvent(java.util.List<javax.swing.tree.TreePath> selection)
Not part of the public API.
|
java.awt.datatransfer.Transferable |
doCopy(java.util.List<? extends AbstractNavTreeNode> selectedChildren)
Called when the copy action is performed.
|
java.awt.datatransfer.Transferable |
doCut(java.util.List<? extends AbstractNavTreeNode> selectedChildren)
Called when the cut action is performed.
|
void |
doDelete(java.util.List<? extends AbstractNavTreeNode> selectedChildren,
AbstractNavTreeNode.DeleteReason reason)
Called when the delete action is performed, if confirmDelete returned true
|
boolean |
doPaste(java.util.List<? extends AbstractNavTreeNode> selectedChildren,
java.awt.datatransfer.Transferable clipboardContents,
boolean isDrop)
Called when the paste action is performed
|
void |
expand() |
AbstractNavTreeNode |
findChild(java.lang.String name)
Looks through the node's children (if any) for a node with the given name
|
static AbstractNavTreeNode |
findCommonEditActionHandler(javax.swing.tree.TreePath[] paths) |
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.
|
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.
|
protected void |
forceChildrenReload()
Will force child nodes to reload the next time checkChildren() is called.
|
boolean |
getAllowsChildren() |
AbstractNavTreeNode |
getChildAt(int idx) |
int |
getChildCount() |
protected java.awt.datatransfer.Clipboard |
getClipboard() |
protected AbstractNavTreeNode |
getCommonEditActionHandler(javax.swing.tree.TreePath[] paths) |
int |
getDepth()
Returns this node's depth in the tree.
|
javax.swing.Icon |
getExpandedIcon()
Returns an alternate icon for when this node is expanded, if applicable.
|
javax.swing.Icon |
getIcon() |
int |
getIndex(javax.swing.tree.TreeNode node) |
NavTreePanel.EditableTreeModel |
getModel() |
java.lang.String |
getName() |
AbstractNavTreeNode |
getParent()
Overridden to narrow the return type
|
javax.swing.tree.TreeSelectionModel |
getSelectionModel() |
int |
getSortOrder()
Returns the relative sort order for peers.
|
java.lang.String |
getText()
The text that will be used to render the node
|
java.awt.image.BufferedImage |
getThumbnail() |
java.lang.String |
getTooltip() |
java.lang.String |
getWorkspaceName()
Returns the name of the desired workspace for this node.
|
protected 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()
|
void |
install(AbstractNavTreeNode parent) |
boolean |
isBold() |
boolean |
isEditable()
Override this and return true if you want your node's text to be editable.
|
boolean |
isEditActionHandler()
Override to return true if you want this node to be an edit action handler for its children.
|
boolean |
isItalic() |
boolean |
isLeaf() |
boolean |
isProtected()
Used to display protected Icon for project resources that are able to be protected.
|
boolean |
isProtectedEnabled()
This method is overridden by AbstractProtectableResourceNavTreeNode to check the if the user has the required
role to protect resources.
|
boolean |
isSelected() |
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 LoggerEx |
newLogger() |
protected void |
notifyChildNameChanged(AbstractNavTreeNode child)
Called back by {
setName(String) so the parent can re-sort its children if necessary. |
void |
onChildrenSelected(java.util.List<javax.swing.tree.TreePath> paths)
Called when child nodes (deep) are selected under this node.
|
void |
onDoubleClick()
Called when this node is double-clicked on.
|
void |
onEdit(java.lang.String newTextValue)
Called after this node has been edited in the tree.
|
void |
onSelected()
Called when this node is selected in the tree
|
javax.swing.tree.TreePath |
pathToRoot() |
protected void |
recreate()
Asks the node to create its child list again, and reloads the structure
|
void |
refresh()
Tells the model that this node's reperesentation 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 selection
|
void |
select(boolean append)
Causes this tree node to become selected.
|
void |
setBold(boolean bold) |
protected void |
setChildren(java.util.List<AbstractNavTreeNode> children,
boolean notify) |
protected void |
setIcon(javax.swing.Icon icon) |
void |
setItalic(boolean italic) |
protected void |
setName(java.lang.String name) |
void |
setProtected(boolean protect)
If protection is enabled, this is the callback from the checkbox menu item when the user toggles the protection
bit.
|
protected void |
setText(java.lang.String text) |
protected void |
setThumbnail(java.awt.image.BufferedImage thumbnail) |
protected void |
setTooltip(java.lang.String tooltip) |
protected void |
setupEditActions(javax.swing.tree.TreePath[] paths,
java.util.List<AbstractNavTreeNode> selection)
Searches for a common edit action handling parent, and if one exists, sets up the edit actions appropriately.
|
boolean |
showPopup(java.awt.Component source,
int x,
int y,
int modifiers,
javax.swing.tree.TreePath[] paths,
java.util.List<AbstractNavTreeNode> selection) |
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.
|
java.lang.String |
toString() |
protected void |
uninstall()
Called when the node is removed from the tree.
|
protected void |
uninstallChildren() |
boolean |
useThumbnailTooltip() |
protected java.util.List<AbstractNavTreeNode> children
protected boolean childrenLoaded
protected AbstractNavTreeNode parent
protected NavTreePanel.EditableTreeModel model
protected javax.swing.tree.TreeSelectionModel selectionModel
protected java.lang.String name
protected java.lang.String text
protected java.lang.String tooltip
protected java.awt.image.BufferedImage thumbnail
protected javax.swing.Icon icon
protected boolean italic
protected boolean bold
protected LoggerEx log
protected int depth
protected static final AbstractNavTreeNode.PopupAction protectedAction
protected static final javax.swing.JCheckBoxMenuItem protectedMenuItem
public static java.util.regex.Pattern NAME_PATTERN
protected static final AbstractNavTreeNode.PopupAction cutAction
protected static final AbstractNavTreeNode.PopupAction copyAction
protected static final AbstractNavTreeNode.PopupAction pasteAction
protected static final AbstractNavTreeNode.PopupAction deleteAction
protected static final AbstractNavTreeNode.PopupAction renameAction
protected LoggerEx newLogger()
public java.lang.String toString()
toString
in class java.lang.Object
public int getSortOrder()
protected void debug(java.lang.String str)
protected void debug()
public int getDepth()
public void install(AbstractNavTreeNode parent)
protected void uninstall()
protected void uninstallChildren()
public boolean useThumbnailTooltip()
public java.util.Enumeration children()
children
in interface javax.swing.tree.TreeNode
public java.util.Iterator<AbstractNavTreeNode> iterator()
iterator
in interface java.lang.Iterable<AbstractNavTreeNode>
public boolean getAllowsChildren()
getAllowsChildren
in interface javax.swing.tree.TreeNode
protected void checkChildren()
protected java.util.List<AbstractNavTreeNode> loadChildren()
public void showPopupMenu(java.awt.Component source, int x, int y, int modifiers, javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection)
source
- The component to use as the invoker for the popup menu.x
- y
- modifiers
- selection
- The list of currently selected nodes.public boolean showPopup(java.awt.Component source, int x, int y, int modifiers, javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection)
protected void initPopupMenu(javax.swing.JPopupMenu menu, javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection, int modifiers)
protected void addEditActions(javax.swing.JPopupMenu menu)
protected void setupEditActions(javax.swing.tree.TreePath[] paths, java.util.List<AbstractNavTreeNode> selection)
public boolean isProtectedEnabled()
public boolean isProtected()
public void setProtected(boolean protect)
protected AbstractNavTreeNode getCommonEditActionHandler(javax.swing.tree.TreePath[] paths)
public static AbstractNavTreeNode findCommonEditActionHandler(javax.swing.tree.TreePath[] paths)
public static AbstractNavTreeNode findEditActionHandler(javax.swing.tree.TreePath path)
public static AbstractNavTreeNode findDropHandler(javax.swing.tree.TreePath path)
public boolean isEditable()
onEdit(String)
public void onEdit(java.lang.String newTextValue)
public void onDoubleClick()
public void onSelected()
public void onChildrenSelected(java.util.List<javax.swing.tree.TreePath> paths)
paths
- public void select()
public void select(boolean append)
append
- Should this node be appended to the current selection, or be selected by itself?public void expand()
public javax.swing.tree.TreePath pathToRoot()
public final AbstractNavTreeNode getChildAt(int idx)
getChildAt
in interface javax.swing.tree.TreeNode
public final int getChildCount()
getChildCount
in interface javax.swing.tree.TreeNode
public final int getIndex(javax.swing.tree.TreeNode node)
getIndex
in interface javax.swing.tree.TreeNode
public boolean isLeaf()
isLeaf
in interface javax.swing.tree.TreeNode
protected final void setChildren(java.util.List<AbstractNavTreeNode> children, boolean notify)
public AbstractNavTreeNode getParent()
getParent
in interface javax.swing.tree.TreeNode
public void refresh()
public void reload()
protected void recreate()
protected void notifyChildNameChanged(AbstractNavTreeNode child)
setName(String)
so the parent can re-sort its children if necessary. Simply calls
recreate() by default assuming the loadChildren()
call sorts alphabetically.public AbstractNavTreeNode findChild(java.lang.String name)
public NavTreePanel.EditableTreeModel getModel()
public javax.swing.tree.TreeSelectionModel getSelectionModel()
public boolean isSelected()
public java.lang.String getText()
public java.lang.String getTooltip()
public java.awt.image.BufferedImage getThumbnail()
public javax.swing.Icon getIcon()
public javax.swing.Icon getExpandedIcon()
public void addBadges(BadgeTreeCellRenderer renderer)
public java.lang.String getName()
public java.lang.String getWorkspaceName()
public final void dispatchSelectionEvent(java.util.List<javax.swing.tree.TreePath> selection)
selection
- protected void setName(java.lang.String name)
protected void setText(java.lang.String text)
public boolean isItalic()
public void setItalic(boolean italic)
public boolean isBold()
public void setBold(boolean bold)
protected void setTooltip(java.lang.String tooltip)
protected void setThumbnail(java.awt.image.BufferedImage thumbnail)
protected void setIcon(javax.swing.Icon icon)
public boolean isEditActionHandler()
public boolean canDelete(java.util.List<AbstractNavTreeNode> selectedChildren)
canCopy(java.util.List)
both return true, the cut action will also be enabled.public boolean canCopy(java.util.List<AbstractNavTreeNode> selectedChildren)
canDelete(java.util.List)
both return true, the cut action will also be enabled.public boolean canPaste(java.util.List<AbstractNavTreeNode> selectedChildren, java.awt.datatransfer.Transferable data)
public boolean canDrop(AbstractNavTreeNode dropTarget, java.util.List<java.awt.datatransfer.DataFlavor> flavors)
public boolean canDrag(java.util.List<AbstractNavTreeNode> draggedChildren)
public void doDelete(java.util.List<? extends AbstractNavTreeNode> selectedChildren, AbstractNavTreeNode.DeleteReason reason)
public boolean confirmDelete(java.util.List<? extends AbstractNavTreeNode> selectedChildren)
public java.awt.datatransfer.Transferable doCopy(java.util.List<? extends AbstractNavTreeNode> selectedChildren)
Transferable
, or null if the copy failed. Will be added to
the system clipboard.public java.awt.datatransfer.Transferable doCut(java.util.List<? extends AbstractNavTreeNode> selectedChildren)
Transferable
, or null if the cut failed. Will be added to the
system clipboard.public boolean doPaste(java.util.List<? extends AbstractNavTreeNode> selectedChildren, java.awt.datatransfer.Transferable clipboardContents, boolean isDrop)
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.protected java.awt.datatransfer.Clipboard getClipboard()
protected void forceChildrenReload()