Skip to content
Snippets Groups Projects
Commit f79f583f authored by Florian Lugou's avatar Florian Lugou
Browse files

added configuration option to config file for Download location

parent b966f3ed
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
# Gradle # Gradle
.gradle .gradle
# TTool user directory
/.ttool
# Compilation # Compilation
/build /build
/bin /bin
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<element id="directory" name="META-INF"> <element id="directory" name="META-INF">
<element id="file-copy" path="$PROJECT_DIR$/ttool/META-INF/MANIFEST.MF" /> <element id="file-copy" path="$PROJECT_DIR$/ttool/META-INF/MANIFEST.MF" />
</element> </element>
<element id="dir-copy" path="$PROJECT_DIR$/src/main/resources" />
</element> </element>
</root> </root>
</artifact> </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 { ...@@ -51,5 +51,6 @@ public interface CallbackLoaderInterface {
void loadDone(); void loadDone();
void loadFailed(); void loadFailed();
void loadFailed(Exception e);
} }
...@@ -81,6 +81,7 @@ public class ConfigurationTTool { ...@@ -81,6 +81,7 @@ public class ConfigurationTTool {
public static String DOTTYHost = ""; public static String DOTTYHost = "";
public static String DOTTYPath = ""; public static String DOTTYPath = "";
public static String FILEPath = ""; public static String FILEPath = "";
public static String DownloadedFILEPath = "";
public static String LOTOSPath = ""; public static String LOTOSPath = "";
public static String LIBPath = ""; public static String LIBPath = "";
public static String IMGPath = ""; public static String IMGPath = "";
...@@ -396,6 +397,7 @@ public class ConfigurationTTool { ...@@ -396,6 +397,7 @@ public class ConfigurationTTool {
sb.append("\nYour files (modeling, librairies, etc.):\n"); sb.append("\nYour files (modeling, librairies, etc.):\n");
sb.append("FILEPath: " + FILEPath + "\n"); sb.append("FILEPath: " + FILEPath + "\n");
sb.append("DownloadedFILEPath: " + DownloadedFILEPath + "\n");
sb.append("LOTOSPath: " + LOTOSPath + "\n"); sb.append("LOTOSPath: " + LOTOSPath + "\n");
sb.append("LIBPath: " + LIBPath + "\n"); sb.append("LIBPath: " + LIBPath + "\n");
sb.append("IMGPath: " + IMGPath + "\n"); sb.append("IMGPath: " + IMGPath + "\n");
...@@ -536,6 +538,9 @@ public class ConfigurationTTool { ...@@ -536,6 +538,9 @@ public class ConfigurationTTool {
nl = doc.getElementsByTagName("FILEPath"); nl = doc.getElementsByTagName("FILEPath");
if (nl.getLength() > 0) if (nl.getLength() > 0)
FILEPath(nl); FILEPath(nl);
nl = doc.getElementsByTagName("DownloadedFILEPath");
if (nl.getLength() > 0)
DownloadedFILEPath(nl);
nl = doc.getElementsByTagName("LOTOSPath"); nl = doc.getElementsByTagName("LOTOSPath");
if (nl.getLength() > 0) if (nl.getLength() > 0)
LOTOSPath(nl); LOTOSPath(nl);
...@@ -898,6 +903,17 @@ public class ConfigurationTTool { ...@@ -898,6 +903,17 @@ public class ConfigurationTTool {
try { try {
Element elt = (Element)(nl.item(0)); Element elt = (Element)(nl.item(0));
FILEPath = elt.getAttribute("data"); 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) { } catch (Exception e) {
throw new MalformedConfigurationException(e.getMessage()); throw new MalformedConfigurationException(e.getMessage());
} }
......
...@@ -47,8 +47,10 @@ import javax.imageio.ImageIO; ...@@ -47,8 +47,10 @@ import javax.imageio.ImageIO;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
/** /**
...@@ -94,7 +96,7 @@ public final class URLManager implements Runnable { ...@@ -94,7 +96,7 @@ public final class URLManager implements Runnable {
} }
} catch (Exception e) { } catch (Exception e) {
if (callback != null) { if (callback != null) {
callback.loadFailed(); callback.loadFailed(e);
} }
} }
busy = false; busy = false;
......
...@@ -346,8 +346,8 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac ...@@ -346,8 +346,8 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
jta.append("Loading model: " + fileName); jta.append("Loading model: " + fileName);
String urlToLoad = URLManager.getBaseURL(url) + fileName; String urlToLoad = URLManager.getBaseURL(url) + fileName;
URLManager urlm = new URLManager(); URLManager urlm = new URLManager();
filePath = ConfigurationTTool.FILEPath + "/" + fileName; filePath = ConfigurationTTool.DownloadedFILEPath + "/" + fileName;
boolean ok = urlm.downloadFile(ConfigurationTTool.FILEPath + "/" + fileName, urlToLoad,this); boolean ok = urlm.downloadFile(filePath, urlToLoad,this);
if (!ok) { if (!ok) {
jta.append("Model transfer failed\nPlease, select another model, or retry\n"); jta.append("Model transfer failed\nPlease, select another model, or retry\n");
panel.reactivateSelection(); panel.reactivateSelection();
...@@ -370,11 +370,20 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac ...@@ -370,11 +370,20 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
//mgui.openProjectFromFile(new File(filePath)); //mgui.openProjectFromFile(new File(filePath));
} }
@Override
public void loadFailed() { public void loadFailed() {
jta.append("Model transfer failed\nPlease, select another model, or retry\n"); jta.append("Model transfer failed\nPlease, select another model, or retry\n");
panel.reactivateSelection(); 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 // JTA manipulation by external objects
public void appendOut(String s) { public void appendOut(String s) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment