/*
 Tiamat - a role-playing game framework
 QuicklaunchFrame.java - main frame for Quicklaunch utility
 
 Copyright  (C) 2004-2005 Hugues Johnson
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 the GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

package com.huguesjohnson.tiamat.tools;

import com.huguesjohnson.LaunchBrowser;
import com.huguesjohnson.tiamat.tools.AreaEditor;
import com.huguesjohnson.tiamat.tools.CharacterEditor;
import com.huguesjohnson.tiamat.tools.SpriteEditor;
import com.huguesjohnson.tiamat.tools.ThemeEditor;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import javax.swing.JFrame;

/**
 * QuicklaunchFrame - main frame for Quicklaunch utility protected regions of
 * code were generated by NetBeans 3.6 form editor
 * 
 * @author Hugues Johnson
 */
public class QuicklaunchFrame extends JFrame{
	/**
	 * Determines if a de-serialized file is compatible with this class. See <a
	 * href="http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/class.html">Java
	 * Object Serialization Specifications</a>.
	 */
	private static final long serialVersionUID=163750530658159076L;

	private final String defaultMessage="<html>"+"<b>Tiamat Role-Playing Game Framework</b>"+"<br>"+"Please select an editor to run"+"</html>";

	private final String homepageLink="http://www.huguesjohnson.com/tiamat.html";

	/**
	 * Creates a new QuicklaunchFrame.
	 */
	public QuicklaunchFrame(){
		this.initComponents();
		this.labelHelp.setText(this.defaultMessage);
		this.labelLink.setText("<html><a href=\""+this.homepageLink+"\">"+this.labelLink.getText()+"</a><html>");
		// re-pack since labels have changed size
		this.pack();
		this.labelHelp.requestFocus();
		this.centerWindow();
	}

	/**
	 * Centers the window in the middle of the screen.
	 */
	private void centerWindow(){
		Dimension screenDimension=Toolkit.getDefaultToolkit().getScreenSize();
		Rectangle windowDimension=this.getBounds();
		this.setLocation((screenDimension.width-windowDimension.width)/2,(screenDimension.height-windowDimension.height)/2);
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	private void initComponents(){// GEN-BEGIN:initComponents
		this.toolBar=new javax.swing.JToolBar();
		this.buttonSpriteEditor=new javax.swing.JButton();
		this.buttonCharacterEditor=new javax.swing.JButton();
		this.buttonAreaEditor=new javax.swing.JButton();
		this.buttonThemeEditor=new javax.swing.JButton();
		this.labelHelp=new javax.swing.JLabel();
		this.labelLink=new javax.swing.JLabel();

		this.getContentPane().setLayout(new javax.swing.BoxLayout(this.getContentPane(),javax.swing.BoxLayout.Y_AXIS));

		this.setTitle("Tiamat Quicklaunch");
		this.setIconImage((new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/icon.gif"))).getImage());
		this.setResizable(false);
		this.addWindowListener(new java.awt.event.WindowAdapter(){
			public void windowClosing(java.awt.event.WindowEvent evt){
				exitForm(evt);
			}
		});

		this.toolBar.setBorder(new javax.swing.border.EtchedBorder());
		this.toolBar.setFloatable(false);
		this.toolBar.setOrientation(1);
		this.toolBar.setRollover(true);
		this.buttonSpriteEditor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_spriteeditor_bw.gif")));
		this.buttonSpriteEditor.setText("Sprite Editor");
		this.buttonSpriteEditor.setToolTipText("Launch the Sprite Editor. Create and edit Sprites supported by the Tiamat RPG Framework.");
		this.buttonSpriteEditor.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_spriteeditor_bw.gif")));
		this.buttonSpriteEditor.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_spriteeditor_bw.gif")));
		this.buttonSpriteEditor.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
		this.buttonSpriteEditor.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
		this.buttonSpriteEditor.setIconTextGap(8);
		this.buttonSpriteEditor.setMaximumSize(new java.awt.Dimension(220,75));
		this.buttonSpriteEditor.setMinimumSize(new java.awt.Dimension(220,75));
		this.buttonSpriteEditor.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_spriteeditor.gif")));
		this.buttonSpriteEditor.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_spriteeditor.gif")));
		this.buttonSpriteEditor.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_spriteeditor.gif")));
		this.buttonSpriteEditor.addActionListener(new java.awt.event.ActionListener(){
			public void actionPerformed(java.awt.event.ActionEvent evt){
				buttonSpriteEditorActionPerformed(evt);
			}
		});

		this.toolBar.add(this.buttonSpriteEditor);

		this.buttonCharacterEditor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_charactereditor_bw.gif")));
		this.buttonCharacterEditor.setText("<html>Character Editor</html>");
		this.buttonCharacterEditor.setToolTipText("Launch the Character Editor. Create and edit Characters supported by the Tiamat RPG Framework.");
		this.buttonCharacterEditor.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_charactereditor_bw.gif")));
		this.buttonCharacterEditor.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_charactereditor_bw.gif")));
		this.buttonCharacterEditor.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
		this.buttonCharacterEditor.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
		this.buttonCharacterEditor.setIconTextGap(8);
		this.buttonCharacterEditor.setMaximumSize(new java.awt.Dimension(220,75));
		this.buttonCharacterEditor.setMinimumSize(new java.awt.Dimension(220,75));
		this.buttonCharacterEditor.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_charactereditor.gif")));
		this.buttonCharacterEditor.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_charactereditor.gif")));
		this.buttonCharacterEditor.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_charactereditor.gif")));
		this.buttonCharacterEditor.addActionListener(new java.awt.event.ActionListener(){
			public void actionPerformed(java.awt.event.ActionEvent evt){
				buttonCharacterEditorActionPerformed(evt);
			}
		});

		this.toolBar.add(this.buttonCharacterEditor);

		this.buttonAreaEditor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_areaeditor_bw.gif")));
		this.buttonAreaEditor.setText("Area Editor");
		this.buttonAreaEditor.setToolTipText("Launch the Area Editor. Create and edit Areas supported by the Tiamat RPG Framework.");
		this.buttonAreaEditor.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_areaeditor_bw.gif")));
		this.buttonAreaEditor.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_areaeditor_bw.gif")));
		this.buttonAreaEditor.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
		this.buttonAreaEditor.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
		this.buttonAreaEditor.setIconTextGap(8);
		this.buttonAreaEditor.setMaximumSize(new java.awt.Dimension(220,75));
		this.buttonAreaEditor.setMinimumSize(new java.awt.Dimension(220,75));
		this.buttonAreaEditor.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_areaeditor.gif")));
		this.buttonAreaEditor.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_areaeditor.gif")));
		this.buttonAreaEditor.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_areaeditor.gif")));
		this.buttonAreaEditor.addActionListener(new java.awt.event.ActionListener(){
			public void actionPerformed(java.awt.event.ActionEvent evt){
				buttonAreaEditorActionPerformed(evt);
			}
		});

		this.toolBar.add(this.buttonAreaEditor);

		this.buttonThemeEditor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_themeeditor_bw.gif")));
		this.buttonThemeEditor.setText("Theme Editor");
		this.buttonThemeEditor.setToolTipText("Launch the Theme Editor. Create and edit Themes supported by the Tiamat RPG Framework.");
		this.buttonThemeEditor.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_themeeditor_bw.gif")));
		this.buttonThemeEditor.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_themeeditor_bw.gif")));
		this.buttonThemeEditor.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
		this.buttonThemeEditor.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
		this.buttonThemeEditor.setIconTextGap(8);
		this.buttonThemeEditor.setMaximumSize(new java.awt.Dimension(220,75));
		this.buttonThemeEditor.setMinimumSize(new java.awt.Dimension(220,75));
		this.buttonThemeEditor.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_themeeditor.gif")));
		this.buttonThemeEditor.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_themeeditor.gif")));
		this.buttonThemeEditor.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/tools/images/qlbutton_themeeditor.gif")));
		this.buttonThemeEditor.addActionListener(new java.awt.event.ActionListener(){
			public void actionPerformed(java.awt.event.ActionEvent evt){
				buttonThemeEditorActionPerformed(evt);
			}
		});

		this.toolBar.add(this.buttonThemeEditor);

		this.getContentPane().add(this.toolBar);

		this.labelHelp.setText("<html>\nWelcome to the Tiamat Quicklaunch.\n</html>");
		this.getContentPane().add(this.labelHelp);

		this.labelLink.setText("Tiamat Homepage");
		this.labelLink.setToolTipText("Click here to go to the Tiamat homepage..");
		this.labelLink.addMouseListener(new java.awt.event.MouseAdapter(){
			public void mouseClicked(java.awt.event.MouseEvent evt){
				labelLinkMouseClicked(evt);
			}
		});

		this.getContentPane().add(this.labelLink);

		this.pack();
	}// GEN-END:initComponents

	public void buttonThemeEditorActionPerformed(java.awt.event.ActionEvent evt){// GEN-FIRST:event_buttonThemeEditorActionPerformed
		this.setVisible(false);
		new ThemeEditor(){
			public void exitHandler(){
				childFrameClosed();
			}
		};
	}// GEN-LAST:event_buttonThemeEditorActionPerformed

	public void labelLinkMouseClicked(java.awt.event.MouseEvent evt){// GEN-FIRST:event_labelLinkMouseClicked
		(new LaunchBrowser()).launch(this.homepageLink);
	}// GEN-LAST:event_labelLinkMouseClicked

	public void buttonAreaEditorActionPerformed(java.awt.event.ActionEvent evt){// GEN-FIRST:event_buttonAreaEditorActionPerformed
		this.setVisible(false);
		new AreaEditor(){
			public void exitHandler(){
				childFrameClosed();
			}
		};
	}// GEN-LAST:event_buttonAreaEditorActionPerformed

	public void buttonCharacterEditorActionPerformed(java.awt.event.ActionEvent evt){// GEN-FIRST:event_buttonCharacterEditorActionPerformed
		this.setVisible(false);
		new CharacterEditor(){
			public void exitHandler(){
				childFrameClosed();
			}
		};
	}// GEN-LAST:event_buttonCharacterEditorActionPerformed

	public void buttonSpriteEditorActionPerformed(java.awt.event.ActionEvent evt){// GEN-FIRST:event_buttonSpriteEditorActionPerformed
		this.setVisible(false);
		new SpriteEditor(){
			public void exitHandler(){
				childFrameClosed();
			}
		};
	}// GEN-LAST:event_buttonSpriteEditorActionPerformed

	/** Exit the Application */
	public void exitForm(java.awt.event.WindowEvent evt){// GEN-FIRST:event_exitForm
		this.onWindowClose();
	}// GEN-LAST:event_exitForm

	/**
	 * Called when a child frame is closed.
	 */
	public void childFrameClosed(){
		this.setVisible(true);
		this.labelHelp.requestFocus();
	}

	/**
	 * Override this if creating an instance of QuicklaunchFrame from another
	 * class.
	 */
	public void onWindowClose(){
		this.dispose();
	}

	/**
	 * Starts a new QuicklaunchFrame.
	 * 
	 * @param args
	 *            The command line arguments.
	 */
	public static void main(String args[]){
		(new QuicklaunchFrame()).setVisible(true);
	}

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton buttonAreaEditor;

	private javax.swing.JButton buttonCharacterEditor;

	private javax.swing.JButton buttonSpriteEditor;

	private javax.swing.JButton buttonThemeEditor;

	private javax.swing.JLabel labelHelp;

	private javax.swing.JLabel labelLink;

	private javax.swing.JToolBar toolBar;
	// End of variables declaration//GEN-END:variables
}