/*
 * Copyright (C) 2010 Teleal GmbH, Switzerland
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.teleal.cling.support.shared;

import org.teleal.common.swingfwk.Controller;

import javax.swing.JFrame;

/**
 * @author Christian Bauer
 */
public class PlatformApple {

    public static void setup(final Controller<JFrame> appController, String appName) throws Exception {

        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", appName);
        System.setProperty("apple.awt.showGrowBox", "true");

        com.apple.eawt.Application.getApplication().addApplicationListener(
                new com.apple.eawt.ApplicationAdapter() {
                    @Override
                    public void handleQuit(com.apple.eawt.ApplicationEvent applicationEvent) {
                        if (appController != null) {
                            appController.dispose();
                            appController.getView().dispose();
                        }
                    }
                }
        );

    }

}
