Skip to content
Snippets Groups Projects
Commit d2dffec8 authored by apvrille's avatar apvrille
Browse files

Updating network model management

parent 5971e0d0
No related branches found
No related tags found
No related merge requests found
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
* *
* ludovic.apvrille AT enst.fr * ludovic.apvrille AT enst.fr
* *
* This software is a computer program whose purpose is to allow the * This software is a computer program whose purpose is to allow the
* edition of TURTLE analysis, design and deployment diagrams, to * edition of TURTLE analysis, design and deployment diagrams, to
* allow the generation of RT-LOTOS or Java code from this diagram, * allow the generation of RT-LOTOS or Java code from this diagram,
* and at last to allow the analysis of formal validation traces * and at last to allow the analysis of formal validation traces
* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
* from INRIA Rhone-Alpes. * from INRIA Rhone-Alpes.
* *
* This software is governed by the CeCILL license under French law and * This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use, * abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL * modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL * license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info". * "http://www.cecill.info".
* *
* As a counterpart to the access to the source code and rights to copy, * As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only * modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the * with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited * economic rights, and the successive licensors have only limited
* liability. * liability.
* *
* In this respect, the user's attention is drawn to the risks associated * In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the * with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software, * software by the user in light of its specific status of free software,
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* requirements in conditions enabling the security of their systems and/or * requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the * data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security. * same conditions as regards security.
* *
* The fact that you are presently reading this means that you have had * The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
*/ */
...@@ -153,9 +153,9 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac ...@@ -153,9 +153,9 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
JPanel options = new JPanel(); JPanel options = new JPanel();
JLabel infoModels = new JLabel("Not loaded"); JLabel infoModels = new JLabel("Not loaded");
options.add(infoModels); options.add(infoModels);
featureList = new JComboBox<String>(FEATURES); featureList = new JComboBox<String>(FEATURES);
featureList.addActionListener(this); featureList.addActionListener(this);
options.add(featureList); options.add(featureList);
...@@ -245,73 +245,78 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac ...@@ -245,73 +245,78 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
//connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); //connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
TraceManager.addDev("Connection setup 1");*/ TraceManager.addDev("Connection setup 1");*/
BufferedReader in = URLManager.getBufferedReader(url); BufferedReader in = URLManager.getBufferedReader(url);
jta.append("Connection established...\n"); if (in == null) {
String inputLine; jta.append("Could not establish a connection to the TTool server\n");
NetworkModel nm = null; } else {
while ((inputLine = in.readLine()) != null) { jta.append("Connection established...\n");
if (inputLine.startsWith("#FILE")) { String inputLine = null;
nm = new NetworkModel(inputLine.substring(5, inputLine.length()).trim()); NetworkModel nm = null;
listOfModels.add(nm); while ((inputLine = in.readLine()) != null) {
} if (inputLine.startsWith("#FILE")) {
nm = new NetworkModel(inputLine.substring(5, inputLine.length()).trim());
listOfModels.add(nm);
}
if (inputLine.startsWith("-FEATURES")) { if (inputLine.startsWith("-FEATURES")) {
if (nm != null) { if (nm != null) {
String tmp = inputLine.substring(9, inputLine.length()).trim().toLowerCase(); String tmp = inputLine.substring(9, inputLine.length()).trim().toLowerCase();
for (int i=1; i<FEATURES.length; i++) { for (int i=1; i<FEATURES.length; i++) {
nm.features[i] = tmp.indexOf(FEATURES[i]) != -1; nm.features[i] = tmp.indexOf(FEATURES[i]) != -1;
}
//nm.type = NetworkModel.stringToNetworkModelType(inputLine.substring(5, inputLine.length()).trim());
} }
//nm.type = NetworkModel.stringToNetworkModelType(inputLine.substring(5, inputLine.length()).trim());
} }
}
if (inputLine.startsWith("-PROPS")) { if (inputLine.startsWith("-PROPS")) {
if (nm != null) { if (nm != null) {
String tmp = inputLine.substring(6, inputLine.length()).trim().toLowerCase(); String tmp = inputLine.substring(6, inputLine.length()).trim().toLowerCase();
for (int i=0; i<PROPS.length; i++) { for (int i=0; i<PROPS.length; i++) {
nm.props[i] = tmp.indexOf(PROPS[i]) != -1; nm.props[i] = tmp.indexOf(PROPS[i]) != -1;
}
//nm.type = NetworkModel.stringToNetworkModelType(inputLine.substring(5, inputLine.length()).trim());
} }
//nm.type = NetworkModel.stringToNetworkModelType(inputLine.substring(5, inputLine.length()).trim());
} }
}
if (inputLine.startsWith("-AUTHOR")) { if (inputLine.startsWith("-AUTHOR")) {
if (nm != null) { if (nm != null) {
nm.author = inputLine.substring(7, inputLine.length()).trim(); nm.author = inputLine.substring(7, inputLine.length()).trim();
}
} }
}
if (inputLine.startsWith("-DESCRIPTION")) { if (inputLine.startsWith("-DESCRIPTION")) {
if (nm != null) { if (nm != null) {
nm.description = inputLine.substring(12, inputLine.length()).trim(); nm.description = inputLine.substring(12, inputLine.length()).trim();
}
} }
}
if (inputLine.startsWith("-IMG")) { if (inputLine.startsWith("-IMG")) {
if (nm != null) { if (nm != null) {
nm.image = inputLine.substring(4, inputLine.length()).trim(); nm.image = inputLine.substring(4, inputLine.length()).trim();
//TraceManager.addDev("Dealing with image:" + nm.image); //TraceManager.addDev("Dealing with image:" + nm.image);
//nm.bi = URLManager.getBufferedImageFromURL(URLManager.getBaseURL(url) + nm.image); //nm.bi = URLManager.getBufferedImageFromURL(URLManager.getBaseURL(url) + nm.image);
}
} }
//System.out.println(inputLine);
} }
//System.out.println(inputLine); jta.append("\n" + listOfModels.size() + " remote models found.\nSelect a model to download it locally and open it.\n\n");
mode = LISTED;
panel.preparePanel(url);
panel.repaint();
in.close();
// Wait 5seconds before refreshing panel
Thread.sleep(5000);
panel.repaint();
} }
jta.append("\n" + listOfModels.size() + " remote models found.\nSelect a model to download it locally and open it.\n\n");
mode = LISTED;
panel.preparePanel(url);
panel.repaint();
in.close();
// Wait 5seconds before refreshing panel
Thread.sleep(5000);
panel.repaint();
} catch (Exception e) { } catch (Exception e) {
jta.append("Error when retreiving file: " + url + "\n No internet connection?\n No right for the Java Virtual Machine to use http connections?\n\n"); jta.append("Error when retreiving file: " + url + "\n No internet connection?\n No right for the Java Virtual Machine to use http connections?\n\n");
TraceManager.addDev("Exception trace in loading network model:"); TraceManager.addDev("Exception trace in loading network model:");
e.printStackTrace(); e.printStackTrace();
} }
} }
...@@ -361,15 +366,15 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac ...@@ -361,15 +366,15 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
public void loadDone() { public void loadDone() {
jta.append("Model transfered, opening it in TTool\n"); jta.append("Model transfered, opening it in TTool\n");
this.dispose(); this.dispose();
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
mgui.openProjectFromFile(new File(filePath)); mgui.openProjectFromFile(new File(filePath));
// Here, we can safely update the GUI // Here, we can safely update the GUI
// because we'll be called from the // because we'll be called from the
// event dispatch thread // event dispatch thread
//statusLabel.setText("Query: " + queryNo); //statusLabel.setText("Query: " + queryNo);
} }
}); });
//mgui.openProjectFromFile(new File(filePath)); //mgui.openProjectFromFile(new File(filePath));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment