public abstract class VPTNode extends javax.swing.tree.DefaultMutableTreeNode implements java.lang.Comparable<VPTNode>
Based on the TreeNode
class from the VirtualProjectTree
plugin by Shad Stafford.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
name |
protected static java.awt.Color |
treeNoSelectionBackground |
protected static java.awt.Color |
treeNoSelectionForeground |
protected static java.awt.Color |
treeSelectionBackground |
protected static java.awt.Color |
treeSelectionForeground |
Modifier | Constructor and Description |
---|---|
protected |
VPTNode(java.lang.String name,
boolean allowsChildren) |
Modifier and Type | Method and Description |
---|---|
boolean |
canOpen()
This method should return whether it makes sense to "open" the node.
|
boolean |
canRename()
Returns whether the underlying resource can be renamed.
|
boolean |
canWrite()
Returns whether the underlying resource can be written to.
|
protected void |
changed()
Called when the tree panel receives a request to notify that
information about the node has changed.
|
void |
close()
"Closes" the node.
|
protected int |
compareName(VPTNode other) |
int |
compareTo(VPTNode node)
This method is used to sort the nodes in the trees.
|
boolean |
delete()
The "delete()" method should remove the resource from the the disk,
if applicable.
|
int |
findIndexForChild(VPTNode child)
Do a binary search with the goal of finding in what index of the child
array of this node the given child would be inserted to maintain order
according to the comparison rules defined by the compareToNode() methods.
|
static VPTProject |
findProjectFor(VPTNode node)
Returns the project associated with the node, or null if the node
is the root of the project tree.
|
java.awt.Color |
getBackgroundColor(boolean sel)
Returns the node's background color.
|
VPTNode |
getChildWithName(java.lang.String name)
Returns the child directly under this node that has the given
name.
|
int |
getClipType()
This method controls how the CellRenderer implementation will clip the
name of the node when it doesn't fit in the tree.
|
java.awt.Color |
getForegroundColor(boolean sel)
Returns the node's foreground color.
|
VPTGroup |
getGroup()
Returns a group to which this node belongs.
|
abstract javax.swing.Icon |
getIcon(boolean expanded)
Returns the icon to be shown on the tree next to the node name.
|
protected java.util.concurrent.locks.ReadWriteLock |
getLock()
Returns the lock object for the parent project of this node,
or null if there is no parent project.
|
java.lang.String |
getName()
Returns the name of this node.
|
abstract java.lang.String |
getNodePath()
Returns a String representing a "path" for this node.
|
int |
getVersionControlState() |
void |
insert(javax.swing.tree.MutableTreeNode newChild,
int childIndex) |
boolean |
isDirectory()
Returns true if this node is a VPTDirectory.
|
boolean |
isFile()
Returns true if this node is a VPTFile.
|
boolean |
isGroup()
Whether this instance if a VPTGroup or any subclass of it.
|
boolean |
isOpened()
Tells if the resource is currently opened in jEdit.
|
boolean |
isProject()
Returns true if this node is a VPTProject.
|
boolean |
isRoot()
Returns whether this node is the root node.
|
protected void |
lock(boolean write)
Convenience method for locking.
|
void |
open()
"Opens" the node.
|
boolean |
persistChildren()
This method should return whether the children of this node should
be persisted when the node is saved to the project config file.
|
void |
remove(int childIndex) |
void |
remove(javax.swing.tree.MutableTreeNode aChild) |
void |
removeAllChildren() |
void |
removeFromParent() |
void |
setName(java.lang.String name)
Changes the name of the node.
|
void |
setParent(javax.swing.tree.MutableTreeNode newParent)
Sets the parent for the node.
|
void |
setVersionControlState(int state) |
void |
sortChildren()
Sort the children list for this node using the default node comparator.
|
void |
sortChildren(boolean recurse)
Sort the children list for this node using the default node comparator.
|
java.lang.String |
toString()
Returns a string representation of the current node.
|
protected void |
unlock(boolean write)
Convenience method for unlocking.
|
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, setAllowsChildren, setUserObject
protected static final java.awt.Color treeSelectionForeground
protected static final java.awt.Color treeNoSelectionForeground
protected static final java.awt.Color treeSelectionBackground
protected static final java.awt.Color treeNoSelectionBackground
protected java.lang.String name
public static VPTProject findProjectFor(VPTNode node)
public void insert(javax.swing.tree.MutableTreeNode newChild, int childIndex)
insert
in interface javax.swing.tree.MutableTreeNode
insert
in class javax.swing.tree.DefaultMutableTreeNode
public void remove(int childIndex)
remove
in interface javax.swing.tree.MutableTreeNode
remove
in class javax.swing.tree.DefaultMutableTreeNode
public void remove(javax.swing.tree.MutableTreeNode aChild)
remove
in interface javax.swing.tree.MutableTreeNode
remove
in class javax.swing.tree.DefaultMutableTreeNode
public void removeAllChildren()
removeAllChildren
in class javax.swing.tree.DefaultMutableTreeNode
public void removeFromParent()
removeFromParent
in interface javax.swing.tree.MutableTreeNode
removeFromParent
in class javax.swing.tree.DefaultMutableTreeNode
public void sortChildren()
public void sortChildren(boolean recurse)
public boolean delete()
public final boolean isFile()
public boolean isDirectory()
public final boolean isProject()
public boolean isGroup()
public final boolean isRoot()
isRoot
in class javax.swing.tree.DefaultMutableTreeNode
public boolean isOpened()
public java.lang.String getName()
public void setName(java.lang.String name)
public boolean canWrite()
public VPTGroup getGroup()
null
.public boolean canRename()
public java.lang.String toString()
toString
in class javax.swing.tree.DefaultMutableTreeNode
public boolean canOpen()
public void open()
public void close()
open()
, normally.public abstract java.lang.String getNodePath()
public int compareTo(VPTNode node)
IT'S VERY IMPORTANT TO IMPLEMENT THIS METHOD CORRECTLY. Especially for nodes that allow children nodes, since VPTDirectory expects nodes of these kinds to take care of the comparison themselves. There's danger of infinite recursion if you don't take this into account.
compareTo
in interface java.lang.Comparable<VPTNode>
public int findIndexForChild(VPTNode child)
child
- The child to be inserted.public void setParent(javax.swing.tree.MutableTreeNode newParent)
setParent
in interface javax.swing.tree.MutableTreeNode
setParent
in class javax.swing.tree.DefaultMutableTreeNode
public boolean persistChildren()
Nodes that provide run time children (for example, allowing for the exploration of the contents of a JAR file) should override this method and return "false".
This only makes sense for nodes that allow children in the first place.
public VPTNode getChildWithName(java.lang.String name)
public abstract javax.swing.Icon getIcon(boolean expanded)
expanded
- If the node is currently expanded or not.public java.awt.Color getForegroundColor(boolean sel)
sel
- If the node is currently selected.public java.awt.Color getBackgroundColor(boolean sel)
sel
- If the node is currently selected.public int getClipType()
VPTCellRenderer
protected void changed()
protected java.util.concurrent.locks.ReadWriteLock getLock()
protected void lock(boolean write)
protected void unlock(boolean write)
protected int compareName(VPTNode other)
public int getVersionControlState()
public void setVersionControlState(int state)