|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.tree.DefaultMutableTreeNode
projectviewer.vpt.VPTNode
Node implementation for the Virtual Project Tree. Keeps track of children and provides basic functionality for the nodes.
Based on the TreeNode
class from the VirtualProjectTree
plugin by Shad Stafford.
Field Summary | |
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
|
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode |
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject |
Constructor Summary | |
protected |
VPTNode(java.lang.String name)
Deprecated. Use VPTNode(String,boolean) |
protected |
VPTNode(java.lang.String name,
boolean allowsChildren)
|
Method Summary | |
boolean |
canOpen()
This method should return whether it makes sense to "open" the node. |
boolean |
canWrite()
Returns whether the underlying resource can be written to. |
void |
close()
"Closes" the node. |
protected int |
compareName(VPTNode other)
|
int |
compareTo(java.lang.Object o)
Implementation of the Comparable interface. |
int |
compareToNode(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. |
abstract javax.swing.Icon |
getIcon(boolean expanded)
Returns the icon to be shown on the tree next to the node name. |
java.lang.String |
getName()
Returns the name of this node. |
abstract java.lang.String |
getNodePath()
Returns a String representing a "path" for this node. |
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. |
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 |
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 |
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. |
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode |
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, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setUserObject |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
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
Constructor Detail |
protected VPTNode(java.lang.String name)
VPTNode(String,boolean)
protected VPTNode(java.lang.String name, boolean allowsChildren)
Method Detail |
public static VPTProject findProjectFor(VPTNode node)
public void sortChildren()
public void sortChildren(boolean recurse)
public boolean delete()
public final boolean isFile()
public final boolean isDirectory()
public final boolean isProject()
public boolean isGroup()
public final boolean isRoot()
public boolean isOpened()
public java.lang.String getName()
public void setName(java.lang.String name)
public boolean canWrite()
public java.lang.String toString()
public boolean canOpen()
open()
and close()
to execute
the opening and closing operations.
public void open()
public void close()
open()
, normally.
public abstract java.lang.String getNodePath()
public int compareToNode(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.
public int compareTo(java.lang.Object o)
compareToNode(VPTNode)
.
compareTo
in interface java.lang.Comparable
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
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 int compareName(VPTNode other)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |