Die Klasse ProductGroupDsp:
public class ProductGroupDsp extends ProductBaseDsp implements TreeGroupDataModel {
/**
* ParentNode
*/
private TreeGroupDataModel parent = null;
/**
* ChildNodes
*/
private Vector children = new Vector();
// ------------------------------------------------
// Methods
// ------------------------------------------------
/**
* Constructor
* @param key Unique Key for the Group
* @param name Name of the Group
* @param unknownChildren true if the Childs should be loaded later
* false if the Childnodes exists
*/
public ProductGroupDsp(String key, String name) {
super();
this.key = key;
this.name = name;
this.type = "prodgroup";
}
/**
* Constructor
* @param key Unique Key for the Group
* @param name Name of the Group
* @param description description for the Group
* @param unknownChildren true if the Childs should be loaded later
* false if the Childnodes exists
*/
public ProductGroupDsp(String key, String name, String description) {
super();
this.key = key;
this.name = name;
this.description = description;
this.type = "prodgroup";
}
/**
* @see TreeGroupDataModel#getChild(int)
*/
public TreeNodeDataModel getChild(int index) {
return (TreeNodeDataModel) children.elementAt(index);
}
/**
* @see TreeGroupDataModel#addChild(TreeNodeDataModel)
*/
public void addChild(TreeNodeDataModel child) {
children.add(child);
child.setParent(this);
}
/**
* Returns the Number of ChildNodes
* -1 = The Number of ChildNodes is unknown.
* When the Node opens an onExpandEx Event is generated
* and the Childs can be loaded at runtime
* 0 = This Node has no ChildNodes
* >0 = This Node has ChildNodes
*
* @see TreeGroupDataModel#size()
*/
public int size() {
return children.size();
}
/**
* @see TreeNodeDataModel#getParent()
*/
public TreeGroupDataModel getParent() {
return parent;
}
/**
* @see TreeNodeDataModel#setParent(TreeGroupDataModel)
*/
public void setParent(TreeGroupDataModel parent) {
this.parent = parent;
}
/**
* @see TreeNodeDataModel#getParentKey()
*/
public String getParentKey() {
return parent.getUniqueKey();
}
/**
* @see TreeNodeDataModel#getUniqueKey()
*/
public String getUniqueKey() {
return this.key;
}
}