// created: 29.12.00
// modified:

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

public class PagePrefGUI
 {
 PagePref pagePreferencer;

 JPanel mainPanel;
 CommandToolbar cmdToolbar;
 AttributePanel attPanel;  // to switch the attributes on and off
 FunctionPanel funcPanel;  // to set the value functions
 WeightPanel wgtPanel;  // to set the weights applied to the value functions
 WebPagePanel pagePanel;  // to display the page details such as location, and their order.

 /***************/
 /* constructor */
 /***************************************/
 /* this sets up the graphical elements */
 /***************************************/

 public PagePrefGUI()
  {
  pagePreferencer = new PagePref();

  // make the main panel
  mainPanel = new JPanel();
  mainPanel.setPreferredSize(new Dimension(600,600));

  // make the main components
  cmdToolbar = new CommandToolbar(this);
  cmdToolbar.setPreferredSize(new Dimension(600,50));

  funcPanel = new FunctionPanel();
  funcPanel.setPreferredSize(new Dimension(310,290)); 

  wgtPanel = new WeightPanel();
  wgtPanel.setPreferredSize(new Dimension(125,290)); 

  attPanel = new AttributePanel(wgtPanel,funcPanel);  //it needs knowledge of the other panels to control their enabled state
  attPanel.setPreferredSize(new Dimension(165,290));  

  pagePanel = new WebPagePanel();
  pagePanel.setPreferredSize(new Dimension(600,260));
 
  // add them to the main panel 
  GridBagLayout gridbag = new GridBagLayout();
  mainPanel.setLayout(gridbag);
  GridBagConstraints c = new GridBagConstraints();
  c.gridx = 0;
  c.gridy = 0;
  c.gridwidth = 3;
  c.anchor = GridBagConstraints.WEST;
  gridbag.setConstraints(cmdToolbar,c);
  c.gridx = 0;
  c.gridy = 1;
  c.gridwidth = 1;
  gridbag.setConstraints(attPanel,c);
  c.gridx = 1;
  c.gridy = 1;
  c.gridwidth = 1;
  gridbag.setConstraints(funcPanel,c);
  c.gridx = 2;
  c.gridy = 1;
  c.gridwidth = 1;
  gridbag.setConstraints(wgtPanel,c);
  c.gridx = 0;
  c.gridy = 2;
  c.gridwidth = 3;
  gridbag.setConstraints(pagePanel,c);
  
  mainPanel.add(cmdToolbar);
  mainPanel.add(attPanel);
  mainPanel.add(funcPanel);
  mainPanel.add(wgtPanel);
  mainPanel.add(pagePanel);

  }

 /***************/
 /* main method */
 /********************************************/
 /* responsible for setting up the interface */
 /********************************************/

 public static void main (String [] args)
  {
  PagePrefGUI GUI = new PagePrefGUI();
 
  // Create a new window
  JFrame mainFrame = new JFrame("PagePref GUI");
  mainFrame.setResizable(false);
  mainFrame.addWindowListener(new
   WindowAdapter() 
    {
    public void windowClosing(WindowEvent e) 
     {
     System.exit(0);
     }
    });

  // Add the JPanel to the window and display the window.
  // We can use a JPanel for the content pane because
  // JPanel is opaque.
  mainFrame.setContentPane(GUI.mainPanel);
  mainFrame.pack();
  mainFrame.setVisible(true);
  }

}