//----------------------------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.XPDLComplexComponent;
import org.huihoo.god4j.editor.elements.atoms.XPDLCreated;
import org.huihoo.god4j.editor.elements.atoms.XPDLDescription;
import org.huihoo.god4j.editor.elements.atoms.XPDLVendor;
import org.huihoo.god4j.editor.elements.atoms.XPDLVersion;
/**
* Represents a WfMC DTD element that has the similar name.
*
* @see XPDL
*/
public class XPDLPackageHeader extends XPDLComplexComponent
{
	private XPDLVersion refXPDLVersion = null;
	private XPDLVendor refVendor = null;
	private XPDLCreated refCreated = null;
	private XPDLDescription refDescription = null; 
	/**
	* Creates a new instance of the class.
	*/
	public XPDLPackageHeader(XPDLComplexComponent parent)
	{
		super(parent,"PackageHeader");		
	}


	public void initComponent()
	{
//	-----------------------------------------------
		super.initComponent();
//	-----------------------------------------------

		refXPDLVersion = new XPDLVersion(this);
		refXPDLVersion.initComponent();
		refXPDLVersion.setValue("1.0");		
		refXPDLVersion.setRequired(true);
		refXPDLVersion.setReadOnly(true);
						
		refVendor = new XPDLVendor(this);
		refVendor.initComponent();
		refVendor.setValue("Huihoo.org");		
		refVendor.setRequired(true);	
		
		refCreated = new XPDLCreated(this);
		refCreated.initComponent();
		//refCreated.setRequired(true);
		
		refDescription = new XPDLDescription(this); // min=0
		refDescription.initComponent();
	}
	
	public void structComponent()
	{
		//	-----------------------------------------------
		super.structComponent();
		//	-----------------------------------------------
		refXPDLVersion.structComponent();
		refVendor.structComponent();
		refCreated.structComponent();
		refDescription.structComponent();
		
		
		complexChildren.add(refXPDLVersion);
		complexChildren.add(refVendor);
		complexChildren.add(refCreated);
		complexChildren.add(refDescription);
	}

	public void loadComponent()
	{
//	-----------------------------------------------
		super.loadComponent();
//	-----------------------------------------------
		refXPDLVersion.loadComponent(); 
		refVendor.loadComponent(); 
		refCreated.loadComponent(); 
		refDescription.loadComponent(); 
	}

	public void saveComponent()
	{
    if(isReadOnly())
    {
      return;
    }
    
//	-----------------------------------------------
		super.saveComponent();
//	-----------------------------------------------

		refXPDLVersion.saveComponent(); 
		refVendor.saveComponent(); 
		refCreated.saveComponent(); 
		refDescription.saveComponent(); 
	}
}
