<commit_before>package pt.uminho.haslab.echo.plugin;

import java.net.URL;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

import pt.uminho.haslab.echo.EchoOptionsSetup;
import pt.uminho.haslab.echo.EchoReporter;
import pt.uminho.haslab.echo.EchoRunner;
import pt.uminho.haslab.echo.EngineFactory;
import pt.uminho.haslab.echo.plugin.listeners.ResourceChangeListener;
import pt.uminho.haslab.echo.plugin.properties.ProjectPropertiesManager;
import pt.uminho.haslab.echo.plugin.views.GraphView;

public class EchoPlugin extends AbstractUIPlugin {
	
    public final static String ID = "pt.uminho.haslab.echo.plugin";
    public final static String ICONS_PATH = "icons/";
    public final static String QVT_ICON = "qvt.gif";
    public final static String XMI_ICON = "xmi.gif";



	/** the current EchoPlugin instance **/
	private static EchoPlugin instance;

	/**
	 * Retrieves the EchoPlugin instance
	 * 
	 * @return the current EchoPlugin instance
	 */
	public static EchoPlugin getInstance() {
		return instance;
	}

	/** the graph visualizer View **/
	private GraphView graphView = null;

    /** the Echo Runner **/
    private EchoRunner runner;

	/**
	 * Contructs a new Echo plugin
	 */
	public EchoPlugin() {
		super();
		instance = this;
		EchoOptionsSetup.init(new PlugInOptions());
		EchoReporter.init(new EchoReporter());
        EngineFactory.init(EngineFactory.ALLOY);
	}


    /**
     *
     * @return the Echo Engine.
     */
    public EchoRunner getRunner(){
        return runner = new EchoRunner();
    }

	/**
	 * Starts the Echo plugin Loads the 
	 * Echo properties of each project and
	 * starts the listeners
	 */
	@Override
	public void start(BundleContext bc) throws Exception {
		super.start(bc);

		for (IProject p : ResourcesPlugin.getWorkspace().getRoot()
				.getProjects())
			if (p.isOpen())
				ProjectPropertiesManager.getProperties(p);

		IResourceChangeListener listener = new ResourceChangeListener();
		ResourcesPlugin.getWorkspace().addResourceChangeListener(listener,
				IResourceChangeEvent.POST_CHANGE);
	}

	/**
	 * Initializes (if necessary) and retrieves the graph visualizer View<commit_msg>EchoRunner is no longer singleton<commit_after>package pt.uminho.haslab.echo.plugin;

import java.net.URL;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

import pt.uminho.haslab.echo.EchoOptionsSetup;
import pt.uminho.haslab.echo.EchoReporter;
import pt.uminho.haslab.echo.EchoRunner;
import pt.uminho.haslab.echo.EngineFactory;
import pt.uminho.haslab.echo.plugin.listeners.ResourceChangeListener;
import pt.uminho.haslab.echo.plugin.properties.ProjectPropertiesManager;
import pt.uminho.haslab.echo.plugin.views.GraphView;

public class EchoPlugin extends AbstractUIPlugin {
	
    public final static String ID = "pt.uminho.haslab.echo.plugin";
    public final static String ICONS_PATH = "icons/";
    public final static String QVT_ICON = "qvt.gif";
    public final static String XMI_ICON = "xmi.gif";



	/** the current EchoPlugin instance **/
	private static EchoPlugin instance;

	/**
	 * Retrieves the EchoPlugin instance
	 * 
	 * @return the current EchoPlugin instance
	 */
	public static EchoPlugin getInstance() {
		return instance;
	}

	/** the graph visualizer View **/
	private GraphView graphView = null;

    /** the Echo Runner **/
    private EchoRunner runner;

	/**
	 * Contructs a new Echo plugin
	 */
	public EchoPlugin() {
		super();
		instance = this;
        runner = new EchoRunner();
		EchoOptionsSetup.init(new PlugInOptions());
		EchoReporter.init(new EchoReporter());
        EngineFactory.init(EngineFactory.ALLOY);

	}


    /**
     *
     * @return the Echo Engine.
     */
    public EchoRunner getRunner(){
        return runner;
    }

	/**
	 * Starts the Echo plugin Loads the 
	 * Echo properties of each project and
	 * starts the listeners
	 */
	@Override
	public void start(BundleContext bc) throws Exception {
		super.start(bc);

		for (IProject p : ResourcesPlugin.getWorkspace().getRoot()
				.getProjects())
			if (p.isOpen())
				ProjectPropertiesManager.getProperties(p);

		IResourceChangeListener listener = new ResourceChangeListener();
		ResourcesPlugin.getWorkspace().addResourceChangeListener(listener,
				IResourceChangeEvent.POST_CHANGE);
	}

	/**
	 * Initializes (if necessary) and retrieves the graph visualizer View
{'fraction_non_alphanumeric': 0.1038937735510497, 'fraction_numerical': 0.0, 'mean_word_length': 4.313632030505243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3876898', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1632, 'n_words': 376}