//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/god4j
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : god4j@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.god4j.tree;
import javax.swing.tree.DefaultMutableTreeNode;

import org.huihoo.god4j.GOD4JConstants;
import org.huihoo.god4j.util.StringManager;
import org.huihoo.workflow.WorkflowComplexComponent;
/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public  class DefaultExplorerNode extends DefaultMutableTreeNode implements ExplorerNode
{
	protected static StringManager sm = StringManager.getManager(GOD4JConstants.PACKAGE);
	
	protected int nodeType;
	protected String name;
	
	public DefaultExplorerNode(String name,int nodeType)
	{
		this(name,nodeType,null);
	}
	
	public DefaultExplorerNode(int nodeType,WorkflowComplexComponent userObject)
	{
		this(null,nodeType,userObject);
	}
	
	public DefaultExplorerNode(String name,int nodeType,WorkflowComplexComponent userObject)
	{
		this.setUserObject(userObject);
		this.setName(name);
		this.setNodeType(nodeType);
	}
	

	public void setNodeType(int nodeType)
	{
		this.nodeType=nodeType;
	}
	
	public int getNodeType()
	{
		return this.nodeType;
	}
	
	public void setName(String name)
	{
		this.name=name;
	}
	
	public String getName()
	{
		if(getWorkflowComponent() != null)
		{
			return getWorkflowComponent().getName();
		}

		return this.name;
	}
	
	public WorkflowComplexComponent getWorkflowComponent()
	{
		return (WorkflowComplexComponent)getUserObject();
	}
	
	public void                     setWorkflowComponent(WorkflowComplexComponent comp)
	{
		setUserObject(comp);
	}
	
	public String toString()
	{
		return getName();
	}
}
