set specified external tools configs read only
+ automatic formatting
This commit is contained in:
parent
3bb9fda749
commit
b67baa7dfc
1 changed files with 210 additions and 152 deletions
|
@ -24,7 +24,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: GUI.java,v 1.55 2007/05/30 10:51:14 fros4943 Exp $
|
* $Id: GUI.java,v 1.56 2007/08/22 11:23:50 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -84,6 +84,7 @@ public class GUI {
|
||||||
public static final String EXTERNAL_TOOLS_USER_SETTINGS_FILENAME = ".cooja.user.properties";
|
public static final String EXTERNAL_TOOLS_USER_SETTINGS_FILENAME = ".cooja.user.properties";
|
||||||
private static File externalToolsUserSettingsFile =
|
private static File externalToolsUserSettingsFile =
|
||||||
new File(System.getProperty("user.home"), EXTERNAL_TOOLS_USER_SETTINGS_FILENAME);
|
new File(System.getProperty("user.home"), EXTERNAL_TOOLS_USER_SETTINGS_FILENAME);
|
||||||
|
private static boolean externalToolsUserSettingsFileReadOnly = false;
|
||||||
|
|
||||||
private static String specifiedContikiPath = null;
|
private static String specifiedContikiPath = null;
|
||||||
|
|
||||||
|
@ -107,11 +108,13 @@ public class GUI {
|
||||||
*/
|
*/
|
||||||
public static final FileFilter SAVED_SIMULATIONS_FILES = new FileFilter() {
|
public static final FileFilter SAVED_SIMULATIONS_FILES = new FileFilter() {
|
||||||
public boolean accept(File file) {
|
public boolean accept(File file) {
|
||||||
if (file.isDirectory())
|
if (file.isDirectory()) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (file.getName().endsWith(".csc"))
|
if (file.getName().endsWith(".csc")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -208,10 +211,12 @@ public class GUI {
|
||||||
myGUI = this;
|
myGUI = this;
|
||||||
mySimulation = null;
|
mySimulation = null;
|
||||||
myDesktopPane = desktop;
|
myDesktopPane = desktop;
|
||||||
if (menuPlugins == null)
|
if (menuPlugins == null) {
|
||||||
menuPlugins = new JMenu("Plugins");
|
menuPlugins = new JMenu("Plugins");
|
||||||
if (menuMotePluginClasses == null)
|
}
|
||||||
|
if (menuMotePluginClasses == null) {
|
||||||
menuMotePluginClasses = new Vector<Class<? extends Plugin>>();
|
menuMotePluginClasses = new Vector<Class<? extends Plugin>>();
|
||||||
|
}
|
||||||
|
|
||||||
// Load default and overwrite with user settings (if any)
|
// Load default and overwrite with user settings (if any)
|
||||||
loadExternalToolsDefaultSettings();
|
loadExternalToolsDefaultSettings();
|
||||||
|
@ -328,10 +333,11 @@ public class GUI {
|
||||||
|
|
||||||
String newHistoryConfig = null;
|
String newHistoryConfig = null;
|
||||||
for (String path: newHistory) {
|
for (String path: newHistory) {
|
||||||
if (newHistoryConfig == null)
|
if (newHistoryConfig == null) {
|
||||||
newHistoryConfig = path;
|
newHistoryConfig = path;
|
||||||
else
|
} else {
|
||||||
newHistoryConfig += ";" + path;
|
newHistoryConfig += ";" + path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setExternalToolsSetting("SIMCFG_HISTORY", newHistoryConfig);
|
setExternalToolsSetting("SIMCFG_HISTORY", newHistoryConfig);
|
||||||
|
@ -553,10 +559,11 @@ public class GUI {
|
||||||
menu.add(menuItem);
|
menu.add(menuItem);
|
||||||
|
|
||||||
// Plugins menu
|
// Plugins menu
|
||||||
if (menuPlugins == null)
|
if (menuPlugins == null) {
|
||||||
menuPlugins = new JMenu("Plugins");
|
menuPlugins = new JMenu("Plugins");
|
||||||
else
|
} else {
|
||||||
menuPlugins.setText("Plugins");
|
menuPlugins.setText("Plugins");
|
||||||
|
}
|
||||||
menuPlugins.setMnemonic(KeyEvent.VK_P);
|
menuPlugins.setMnemonic(KeyEvent.VK_P);
|
||||||
menuBar.add(menuPlugins);
|
menuBar.add(menuPlugins);
|
||||||
|
|
||||||
|
@ -583,8 +590,9 @@ public class GUI {
|
||||||
menu.add(menuItem);
|
menu.add(menuItem);
|
||||||
|
|
||||||
// Mote plugins popup menu (not available via menu bar)
|
// Mote plugins popup menu (not available via menu bar)
|
||||||
if (menuMotePluginClasses == null)
|
if (menuMotePluginClasses == null) {
|
||||||
menuMotePluginClasses = new Vector<Class<? extends Plugin>>();
|
menuMotePluginClasses = new Vector<Class<? extends Plugin>>();
|
||||||
|
}
|
||||||
return menuBar;
|
return menuBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,8 +606,9 @@ public class GUI {
|
||||||
|
|
||||||
// Create and set up the window.
|
// Create and set up the window.
|
||||||
frame = new JFrame("COOJA Simulator");
|
frame = new JFrame("COOJA Simulator");
|
||||||
if (maxSize != null)
|
if (maxSize != null) {
|
||||||
frame.setMaximizedBounds(maxSize);
|
frame.setMaximizedBounds(maxSize);
|
||||||
|
}
|
||||||
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
|
||||||
// Add menu bar
|
// Add menu bar
|
||||||
|
@ -712,8 +721,9 @@ public class GUI {
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
|
|
||||||
// Set manual Contiki path if specified
|
// Set manual Contiki path if specified
|
||||||
if (contikiPath != null)
|
if (contikiPath != null) {
|
||||||
setExternalToolsSetting("PATH_CONTIKI", contikiPath);
|
setExternalToolsSetting("PATH_CONTIKI", contikiPath);
|
||||||
|
}
|
||||||
|
|
||||||
// Parse project directories and create config
|
// Parse project directories and create config
|
||||||
if (projectDirs == null) {
|
if (projectDirs == null) {
|
||||||
|
@ -747,8 +757,9 @@ public class GUI {
|
||||||
|
|
||||||
// Check file permissions and paths
|
// Check file permissions and paths
|
||||||
logger.info("> Checking paths and file permissions");
|
logger.info("> Checking paths and file permissions");
|
||||||
if (moteTypeID == null)
|
if (moteTypeID == null) {
|
||||||
moteTypeID = "mtype1";
|
moteTypeID = "mtype1";
|
||||||
|
}
|
||||||
File contikiBaseDir = new File(getExternalToolsSetting("PATH_CONTIKI"));
|
File contikiBaseDir = new File(getExternalToolsSetting("PATH_CONTIKI"));
|
||||||
File contikiCoreDir = new File(contikiBaseDir,
|
File contikiCoreDir = new File(contikiBaseDir,
|
||||||
getExternalToolsSetting("PATH_COOJA_CORE_RELATIVE"));
|
getExternalToolsSetting("PATH_COOJA_CORE_RELATIVE"));
|
||||||
|
@ -758,12 +769,15 @@ public class GUI {
|
||||||
+ ContikiMoteType.mapSuffix);
|
+ ContikiMoteType.mapSuffix);
|
||||||
File depFile = new File(ContikiMoteType.tempOutputDirectory, moteTypeID
|
File depFile = new File(ContikiMoteType.tempOutputDirectory, moteTypeID
|
||||||
+ ContikiMoteType.dependSuffix);
|
+ ContikiMoteType.dependSuffix);
|
||||||
if (libFile.exists())
|
if (libFile.exists()) {
|
||||||
libFile.delete();
|
libFile.delete();
|
||||||
if (depFile.exists())
|
}
|
||||||
|
if (depFile.exists()) {
|
||||||
depFile.delete();
|
depFile.delete();
|
||||||
if (mapFile.exists())
|
}
|
||||||
|
if (mapFile.exists()) {
|
||||||
mapFile.delete();
|
mapFile.delete();
|
||||||
|
}
|
||||||
if (libFile.exists()) {
|
if (libFile.exists()) {
|
||||||
logger.fatal(">> Can't delete output file, aborting: " + libFile);
|
logger.fatal(">> Can't delete output file, aborting: " + libFile);
|
||||||
return false;
|
return false;
|
||||||
|
@ -804,9 +818,10 @@ public class GUI {
|
||||||
logger.info("> Setting up compilation arguments");
|
logger.info("> Setting up compilation arguments");
|
||||||
Vector<File> filesToCompile = new Vector<File>();
|
Vector<File> filesToCompile = new Vector<File>();
|
||||||
filesToCompile.add(mainProcessFile); // main process file
|
filesToCompile.add(mainProcessFile); // main process file
|
||||||
for (String projectDir : projectDirs)
|
for (String projectDir : projectDirs) {
|
||||||
// project directories
|
// project directories
|
||||||
filesToCompile.add(new File(projectDir));
|
filesToCompile.add(new File(projectDir));
|
||||||
|
}
|
||||||
String[] projectSources = // project config sources
|
String[] projectSources = // project config sources
|
||||||
gui.getProjectConfig().getStringArrayValue(ContikiMoteType.class,
|
gui.getProjectConfig().getStringArrayValue(ContikiMoteType.class,
|
||||||
"C_SOURCES");
|
"C_SOURCES");
|
||||||
|
@ -833,10 +848,11 @@ public class GUI {
|
||||||
sensors = new Vector<String>();
|
sensors = new Vector<String>();
|
||||||
Vector<String[]> scannedSensorInfo = ContikiMoteTypeDialog
|
Vector<String[]> scannedSensorInfo = ContikiMoteTypeDialog
|
||||||
.scanForSensors(contikiCoreDir);
|
.scanForSensors(contikiCoreDir);
|
||||||
for (String projectDir : projectDirs)
|
for (String projectDir : projectDirs) {
|
||||||
// project directories
|
// project directories
|
||||||
scannedSensorInfo.addAll(ContikiMoteTypeDialog.scanForSensors(new File(
|
scannedSensorInfo.addAll(ContikiMoteTypeDialog.scanForSensors(new File(
|
||||||
projectDir)));
|
projectDir)));
|
||||||
|
}
|
||||||
|
|
||||||
for (String[] sensorInfo : scannedSensorInfo) {
|
for (String[] sensorInfo : scannedSensorInfo) {
|
||||||
// logger.info(">> Found and added: " + sensorInfo[1] + " (" +
|
// logger.info(">> Found and added: " + sensorInfo[1] + " (" +
|
||||||
|
@ -851,10 +867,11 @@ public class GUI {
|
||||||
coreInterfaces = new Vector<String>();
|
coreInterfaces = new Vector<String>();
|
||||||
Vector<String[]> scannedCoreInterfaceInfo = ContikiMoteTypeDialog
|
Vector<String[]> scannedCoreInterfaceInfo = ContikiMoteTypeDialog
|
||||||
.scanForInterfaces(contikiCoreDir);
|
.scanForInterfaces(contikiCoreDir);
|
||||||
for (String projectDir : projectDirs)
|
for (String projectDir : projectDirs) {
|
||||||
// project directories
|
// project directories
|
||||||
scannedCoreInterfaceInfo.addAll(ContikiMoteTypeDialog
|
scannedCoreInterfaceInfo.addAll(ContikiMoteTypeDialog
|
||||||
.scanForInterfaces(new File(projectDir)));
|
.scanForInterfaces(new File(projectDir)));
|
||||||
|
}
|
||||||
|
|
||||||
for (String[] coreInterfaceInfo : scannedCoreInterfaceInfo) {
|
for (String[] coreInterfaceInfo : scannedCoreInterfaceInfo) {
|
||||||
// logger.info(">> Found and added: " + coreInterfaceInfo[1] + " (" +
|
// logger.info(">> Found and added: " + coreInterfaceInfo[1] + " (" +
|
||||||
|
@ -888,10 +905,11 @@ public class GUI {
|
||||||
Vector<String> autostartProcesses = new Vector<String>();
|
Vector<String> autostartProcesses = new Vector<String>();
|
||||||
Vector<String[]> scannedProcessInfo = ContikiMoteTypeDialog
|
Vector<String[]> scannedProcessInfo = ContikiMoteTypeDialog
|
||||||
.scanForProcesses(contikiCoreDir);
|
.scanForProcesses(contikiCoreDir);
|
||||||
for (String projectDir : projectDirs)
|
for (String projectDir : projectDirs) {
|
||||||
// project directories
|
// project directories
|
||||||
scannedProcessInfo.addAll(ContikiMoteTypeDialog
|
scannedProcessInfo.addAll(ContikiMoteTypeDialog
|
||||||
.scanForProcesses(new File(projectDir)));
|
.scanForProcesses(new File(projectDir)));
|
||||||
|
}
|
||||||
|
|
||||||
for (String[] processInfo : scannedProcessInfo) {
|
for (String[] processInfo : scannedProcessInfo) {
|
||||||
if (processInfo[0].equals(mainProcessFile.getName())) {
|
if (processInfo[0].equals(mainProcessFile.getName())) {
|
||||||
|
@ -906,8 +924,9 @@ public class GUI {
|
||||||
// processes");
|
// processes");
|
||||||
Vector<String> autostarters = ContikiMoteTypeDialog
|
Vector<String> autostarters = ContikiMoteTypeDialog
|
||||||
.parseAutostartProcesses(mainProcessFile);
|
.parseAutostartProcesses(mainProcessFile);
|
||||||
if (autostarters != null)
|
if (autostarters != null) {
|
||||||
autostartProcesses.addAll(autostarters);
|
autostartProcesses.addAll(autostarters);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger
|
logger
|
||||||
.fatal(">>> Error when parsing autostart processes, aborting: "
|
.fatal(">>> Error when parsing autostart processes, aborting: "
|
||||||
|
@ -944,8 +963,9 @@ public class GUI {
|
||||||
|
|
||||||
// Generate Contiki main source file
|
// Generate Contiki main source file
|
||||||
logger.info("> Generating Contiki main source file");
|
logger.info("> Generating Contiki main source file");
|
||||||
if (!ContikiMoteType.tempOutputDirectory.exists())
|
if (!ContikiMoteType.tempOutputDirectory.exists()) {
|
||||||
ContikiMoteType.tempOutputDirectory.mkdir();
|
ContikiMoteType.tempOutputDirectory.mkdir();
|
||||||
|
}
|
||||||
if (!ContikiMoteType.tempOutputDirectory.exists()) {
|
if (!ContikiMoteType.tempOutputDirectory.exists()) {
|
||||||
logger.fatal(">> Could not create output directory: "
|
logger.fatal(">> Could not create output directory: "
|
||||||
+ ContikiMoteType.tempOutputDirectory);
|
+ ContikiMoteType.tempOutputDirectory);
|
||||||
|
@ -969,8 +989,9 @@ public class GUI {
|
||||||
moteTypeID, contikiBaseDir, filesToCompile, false,
|
moteTypeID, contikiBaseDir, filesToCompile, false,
|
||||||
ContikiMoteType.CommunicationStack.UIP,
|
ContikiMoteType.CommunicationStack.UIP,
|
||||||
null, System.err);
|
null, System.err);
|
||||||
if (!libFile.exists() || !depFile.exists() || !mapFile.exists())
|
if (!libFile.exists() || !depFile.exists() || !mapFile.exists()) {
|
||||||
compilationSucceded = false;
|
compilationSucceded = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (compilationSucceded) {
|
if (compilationSucceded) {
|
||||||
// logger.info(">> Compilation complete");
|
// logger.info(">> Compilation complete");
|
||||||
|
@ -1032,14 +1053,16 @@ public class GUI {
|
||||||
ContikiMote mote = (ContikiMote) moteType.generateMote(simulation);
|
ContikiMote mote = (ContikiMote) moteType.generateMote(simulation);
|
||||||
|
|
||||||
// Set random position
|
// Set random position
|
||||||
if (mote.getInterfaces().getPosition() != null)
|
if (mote.getInterfaces().getPosition() != null) {
|
||||||
mote.getInterfaces().getPosition().setCoordinates(
|
mote.getInterfaces().getPosition().setCoordinates(
|
||||||
random.nextDouble() * areaSideLength,
|
random.nextDouble() * areaSideLength,
|
||||||
random.nextDouble() * areaSideLength, 0);
|
random.nextDouble() * areaSideLength, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Set unique mote ID's
|
// Set unique mote ID's
|
||||||
if (mote.getInterfaces().getMoteID() != null)
|
if (mote.getInterfaces().getMoteID() != null) {
|
||||||
mote.getInterfaces().getMoteID().setMoteID(nextMoteID++);
|
mote.getInterfaces().getMoteID().setMoteID(nextMoteID++);
|
||||||
|
}
|
||||||
|
|
||||||
// Set unique IP address
|
// Set unique IP address
|
||||||
if (mote.getInterfaces().getIPAddress() != null) {
|
if (mote.getInterfaces().getIPAddress() != null) {
|
||||||
|
@ -1314,9 +1337,10 @@ public class GUI {
|
||||||
if (registerTemporaryPlugin(pluginClass)) {
|
if (registerTemporaryPlugin(pluginClass)) {
|
||||||
// logger.info("Reregistered temporary plugin class: " +
|
// logger.info("Reregistered temporary plugin class: " +
|
||||||
// getDescriptionOf(pluginClass));
|
// getDescriptionOf(pluginClass));
|
||||||
} else
|
} else {
|
||||||
logger.warn("Could not reregister temporary plugin class: "
|
logger.warn("Could not reregister temporary plugin class: "
|
||||||
+ getDescriptionOf(pluginClass));
|
+ getDescriptionOf(pluginClass));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1544,8 +1568,9 @@ public class GUI {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newPlugin == null)
|
if (newPlugin == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Add to active plugins list
|
// Add to active plugins list
|
||||||
startedPlugins.add(newPlugin);
|
startedPlugins.add(newPlugin);
|
||||||
|
@ -1580,12 +1605,14 @@ public class GUI {
|
||||||
* @return True if this plugin was registered ok, false otherwise
|
* @return True if this plugin was registered ok, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean registerTemporaryPlugin(Class<? extends Plugin> newPluginClass) {
|
public boolean registerTemporaryPlugin(Class<? extends Plugin> newPluginClass) {
|
||||||
if (pluginClasses.contains(newPluginClass))
|
if (pluginClasses.contains(newPluginClass)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean returnVal = registerPlugin(newPluginClass, true);
|
boolean returnVal = registerPlugin(newPluginClass, true);
|
||||||
if (!returnVal)
|
if (!returnVal) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
pluginClassesTemporary.add(newPluginClass);
|
pluginClassesTemporary.add(newPluginClass);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1603,18 +1630,22 @@ public class GUI {
|
||||||
for (Component menuComponent : menuPlugins.getMenuComponents()) {
|
for (Component menuComponent : menuPlugins.getMenuComponents()) {
|
||||||
if (menuComponent.getClass().isAssignableFrom(JMenuItem.class)) {
|
if (menuComponent.getClass().isAssignableFrom(JMenuItem.class)) {
|
||||||
JMenuItem menuItem = (JMenuItem) menuComponent;
|
JMenuItem menuItem = (JMenuItem) menuComponent;
|
||||||
if (menuItem.getClientProperty("class").equals(pluginClass))
|
if (menuItem.getClientProperty("class").equals(pluginClass)) {
|
||||||
menuPlugins.remove(menuItem);
|
menuPlugins.remove(menuItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (menuMotePluginClasses.contains(pluginClass))
|
if (menuMotePluginClasses.contains(pluginClass)) {
|
||||||
menuMotePluginClasses.remove(pluginClass);
|
menuMotePluginClasses.remove(pluginClass);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove from plugin vectors (including temporary)
|
// Remove from plugin vectors (including temporary)
|
||||||
if (pluginClasses.contains(pluginClass))
|
if (pluginClasses.contains(pluginClass)) {
|
||||||
pluginClasses.remove(pluginClass);
|
pluginClasses.remove(pluginClass);
|
||||||
if (pluginClassesTemporary.contains(pluginClass))
|
}
|
||||||
|
if (pluginClassesTemporary.contains(pluginClass)) {
|
||||||
pluginClassesTemporary.remove(pluginClass);
|
pluginClassesTemporary.remove(pluginClass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1734,17 +1765,19 @@ public class GUI {
|
||||||
mySimulation = sim;
|
mySimulation = sim;
|
||||||
|
|
||||||
// Set frame title
|
// Set frame title
|
||||||
if (frame != null)
|
if (frame != null) {
|
||||||
frame.setTitle("COOJA Simulator" + " - " + sim.getTitle());
|
frame.setTitle("COOJA Simulator" + " - " + sim.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
// Open standard plugins (if none opened already)
|
// Open standard plugins (if none opened already)
|
||||||
if (startedPlugins.size() == 0)
|
if (startedPlugins.size() == 0) {
|
||||||
for (Class<? extends Plugin> pluginClass : pluginClasses) {
|
for (Class<? extends Plugin> pluginClass : pluginClasses) {
|
||||||
int pluginType = pluginClass.getAnnotation(PluginType.class).value();
|
int pluginType = pluginClass.getAnnotation(PluginType.class).value();
|
||||||
if (pluginType == PluginType.SIM_STANDARD_PLUGIN) {
|
if (pluginType == PluginType.SIM_STANDARD_PLUGIN) {
|
||||||
startPlugin(pluginClass, this, sim, null);
|
startPlugin(pluginClass, this, sim, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1813,8 +1846,9 @@ public class GUI {
|
||||||
int pluginType = startedPlugin.getClass().getAnnotation(
|
int pluginType = startedPlugin.getClass().getAnnotation(
|
||||||
PluginType.class).value();
|
PluginType.class).value();
|
||||||
if (pluginType != PluginType.COOJA_PLUGIN
|
if (pluginType != PluginType.COOJA_PLUGIN
|
||||||
&& pluginType != PluginType.COOJA_STANDARD_PLUGIN)
|
&& pluginType != PluginType.COOJA_STANDARD_PLUGIN) {
|
||||||
removePlugin((Plugin) startedPlugin, false);
|
removePlugin((Plugin) startedPlugin, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete simulation
|
// Delete simulation
|
||||||
|
@ -1921,14 +1955,16 @@ public class GUI {
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
showErrorDialog(frame, "Simulation load error", e, false);
|
showErrorDialog(frame, "Simulation load error", e, false);
|
||||||
|
|
||||||
if (progressDialog != null && progressDialog.isDisplayable())
|
if (progressDialog != null && progressDialog.isDisplayable()) {
|
||||||
progressDialog.dispose();
|
progressDialog.dispose();
|
||||||
|
}
|
||||||
newSim = null;
|
newSim = null;
|
||||||
} catch (SimulationCreationException e) {
|
} catch (SimulationCreationException e) {
|
||||||
showErrorDialog(frame, "Simulation load error", e, false);
|
showErrorDialog(frame, "Simulation load error", e, false);
|
||||||
|
|
||||||
if (progressDialog != null && progressDialog.isDisplayable())
|
if (progressDialog != null && progressDialog.isDisplayable()) {
|
||||||
progressDialog.dispose();
|
progressDialog.dispose();
|
||||||
|
}
|
||||||
newSim = null;
|
newSim = null;
|
||||||
}
|
}
|
||||||
if (newSim != null) {
|
if (newSim != null) {
|
||||||
|
@ -1970,12 +2006,13 @@ public class GUI {
|
||||||
progressDialog.setLocationRelativeTo(frame);
|
progressDialog.setLocationRelativeTo(frame);
|
||||||
progressDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
|
progressDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
|
||||||
loadThread.start();
|
loadThread.start();
|
||||||
if (quick)
|
if (quick) {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
progressDialog.setVisible(true);
|
progressDialog.setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2042,8 +2079,9 @@ public class GUI {
|
||||||
Element root = new Element("simconf");
|
Element root = new Element("simconf");
|
||||||
root.addContent(simulationElement);
|
root.addContent(simulationElement);
|
||||||
|
|
||||||
if (pluginsConfig != null)
|
if (pluginsConfig != null) {
|
||||||
root.addContent(pluginsConfig);
|
root.addContent(pluginsConfig);
|
||||||
|
}
|
||||||
|
|
||||||
Document doc = new Document(root);
|
Document doc = new Document(root);
|
||||||
XMLOutputter outputter = new XMLOutputter();
|
XMLOutputter outputter = new XMLOutputter();
|
||||||
|
@ -2166,8 +2204,9 @@ public class GUI {
|
||||||
if (!saveFile.exists() || saveFile.canWrite()) {
|
if (!saveFile.exists() || saveFile.canWrite()) {
|
||||||
saveSimulationConfig(saveFile);
|
saveSimulationConfig(saveFile);
|
||||||
addToFileHistory(saveFile);
|
addToFileHistory(saveFile);
|
||||||
} else
|
} else {
|
||||||
logger.fatal("No write access to file");
|
logger.fatal("No write access to file");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.info("Save command cancelled by user...");
|
logger.info("Save command cancelled by user...");
|
||||||
|
@ -2185,12 +2224,14 @@ public class GUI {
|
||||||
Vector<Mote> newMotes = AddMoteDialog.showDialog(frame, mySimulation,
|
Vector<Mote> newMotes = AddMoteDialog.showDialog(frame, mySimulation,
|
||||||
moteType);
|
moteType);
|
||||||
if (newMotes != null) {
|
if (newMotes != null) {
|
||||||
for (Mote newMote : newMotes)
|
for (Mote newMote : newMotes) {
|
||||||
mySimulation.addMote(newMote);
|
mySimulation.addMote(newMote);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else {
|
||||||
logger.warn("No simulation active");
|
logger.warn("No simulation active");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2236,14 +2277,16 @@ public class GUI {
|
||||||
int n = JOptionPane.showOptionDialog(frame, "Sure you want to quit?",
|
int n = JOptionPane.showOptionDialog(frame, "Sure you want to quit?",
|
||||||
"Close COOJA Simulator", JOptionPane.YES_NO_OPTION,
|
"Close COOJA Simulator", JOptionPane.YES_NO_OPTION,
|
||||||
JOptionPane.QUESTION_MESSAGE, null, options, s1);
|
JOptionPane.QUESTION_MESSAGE, null, options, s1);
|
||||||
if (n != JOptionPane.YES_OPTION)
|
if (n != JOptionPane.YES_OPTION) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up resources
|
// Clean up resources
|
||||||
Object[] plugins = startedPlugins.toArray();
|
Object[] plugins = startedPlugins.toArray();
|
||||||
for (Object plugin : plugins)
|
for (Object plugin : plugins) {
|
||||||
removePlugin((Plugin) plugin, false);
|
removePlugin((Plugin) plugin, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Restore last frame size and position
|
// Restore last frame size and position
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
|
@ -2323,8 +2366,9 @@ public class GUI {
|
||||||
*/
|
*/
|
||||||
public static void loadExternalToolsDefaultSettings() {
|
public static void loadExternalToolsDefaultSettings() {
|
||||||
String filename = GUI.EXTERNAL_TOOLS_LINUX_SETTINGS_FILENAME;
|
String filename = GUI.EXTERNAL_TOOLS_LINUX_SETTINGS_FILENAME;
|
||||||
if (System.getProperty("os.name").startsWith("Win"))
|
if (System.getProperty("os.name").startsWith("Win")) {
|
||||||
filename = GUI.EXTERNAL_TOOLS_WIN32_SETTINGS_FILENAME;
|
filename = GUI.EXTERNAL_TOOLS_WIN32_SETTINGS_FILENAME;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InputStream in = GUI.class.getResourceAsStream(filename);
|
InputStream in = GUI.class.getResourceAsStream(filename);
|
||||||
|
@ -2377,6 +2421,10 @@ public class GUI {
|
||||||
* Save external tools user settings to file.
|
* Save external tools user settings to file.
|
||||||
*/
|
*/
|
||||||
public static void saveExternalToolsUserSettings() {
|
public static void saveExternalToolsUserSettings() {
|
||||||
|
if (externalToolsUserSettingsFileReadOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileOutputStream out = new FileOutputStream(externalToolsUserSettingsFile);
|
FileOutputStream out = new FileOutputStream(externalToolsUserSettingsFile);
|
||||||
|
|
||||||
|
@ -2458,12 +2506,14 @@ public class GUI {
|
||||||
ExternalToolsDialog.showDialog(frame);
|
ExternalToolsDialog.showDialog(frame);
|
||||||
} else if (e.getActionCommand().equals("close plugins")) {
|
} else if (e.getActionCommand().equals("close plugins")) {
|
||||||
Object[] plugins = startedPlugins.toArray();
|
Object[] plugins = startedPlugins.toArray();
|
||||||
for (Object plugin : plugins)
|
for (Object plugin : plugins) {
|
||||||
removePlugin((Plugin) plugin, false);
|
removePlugin((Plugin) plugin, false);
|
||||||
|
}
|
||||||
} else if (e.getActionCommand().equals("remove all motes")) {
|
} else if (e.getActionCommand().equals("remove all motes")) {
|
||||||
if (getSimulation() != null) {
|
if (getSimulation() != null) {
|
||||||
if (getSimulation().isRunning())
|
if (getSimulation().isRunning()) {
|
||||||
getSimulation().stopSimulation();
|
getSimulation().stopSimulation();
|
||||||
|
}
|
||||||
|
|
||||||
while (getSimulation().getMotesCount() > 0) {
|
while (getSimulation().getMotesCount() > 0) {
|
||||||
getSimulation().removeMote(getSimulation().getMote(0));
|
getSimulation().removeMote(getSimulation().getMote(0));
|
||||||
|
@ -2481,8 +2531,9 @@ public class GUI {
|
||||||
.getSource()).getClientProperty("class");
|
.getSource()).getClientProperty("class");
|
||||||
Mote mote = (Mote) ((JMenuItem) e.getSource()).getClientProperty("mote");
|
Mote mote = (Mote) ((JMenuItem) e.getSource()).getClientProperty("mote");
|
||||||
startPlugin(pluginClass, myGUI, mySimulation, mote);
|
startPlugin(pluginClass, myGUI, mySimulation, mote);
|
||||||
} else
|
} else {
|
||||||
logger.warn("Unhandled action: " + e.getActionCommand());
|
logger.warn("Unhandled action: " + e.getActionCommand());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2590,7 +2641,7 @@ public class GUI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new URLClassLoader((URL[]) urls.toArray(new URL[urls.size()]),
|
return new URLClassLoader(urls.toArray(new URL[urls.size()]),
|
||||||
parent);
|
parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2640,14 +2691,14 @@ public class GUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse general command arguments
|
// Parse general command arguments
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (String element : args) {
|
||||||
if (args[i].startsWith("-contiki=")) {
|
if (element.startsWith("-contiki=")) {
|
||||||
String arg = args[i].substring("-contiki=".length());
|
String arg = element.substring("-contiki=".length());
|
||||||
GUI.specifiedContikiPath = arg;
|
GUI.specifiedContikiPath = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[i].startsWith("-external_tools_config=")) {
|
if (element.startsWith("-external_tools_config=")) {
|
||||||
String arg = args[i].substring("-external_tools_config=".length());
|
String arg = element.substring("-external_tools_config=".length());
|
||||||
File specifiedExternalToolsConfigFile = new File(arg);
|
File specifiedExternalToolsConfigFile = new File(arg);
|
||||||
if (!specifiedExternalToolsConfigFile.exists()) {
|
if (!specifiedExternalToolsConfigFile.exists()) {
|
||||||
logger.fatal("Specified external tools configuration not found: " + specifiedExternalToolsConfigFile);
|
logger.fatal("Specified external tools configuration not found: " + specifiedExternalToolsConfigFile);
|
||||||
|
@ -2655,6 +2706,7 @@ public class GUI {
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
} else {
|
} else {
|
||||||
GUI.externalToolsUserSettingsFile = specifiedExternalToolsConfigFile;
|
GUI.externalToolsUserSettingsFile = specifiedExternalToolsConfigFile;
|
||||||
|
GUI.externalToolsUserSettingsFileReadOnly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2685,29 +2737,33 @@ public class GUI {
|
||||||
String arg = args[i].substring("-projects=".length());
|
String arg = args[i].substring("-projects=".length());
|
||||||
String[] argArray = arg.split(",");
|
String[] argArray = arg.split(",");
|
||||||
projectDirs = new Vector<String>();
|
projectDirs = new Vector<String>();
|
||||||
for (String argValue : argArray)
|
for (String argValue : argArray) {
|
||||||
projectDirs.add(argValue);
|
projectDirs.add(argValue);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (args[i].startsWith("-sensors=")) {
|
} else if (args[i].startsWith("-sensors=")) {
|
||||||
String arg = args[i].substring("-sensors=".length());
|
String arg = args[i].substring("-sensors=".length());
|
||||||
String[] argArray = arg.split(",");
|
String[] argArray = arg.split(",");
|
||||||
sensors = new Vector<String>();
|
sensors = new Vector<String>();
|
||||||
for (String argValue : argArray)
|
for (String argValue : argArray) {
|
||||||
sensors.add(argValue);
|
sensors.add(argValue);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (args[i].startsWith("-interfaces=")) {
|
} else if (args[i].startsWith("-interfaces=")) {
|
||||||
String arg = args[i].substring("-interfaces=".length());
|
String arg = args[i].substring("-interfaces=".length());
|
||||||
String[] argArray = arg.split(",");
|
String[] argArray = arg.split(",");
|
||||||
coreInterfaces = new Vector<String>();
|
coreInterfaces = new Vector<String>();
|
||||||
for (String argValue : argArray)
|
for (String argValue : argArray) {
|
||||||
coreInterfaces.add(argValue);
|
coreInterfaces.add(argValue);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (args[i].startsWith("-processes=")) {
|
} else if (args[i].startsWith("-processes=")) {
|
||||||
String arg = args[i].substring("-processes=".length());
|
String arg = args[i].substring("-processes=".length());
|
||||||
String[] argArray = arg.split(",");
|
String[] argArray = arg.split(",");
|
||||||
userProcesses = new Vector<String>();
|
userProcesses = new Vector<String>();
|
||||||
for (String argValue : argArray)
|
for (String argValue : argArray) {
|
||||||
userProcesses.add(argValue);
|
userProcesses.add(argValue);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (args[i].equals("-noautostartscan")) {
|
} else if (args[i].equals("-noautostartscan")) {
|
||||||
addAutostartProcesses = false;
|
addAutostartProcesses = false;
|
||||||
|
@ -2740,8 +2796,9 @@ public class GUI {
|
||||||
boolean ok = quickStartSimulation(moteTypeID, projectDirs, sensors,
|
boolean ok = quickStartSimulation(moteTypeID, projectDirs, sensors,
|
||||||
coreInterfaces, userProcesses, addAutostartProcesses, numberOfNodes,
|
coreInterfaces, userProcesses, addAutostartProcesses, numberOfNodes,
|
||||||
areaSideLength, delayTime, startSimulation, filename, contikiPath);
|
areaSideLength, delayTime, startSimulation, filename, contikiPath);
|
||||||
if (!ok)
|
if (!ok) {
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (args.length > 0 && args[0].startsWith("-nogui")) {
|
} else if (args.length > 0 && args[0].startsWith("-nogui")) {
|
||||||
|
|
||||||
|
@ -2879,8 +2936,9 @@ public class GUI {
|
||||||
|
|
||||||
// Create started plugins config
|
// Create started plugins config
|
||||||
Collection<Element> pluginsConfig = getPluginsConfigXML();
|
Collection<Element> pluginsConfig = getPluginsConfigXML();
|
||||||
if (pluginsConfig != null)
|
if (pluginsConfig != null) {
|
||||||
root.addContent(pluginsConfig);
|
root.addContent(pluginsConfig);
|
||||||
|
}
|
||||||
|
|
||||||
// Create and write to document
|
// Create and write to document
|
||||||
Document doc = new Document(root);
|
Document doc = new Document(root);
|
||||||
|
@ -2914,8 +2972,9 @@ public class GUI {
|
||||||
|
|
||||||
// Ignore GUI plugins
|
// Ignore GUI plugins
|
||||||
if (pluginType == PluginType.COOJA_PLUGIN
|
if (pluginType == PluginType.COOJA_PLUGIN
|
||||||
|| pluginType == PluginType.COOJA_STANDARD_PLUGIN)
|
|| pluginType == PluginType.COOJA_STANDARD_PLUGIN) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
pluginElement = new Element("plugin");
|
pluginElement = new Element("plugin");
|
||||||
pluginElement.setText(startedPlugin.getClass().getName());
|
pluginElement.setText(startedPlugin.getClass().getName());
|
||||||
|
@ -3114,8 +3173,9 @@ public class GUI {
|
||||||
String message = title;
|
String message = title;
|
||||||
|
|
||||||
// Create message
|
// Create message
|
||||||
if (exception != null)
|
if (exception != null) {
|
||||||
message = exception.getMessage();
|
message = exception.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
// Create stack trace message list
|
// Create stack trace message list
|
||||||
if (exception != null) {
|
if (exception != null) {
|
||||||
|
@ -3140,14 +3200,11 @@ public class GUI {
|
||||||
|
|
||||||
// Create error dialog
|
// Create error dialog
|
||||||
final JDialog errorDialog;
|
final JDialog errorDialog;
|
||||||
if (parentComponent instanceof Dialog)
|
if (parentComponent instanceof Dialog) {
|
||||||
errorDialog = new JDialog((Dialog) parentComponent, title, true);
|
errorDialog = new JDialog((Dialog) parentComponent, title, true);
|
||||||
else if (parentComponent instanceof Frame)
|
} else if (parentComponent instanceof Frame) {
|
||||||
errorDialog = new JDialog((Frame) parentComponent, title, true);
|
errorDialog = new JDialog((Frame) parentComponent, title, true);
|
||||||
// else if (parentComponent instanceof Window)
|
} else {
|
||||||
// errorDialog = new JDialog((Window) parentComponent, title,
|
|
||||||
// ModalityType.APPLICATION_MODAL);
|
|
||||||
else {
|
|
||||||
logger.fatal("Bad parent for error dialog");
|
logger.fatal("Bad parent for error dialog");
|
||||||
errorDialog = new JDialog((Frame) null, title + " (Java stack trace)");
|
errorDialog = new JDialog((Frame) null, title + " (Java stack trace)");
|
||||||
}
|
}
|
||||||
|
@ -3283,8 +3340,9 @@ public class GUI {
|
||||||
errorDialog.setLocationRelativeTo(parentComponent);
|
errorDialog.setLocationRelativeTo(parentComponent);
|
||||||
errorDialog.setVisible(true);
|
errorDialog.setVisible(true);
|
||||||
|
|
||||||
if (errorDialog.getTitle().equals("-RETRY-"))
|
if (errorDialog.getTitle().equals("-RETRY-")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue