package gradertool.admin;

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

/**
 * ExportDisplay
 */
public class ExportDisplay extends JFrame {

   /**
    * Construct this, per the design explained in the class comment.
    */
   public ExportDisplay() {
      Panel box = new Panel();
      Panel outerBox = new Panel();
      
      box.setPreferredSize(new Dimension(300, 250));
      
      box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
      outerBox.setLayout(new BoxLayout(outerBox, BoxLayout.X_AXIS));
      
      setContentPane(outerBox);
      
      // set up inner box (top to bottom)
      box.add(Box.createHorizontalStrut(3));
      
      Button buttonImport = new Button("Server Setup");
      buttonImport.setPreferredSize(new Dimension(225, 75));
      box.add(buttonImport);
      
      box.add(Box.createHorizontalStrut(3));
      
      Button buttonCreate = new Button("Posting Grades");
      buttonCreate.setPreferredSize(new Dimension(225, 75));
      box.add(buttonCreate);
      
      box.add(Box.createHorizontalStrut(3));
      
      // set up outer box (left to right)
      outerBox.add(Box.createRigidArea(new Dimension(25,25)));
      outerBox.add(box);
      outerBox.add(Box.createRigidArea(new Dimension(25,25)));
      
      setTitle("Export - CPE 308");
      
      importButtonAction(buttonImport);
      createButtonAction(buttonCreate);
      
      pack();
   }

   /**
    * Add the 'Server Setup' button.
    */
   protected void importButtonAction(Button buttonImport) {
      buttonImport.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            ExportUI exportUI = new ExportUI();
            exportUI.getServerSetupDisplay().setVisible(true);
            setVisible(false);
         }
      });
   }

   /**
    * Add the 'Posting Grades' button.
    */
   protected void createButtonAction(Button buttonCreate) {
      buttonCreate.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            // Print a message
            System.out.println("Grades Posted!");
         }
      });
   }
}