com.threerings.config.swing
Class ConfigTreeNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by com.threerings.config.swing.ConfigTreeNode
All Implemented Interfaces:
Exportable, Serializable, Cloneable, MutableTreeNode, TreeNode

public class ConfigTreeNode
extends DefaultMutableTreeNode
implements Exportable

A node in the config tree.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
EMPTY_ENUMERATION
 
Constructor Summary
ConfigTreeNode()
          No-arg constructor for deserialization.
ConfigTreeNode(String partialName, ManagedConfig config)
          Creates a new node with the specified partial name.
 
Method Summary
 void addConfigs(ConfigGroup<ManagedConfig> group)
          Adds all configurations under this node to the supplied group.
 ConfigTreeNode clone()
           
 int decrementCount()
          Decrements the count for this node.
 void expandPaths(JTree tree)
          Expands paths according to the _expanded field.
 void expandPaths(JTree tree, int depth)
          Expands all paths up to the specified depth.
 String findNameForChild(String base)
          Finds an unused name for a child of this node from the specified base.
 ManagedConfig getConfig()
          Returns the configuration contained in this node, or null for none.
 void getConfigs(List<ManagedConfig> configs)
          Puts all of the configurations under this node into the supplied list.
 void getConfigs(List<ManagedConfig> configs, boolean immediate)
          Puts all of the configurations under this node into the supplied list.
 int getInsertionIndex(ConfigTreeNode child)
          Returns the index at which the specified node should be inserted to maintain the sort order.
 Tuple<ConfigTreeNode,ConfigTreeNode> getInsertionPoint(ManagedConfig config, String name)
          Finds the insertion point (existing parent and new child) for the specified configuration.
 String getName()
          Returns the full name of this node.
 ConfigTreeNode getNode(String name)
          Finds and returns the node with the specified name (or null if it can't be found).
 void incrementCount()
          Increments the count for this node.
 void insert(MutableTreeNode child, int index)
           
 void insertConfig(ManagedConfig config, String name)
          Inserts the given configuration under this node, creating any required intermediate nodes.
 void readFields(Importer in)
          Reads the exportable fields of the object.
 void remove(int index)
           
 void removeConfigs(ConfigGroup<ManagedConfig> group)
          Removes all configurations under this node from the supplied group.
 void setExpanded(boolean expanded)
          Sets whether or not this node is expanded in the tree.
 boolean verifyConfigClass(Class<?> clazz)
          Verifies that if this node contains any actual configurations, they're instances of the supplied class.
 void writeFields(Exporter out)
          Writes the exportable fields of the object.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigTreeNode

public ConfigTreeNode(String partialName,
                      ManagedConfig config)
Creates a new node with the specified partial name.

Parameters:
config - the configuration for this node, or null if this is a folder node.

ConfigTreeNode

public ConfigTreeNode()
No-arg constructor for deserialization.

Method Detail

getName

public String getName()
Returns the full name of this node.


getConfig

public ManagedConfig getConfig()
Returns the configuration contained in this node, or null for none.


incrementCount

public void incrementCount()
Increments the count for this node.


decrementCount

public int decrementCount()
Decrements the count for this node.


setExpanded

public void setExpanded(boolean expanded)
Sets whether or not this node is expanded in the tree.


getInsertionPoint

public Tuple<ConfigTreeNode,ConfigTreeNode> getInsertionPoint(ManagedConfig config,
                                                              String name)
Finds the insertion point (existing parent and new child) for the specified configuration. The new child will contain the necessary intermediate nodes.


insertConfig

public void insertConfig(ManagedConfig config,
                         String name)
Inserts the given configuration under this node, creating any required intermediate nodes.


addConfigs

public void addConfigs(ConfigGroup<ManagedConfig> group)
Adds all configurations under this node to the supplied group.


removeConfigs

public void removeConfigs(ConfigGroup<ManagedConfig> group)
Removes all configurations under this node from the supplied group.


getConfigs

public void getConfigs(List<ManagedConfig> configs)
Puts all of the configurations under this node into the supplied list.


getConfigs

public void getConfigs(List<ManagedConfig> configs,
                       boolean immediate)
Puts all of the configurations under this node into the supplied list.


getNode

public ConfigTreeNode getNode(String name)
Finds and returns the node with the specified name (or null if it can't be found).


verifyConfigClass

public boolean verifyConfigClass(Class<?> clazz)
Verifies that if this node contains any actual configurations, they're instances of the supplied class.


findNameForChild

public String findNameForChild(String base)
Finds an unused name for a child of this node from the specified base.


getInsertionIndex

public int getInsertionIndex(ConfigTreeNode child)
Returns the index at which the specified node should be inserted to maintain the sort order.


expandPaths

public void expandPaths(JTree tree)
Expands paths according to the _expanded field.


expandPaths

public void expandPaths(JTree tree,
                        int depth)
Expands all paths up to the specified depth.


writeFields

public void writeFields(Exporter out)
                 throws IOException
Writes the exportable fields of the object.

Throws:
IOException

readFields

public void readFields(Importer in)
                throws IOException
Reads the exportable fields of the object.

Throws:
IOException

insert

public void insert(MutableTreeNode child,
                   int index)
Specified by:
insert in interface MutableTreeNode
Overrides:
insert in class DefaultMutableTreeNode

remove

public void remove(int index)
Specified by:
remove in interface MutableTreeNode
Overrides:
remove in class DefaultMutableTreeNode

clone

public ConfigTreeNode clone()
Overrides:
clone in class DefaultMutableTreeNode


Copyright © 2011. All Rights Reserved.