package tmcsim.cadsimulator.viewer.actions;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import tmcsim.cadsimulator.viewer.CADServerViewer;

/**
 * Abstract action to exit the CADSimulator. When the action is performed the
 * CADSimulatorView.closeViewer() method is called.
 *
 * @author Matthew Cechini
 * @version
 */
@SuppressWarnings("serial")
public class ExitAction extends AbstractAction
{

    /**
     * Reference to the CADSimulatorViewer.
     */
    private CADServerViewer theViewer;

    public ExitAction(CADServerViewer viewer)
    {
        super("Exit");

        theViewer = viewer;
    }

    public void actionPerformed(ActionEvent arg0)
    {
        //theViewer.closeViewer();
        /* closeViewer() will prompt the user for confirmation.
         * 26 Apr 2016 I'm tired of seeing the confirmation message,
         * so if the user chooses File>Exit, assume they intend to exit
         * and don't ask for confirmation.  If they click window close
         * button, they will still get the confirmation prompt. jdalbey
         */
        System.exit(0);
    }
}
