/*
 *    Debrief - the Open Source Maritime Analysis Application
 *    http://debrief.info
 *
 *    (C) 2016, PlanetMayo Ltd
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the Eclipse Public License v1.0
 *    (http://www.eclipse.org/legal/epl-v10.html)
 *
 *    This library 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. 
 */
package org.mwc.debrief.dis;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
 * The activator class controls the plug-in life cycle
 */
public class DisActivator extends AbstractUIPlugin
{

  // The plug-in ID
  public static final String PLUGIN_ID = "org.mwc.debrief.dis"; //$NON-NLS-1$

  public static final String PATH_TO_SIMULATION_EXECUTABLE =
      "pathToSimulationExecutable";
  public static final String PATH_TO_INPUT_FILE =
      "pathToSimulationInput";
  public static final String IP_ADDRESS = "ipAddress";
  public static final String PORT = "port";

  public static final String APP_FILTER = "appFilter";

  public static final String SITE_FILTER = "siteFilter";

  public static final String EXERCISE_FILTER = "exerciseFilter";

  public static final String APP_ID = "appId";

  public static final String SITE_ID = "siteId";

  // The shared instance
  private static DisActivator plugin;

  /**
   * The constructor
   */
  public DisActivator()
  {
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
   */
  public void start(BundleContext context) throws Exception
  {
    super.start(context);
    plugin = this;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
   */
  public void stop(BundleContext context) throws Exception
  {
    plugin = null;
    super.stop(context);
  }

  /**
   * Returns the shared instance
   *
   * @return the shared instance
   */
  public static DisActivator getDefault()
  {
    return plugin;
  }

  public static void log (Throwable t)
  {
    IStatus status = new Status(IStatus.WARNING, PLUGIN_ID, t.getMessage(), t);
    getDefault().getLog().log(status);
  }
}

/*
 *    Debrief - the Open Source Maritime Analysis Application
 *    http://debrief.info
 *
 *    (C) 2016, PlanetMayo Ltd
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the Eclipse Public License v1.0
 *    (http://www.eclipse.org/legal/epl-v10.html)
 *
 *    This library 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. 
 */
package org.mwc.debrief.dis;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
 * The activator class controls the plug-in life cycle
 */
public class DisActivator extends AbstractUIPlugin
{

  // The plug-in ID
  public static final String PLUGIN_ID = "org.mwc.debrief.dis"; //$NON-NLS-1$

  public static final String PATH_TO_SIMULATION_EXECUTABLE =
      "pathToSimulationExecutable";
  public static final String PATH_TO_INPUT_FILE =
      "pathToSimulationInput";
  public static final String IP_ADDRESS = "ipAddress";
  public static final String PORT = "port";

  public static final String APP_FILTER = "appFilter";

  public static final String SITE_FILTER = "siteFilter";

  public static final String EXERCISE_FILTER = "exerciseFilter";

  public static final String APP_ID = "appId";

  public static final String SITE_ID = "siteId";

  // The shared instance
  private static DisActivator plugin;

  /**
   * The constructor
   */
  public DisActivator()
  {
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
   */
  public void start(BundleContext context) throws Exception
  {
    super.start(context);
    plugin = this;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
   */
  public void stop(BundleContext context) throws Exception
  {
    plugin = null;
    super.stop(context);
  }

  /**
   * Returns the shared instance
   *
   * @return the shared instance
   */
  public static DisActivator getDefault()
  {
    return plugin;
  }

  public static void log (int statusVal, String message, Throwable t)
  {
    IStatus status = new Status(statusVal, PLUGIN_ID, message, t);
    getDefault().getLog().log(status);
  }

  public static void log (Throwable t)
  {
    IStatus status = new Status(IStatus.WARNING, PLUGIN_ID, t.getMessage(), t);
    getDefault().getLog().log(status);
  }
}

allow provision of more complex error log messages