import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.awt.event.*;

/**

GuiController is a class the central administrator of all the operations that are occuring in the 2dfQSO system
Any operation 

*/


class GuiController
{
	public static void main (String[] args)
	{
		GuiController theApp = new GuiController ();
		theApp.init();
	}
	
	public void init()
	{
		JFrame.setDefaultLookAndFeelDecorated(true);
		window = new JFrame ("2dfQSO Database System");		
		
		Toolkit theKit = window.getToolkit();          // Get the window toolkit
		Dimension wndSize = theKit.getScreenSize();    // Get screen size

	    	window.setBounds (0,0, wndSize.width - 10, wndSize.height - 20);  // Set Size for the main Frame
		window.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); 		

		//Creating the split
		leftPane = new JPanel (new BorderLayout());
		rightPane = new JPanel (new BorderLayout());
		
		dataPane = new JPanel (new BorderLayout ());
		toolBar = new JPanel (new BorderLayout ());
		
		// creating the query object
		tdfInterface = new TdfInterface (this, (int) wndSize.width/4, wndSize.height);
				
		// add the left and right components to the panes
		leftPane.add (tdfInterface, BorderLayout.CENTER);
		
		// create the split pane
		JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,leftPane,rightPane);
		splitPane.setDividerLocation((int)wndSize.width/4);  // sets
		splitPane.setOneTouchExpandable (true);
		
		JSplitPane splitOutput = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT,true,dataPane,toolBar);
		splitOutput.setDividerLocation ((int) ((wndSize.width * 3)/5));
		splitOutput.setOneTouchExpandable (true);
		toolBar.setPreferredSize (new Dimension 
					((int) ((wndSize.width * 2)/7), wndSize.height - 50));
		
		rightPane.add (splitOutput);
		
		// set the splitpane pane position !
		int minWidth =  (3 * wndSize.width)/4;
		int minHeight = (3 * wndSize.height)/4;
		rightPane.setMinimumSize (new Dimension (minWidth,minHeight));

		// add the splitpane to the content pane !
		window.getContentPane().add(splitPane, BorderLayout.CENTER);	
		window.setVisible (true);
	}
	
	public void showResults (JScrollPane results)
        {
                dataPane.add (results, BorderLayout.CENTER);
                window.setVisible (true);
        }

	public void removeComponents ()
	{
		dataPane.removeAll ();
	}
	
	/**
	*
	*/
	private GuiController theApp; 
	private JFrame window;
	private JPanel leftPane,rightPane, dataPane, toolBar;
	private TdfInterface tdfInterface;
}
