/**
 *
 */
package de.rico.editor.gui.dialog;

import java.awt.Font;
import java.awt.Frame;
import java.awt.Rectangle;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import de.rico.editor.WorldEditor;

/**
 * A dialog to save a room file.
 * @author Frank Bruns
 *
 */
public class DialogSetRoomScriptId extends JDialog
{

	private static final long serialVersionUID = 1L;

	private DialogSetRoomScriptId self = null;

	private JPanel jContentPane = null;

	private JLabel labelHead = null;

	private JTextField txtScriptId = null;

	private JButton btnConfirm = null;

	/**
	 * @param owner
	 */
	public DialogSetRoomScriptId(Frame owner)
	{
		super(owner);
		this.initialize();
		this.self = this;
	}

	/**
	 * This method initializes this
	 *
	 * @return void
	 */
	private void initialize()
	{
		this.setSize(268, 153);
		this.setTitle("Save the room");
		this.setContentPane(this.getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane()
	{
		if (this.jContentPane == null)
		{
			this.labelHead = new JLabel();
			this.labelHead.setText("Specify the room's script id");
			this.labelHead.setBounds(new Rectangle(15, 15, 211, 19));
			this.labelHead.setFont(new Font("Dialog", Font.BOLD, 14));
			this.jContentPane = new JPanel();
			this.jContentPane.setLayout(null);
			this.jContentPane.add(this.labelHead, null);
			this.jContentPane.add(this.getTxtScriptId(), null);
			this.jContentPane.add(this.getBtnConfirm(), null);
		}
		return this.jContentPane;
	}

	/**
	 * This method initializes txtScriptId
	 *
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtScriptId()
	{
		if (this.txtScriptId == null)
		{
			this.txtScriptId = new JTextField();
			this.txtScriptId.setBounds(new Rectangle(15, 45, 211, 16));
			if(WorldEditor.room.getScriptId() != null)
				this.txtScriptId.setText(WorldEditor.room.getScriptId());
		}
		return this.txtScriptId;
	}

	/**
	 * This method initializes btnConfirm
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getBtnConfirm()
	{
		if (this.btnConfirm == null)
		{
			this.btnConfirm = new JButton();
			this.btnConfirm.setBounds(new Rectangle(135, 75, 91, 22));
			this.btnConfirm.setText("Confirm");
			this.btnConfirm.addActionListener(new java.awt.event.ActionListener()
			{
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					WorldEditor.room.setScriptId(DialogSetRoomScriptId.this.txtScriptId.getText());
					DialogSetRoomScriptId.this.dispose();
				}
			});
		}
		return this.btnConfirm;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
