/*******************************************************************************
 * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the LGPL 3.0
 * which accompanies this distribution, and is available at
 * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
 *
 * Contributors:
 *     Faiez Zalila - initial API and implementation and/or initial documentation
 *     Jorge Enrique Gutierrez Zuluaga
 *******************************************************************************/
package com.irtsaintexupery.fiacre.simulator.core;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

import com.irtsaintexupery.fiacre.simulator.marking.MarkingController;
import com.irtsaintexupery.fiacre.simulator.perspective.ViewsController;

import fr.laas.libtts.LibTTS;

public class QuitSimulator extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
				
		LibTTS libtts = FiacreSimulator.getLibTTS();
		if (libtts != null) {
			//resets Marking on current file
			ViewsController.INSTANCE.deleteMarkers();
			libtts.quit();
			FiacreSimulator.setLibtts(null);
			//clean all content in each view
			ViewsController.INSTANCE.clearAllViews();
			System.out.println("quit simulator");
			MarkingController.file = null;
		}		
		
		return null;
	}

}
