//----------------------------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.editor.elements;
import org.huihoo.god4j.editor.XPDLComplexChoice;
import org.huihoo.god4j.editor.XPDLComplexComponent;
import org.huihoo.god4j.editor.XPDLComponent;
import org.huihoo.god4j.editor.elements.set.XPDLTools;
import org.huihoo.god4j.editor.panels.JavaPanel;
import org.huihoo.workflow.WorkflowComponent;
/**
* Represents a WfMC DTD element that has the similar name.
*
* @see XPDL
*/
public class XPDLImplementation extends XPDLComplexComponent
{
	// we use tools instead of tool
	private XPDLComplexChoice refType;
	/**
	* Creates a new instance of the class.
	*
	* @param act The activity that holds this object.
	*/
	public XPDLImplementation(XPDLComplexComponent parent)
	{
		super(parent,"Implementation");
	}

	/**
	* Prepares the panel with a combo box to choose the one of
	* types of implementation.
	*
	* @return XPDLPanel to be shown.
	*/
	public JavaPanel getJavaPanel()
	{
		return refType.getJavaPanel();
	}
	/**
	* Used to create exact copy of instance of this class.
	* The newly created instance will have all the properties
	* same as the copied one.
	*
	* @return The newly created instance of this class.
	*/
	public Object clone()
	{
		XPDLImplementation a = (XPDLImplementation) super.clone();
		a.refType = (XPDLComplexChoice) this.refType.clone();
		a.structComponent();
		
		return a;
	}
//==================================================================
	public void initComponent()
	{
//	-----------------------------------------------
		super.initComponent();
//	-----------------------------------------------	
		refType = new XPDLComplexChoice(this,"Type", new XPDLComponent[] { new XPDLNoImplementation(this), new XPDLTools(this), new XPDLSubFlow(this)}, 1, true);
		refType.initComponent();
		refType.setRequired(true);
	}

	public void structComponent()
	{
		//	-----------------------------------------------
		super.structComponent();
		//	-----------------------------------------------
		refType.structComponent();
		
		complexChildren.add(refType);
	}
	

	public void loadComponent() 
	{
//	-----------------------------------------------
		super.loadComponent();
//	-----------------------------------------------
		refType.loadComponent();
	}


	public void saveComponent() 
	{
    if(isReadOnly())
    {
      return;
    }
//	-----------------------------------------------
		super.saveComponent();
//	-----------------------------------------------
		refType.saveComponent();
	}
	
	public void saveComponent(WorkflowComponent workflow_component) 
	{
//	-----------------------------------------------
		super.saveComponent(workflow_component);
//	-----------------------------------------------
		refType.saveComponent();
	}
//==================================================================
}
