// Path: src/main/java/BlueTurtle/gui/GUIController.java
// public enum ASAT { CheckStyle, PMD, FindBugs; }
// 
// Path: src/main/java/BlueTurtle/uav/JavaController.java
// public class JavaController implements Controller {
// 	
// 	@Getter @Setter private static String userDir = System.getProperty("user.dir"); //NOPMD - caused by lombok.
// 	@Getter @Setter private static ArrayList<String> checkStyleOutputFiles; //NOPMD - caused by lombok.
// 	@Getter @Setter private static ArrayList<String> pmdOutputFiles; //NOPMD - caused by lombok.
// 	@Getter @Setter private static ArrayList<String> findBugsOutputFiles; //NOPMD - caused by lombok.
// 
// 	/**
// 	 * Execute controller. A command is constructed for every ASAT which needs
// 	 * to be run.
// 	 * 
// 	 * @throws IOException
// 	 *             throws an exception if a problem is encountered when
// 	 *             executing the commands.
// 	 */
// 	public void execute() throws IOException {
// 		new JSONFormatter().format();
// 	}
// 	
// 	/**
// 	 * Set the output paths for the ASAT.
// 	 * 
// 	 * @param asat
// 	 *            the ASAT type.
// 	 * @param filePaths
// 	 *            the list of output file paths.
// 	 */
// 	public static void setASATOutputFiles(ASAT asat, ArrayList<String> filePaths) {
// 		if (filePaths == null) {
// 			return;
// 		}
// 		switch (asat) {
// 		case PMD:
// 			pmdOutputFiles = filePaths;
// 			break;
// 		case CheckStyle:
// 			checkStyleOutputFiles = filePaths;
// 			break;
// 		case FindBugs:
// 			findBugsOutputFiles = filePaths;
// 			break;
// 		default:
// 			break;
// 		}
// 	}
// }


import java.awt.Desktop;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType; 
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import BlueTurtle.finders.ProjectInfoFinder;
import BlueTurtle.gui.GUIController.ASAT;
import BlueTurtle.uav.JavaController;
import BlueTurtle.uav.Main;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.text.Text;
import javafx.stage.DirectoryChooser;
import javafx.stage.Stage;
import lombok.Getter;
import lombok.Setter;
	@Override
	public void handle(MouseEvent event) {
		try {
			Alert alert = alertCreator.createAlert(AlertType.INFORMATION, "info", "Collecting the data may take a few minutes for large projects.");
			alert.showAndWait();
			findProjectInfo();
			Main.runVisualization();
			Desktop.getDesktop().browse(new File("visualization/main.html").toURI());
			ProjectInfoFinder.cleanup();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * Find all necessary information of the project.
	 * @throws IOException 
	 * 				throws an exception if a problem is encountered while reading the files.
	 */
	public void findProjectInfo() throws IOException {
		ProjectInfoFinder pif = new ProjectInfoFinder();
		pif.findFiles(new File(GUIController.getProjectPath()));
		setListOfOutputFiles();
		pif.retrieveCodeFiles();
	}
	
	/**
	 * Set the list of output files (generated by Maven) for each ASAT.
	 */
	public void setListOfOutputFiles() {
// Path: src/main/java/BlueTurtle/gui/GUIController.java
// public enum ASAT { CheckStyle, PMD, FindBugs; }
// 
// Path: src/main/java/BlueTurtle/uav/JavaController.java
// public class JavaController implements Controller {
// 	
// 	@Getter @Setter private static String userDir = System.getProperty("user.dir"); //NOPMD - caused by lombok.
// 	@Getter @Setter private static ArrayList<String> checkStyleOutputFiles; //NOPMD - caused by lombok.
// 	@Getter @Setter private static ArrayList<String> pmdOutputFiles; //NOPMD - caused by lombok.
// 	@Getter @Setter private static ArrayList<String> findBugsOutputFiles; //NOPMD - caused by lombok.
// 
// 	/**
// 	 * Execute controller. A command is constructed for every ASAT which needs
// 	 * to be run.
// 	 * 
// 	 * @throws IOException
// 	 *             throws an exception if a problem is encountered when
// 	 *             executing the commands.
// 	 */
// 	public void execute() throws IOException {
// 		new JSONFormatter().format();
// 	}
// 	
// 	/**
// 	 * Set the output paths for the ASAT.
// 	 * 
// 	 * @param asat
// 	 *            the ASAT type.
// 	 * @param filePaths
// 	 *            the list of output file paths.
// 	 */
// 	public static void setASATOutputFiles(ASAT asat, ArrayList<String> filePaths) {
// 		if (filePaths == null) {
// 			return;
// 		}
// 		switch (asat) {
// 		case PMD:
// 			pmdOutputFiles = filePaths;
// 			break;
// 		case CheckStyle:
// 			checkStyleOutputFiles = filePaths;
// 			break;
// 		case FindBugs:
// 			findBugsOutputFiles = filePaths;
// 			break;
// 		default:
// 			break;
// 		}
// 	}
// }


// Path: src/main/java/BlueTurtle/gui/GUIController.java
import java.awt.Desktop;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType; 
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import BlueTurtle.finders.ProjectInfoFinder;
import BlueTurtle.gui.GUIController.ASAT;
import BlueTurtle.uav.JavaController;
import BlueTurtle.uav.Main;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.text.Text;
import javafx.stage.DirectoryChooser;
import javafx.stage.Stage;
import lombok.Getter;
import lombok.Setter;

	@Override
	public void handle(MouseEvent event) {
		try {
			Alert alert = alertCreator.createAlert(AlertType.INFORMATION, "info", "Collecting the data may take a few minutes for large projects.");
			alert.showAndWait();
			findProjectInfo();
			Main.runVisualization();
			Desktop.getDesktop().browse(new File("visualization/main.html").toURI());
			ProjectInfoFinder.cleanup();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * Find all necessary information of the project.
	 * @throws IOException 
	 * 				throws an exception if a problem is encountered while reading the files.
	 */
	public void findProjectInfo() throws IOException {
		ProjectInfoFinder pif = new ProjectInfoFinder();
		pif.findFiles(new File(GUIController.getProjectPath()));
		setListOfOutputFiles();
		pif.retrieveCodeFiles();
	}
	
	/**
	 * Set the list of output files (generated by Maven) for each ASAT.
	 */
	public void setListOfOutputFiles() {
		JavaController.setASATOutputFiles(ASAT.CheckStyle, ProjectInfoFinder.getOutputFilesPaths().get(ASAT.CheckStyle));