package schedule;

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

/****
 *
 * Class ScheduleMenu is the "Schedule" pulldown menu in the CalendarToolUI
 * prototype.  Anonymous instances of JMenuItem are defined for each item in
 * the menu.
 *                                                                           <p>
 * The constructor for this class receives a reference to the containing
 * ScheduleUI.  It uses this reference to access the dialogs that ScheduleUI
 * constructs.  Since this class and ScheduleUI are in the same package, it has
 * access to its protected data fields.  This is not the best practice for info
 * hiding, but it's fine in a rapid prototype.
 *                                                                           <p>
 * In the current prototype, only the first menu item has an action listener
 * that brings up a dialog.  The other items just print a message to stdout.
 *                                                                           <p>
 * See <a href=FileMenu.html>FileMenu.java</a> documentation for further
 * discussion on setting up menu items.  See <a href=PrintOnlyMenuItem.html>
 * documentation for a description of the convenience class that constructs
 * menu items that do nothing but print a message to stdout.
 *
 */
public class ScheduleMenu extends JMenu {

    /**
     * Construct this by inserting each of its items, which are Appointment,
     * Meeting, Task, Event, and Categories.  A JSepartor goes after Event.
     *                                                                       <p>
     * The input parameter is used to reference the dialogs that ScheduleUI
     * creates.  Note that it must be declared final, since it is referenced
     * inside an anonymous inner class.
     */
    public ScheduleMenu(final ScheduleUI scheduleUI) {
        super("Schedule");

        add(new JMenuItem("Appointment ...")).addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    scheduleUI.apptDialog.setVisible(true);
                    scheduleUI.apptDialog.setLocation(new Point(50, 125));
                }
            }
        );

        add(new PrintOnlyMenuItem("Schedule", "Meeting ..."));
        add(new PrintOnlyMenuItem("Schedule", "Task ..."));
        add(new PrintOnlyMenuItem("Schedule", "Event ..."));
        add(new JSeparator());
        add(new PrintOnlyMenuItem("Schedule", "Categories ..."));
    }

}