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

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

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

import de.rico.editor.WorldEditor;
import de.rico.editor.datamodel.SkyBoxData;
import de.rico.editor.gui.filter.FilterImage;

/**
 * A dialog to add a skybox.
 * @author Frank Bruns
 *
 */
public class DialogAddSkybox extends JDialog
{

	private static final long serialVersionUID = 1L;

	private DialogAddSkybox self = null;

	private JPanel jContentPane = null;

	private JLabel jLabel = null;

	private JLabel labelPosX = null;

	private JLabel labelNegX = null;

	private JLabel labelPosY = null;

	private JLabel labelNegY = null;

	private JLabel labelPosZ = null;

	private JLabel labelNegZ = null;

	private JTextField txtPosX = null;

	private JTextField txtNegX = null;

	private JTextField txtPosY = null;

	private JTextField txtNegY = null;

	private JTextField txtPosZ = null;

	private JTextField txtNegZ = null;

	private JButton btnAddSkybox = null;

	private JButton btnTexPosX = null;

	private JButton btnTexNegX = null;

	private JButton btnTexPosY = null;

	private JButton btnTexNegY = null;

	private JButton btnTexPosZ = null;

	private JButton btnTexNegZ = null;

	/**
	 * @param owner
	 */
	public DialogAddSkybox(Frame owner)
	{
		super(owner, true);
		this.initialize();

		this.self = this;
	}

	/**
	 * This method initializes this
	 *
	 * @return void
	 */
	private void initialize()
	{
		this.setSize(373, 263);
		this.setTitle("Add a skybox to the scene");
		this.setContentPane(this.getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane()
	{
		if (this.jContentPane == null)
		{
			this.labelNegZ = new JLabel();
			this.labelNegZ.setBounds(new Rectangle(15, 165, 91, 14));
			this.labelNegZ.setText("Texture neg z:");
			this.labelPosZ = new JLabel();
			this.labelPosZ.setBounds(new Rectangle(15, 150, 91, 14));
			this.labelPosZ.setText("Texture pos z:");
			this.labelNegY = new JLabel();
			this.labelNegY.setBounds(new Rectangle(15, 120, 91, 14));
			this.labelNegY.setText("Texture neg y:");
			this.labelPosY = new JLabel();
			this.labelPosY.setBounds(new Rectangle(15, 105, 91, 14));
			this.labelPosY.setText("Texture pos y:");
			this.labelNegX = new JLabel();
			this.labelNegX.setBounds(new Rectangle(15, 75, 91, 14));
			this.labelNegX.setText("Texture neg x:");
			this.labelPosX = new JLabel();
			this.labelPosX.setBounds(new Rectangle(15, 60, 91, 14));
			this.labelPosX.setText("Texture pos x:");
			this.jLabel = new JLabel();
			this.jLabel.setText("Add a skybox to the scene");
			this.jLabel.setFont(new Font("Tahoma", Font.PLAIN, 18));
			this.jLabel.setBounds(new Rectangle(63, 8, 241, 35));
			this.jContentPane = new JPanel();
			this.jContentPane.setLayout(null);
			this.jContentPane.add(this.jLabel, null);
			this.jContentPane.add(this.labelPosX, null);
			this.jContentPane.add(this.labelNegX, null);
			this.jContentPane.add(this.labelPosY, null);
			this.jContentPane.add(this.labelNegY, null);
			this.jContentPane.add(this.labelPosZ, null);
			this.jContentPane.add(this.labelNegZ, null);
			this.jContentPane.add(this.getTxtPosX(), null);
			this.jContentPane.add(this.getTxtNegX(), null);
			this.jContentPane.add(this.getTxtPosY(), null);
			this.jContentPane.add(this.getTxtNegY(), null);
			this.jContentPane.add(this.getTxtPosZ(), null);
			this.jContentPane.add(this.getTxtNegZ(), null);
			this.jContentPane.add(this.getBtnAddSkybox(), null);
			this.jContentPane.add(this.getBtnTexPosX(), null);
			this.jContentPane.add(this.getBtnTexNegX(), null);
			this.jContentPane.add(this.getBtnTexPosY(), null);
			this.jContentPane.add(this.getBtnTexNegY(), null);
			this.jContentPane.add(this.getBtnTexPosZ(), null);
			this.jContentPane.add(this.getBtnTexNegZ(), null);
		}
		return this.jContentPane;
	}

	/**
	 * This method initializes txtPosX
	 *
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtPosX()
	{
		if (this.txtPosX == null)
		{
			this.txtPosX = new JTextField();
			this.txtPosX.setBounds(new Rectangle(105, 60, 151, 16));
		}
		return this.txtPosX;
	}

	/**
	 * This method initializes txtNegX
	 *
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtNegX()
	{
		if (this.txtNegX == null)
		{
			this.txtNegX = new JTextField();
			this.txtNegX.setBounds(new Rectangle(105, 75, 151, 16));
		}
		return this.txtNegX;
	}

	/**
	 * This method initializes txtPosY
	 *
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtPosY()
	{
		if (this.txtPosY == null)
		{
			this.txtPosY = new JTextField();
			this.txtPosY.setBounds(new Rectangle(105, 105, 151, 16));
		}
		return this.txtPosY;
	}

	/**
	 * This method initializes txtNegY
	 *
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtNegY()
	{
		if (this.txtNegY == null)
		{
			this.txtNegY = new JTextField();
			this.txtNegY.setBounds(new Rectangle(105, 120, 151, 16));
		}
		return this.txtNegY;
	}

	/**
	 * This method initializes txtPosZ
	 *
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtPosZ()
	{
		if (this.txtPosZ == null)
		{
			this.txtPosZ = new JTextField();
			this.txtPosZ.setBounds(new Rectangle(105, 150, 151, 16));
		}
		return this.txtPosZ;
	}

	/**
	 * This method initializes txtNegZ
	 *
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtNegZ()
	{
		if (this.txtNegZ == null)
		{
			this.txtNegZ = new JTextField();
			this.txtNegZ.setBounds(new Rectangle(105, 165, 151, 16));
		}
		return this.txtNegZ;
	}

	/**
	 * This method initializes btnAddSkybox
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getBtnAddSkybox()
	{
		if (this.btnAddSkybox == null)
		{
			this.btnAddSkybox = new JButton();
			this.btnAddSkybox.setBounds(new Rectangle(195, 195, 106, 23));
			this.btnAddSkybox.setText("Add Skybox");
			this.btnAddSkybox.addActionListener(new java.awt.event.ActionListener()
			{
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					String posX = DialogAddSkybox.this.txtPosX.getText();
					String posY = DialogAddSkybox.this.txtPosY.getText();
					String posZ = DialogAddSkybox.this.txtPosZ.getText();
					String negX = DialogAddSkybox.this.txtNegX.getText();
					String negY = DialogAddSkybox.this.txtNegY.getText();
					String negZ = DialogAddSkybox.this.txtNegZ.getText();
					SkyBoxData sky = new SkyBoxData(posX,negX,posY,negY,posZ,negZ);
					WorldEditor.markSkyBoxForAdding(sky);
					DialogAddSkybox.this.dispose();
				}
			});
		}
		return this.btnAddSkybox;
	}

	/**
	 * This method initializes btnTexPosX
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getBtnTexPosX()
	{
		if (this.btnTexPosX == null)
		{
			this.btnTexPosX = new JButton();
			this.btnTexPosX.setBounds(new Rectangle(270, 60, 31, 16));
			this.btnTexPosX.setText("...");
			this.btnTexPosX.addActionListener(new java.awt.event.ActionListener()
			{
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					JFileChooser fc = new JFileChooser();
					fc.setCurrentDirectory(new File("./"));
					fc.setAcceptAllFileFilterUsed(false);
					fc.setFileFilter(new FilterImage());

					int returnVal = fc.showOpenDialog(DialogAddSkybox.this.self);

					if (returnVal == JFileChooser.APPROVE_OPTION)
					{
						File file = fc.getSelectedFile();
						DialogAddSkybox.this.txtPosX.setText(file.getAbsolutePath());
					}
				}
			});
		}
		return this.btnTexPosX;
	}

	/**
	 * This method initializes btnTexNegX
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getBtnTexNegX()
	{
		if (this.btnTexNegX == null)
		{
			this.btnTexNegX = new JButton();
			this.btnTexNegX.setBounds(new Rectangle(270, 75, 31, 16));
			this.btnTexNegX.setText("...");
			this.btnTexNegX.addActionListener(new java.awt.event.ActionListener()
			{
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					JFileChooser fc = new JFileChooser();
					fc.setCurrentDirectory(new File("./"));
					fc.setAcceptAllFileFilterUsed(false);
					fc.setFileFilter(new FilterImage());

					int returnVal = fc.showOpenDialog(DialogAddSkybox.this.self);

					if (returnVal == JFileChooser.APPROVE_OPTION)
					{
						File file = fc.getSelectedFile();
						DialogAddSkybox.this.txtNegX.setText(file.getAbsolutePath());
					}
				}
			});
		}
		return this.btnTexNegX;
	}

	/**
	 * This method initializes btnTexPosY
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getBtnTexPosY()
	{
		if (this.btnTexPosY == null)
		{
			this.btnTexPosY = new JButton();
			this.btnTexPosY.setBounds(new Rectangle(270, 105, 31, 16));
			this.btnTexPosY.setText("...");
			this.btnTexPosY.addActionListener(new java.awt.event.ActionListener()
			{
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					JFileChooser fc = new JFileChooser();
					fc.setCurrentDirectory(new File("./"));
					fc.setAcceptAllFileFilterUsed(false);
					fc.setFileFilter(new FilterImage());

					int returnVal = fc.showOpenDialog(DialogAddSkybox.this.self);

					if (returnVal == JFileChooser.APPROVE_OPTION)
					{
						File file = fc.getSelectedFile();
						DialogAddSkybox.this.txtPosY.setText(file.getAbsolutePath());
					}
				}
			});
		}
		return this.btnTexPosY;
	}

	/**
	 * This method initializes btnTexNegY
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getBtnTexNegY()
	{
		if (this.btnTexNegY == null)
		{
			this.btnTexNegY = new JButton();
			this.btnTexNegY.setBounds(new Rectangle(270, 120, 31, 16));
			this.btnTexNegY.setText("...");
			this.btnTexNegY.addActionListener(new java.awt.event.ActionListener()
			{
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					JFileChooser fc = new JFileChooser();
					fc.setCurrentDirectory(new File("./"));
					fc.setAcceptAllFileFilterUsed(false);
					fc.setFileFilter(new FilterImage());

					int returnVal = fc.showOpenDialog(DialogAddSkybox.this.self);

					if (returnVal == JFileChooser.APPROVE_OPTION)
					{
						File file = fc.getSelectedFile();
						DialogAddSkybox.this.txtNegY.setText(file.getAbsolutePath());
					}
				}
			});
		}
		return this.btnTexNegY;
	}

	/**
	 * This method initializes btnTexPosZ
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getBtnTexPosZ()
	{
		if (this.btnTexPosZ == null)
		{
			this.btnTexPosZ = new JButton();
			this.btnTexPosZ.setBounds(new Rectangle(270, 150, 31, 16));
			this.btnTexPosZ.setText("...");
			this.btnTexPosZ.addActionListener(new java.awt.event.ActionListener()
			{
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					JFileChooser fc = new JFileChooser();
					fc.setCurrentDirectory(new File("./"));
					fc.setAcceptAllFileFilterUsed(false);
					fc.setFileFilter(new FilterImage());

					int returnVal = fc.showOpenDialog(DialogAddSkybox.this.self);

					if (returnVal == JFileChooser.APPROVE_OPTION)
					{
						File file = fc.getSelectedFile();
						DialogAddSkybox.this.txtPosZ.setText(file.getAbsolutePath());
					}
				}
			});
		}
		return this.btnTexPosZ;
	}

	/**
	 * This method initializes btnTexNegZ
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getBtnTexNegZ()
	{
		if (this.btnTexNegZ == null)
		{
			this.btnTexNegZ = new JButton();
			this.btnTexNegZ.setBounds(new Rectangle(270, 165, 31, 16));
			this.btnTexNegZ.setText("...");
			this.btnTexNegZ.addActionListener(new java.awt.event.ActionListener()
			{
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					JFileChooser fc = new JFileChooser();
					fc.setCurrentDirectory(new File("./"));
					fc.setAcceptAllFileFilterUsed(false);
					fc.setFileFilter(new FilterImage());

					int returnVal = fc.showOpenDialog(DialogAddSkybox.this.self);

					if (returnVal == JFileChooser.APPROVE_OPTION)
					{
						File file = fc.getSelectedFile();
						DialogAddSkybox.this.txtNegZ.setText(file.getAbsolutePath());
					}
				}
			});
		}
		return this.btnTexNegZ;
	}

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