//----------------------------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;
import org.huihoo.god4j.editor.panels.JavaComboxChoicePanel;
import org.huihoo.god4j.editor.panels.JavaPanel;
import org.huihoo.god4j.editor.panels.JavaRadioChoicePanel;
/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class XPDLComplexChoice extends XPDLChoice
{
	/** Attribute for visual presentation of an object within the panel. */
	private boolean isComboPanel;
	/** Attribute for visual presentation of an object within the panel. */
	private boolean isVertical;
	/** Attribute for visual presentation of an object within the panel. */
	private boolean isChoiceVertical;
	/** Attribute for visual presentation of an object within the panel. */
	private boolean hasBorder;
	/** Attribute for visual presentation of an object within the panel. */
	private boolean hasTitle;
	/**
	* Creates a new instance of element with the specified name,
	* specified choices for the element, and with <b>chooseIndex</b>'th
	* element choosen. All visual attributes are default, and the
	* 'shortcut' to the dialog for defining the new choice does not exist.
	*
	* @param name         The name of the 'choice' XPDL element
	*                     that this class represents.
	* @param choices      The possible choices for this element.
	* @param choosenIndex The index of element to be choosen right after
	*                     creation.
	*/
	public XPDLComplexChoice(XPDLComplexComponent parent,String name,  XPDLComponent[] choices, int choosenIndex)
	{
		this(parent, name, choices, choosenIndex, true);
	}
	/**
	* Creates a new instance of element with the specified name,
	* specified choices for the element, and with <b>chooseIndex</b>'th
	* element choosen, and with specified panel type (combo or radio).
	* All other visual attributes are default, and the 'shortcut'
	* to the dialog for defining the new choice does not exist.
	*
	* @param name         The name of the 'choice' XPDL element
	*                     that this class represents.
	* @param choices      The possible choices for this element.
	* @param choosenIndex The index of element to be choosen right after
	*                     creation.
	* @param isComboPanel Indicates if the choices are displayed within the
	*                     combo panel, or the radio panel.
	*/
	public XPDLComplexChoice(
		XPDLComplexComponent parent,
		String name,
		XPDLComponent[] choices,
		int choosenIndex,
		boolean isComboPanel)
	{
		this(parent,name,  choices, choosenIndex, isComboPanel, true, false, true, true);
	}
	/**
	* Creates a new instance of element with the specified name,
	* specified choices for the element, and with <b>chooseIndex</b>'th
	* element choosen, and with specified all visual attributes. The
	* 'shortcut' to the dialog for defining the new choice might exist.
	*
	* @param name             The name of the 'choice' XPDL element
	*                         that this class represents.
	* @param choices          The possible choices for this element.
	* @param choosenIndex     The index of element to be choosen right after
	*                         creation.
	* @param isComboPanel     Indicates if the choices are displayed within the
	*                         combo panel, or the radio panel.
	* @param isVertical       Indicates if label will stand left to the combo
	*                         panel, or above it.
	* @param isChoiceVertical Indicates if the panel of choosen element will
	*                         be vertical or not.
	* @param hasBorder        Indicates if the panel will have the border
	*                         around it's area.
	* @param hasTitle         Indicates if the panel will have the title
	*                         for it's area.
	*/
	public XPDLComplexChoice(
		XPDLComplexComponent parent,
		String name,
		XPDLComponent[] choices,
		int choosenIndex,
		boolean isComboPanel,
		boolean isVertical,
		boolean isChoiceVertical,
		boolean hasBorder,
		boolean hasTitle)
	{
		super( parent, name,choices, choosenIndex);
		this.isComboPanel = isComboPanel;
		this.isVertical = isVertical;
		this.isChoiceVertical = isChoiceVertical;
		this.hasBorder = hasBorder;
		this.hasTitle = hasTitle;
	}
	/**
	* Indicates if element is empty.
	*
	* @return <tt>true</tt> if user haven't defined the element
	*         value within dialog, <tt>false</tt> otherwise.
	*/
	public boolean isEmpty()
	{
		if (choices == null)
		{
			return true;
		}
		else
		{
			if (choosen != null)
			{
				return false;
			}
			else
			{
				return true;
			}
		}
	}
	public JavaPanel getJavaPanel()
	{
		if (isComboPanel)
		{
			return new JavaComboxChoicePanel(
				this,
				(hasTitle) ? getLabel() : "",
				JavaPanel.BOX_LAYOUT,
				isVertical,
				isChoiceVertical,
				hasBorder);
		}
		else
		{
			return new JavaRadioChoicePanel(
				this,
				(hasTitle) ? getLabel() : "",
				JavaPanel.BOX_LAYOUT,
				isVertical,
				isChoiceVertical,
				hasBorder);
		}
	}
	public Object clone()
	{
		XPDLComplexChoice d = (XPDLComplexChoice) super.clone();
		d.isComboPanel = this.isComboPanel;
		d.isVertical = this.isVertical;
		d.isChoiceVertical = this.isChoiceVertical;
		d.hasBorder = this.hasBorder;
		d.hasTitle = this.hasTitle;
		return d;
	}

	//==================================================================

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

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

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

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

	//==================================================================

}