/*
 * DocumentStructureTreeNode.java
 *
 * Created on 28 novembre 2005, 16.07
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package it.businesslogic.ireport.gui.documentstructure;

import it.businesslogic.ireport.ElementGroup;
import it.businesslogic.ireport.ReportElement;

/**
 *
 * @author Administrator
 */
public class DocumentStructureTreeNode extends javax.swing.tree.DefaultMutableTreeNode {
    
    /** Creates a new instance of DocumentStructureTreeNode */
    public DocumentStructureTreeNode() {
        super();
    }
    
    public DocumentStructureTreeNode(Object userObject) {
        super(userObject);
    }
    
    public DocumentStructureTreeNode(Object userObject, boolean allowChilds) {
        super(userObject, allowChilds);
    }
    
    public String getNodeId()
    {
        if (this.getUserObject() == null) return "";
        if (this.getUserObject() instanceof ElementGroup)
        {
            return "group-" + ((ElementGroup)(this.getUserObject())).getName();
        }
        if (this.getUserObject() instanceof ReportElement)
        {
            return "element-" + ((ReportElement)(this.getUserObject())).getElementID()+"";
        }
    
        
        return "" + this.getUserObject();
    }
   /*
    public String toString()
    {
        return getNodeId();
    }
    */
    
    public boolean equals(Object obj)
    {
        if (obj instanceof DocumentStructureTreeNode)
        {
             return ((DocumentStructureTreeNode)obj).getNodeId().equalsIgnoreCase( getNodeId() );
        }
        return super.equals( obj );
    }
}
