//----------------------------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.XPDLAttribute;
import org.huihoo.god4j.editor.XPDLComplexComponent;
import org.huihoo.workflow.WorkflowComponent;

/**
* Represents a WfMC DTD element that has the similar name.
*
* @see XPDL
*/
public class XPDLExternalReference extends XPDLComplexComponent
{
	private XPDLAttribute attrXref = null; // optional
	private XPDLAttribute attrLocation = null; // required
	private XPDLAttribute attrNamespace = null; // optional

	/**
	* Creates a new instance of the class.
	*/
	public XPDLExternalReference(XPDLComplexComponent parent)
	{
		super(parent,"ExternalReference");
	}

//==================================================================
	public void initComponent()
	{
//	-----------------------------------------------
		super.initComponent();
//	-----------------------------------------------
		attrXref = new XPDLAttribute(this,"xref"); // optional
		attrXref.initComponent();
		
		attrLocation = new XPDLAttribute(this, "location",XPDLAttribute.PANEL_LOCATION); // required
		attrLocation.initComponent();
		attrLocation.setRequired(true);
		
		attrNamespace = new XPDLAttribute(this,"namespace", XPDLAttribute.PANEL_LOCATION); // optional
		attrNamespace.initComponent();

	}
	public void structComponent()
	{
		//	-----------------------------------------------
		super.structComponent();
		//	-----------------------------------------------
		//-------------------------------------------------
		attrXref.structComponent();
		attrLocation.structComponent();
		attrNamespace.structComponent();
			
		complexChildren.add(attrXref);
		complexChildren.add(attrLocation);
		complexChildren.add(attrNamespace);
		
		attributes.add(attrXref);
		attributes.add(attrLocation);
		attributes.add(attrNamespace);
	}

	public void loadComponent() 
	{
//	-----------------------------------------------
		super.loadComponent();
//	-----------------------------------------------
		attrXref.loadComponent();
		attrLocation.loadComponent();
		attrNamespace.loadComponent();
	}


	public void saveComponent() 
	{
    if(isReadOnly())
    {
      return;
    }	
    
//	-----------------------------------------------
		super.saveComponent();
//	-----------------------------------------------
		attrXref.saveComponent();
		attrLocation.saveComponent();
		attrNamespace.saveComponent();
	}
	
	public void saveComponent(WorkflowComponent workflow_component)
	{
//	-----------------------------------------------
		super.saveComponent(workflow_component);
//	-----------------------------------------------

		attrXref.saveComponent(workflow_component);
		attrLocation.saveComponent(workflow_component);
		attrNamespace.saveComponent(workflow_component);	
	}
	
//==================================================================
}
