Commit f79f583f authored by Florian Lugou's avatar Florian Lugou

added configuration option to config file for Download location

parent b966f3ed
......@@ -10,6 +10,9 @@
# Gradle
.gradle
# TTool user directory
/.ttool
# Compilation
/build
/bin
......
......@@ -8,6 +8,7 @@
<element id="directory" name="META-INF">
<element id="file-copy" path="$PROJECT_DIR$/ttool/META-INF/MANIFEST.MF" />
</element>
<element id="dir-copy" path="$PROJECT_DIR$/src/main/resources" />
</element>
</root>
</artifact>
......
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TTool" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="Main" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="-debug -proverif -experimental -config bin/config.xml" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="ttool" />
<envs />
<method>
<option name="BuildArtifacts" enabled="true">
<artifact name="dependencies" />
</option>
<option name="BuildArtifacts" enabled="true">
<artifact name="ttool.jar" />
</option>
</method>
</configuration>
</component>
\ No newline at end of file
......@@ -51,5 +51,6 @@ public interface CallbackLoaderInterface {
void loadDone();
void loadFailed();
void loadFailed(Exception e);
}
......@@ -81,6 +81,7 @@ public class ConfigurationTTool {
public static String DOTTYHost = "";
public static String DOTTYPath = "";
public static String FILEPath = "";
public static String DownloadedFILEPath = "";
public static String LOTOSPath = "";
public static String LIBPath = "";
public static String IMGPath = "";
......@@ -396,6 +397,7 @@ public class ConfigurationTTool {
sb.append("\nYour files (modeling, librairies, etc.):\n");
sb.append("FILEPath: " + FILEPath + "\n");
sb.append("DownloadedFILEPath: " + DownloadedFILEPath + "\n");
sb.append("LOTOSPath: " + LOTOSPath + "\n");
sb.append("LIBPath: " + LIBPath + "\n");
sb.append("IMGPath: " + IMGPath + "\n");
......@@ -536,6 +538,9 @@ public class ConfigurationTTool {
nl = doc.getElementsByTagName("FILEPath");
if (nl.getLength() > 0)
FILEPath(nl);
nl = doc.getElementsByTagName("DownloadedFILEPath");
if (nl.getLength() > 0)
DownloadedFILEPath(nl);
nl = doc.getElementsByTagName("LOTOSPath");
if (nl.getLength() > 0)
LOTOSPath(nl);
......@@ -898,6 +903,17 @@ public class ConfigurationTTool {
try {
Element elt = (Element)(nl.item(0));
FILEPath = elt.getAttribute("data");
if (DownloadedFILEPath.isEmpty())
DownloadedFILEPath = FILEPath;
} catch (Exception e) {
throw new MalformedConfigurationException(e.getMessage());
}
}
private static void DownloadedFILEPath(NodeList nl) throws MalformedConfigurationException {
try {
Element elt = (Element)(nl.item(0));
DownloadedFILEPath = elt.getAttribute("data");
} catch (Exception e) {
throw new MalformedConfigurationException(e.getMessage());
}
......
......@@ -47,8 +47,10 @@ import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
/**
......@@ -94,7 +96,7 @@ public final class URLManager implements Runnable {
}
} catch (Exception e) {
if (callback != null) {
callback.loadFailed();
callback.loadFailed(e);
}
}
busy = false;
......
......@@ -346,8 +346,8 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
jta.append("Loading model: " + fileName);
String urlToLoad = URLManager.getBaseURL(url) + fileName;
URLManager urlm = new URLManager();
filePath = ConfigurationTTool.FILEPath + "/" + fileName;
boolean ok = urlm.downloadFile(ConfigurationTTool.FILEPath + "/" + fileName, urlToLoad,this);
filePath = ConfigurationTTool.DownloadedFILEPath + "/" + fileName;
boolean ok = urlm.downloadFile(filePath, urlToLoad,this);
if (!ok) {
jta.append("Model transfer failed\nPlease, select another model, or retry\n");
panel.reactivateSelection();
......@@ -370,11 +370,20 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
//mgui.openProjectFromFile(new File(filePath));
}
@Override
public void loadFailed() {
jta.append("Model transfer failed\nPlease, select another model, or retry\n");
panel.reactivateSelection();
}
@Override
public void loadFailed(Exception e) {
jta.append("Model transfer failed with message:\n");
jta.append(e.getMessage());
jta.append("\n\nPlease, select another model, or retry\n");
panel.reactivateSelection();
}
// JTA manipulation by external objects
public void appendOut(String s) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment