From 4b6fc84bd831023866b65fd0c092dde55cedef73 Mon Sep 17 00:00:00 2001
From: Fabien Tessier <fabien.tessier@telecom-paristech.fr>
Date: Fri, 20 Oct 2017 14:42:01 +0200
Subject: [PATCH] Fix screenshot path for .ttool project

---
 src/main/java/common/SpecConfigTTool.java    |  9 +++++++++
 src/main/java/ui/DocumentationGenerator.java |  5 +++--
 src/main/java/ui/MainGUI.java                | 10 ++++++----
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/main/java/common/SpecConfigTTool.java b/src/main/java/common/SpecConfigTTool.java
index 24a305aa06..aeff9c844c 100644
--- a/src/main/java/common/SpecConfigTTool.java
+++ b/src/main/java/common/SpecConfigTTool.java
@@ -45,12 +45,15 @@ public class SpecConfigTTool {
 	
 	public static String TMLCodeDirectory="";
 	
+	public static String IMGPath="";
+	
 	private static String ProjectSystemCCodeDirectory = "/c++_code/";
 	private static String ProjectCCodeDirectory = "/c_code/";
 	private static String ProjectProVerifCodeDirectory = "/proverif/";
 	private static String ProjectAVATARExecutableCodeDirectory = "/AVATAR_executablecode/";
 	private static String ProjectAVATARMPSoCCodeDirectory = "/MPSoC/";
 	private static String ProjectTMLCodeDirectory = "/tmlcode/";
+	private static String ProjectIMGPath = "/figures";
 	
 	public static int lastPanel = -1;
 	public static int lastTab = -1;
@@ -76,6 +79,8 @@ public class SpecConfigTTool {
 		AVATARExecutableSoclibCodeTraceCommand = ConfigurationTTool.AVATARExecutableSoclibCodeTraceCommand;
 		
 		TMLCodeDirectory = ConfigurationTTool.TMLCodeDirectory;
+		
+		IMGPath = ConfigurationTTool.IMGPath;
 	}
 	
 	public static void setDirConfig(File dir) {
@@ -85,6 +90,7 @@ public class SpecConfigTTool {
     	AVATARExecutableCodeDirectory = dir.getAbsolutePath() + ProjectAVATARExecutableCodeDirectory;
     	AVATARMPSoCCodeDirectory = dir.getAbsolutePath() + ProjectAVATARMPSoCCodeDirectory;
     	TMLCodeDirectory = dir.getAbsolutePath() + ProjectTMLCodeDirectory;
+    	IMGPath = dir.getAbsolutePath() + ProjectIMGPath;
     	
     	SystemCCodeCompileCommand = ConfigurationTTool.SystemCCodeCompileCommand.replace(ConfigurationTTool.SystemCCodeDirectory, SystemCCodeDirectory);
     	SystemCCodeExecuteCommand = ConfigurationTTool.SystemCCodeExecuteCommand.replace(ConfigurationTTool.SystemCCodeDirectory, SystemCCodeDirectory);
@@ -108,6 +114,9 @@ public class SpecConfigTTool {
     }
 	
 	public static File createProjectConfig(File dir) {
+		File figures = new File(IMGPath);
+		figures.mkdir();
+		
 		File test = new File ("./");
 		File base;
 		if (test.getAbsolutePath().contains("TTool/bin/"))
diff --git a/src/main/java/ui/DocumentationGenerator.java b/src/main/java/ui/DocumentationGenerator.java
index 26ceeb9237..c7883afab8 100644
--- a/src/main/java/ui/DocumentationGenerator.java
+++ b/src/main/java/ui/DocumentationGenerator.java
@@ -58,6 +58,7 @@ import javax.imageio.ImageIO;
 import javax.swing.*;
 
 import common.ConfigurationTTool;
+import common.SpecConfigTTool;
 
 import java.awt.image.BufferedImage;
 import java.io.File;
@@ -189,7 +190,7 @@ public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIEle
         	docFolder.mkdir();
     
     		final String makefileName = File.separator + "Makefile";
-        	final File makeFile = new File( ConfigurationTTool.IMGPath + makefileName );
+        	final File makeFile = new File( SpecConfigTTool.IMGPath + makefileName );
         	
         	try {
 	        	if ( makeFile.exists() ) {
@@ -197,7 +198,7 @@ public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIEle
 	        	}
 	            
 	    		final String mliFileName = File.separator + "mli.mk";
-	        	final File mliFile = new File( ConfigurationTTool.IMGPath + mliFileName );
+	        	final File mliFile = new File( SpecConfigTTool.IMGPath + mliFileName );
 	        	
 	        	if ( mliFile.exists() ) {
 	        		Files.copy( mliFile.toPath(), new File( getPath() + mliFileName ).toPath() );
diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java
index 5c74cb34e2..1a04e37c33 100644
--- a/src/main/java/ui/MainGUI.java
+++ b/src/main/java/ui/MainGUI.java
@@ -418,14 +418,14 @@ public  class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
             jfclib = new JFileChooser();
         }
 
-        if (ConfigurationTTool.IMGPath.length() > 0) {
-            jfcimg = new JFileChooser(ConfigurationTTool.IMGPath);
+        if (SpecConfigTTool.IMGPath.length() > 0) {
+            jfcimg = new JFileChooser(SpecConfigTTool.IMGPath);
         } else {
             jfcimg = new JFileChooser();
         }
 
-        if (ConfigurationTTool.IMGPath.length() > 0) {
-            jfcimgsvg = new JFileChooser(ConfigurationTTool.IMGPath);
+        if (SpecConfigTTool.IMGPath.length() > 0) {
+            jfcimgsvg = new JFileChooser(SpecConfigTTool.IMGPath);
         } else {
             jfcimgsvg = new JFileChooser();
         }
@@ -5451,6 +5451,7 @@ public  class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
 
     public File selectFileForCapture() {
         File file = null;
+        jfcimg.setCurrentDirectory(new File(SpecConfigTTool.IMGPath));
         int returnVal = jfcimg.showSaveDialog(frame);
         if(returnVal == JFileChooser.APPROVE_OPTION) {
             file = jfcimg.getSelectedFile();
@@ -5469,6 +5470,7 @@ public  class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
 
     public File selectSVGFileForCapture() {
         File file = null;
+        jfcimgsvg.setCurrentDirectory(new File(SpecConfigTTool.IMGPath));
         int returnVal = jfcimgsvg.showSaveDialog(frame);
         if(returnVal == JFileChooser.APPROVE_OPTION) {
             file = jfcimgsvg.getSelectedFile();
-- 
GitLab