com.gridsystems.config.app
Class ConfigNode

java.lang.Object
  extended by com.gridsystems.config.app.ConfigNode
All Implemented Interfaces:
java.lang.Comparable

public class ConfigNode
extends java.lang.Object
implements java.lang.Comparable

Tree node implementation for use in Swing JTree models, and in console menu trees.

It provides helper methods for easier Configurator trees construction.

Version:
1.0
Author:
Rodrigo Ruiz Aguayo

Constructor Summary
ConfigNode(java.lang.String label, Configurator cfg)
          Creates a node with the specified label and configurator.
 
Method Summary
 void addConfigurator(Configurator cfg)
          Adds a configurator into its path.
 void addNode(java.lang.String path, Configurator cfg)
          Adds a configurator node in the specified path.
 int compareTo(java.lang.Object o)
          
 ConfigNode getChild(int i)
          Gets the ith child node.
 int getChildCount()
          Gets the number of children nodes.
 Configurator getConfigurator()
          Gets the configurator instance associated to this node.
 javax.swing.Icon getIcon()
          Gets the icon for this configurator.
 java.lang.String getLabel()
          Gets this node label.
 int indexOf(ConfigNode child)
          Gets the index at which the specified node is located.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigNode

public ConfigNode(java.lang.String label,
                  Configurator cfg)
Creates a node with the specified label and configurator.

Parameters:
label - The node label
cfg - The associated configurator instance. It can be null.
Method Detail

getLabel

public java.lang.String getLabel()
Gets this node label.

Returns:
The label

getConfigurator

public Configurator getConfigurator()
Gets the configurator instance associated to this node.

Returns:
The associated configurator, or null if none

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getIcon

public javax.swing.Icon getIcon()
Gets the icon for this configurator. It makes sense only on Swing view mode, so it MUST not be called when in other modes.

Returns:
An icon for this node.

getChildCount

public int getChildCount()
Gets the number of children nodes.

Returns:
The number of children nodes

getChild

public ConfigNode getChild(int i)
Gets the ith child node.

Parameters:
i - The index of the child node to retrieve
Returns:
The child node at position i

indexOf

public int indexOf(ConfigNode child)
Gets the index at which the specified node is located.

Parameters:
child - The child node
Returns:
Its position in the children array

addNode

public void addNode(java.lang.String path,
                    Configurator cfg)
Adds a configurator node in the specified path. It recursively constructs the node path to the configurator instance.

Parameters:
path - The path to the configurator node
cfg - The configurator instance to associate to the leaf node

addConfigurator

public void addConfigurator(Configurator cfg)
Adds a configurator into its path.

Parameters:
cfg - The configurator to add to the tree

compareTo

public int compareTo(java.lang.Object o)

Specified by:
compareTo in interface java.lang.Comparable


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.