/*
 * Licensed Materials - Property of Rogue Wave Software, Inc. 
 * © Copyright Rogue Wave Software, Inc. 2014, 2015 
 * © Copyright IBM Corp. 2009, 2014
 * © Copyright ILOG 1996, 2009
 * All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:
 * The Software and Documentation were developed at private expense and
 * are "Commercial Items" as that term is defined at 48 CFR 2.101,
 * consisting of "Commercial Computer Software" and
 * "Commercial Computer Software Documentation", as such terms are
 * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4,
 * as applicable.
 */

import ilog.views.util.IlvImageUtil;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import shared.BaseDemo;
import shared.MapBuilder;

/**
 * This example shows how to extend or restrict the map builder to use the FME bridge.
 * Using this example requires installing FME product on your machine.
 * for more information, go to http://www.safe.com/
 * @since JViews 7.5
 */
public class FMEDemo extends MapBuilder {

  /** Overridden method to change the menu buttons available to the user 
   * @param isApplet
   */
  public FMEDemo(boolean isApplet) {
    super(isApplet);
  }

  /**
   * Overridden method to change the preference file name.
   * @return the name of the preference file.
   */
  protected String getPreferenceFileName() {
    return "FMEDemo.settings";//$NON-NLS-1$
  }
  /**
   * Overridden method to change formats available in the import menu.
   * @see shared.MapBuilder#getImportActionClassNames()
   */
  protected ArrayList getImportActionClassNames() {
    ArrayList list = new ArrayList();//super.getImportActionClassNames();
     // add my import format
    list.add("fme.FMEShapeLoadAction");//$NON-NLS-1$
    list.add("fme.FMEKMLLoadAction");//$NON-NLS-1$
    list.add("fme.FMESDTSLoadAction");//$NON-NLS-1$
    return list;
  }
  /**
   * Main method: creates an FMEDemo in a JFrame.
   * @param args
   *          (ignored)
   */
  public static void main(String[] args) {
    BaseDemo.showSplashScreen();
    // Sun recommends that to put the entire GUI initialization into the
    // AWT thread
    javax.swing.SwingUtilities.invokeLater(
      new Runnable() {
        public void run() {
          final JFrame frame = new JFrame();
          final FMEDemo applet = new FMEDemo(false);
          frame.getContentPane().add(applet);
          
          // change the frame title
          frame.setTitle("FME Demo");//$NON-NLS-1$
          // Change the frame icon
          try {
            frame.setIconImage(IlvImageUtil.getImageFromFile(BaseDemo.class, "/icons/default_frame_icon.gif"));//$NON-NLS-1$
          } catch (IOException e1) {
            // ignore
          }
          // Manage application exit when we close its window.
          frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
          frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              applet.exitApplication();
            }
          });
          frame.pack();
          frame.setVisible(true);
        }
      }
      );
  }
}