//----------------------------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.panels;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;

import org.huihoo.god4j.editor.XPDLComponent;
/**
* Creates a combo panel and a panel which type is determined by the
* choosen element from combo panel.
*/
public class JavaComplexContentPanel extends JavaMultiLineTextPanel
{
	public JavaComplexContentPanel(XPDLComponent myOwner)
	{
		super(myOwner, JavaPanel.BOX_LAYOUT, false, true, false);
		String s = sm.getString("NamespacesKey");
		double w = 0;
		try
		{
			w = getFontMetrics(getFont()).stringWidth(s);
		}
		catch (Exception ex)
		{
		}
		double h = getFontMetrics(getFont()).getHeight();
		w += 25;
		if (w < 30)
			w = 30;
		Dimension dim = new Dimension((int) w, (int) h);
		JavaButton buttonDefine = new JavaButton(s, "Define", dim);
		buttonDefine.setAlignmentX(Component.LEFT_ALIGNMENT);
		buttonDefine.setAlignmentY(Component.TOP_ALIGNMENT);
		buttonDefine.setEnabled(!myOwner.isReadOnly());
		buttonDefine.setToolTipText(sm.getString("DefineAdditionalNamespacesKey"));
		// action listener for defining new element
		buttonDefine.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent ae)
			{
//				if (pkg == null)
//					return;
//				XPDLPanel p = pkg.getPanel(11);
//				XPDLCompDialog d =
//					new XPDLCompDialog(getDialog(), sm.getString("PackageKey") + " '" + pkg.toString() + "' - " + sm.getString("NamespacesKey"));
//				d.editXPDLComp(p, false, false);
			}
		});
		add(Box.createRigidArea(new Dimension(10, 0)));
		add(buttonDefine);
	}
	
	public void applyChanges()
	{
	}
}
