<commit_before>package de.ptb.epics.eve.viewer;

import java.io.File;
import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.epics.pvmanager.PVManager;
import org.epics.pvmanager.jca.JCADataSource;
import org.osgi.framework.BundleContext;
import org.xml.sax.SAXException;

import de.ptb.epics.eve.data.measuringstation.IMeasuringStation;
import de.ptb.epics.eve.data.measuringstation.processors.MeasuringStationLoader;
import de.ptb.epics.eve.data.scandescription.ScanDescription;
import de.ptb.epics.eve.ecp1.client.ECP1Client;
import de.ptb.epics.eve.preferences.PreferenceConstants;
import de.ptb.epics.eve.viewer.messages.MessagesContainer;

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

	/**
	 * The unique identifier of the plug in
	 */
	public static final String PLUGIN_ID = "de.ptb.epics.eve.viewer";

	// The shared instance
	private static Activator plugin;
	
	private static Logger logger = Logger.getLogger(Activator.class.getName());
	
	private final MessagesContainer messagesContainer;
	private final XMLFileDispatcher xmlFileDispatcher;
	private final EngineErrorReader engineErrorReader;
	private final ChainStatusAnalyzer chainStatusAnalyzer;
	private IMeasuringStation measuringStation;
	private ColorRegistry colorreg;
	private FontRegistry fontreg;
	
	private ScanDescription currentScanDescription;
	
	private ECP1Client ecp1Client;
	
	private RequestProcessor requestProcessor;

	private File schemaFile;
	private String rootDir;
	private boolean debug;
	
	/**
	 * The constructor
	 */
	public Activator() {
		plugin = this;
		this.ecp1Client = new ECP1Client();
		this.messagesContainer = new MessagesContainer();
		this.xmlFileDispatcher = new XMLFileDispatcher();
		this.engineErrorReader = new EngineErrorReader();
		this.chainStatusAnalyzer = new ChainStatusAnalyzer();
		
		PVManager.setDefaultDataSource(new JCADataSource());
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void start(final BundleContext context) throws Exception {
		super.start(context);
		
		readStartupParameters();
		if(!checkRootDir()) {
			context.getBundle().stop();
			context.getBundle().uninstall();
			return;
		}
		configureLogging();
		loadMeasuringStation();
		loadColorsAndFonts();
		startupReport();

		this.ecp1Client.getPlayListController().addNewXMLFileListener(this.xmlFileDispatcher);
		this.ecp1Client.addErrorListener(this.engineErrorReader);
		this.ecp1Client.addEngineStatusListener(this.chainStatusAnalyzer);
		this.ecp1Client.addChainStatusListener(this.chainStatusAnalyzer);
		this.requestProcessor = new RequestProcessor(Display.getCurrent());
		this.ecp1Client.addRequestListener(this.requestProcessor);<commit_msg>added simulation data source<commit_after>package de.ptb.epics.eve.viewer;

import java.io.File;
import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.epics.pvmanager.CompositeDataSource;
import org.epics.pvmanager.PVManager;
import org.epics.pvmanager.jca.JCADataSource;
import org.epics.pvmanager.sim.SimulationDataSource;
import org.osgi.framework.BundleContext;
import org.xml.sax.SAXException;

import de.ptb.epics.eve.data.measuringstation.IMeasuringStation;
import de.ptb.epics.eve.data.measuringstation.processors.MeasuringStationLoader;
import de.ptb.epics.eve.data.scandescription.ScanDescription;
import de.ptb.epics.eve.ecp1.client.ECP1Client;
import de.ptb.epics.eve.preferences.PreferenceConstants;
import de.ptb.epics.eve.viewer.messages.MessagesContainer;

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

	/**
	 * The unique identifier of the plug in
	 */
	public static final String PLUGIN_ID = "de.ptb.epics.eve.viewer";

	// The shared instance
	private static Activator plugin;
	
	private static Logger logger = Logger.getLogger(Activator.class.getName());
	
	private final MessagesContainer messagesContainer;
	private final XMLFileDispatcher xmlFileDispatcher;
	private final EngineErrorReader engineErrorReader;
	private final ChainStatusAnalyzer chainStatusAnalyzer;
	private IMeasuringStation measuringStation;
	private ColorRegistry colorreg;
	private FontRegistry fontreg;
	
	private ScanDescription currentScanDescription;
	
	private ECP1Client ecp1Client;
	
	private RequestProcessor requestProcessor;

	private File schemaFile;
	private String rootDir;
	private boolean debug;
	
	/**
	 * The constructor
	 */
	public Activator() {
		plugin = this;
		this.ecp1Client = new ECP1Client();
		this.messagesContainer = new MessagesContainer();
		this.xmlFileDispatcher = new XMLFileDispatcher();
		this.engineErrorReader = new EngineErrorReader();
		this.chainStatusAnalyzer = new ChainStatusAnalyzer();
		
		// Create a multiple data source, and add different data sources
		CompositeDataSource composite = new CompositeDataSource();
		composite.putDataSource("ca", new JCADataSource());
		composite.putDataSource("sim", new SimulationDataSource());
		
		// If no prefix is given to a channel, use JCA as default
		composite.setDefaultDataSource("ca");
		
		// Set the composite as the default
		PVManager.setDefaultDataSource(composite);
		
		// PVManager.setDefaultDataSource(new JCADataSource());
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void start(final BundleContext context) throws Exception {
		super.start(context);
		
		readStartupParameters();
		if(!checkRootDir()) {
			context.getBundle().stop();
			context.getBundle().uninstall();
			return;
		}
		configureLogging();
		loadMeasuringStation();
		loadColorsAndFonts();
		startupReport();

		this.ecp1Client.getPlayListController().addNewXMLFileListener(this.xmlFileDispatcher);
		this.ecp1Client.addErrorListener(this.engineErrorReader);
		this.ecp1Client.addEngineStatusListener(this.chainStatusAnalyzer);
		this.ecp1Client.addChainStatusListener(this.chainStatusAnalyzer);
		this.requestProcessor = new RequestProcessor(Display.getCurrent());
		this.ecp1Client.addRequestListener(this.requestProcessor);
{'fraction_non_alphanumeric': 0.09856560073693907, 'fraction_numerical': 0.003421502829319647, 'mean_word_length': 5.743566992014197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '1377884', 'n_tokens_mistral': 2378, 'n_tokens_neox': 2238, 'n_words': 436}