package geisplugin;

//import java.io.File;
//import java.io.FileNotFoundException;
//import java.io.FileOutputStream;
//import java.io.PrintStream;
//import java.util.Date;

import javax.swing.JFrame;
import javax.swing.UIManager;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
 * DE:
 *
 * EN:
 *
 *
 * Program changes
 * **************************************************************************************
 * Date			* Ticket	* KonzFirm	* Responsible	* programmer    *
 * Change										*
 * **************************************************************************************
 *
 * @author Huellmante
 * @version 1.0
 *
 */


public class Activator extends AbstractUIPlugin {

//Logging zum Testen
//	static {
//		try {
//			System.setOut(new PrintStream(new FileOutputStream("C:/output.txt"), true));
//		} catch (FileNotFoundException e) {
//			e.printStackTrace();
//		}
//		try {
//			System.setErr(new PrintStream(new FileOutputStream("C:/err.txt"), true));
//		} catch (FileNotFoundException e) {
//			e.printStackTrace();
//		}
//	}

	public static final String PLUGIN_ID = "hbmToPoJoPlugIn";

	public final static JFrame frame = createPluginFrame();

	private static JFrame createPluginFrame() {
		try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());} catch (Exception e){}
		JFrame.setDefaultLookAndFeelDecorated(true);
		JFrame frame = new JFrame("Geis Tools");
		frame.setLocationRelativeTo(null);
		frame.pack();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		return frame;
	}

	@Override
	public void start(final BundleContext context) throws Exception {
		super.start(context);
		//JOptionPane.showMessageDialog(null, "start");
	}

	@Override
	public void stop(final BundleContext context) throws Exception {
		//JOptionPane.showMessageDialog(null, "stop");
		frame.dispose();
		super.stop(context);
	}

	@SuppressWarnings("deprecation")
	public static ImageDescriptor getImageDescriptor(String path) {
		return imageDescriptorFromPlugin(PLUGIN_ID, path);
	}
}
