001    /*
002     * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    /* $Id: MainFrameAppListener.java,v 104426324a39 2010/01/05 14:15:34 MARIO $ */
018    
019    package net.sourceforge.jeuclid.app.mathviewer;
020    
021    import java.io.File;
022    
023    import com.apple.eawt.ApplicationAdapter;
024    import com.apple.eawt.ApplicationEvent;
025    
026    /**
027     * @version $Revision: 104426324a39 $
028     */
029    public class MainFrameAppListener extends ApplicationAdapter {
030    
031        private final MainFrame frame;
032    
033        // /**
034        // * Logger for this class
035        // */
036        // Unused.
037        // private static final Log LOGGER = LogFactory
038        // .getLog(MainFrameAppListener.class);
039    
040        /**
041         * Default Constructor.
042         * 
043         * @param mainFrame
044         *            MainFrame to use
045         */
046        public MainFrameAppListener(final MainFrame mainFrame) {
047            this.frame = mainFrame;
048        }
049    
050        /** {@inheritDoc} */
051        @Override
052        public void handleOpenFile(final ApplicationEvent arg0) {
053            this.frame.loadFile(new File(arg0.getFilename()));
054            arg0.setHandled(true);
055        }
056    
057        /** {@inheritDoc} */
058        @Override
059        public void handleAbout(final ApplicationEvent arg0) {
060            this.frame.displayAbout();
061            arg0.setHandled(true);
062        }
063    
064        /** {@inheritDoc} */
065        @Override
066        public void handlePreferences(final ApplicationEvent arg0) {
067            this.frame.displaySettings();
068            arg0.setHandled(true);
069        }
070    
071        /** {@inheritDoc} */
072        @Override
073        public void handleQuit(final ApplicationEvent arg0) {
074            System.exit(0);
075            arg0.setHandled(true);
076        }
077    }