Refactored window title that was duplicated in multiple places

This commit is contained in:
Adam Dunkels 2012-05-31 18:01:53 +02:00
parent f8da0ea206
commit cb00219096
1 changed files with 104 additions and 100 deletions

View File

@ -143,7 +143,7 @@ import se.sics.cooja.util.ExecuteJAR;
* Main file of COOJA Simulator. Typically contains a visualizer for the * Main file of COOJA Simulator. Typically contains a visualizer for the
* simulator, but can also be started without visualizer. * simulator, but can also be started without visualizer.
* *
* This class loads external Java classes (in project directories), and handles the * This class loads external Java classes (in extension directories), and handles the
* COOJA plugins as well as the configuration system. If provides a number of * COOJA plugins as well as the configuration system. If provides a number of
* help methods for the rest of the COOJA system, and is the starting point for * help methods for the rest of the COOJA system, and is the starting point for
* loading and saving simulation configs. * loading and saving simulation configs.
@ -197,12 +197,12 @@ public class GUI extends Observable {
public static final String LOG_CONFIG_FILE = "log4j_config.xml"; public static final String LOG_CONFIG_FILE = "log4j_config.xml";
/** /**
* Default project configuration filename. * Default extension configuration filename.
*/ */
public static String PROJECT_DEFAULT_CONFIG_FILENAME = null; public static String PROJECT_DEFAULT_CONFIG_FILENAME = null;
/** /**
* User project configuration filename. * User extension configuration filename.
*/ */
public static final String PROJECT_CONFIG_FILENAME = "cooja.config"; public static final String PROJECT_CONFIG_FILENAME = "cooja.config";
@ -225,7 +225,7 @@ public class GUI extends Observable {
return false; return false;
} }
public String getDescription() { public String getDescription() {
return "COOJA Configuration files (.csc or .csc.gz)"; return "Cooja simulation (.csc, .csc.gz)";
} }
public String toString() { public String toString() {
return ".csc"; return ".csc";
@ -281,6 +281,8 @@ public class GUI extends Observable {
private static final int FRAME_STANDARD_HEIGHT = 300; private static final int FRAME_STANDARD_HEIGHT = 300;
private static final String WINDOW_TITLE = "Cooja: The Contiki Simulation Environment";
private GUI myGUI; private GUI myGUI;
private Simulation mySimulation; private Simulation mySimulation;
@ -361,7 +363,7 @@ public class GUI extends Observable {
mySimulation = null; mySimulation = null;
myDesktopPane = desktop; myDesktopPane = desktop;
if (menuPlugins == null) { if (menuPlugins == null) {
menuPlugins = new JMenu("Plugins"); menuPlugins = new JMenu("Tools");
menuPlugins.removeAll(); menuPlugins.removeAll();
/* COOJA/GUI plugins at top, simulation plugins in middle, mote plugins at bottom */ /* COOJA/GUI plugins at top, simulation plugins in middle, mote plugins at bottom */
@ -400,7 +402,7 @@ public class GUI extends Observable {
} }
});*/ });*/
// Register default project directories // Register default extension directories
String defaultProjectDirs = getExternalToolsSetting("DEFAULT_PROJECTDIRS", null); String defaultProjectDirs = getExternalToolsSetting("DEFAULT_PROJECTDIRS", null);
if (defaultProjectDirs != null && defaultProjectDirs.length() > 0) { if (defaultProjectDirs != null && defaultProjectDirs.length() > 0) {
String[] arr = defaultProjectDirs.split(";"); String[] arr = defaultProjectDirs.split(";");
@ -410,18 +412,18 @@ public class GUI extends Observable {
} }
} }
/* Parse current project configuration */ /* Parse current extension configuration */
try { try {
reparseProjectConfig(); reparseProjectConfig();
} catch (ParseProjectsException e) { } catch (ParseProjectsException e) {
logger.fatal("Error when loading projects: " + e.getMessage(), e); logger.fatal("Error when loading extensions: " + e.getMessage(), e);
if (isVisualized()) { if (isVisualized()) {
JOptionPane.showMessageDialog(GUI.getTopParentContainer(), JOptionPane.showMessageDialog(GUI.getTopParentContainer(),
"All COOJA projects could not load.\n\n" + "All Cooja extensions could not load.\n\n" +
"To manage COOJA projects:\n" + "To manage Cooja extensions:\n" +
"Menu->Settings->COOJA projects", "Menu->Settings->Cooja extensions",
"Reconfigure COOJA projects", JOptionPane.INFORMATION_MESSAGE); "Reconfigure Cooja extensions", JOptionPane.INFORMATION_MESSAGE);
showErrorDialog(getTopParentContainer(), "COOJA projects load error", e, false); showErrorDialog(getTopParentContainer(), "Cooja extensions load error", e, false);
} }
} }
@ -667,7 +669,7 @@ public class GUI extends Observable {
guiActions.add(reloadSimulationAction); guiActions.add(reloadSimulationAction);
guiActions.add(reloadRandomSimulationAction); guiActions.add(reloadRandomSimulationAction);
guiActions.add(saveSimulationAction); guiActions.add(saveSimulationAction);
guiActions.add(closePluginsAction); /* guiActions.add(closePluginsAction);*/
guiActions.add(exportExecutableJARAction); guiActions.add(exportExecutableJARAction);
guiActions.add(exitCoojaAction); guiActions.add(exitCoojaAction);
guiActions.add(startStopSimulationAction); guiActions.add(startStopSimulationAction);
@ -692,13 +694,6 @@ public class GUI extends Observable {
menu.add(new JMenuItem(newSimulationAction)); menu.add(new JMenuItem(newSimulationAction));
menuItem = new JMenu("Reload simulation");
menuItem.add(new JMenuItem(reloadSimulationAction));
menuItem.add(new JMenuItem(reloadRandomSimulationAction));
menu.add(menuItem);
menu.add(new JMenuItem(closeSimulationAction));
menuOpenSimulation = new JMenu("Open simulation"); menuOpenSimulation = new JMenu("Open simulation");
menuOpenSimulation.setMnemonic(KeyEvent.VK_O); menuOpenSimulation.setMnemonic(KeyEvent.VK_O);
menu.add(menuOpenSimulation); menu.add(menuOpenSimulation);
@ -707,15 +702,23 @@ public class GUI extends Observable {
menuOpenSimulation.setToolTipText("Not available in applet version"); menuOpenSimulation.setToolTipText("Not available in applet version");
} }
menu.add(new JMenuItem(closeSimulationAction));
hasFileHistoryChanged = true; hasFileHistoryChanged = true;
menu.add(new JMenuItem(saveSimulationAction)); menu.add(new JMenuItem(saveSimulationAction));
menu.addSeparator();
menu.add(new JMenuItem(closePluginsAction));
menu.add(new JMenuItem(exportExecutableJARAction)); menu.add(new JMenuItem(exportExecutableJARAction));
menuItem = new JMenu("Reload simulation");
menuItem.add(new JMenuItem(reloadSimulationAction));
menuItem.add(new JMenuItem(reloadRandomSimulationAction));
menu.add(menuItem);
/* menu.addSeparator();*/
/* menu.add(new JMenuItem(closePluginsAction));*/
menu.addSeparator(); menu.addSeparator();
menu.add(new JMenuItem(exitCoojaAction)); menu.add(new JMenuItem(exitCoojaAction));
@ -736,14 +739,14 @@ public class GUI extends Observable {
menu.add(new JMenuItem(startStopSimulationAction)); menu.add(new JMenuItem(startStopSimulationAction));
GUIAction guiAction = new StartPluginGUIAction("Control panel"); GUIAction guiAction = new StartPluginGUIAction("Control panel...");
menuItem = new JMenuItem(guiAction); menuItem = new JMenuItem(guiAction);
guiActions.add(guiAction); guiActions.add(guiAction);
menuItem.setMnemonic(KeyEvent.VK_C); menuItem.setMnemonic(KeyEvent.VK_C);
menuItem.putClientProperty("class", SimControl.class); menuItem.putClientProperty("class", SimControl.class);
menu.add(menuItem); menu.add(menuItem);
guiAction = new StartPluginGUIAction("Information"); guiAction = new StartPluginGUIAction("Simulation...");
menuItem = new JMenuItem(guiAction); menuItem = new JMenuItem(guiAction);
guiActions.add(guiAction); guiActions.add(guiAction);
menuItem.setMnemonic(KeyEvent.VK_I); menuItem.setMnemonic(KeyEvent.VK_I);
@ -751,7 +754,7 @@ public class GUI extends Observable {
menu.add(menuItem); menu.add(menuItem);
// Mote type menu // Mote type menu
menu = new JMenu("Mote Types"); menu = new JMenu("Mote types");
menu.addMenuListener(new MenuListener() { menu.addMenuListener(new MenuListener() {
public void menuSelected(MenuEvent e) { public void menuSelected(MenuEvent e) {
updateGUIComponentState(); updateGUIComponentState();
@ -829,7 +832,7 @@ public class GUI extends Observable {
}); });
menu.add(menuMoteTypeClasses); menu.add(menuMoteTypeClasses);
guiAction = new StartPluginGUIAction("Information"); guiAction = new StartPluginGUIAction("Mote types...");
menuItem = new JMenuItem(guiAction); menuItem = new JMenuItem(guiAction);
guiActions.add(guiAction); guiActions.add(guiAction);
menuItem.putClientProperty("class", MoteTypeInformation.class); menuItem.putClientProperty("class", MoteTypeInformation.class);
@ -883,18 +886,19 @@ public class GUI extends Observable {
}); });
menu.add(menuMoteTypes); menu.add(menuMoteTypes);
menu.add(new JMenuItem(removeAllMotesAction)); menu.add(new JMenuItem(removeAllMotesAction));
// Plugins menu // Plugins menu
if (menuPlugins == null) { if (menuPlugins == null) {
menuPlugins = new JMenu("Plugins"); menuPlugins = new JMenu("Tools");
menuPlugins.removeAll(); menuPlugins.removeAll();
/* COOJA/GUI plugins at top, simulation plugins in middle, mote plugins at bottom */ /* COOJA/GUI plugins at top, simulation plugins in middle, mote plugins at bottom */
menuPlugins.addSeparator(); menuPlugins.addSeparator();
menuPlugins.addSeparator(); menuPlugins.addSeparator();
} else { } else {
menuPlugins.setText("Plugins"); menuPlugins.setText("Tools");
} }
menuPlugins.setMnemonic(KeyEvent.VK_P); menuPlugins.setMnemonic(KeyEvent.VK_P);
menuBar.add(menuPlugins); menuBar.add(menuPlugins);
@ -967,7 +971,7 @@ public class GUI extends Observable {
}); });
menuBar.add(menu); menuBar.add(menu);
menuItem = new JMenuItem("External tools paths"); menuItem = new JMenuItem("External tools paths...");
menuItem.setActionCommand("edit paths"); menuItem.setActionCommand("edit paths");
menuItem.addActionListener(guiEventHandler); menuItem.addActionListener(guiEventHandler);
menu.add(menuItem); menu.add(menuItem);
@ -976,8 +980,8 @@ public class GUI extends Observable {
menuItem.setToolTipText("Not available in applet version"); menuItem.setToolTipText("Not available in applet version");
} }
menuItem = new JMenuItem("COOJA projects"); menuItem = new JMenuItem("Cooja extensions...");
menuItem.setActionCommand("manage projects"); menuItem.setActionCommand("manage extensions");
menuItem.addActionListener(guiEventHandler); menuItem.addActionListener(guiEventHandler);
menu.add(menuItem); menu.add(menuItem);
if (isVisualizedInApplet()) { if (isVisualizedInApplet()) {
@ -985,7 +989,7 @@ public class GUI extends Observable {
menuItem.setToolTipText("Not available in applet version"); menuItem.setToolTipText("Not available in applet version");
} }
menuItem = new JMenuItem("Contiki mote configuration wizard"); menuItem = new JMenuItem("Cooja mote configuration wizard...");
menuItem.setActionCommand("configuration wizard"); menuItem.setActionCommand("configuration wizard");
menuItem.addActionListener(guiEventHandler); menuItem.addActionListener(guiEventHandler);
menu.add(menuItem); menu.add(menuItem);
@ -1012,11 +1016,11 @@ public class GUI extends Observable {
+ System.getProperty("java.vendor") + ")"); + System.getProperty("java.vendor") + ")");
menuItem.setEnabled(false); menuItem.setEnabled(false);
menu.add(menuItem); menu.add(menuItem);
menuItem = new JMenuItem("System's \"os.arch\": " menuItem = new JMenuItem("System \"os.arch\": "
+ System.getProperty("os.arch")); + System.getProperty("os.arch"));
menuItem.setEnabled(false); menuItem.setEnabled(false);
menu.add(menuItem); menu.add(menuItem);
menuItem = new JMenuItem("System's \"sun.arch.data.model\": " menuItem = new JMenuItem("System \"sun.arch.data.model\": "
+ System.getProperty("sun.arch.data.model")); + System.getProperty("sun.arch.data.model"));
menuItem.setEnabled(false); menuItem.setEnabled(false);
menu.add(menuItem); menu.add(menuItem);
@ -1031,7 +1035,7 @@ public class GUI extends Observable {
private static void configureFrame(final GUI gui, boolean createSimDialog) { private static void configureFrame(final GUI gui, boolean createSimDialog) {
if (frame == null) { if (frame == null) {
frame = new JFrame("COOJA Simulator"); frame = new JFrame(WINDOW_TITLE);
} }
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
@ -1217,10 +1221,10 @@ public class GUI extends Observable {
} }
public static Simulation quickStartSimulationConfig(File config, boolean vis) { public static Simulation quickStartSimulationConfig(File config, boolean vis) {
logger.info("> Starting COOJA"); logger.info("> Starting Cooja");
JDesktopPane desktop = createDesktopPane(); JDesktopPane desktop = createDesktopPane();
if (vis) { if (vis) {
frame = new JFrame("COOJA Simulator"); frame = new JFrame(WINDOW_TITLE);
} }
GUI gui = new GUI(desktop); GUI gui = new GUI(desktop);
if (vis) { if (vis) {
@ -1252,9 +1256,9 @@ public class GUI extends Observable {
* @return True if simulation was created * @return True if simulation was created
*/ */
private static boolean quickStartSimulation(String source) { private static boolean quickStartSimulation(String source) {
logger.info("> Starting COOJA"); logger.info("> Starting Cooja");
JDesktopPane desktop = createDesktopPane(); JDesktopPane desktop = createDesktopPane();
frame = new JFrame("COOJA Simulator"); frame = new JFrame(WINDOW_TITLE);
GUI gui = new GUI(desktop); GUI gui = new GUI(desktop);
configureFrame(gui, false); configureFrame(gui, false);
@ -1271,7 +1275,7 @@ public class GUI extends Observable {
logger.info("> Creating mote type"); logger.info("> Creating mote type");
ContikiMoteType moteType = new ContikiMoteType(); ContikiMoteType moteType = new ContikiMoteType();
moteType.setContikiSourceFile(new File(source)); moteType.setContikiSourceFile(new File(source));
moteType.setDescription("Contiki Mote Type (" + source + ")"); moteType.setDescription("Cooja Mote Type (" + source + ")");
try { try {
boolean compileOK = moteType.configureAndInit(GUI.getTopParentContainer(), simulation, true); boolean compileOK = moteType.configureAndInit(GUI.getTopParentContainer(), simulation, true);
@ -1390,10 +1394,10 @@ public class GUI extends Observable {
} }
/** /**
* Builds new project configuration using current project directories settings. * Builds new extension configuration using current extension directories settings.
* Reregisters mote types, plugins, positioners and radio * Reregisters mote types, plugins, positioners and radio
* mediums. This method may still return true even if all classes could not be * mediums. This method may still return true even if all classes could not be
* registered, but always returns false if all project directory configuration * registered, but always returns false if all extension directory configuration
* files were not parsed correctly. * files were not parsed correctly.
*/ */
public void reparseProjectConfig() throws ParseProjectsException { public void reparseProjectConfig() throws ParseProjectsException {
@ -1416,13 +1420,13 @@ public class GUI extends Observable {
try { try {
projectConfig = new ProjectConfig(true); projectConfig = new ProjectConfig(true);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
logger.fatal("Could not find default project config file: " + PROJECT_DEFAULT_CONFIG_FILENAME); logger.fatal("Could not find default extension config file: " + PROJECT_DEFAULT_CONFIG_FILENAME);
throw (ParseProjectsException) new ParseProjectsException( throw (ParseProjectsException) new ParseProjectsException(
"Could not find default project config file: " + PROJECT_DEFAULT_CONFIG_FILENAME).initCause(e); "Could not find default extension config file: " + PROJECT_DEFAULT_CONFIG_FILENAME).initCause(e);
} catch (IOException e) { } catch (IOException e) {
logger.fatal("Error when reading default project config file: " + PROJECT_DEFAULT_CONFIG_FILENAME); logger.fatal("Error when reading default extension config file: " + PROJECT_DEFAULT_CONFIG_FILENAME);
throw (ParseProjectsException) new ParseProjectsException( throw (ParseProjectsException) new ParseProjectsException(
"Error when reading default project config file: " + PROJECT_DEFAULT_CONFIG_FILENAME).initCause(e); "Error when reading default extension config file: " + PROJECT_DEFAULT_CONFIG_FILENAME).initCause(e);
} }
if (!isVisualizedInApplet()) { if (!isVisualizedInApplet()) {
for (COOJAProject project: currentProjects) { for (COOJAProject project: currentProjects) {
@ -1430,14 +1434,14 @@ public class GUI extends Observable {
projectConfig.appendProjectDir(project.dir); projectConfig.appendProjectDir(project.dir);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw (ParseProjectsException) new ParseProjectsException( throw (ParseProjectsException) new ParseProjectsException(
"Error when loading project: " + e.getMessage()).initCause(e); "Error when loading extension: " + e.getMessage()).initCause(e);
} catch (IOException e) { } catch (IOException e) {
throw (ParseProjectsException) new ParseProjectsException( throw (ParseProjectsException) new ParseProjectsException(
"Error when reading project config: " + e.getMessage()).initCause(e); "Error when reading extension config: " + e.getMessage()).initCause(e);
} }
} }
/* Create project class loader */ /* Create extension class loader */
try { try {
projectDirClassLoader = createClassLoader(currentProjects); projectDirClassLoader = createClassLoader(currentProjects);
} catch (ClassLoaderCreationException e) { } catch (ClassLoaderCreationException e) {
@ -1522,18 +1526,18 @@ public class GUI extends Observable {
} }
/** /**
* Returns the current project configuration common to the entire simulator. * Returns the current extension configuration common to the entire simulator.
* *
* @return Current project configuration * @return Current extension configuration
*/ */
public ProjectConfig getProjectConfig() { public ProjectConfig getProjectConfig() {
return projectConfig; return projectConfig;
} }
/** /**
* Returns the current project directories common to the entire simulator. * Returns the current extension directories common to the entire simulator.
* *
* @return Current project directories. * @return Current extension directories.
*/ */
public COOJAProject[] getProjects() { public COOJAProject[] getProjects() {
return currentProjects.toArray(new COOJAProject[0]); return currentProjects.toArray(new COOJAProject[0]);
@ -1551,7 +1555,7 @@ public class GUI extends Observable {
public Boolean work() { public Boolean work() {
JInternalFrame pluginFrame = plugin.getGUI(); JInternalFrame pluginFrame = plugin.getGUI();
if (pluginFrame == null) { if (pluginFrame == null) {
logger.fatal("Failed trying to show plugin without visualizer!"); logger.fatal("Failed trying to show plugin without visualizer.");
return false; return false;
} }
@ -1701,7 +1705,7 @@ public class GUI extends Observable {
// Check that plugin class is registered // Check that plugin class is registered
if (!pluginClasses.contains(pluginClass)) { if (!pluginClasses.contains(pluginClass)) {
throw new PluginConstructionException("Plugin class not registered: " + pluginClass); throw new PluginConstructionException("Tool class not registered: " + pluginClass);
} }
// Construct plugin depending on plugin type // Construct plugin depending on plugin type
@ -1751,11 +1755,11 @@ public class GUI extends Observable {
throw new PluginConstructionException("Bad plugin type: " + pluginType); throw new PluginConstructionException("Bad plugin type: " + pluginType);
} }
} catch (PluginRequiresVisualizationException e) { } catch (PluginRequiresVisualizationException e) {
PluginConstructionException ex = new PluginConstructionException("Plugin class requires visualization: " + pluginClass.getName()); PluginConstructionException ex = new PluginConstructionException("Tool class requires visualization: " + pluginClass.getName());
ex.initCause(e); ex.initCause(e);
throw ex; throw ex;
} catch (Exception e) { } catch (Exception e) {
PluginConstructionException ex = new PluginConstructionException("Construction error for plugin of class: " + pluginClass.getName()); PluginConstructionException ex = new PluginConstructionException("Construction error for tool of class: " + pluginClass.getName());
ex.initCause(e); ex.initCause(e);
throw ex; throw ex;
} }
@ -1871,7 +1875,7 @@ public class GUI extends Observable {
break; break;
} }
} }
tooltip += "COOJA plugin: " + newPluginClass.getName(); tooltip += "Cooja plugin: " + newPluginClass.getName();
menuItem = new JMenuItem(description); menuItem = new JMenuItem(description);
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -1907,11 +1911,11 @@ public class GUI extends Observable {
return false; return false;
} }
/* Check if plugin was imported by a project directory */ /* Check if plugin was imported by a extension directory */
File project = File project =
getProjectConfig().getUserProjectDefining(GUI.class, "PLUGINS", newPluginClass.getName()); getProjectConfig().getUserProjectDefining(GUI.class, "PLUGINS", newPluginClass.getName());
if (project != null) { if (project != null) {
tooltip += "\nLoaded by project: " + project.getPath(); tooltip += "\nLoaded by extension: " + project.getPath();
} }
tooltip += "</html>"; tooltip += "</html>";
@ -1982,7 +1986,7 @@ public class GUI extends Observable {
* @return Mote plugins menu * @return Mote plugins menu
*/ */
public JMenu createMotePluginsSubmenu(Mote mote) { public JMenu createMotePluginsSubmenu(Mote mote) {
JMenu menuMotePlugins = new JMenu("Open mote plugin for " + mote); JMenu menuMotePlugins = new JMenu("Mote tools for " + mote);
for (Class<? extends Plugin> motePluginClass: menuMotePluginClasses) { for (Class<? extends Plugin> motePluginClass: menuMotePluginClasses) {
GUIAction guiAction = new StartPluginGUIAction(getDescriptionOf(motePluginClass)); GUIAction guiAction = new StartPluginGUIAction(getDescriptionOf(motePluginClass));
@ -2040,7 +2044,7 @@ public class GUI extends Observable {
// Set frame title // Set frame title
if (frame != null) { if (frame != null) {
frame.setTitle(sim.getTitle() + " - COOJA Simulator"); frame.setTitle(sim.getTitle() + " - The Contiki Simulation Environment");
} }
// Open standard plugins (if none opened already) // Open standard plugins (if none opened already)
@ -2165,7 +2169,7 @@ public class GUI extends Observable {
// Reset frame title // Reset frame title
if (isVisualizedInFrame()) { if (isVisualizedInFrame()) {
frame.setTitle("COOJA Simulator"); frame.setTitle(WINDOW_TITLE);
} }
setChanged(); setChanged();
@ -2272,7 +2276,7 @@ public class GUI extends Observable {
PROGRESS_BAR = progressBar; /* Allow various parts of COOJA to show messages */ PROGRESS_BAR = progressBar; /* Allow various parts of COOJA to show messages */
button = new JButton("Cancel"); button = new JButton("Abort");
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (loadThread.isAlive()) { if (loadThread.isAlive()) {
@ -2422,7 +2426,7 @@ public class GUI extends Observable {
PROGRESS_BAR = progressBar; /* Allow various parts of COOJA to show messages */ PROGRESS_BAR = progressBar; /* Allow various parts of COOJA to show messages */
JButton button = new JButton("Cancel"); JButton button = new JButton("Abort");
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (loadThread.isAlive()) { if (loadThread.isAlive()) {
@ -2459,12 +2463,12 @@ public class GUI extends Observable {
} }
DecimalFormat format = new DecimalFormat("0.000"); DecimalFormat format = new DecimalFormat("0.000");
logger.warn("Reboot COOJA to avoid out of memory error! (memory usage: " + format.format(100*memRatio) + "%)"); logger.warn("Memory usage is getting critical. Reboot Cooja to avoid out of memory error. Current memory usage is " + format.format(100*memRatio) + "%.");
if (isVisualized()) { if (isVisualized()) {
int n = JOptionPane.showOptionDialog( int n = JOptionPane.showOptionDialog(
GUI.getTopParentContainer(), GUI.getTopParentContainer(),
"Reboot COOJA to avoid out of memory error!\n" + "Reboot Cooja to avoid out of memory error.\n" +
"Current memory usage: " + format.format(100*memRatio) + "%.", "Current memory usage is " + format.format(100*memRatio) + "%.",
"Out of memory warning", "Out of memory warning",
JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE, null, JOptionPane.WARNING_MESSAGE, null,
@ -2609,7 +2613,7 @@ public class GUI extends Observable {
Object[] options = { s1, s2 }; Object[] options = { s1, s2 };
int n = JOptionPane.showOptionDialog(GUI.getTopParentContainer(), int n = JOptionPane.showOptionDialog(GUI.getTopParentContainer(),
"Sure you want to quit?", "Sure you want to quit?",
"Close COOJA Simulator", JOptionPane.YES_NO_OPTION, "Quit", 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;
@ -2813,7 +2817,7 @@ public class GUI extends Observable {
} }
} }
differingSettings.store(out, "COOJA External Tools (User specific)"); differingSettings.store(out, "Cooja External Tools (User specific)");
out.close(); out.close();
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
// Could not open settings file for writing, aborting // Could not open settings file for writing, aborting
@ -2838,7 +2842,7 @@ public class GUI extends Observable {
.getClientProperty("motetype")); .getClientProperty("motetype"));
} else if (e.getActionCommand().equals("edit paths")) { } else if (e.getActionCommand().equals("edit paths")) {
ExternalToolsDialog.showDialog(GUI.getTopParentContainer()); ExternalToolsDialog.showDialog(GUI.getTopParentContainer());
} else if (e.getActionCommand().equals("manage projects")) { } else if (e.getActionCommand().equals("manage extensions")) {
COOJAProject[] newProjects = ProjectDirectoriesDialog.showDialog( COOJAProject[] newProjects = ProjectDirectoriesDialog.showDialog(
GUI.getTopParentContainer(), GUI.getTopParentContainer(),
GUI.this, GUI.this,
@ -2852,15 +2856,15 @@ public class GUI extends Observable {
try { try {
reparseProjectConfig(); reparseProjectConfig();
} catch (ParseProjectsException ex) { } catch (ParseProjectsException ex) {
logger.fatal("Error when loading projects: " + ex.getMessage(), ex); logger.fatal("Error when loading extensions: " + ex.getMessage(), ex);
if (isVisualized()) { if (isVisualized()) {
JOptionPane.showMessageDialog(GUI.getTopParentContainer(), JOptionPane.showMessageDialog(GUI.getTopParentContainer(),
"All COOJA projects could not load.\n\n" + "All Cooja extensions could not load.\n\n" +
"To manage COOJA projects:\n" + "To manage Cooja extensions:\n" +
"Menu->Settings->COOJA projects", "Menu->Settings->Cooja extensions",
"Reconfigure COOJA projects", JOptionPane.INFORMATION_MESSAGE); "Reconfigure Cooja extensions", JOptionPane.INFORMATION_MESSAGE);
} }
showErrorDialog(getTopParentContainer(), "COOJA projects load error", ex, false); showErrorDialog(getTopParentContainer(), "Cooja extensions load error", ex, false);
} }
} }
} else if (e.getActionCommand().equals("configuration wizard")) { } else if (e.getActionCommand().equals("configuration wizard")) {
@ -3062,7 +3066,7 @@ public class GUI extends Observable {
/* Warn at no JAVA_HOME */ /* Warn at no JAVA_HOME */
String javaHome = System.getenv().get("JAVA_HOME"); String javaHome = System.getenv().get("JAVA_HOME");
if (javaHome == null || javaHome.equals("")) { if (javaHome == null || javaHome.equals("")) {
logger.warn("JAVA_HOME environment variable not set, Contiki motes (OS-level) may not compile"); logger.warn("JAVA_HOME environment variable not set, Cooja motes may not compile");
} }
// Parse general command arguments // Parse general command arguments
@ -3203,7 +3207,7 @@ public class GUI extends Observable {
javax.swing.SwingUtilities.invokeLater(new Runnable() { javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
JDesktopPane desktop = createDesktopPane(); JDesktopPane desktop = createDesktopPane();
frame = new JFrame("COOJA Simulator"); frame = new JFrame(WINDOW_TITLE);
GUI gui = new GUI(desktop); GUI gui = new GUI(desktop);
configureFrame(gui, false); configureFrame(gui, false);
} }
@ -3258,11 +3262,11 @@ public class GUI extends Observable {
try { try {
// Check that config file version is correct // Check that config file version is correct
if (!root.getName().equals("simconf")) { if (!root.getName().equals("simconf")) {
logger.fatal("Not a valid COOJA simulation config!"); logger.fatal("Not a valid Cooja simulation config.");
return null; return null;
} }
/* Verify project directories */ /* Verify extension directories */
boolean projectsOk = verifyProjects(root.getChildren(), !quick); boolean projectsOk = verifyProjects(root.getChildren(), !quick);
/* GENERATE UNIQUE MOTE TYPE IDENTIFIERS */ /* GENERATE UNIQUE MOTE TYPE IDENTIFIERS */
@ -3381,7 +3385,7 @@ public class GUI extends Observable {
// Create simulation config // Create simulation config
Element root = new Element("simconf"); Element root = new Element("simconf");
/* Store project directories meta data */ /* Store extension directories meta data */
for (COOJAProject project: currentProjects) { for (COOJAProject project: currentProjects) {
Element projectElement = new Element("project"); Element projectElement = new Element("project");
projectElement.addContent(createPortablePath(project.dir).getPath().replaceAll("\\\\", "/")); projectElement.addContent(createPortablePath(project.dir).getPath().replaceAll("\\\\", "/"));
@ -3485,7 +3489,7 @@ public class GUI extends Observable {
public boolean verifyProjects(Collection<Element> configXML, boolean visAvailable) { public boolean verifyProjects(Collection<Element> configXML, boolean visAvailable) {
boolean allOk = true; boolean allOk = true;
/* Match current projects against projects in simulation config */ /* Match current extensions against extensions in simulation config */
for (final Element pluginElement : configXML.toArray(new Element[0])) { for (final Element pluginElement : configXML.toArray(new Element[0])) {
if (pluginElement.getName().equals("project")) { if (pluginElement.getName().equals("project")) {
File projectFile = restorePortablePath(new File(pluginElement.getText())); File projectFile = restorePortablePath(new File(pluginElement.getText()));
@ -3504,7 +3508,7 @@ public class GUI extends Observable {
} }
if (!found) { if (!found) {
logger.warn("Loaded simulation may depend on not found project: '" + projectFile + "'"); logger.warn("Loaded simulation may depend on not found extension: '" + projectFile + "'");
allOk = false; allOk = false;
} }
} }
@ -4259,7 +4263,7 @@ public class GUI extends Observable {
} }
public abstract boolean shouldBeEnabled(); public abstract boolean shouldBeEnabled();
} }
GUIAction newSimulationAction = new GUIAction("New simulation", KeyEvent.VK_N, KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)) { GUIAction newSimulationAction = new GUIAction("New simulation...", KeyEvent.VK_N, KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)) {
private static final long serialVersionUID = 5053703908505299911L; private static final long serialVersionUID = 5053703908505299911L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
myGUI.doCreateSimulation(true); myGUI.doCreateSimulation(true);
@ -4277,7 +4281,7 @@ public class GUI extends Observable {
return getSimulation() != null; return getSimulation() != null;
} }
}; };
GUIAction reloadSimulationAction = new GUIAction("keep random seed", KeyEvent.VK_K, KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)) { GUIAction reloadSimulationAction = new GUIAction("Reload with same random seed", KeyEvent.VK_K, KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)) {
private static final long serialVersionUID = 66579555555421977L; private static final long serialVersionUID = 66579555555421977L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (getSimulation() == null) { if (getSimulation() == null) {
@ -4299,7 +4303,7 @@ public class GUI extends Observable {
return true; return true;
} }
}; };
GUIAction reloadRandomSimulationAction = new GUIAction("new random seed", KeyEvent.VK_N, KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)) { GUIAction reloadRandomSimulationAction = new GUIAction("Reload with new random seed", KeyEvent.VK_N, KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)) {
private static final long serialVersionUID = -4494402222740250203L; private static final long serialVersionUID = -4494402222740250203L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
/* Replace seed before reloading */ /* Replace seed before reloading */
@ -4312,7 +4316,7 @@ public class GUI extends Observable {
return getSimulation() != null; return getSimulation() != null;
} }
}; };
GUIAction saveSimulationAction = new GUIAction("Save simulation", KeyEvent.VK_S) { GUIAction saveSimulationAction = new GUIAction("Save simulation as...", KeyEvent.VK_S) {
private static final long serialVersionUID = 1132582220401954286L; private static final long serialVersionUID = 1132582220401954286L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
myGUI.doSaveConfig(true); myGUI.doSaveConfig(true);
@ -4324,7 +4328,7 @@ public class GUI extends Observable {
return getSimulation() != null; return getSimulation() != null;
} }
}; };
GUIAction closePluginsAction = new GUIAction("Close all plugins") { /* GUIAction closePluginsAction = new GUIAction("Close all plugins") {
private static final long serialVersionUID = -37575622808266989L; private static final long serialVersionUID = -37575622808266989L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Object[] plugins = startedPlugins.toArray(); Object[] plugins = startedPlugins.toArray();
@ -4335,8 +4339,8 @@ public class GUI extends Observable {
public boolean shouldBeEnabled() { public boolean shouldBeEnabled() {
return !startedPlugins.isEmpty(); return !startedPlugins.isEmpty();
} }
}; };*/
GUIAction exportExecutableJARAction = new GUIAction("Export simulation as executable JAR") { GUIAction exportExecutableJARAction = new GUIAction("Export simulation...") {
private static final long serialVersionUID = -203601967460630049L; private static final long serialVersionUID = -203601967460630049L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
getSimulation().stopSimulation(); getSimulation().stopSimulation();
@ -4345,10 +4349,10 @@ public class GUI extends Observable {
String[] options = new String[] { "OK", "Cancel" }; String[] options = new String[] { "OK", "Cancel" };
int n = JOptionPane.showOptionDialog( int n = JOptionPane.showOptionDialog(
GUI.getTopParentContainer(), GUI.getTopParentContainer(),
"This function attempts to build an executable COOJA JAR from the current simulation.\n" + "This function attempts to build an executable Cooja JAR from the current simulation.\n" +
"The JAR will contain all simulation dependencies, including project JAR files and mote firmware files.\n" + "The JAR will contain all simulation dependencies, including extension JAR files and mote firmware files.\n" +
"\nExecutable simulations can be used to run already prepared simulations on several computers.\n" + "\nExecutable simulations can be used to run already prepared simulations on several computers.\n" +
"\nThis is an experimental feature!", "\nThis is an experimental feature.",
"Export simulation to executable JAR", JOptionPane.OK_CANCEL_OPTION, "Export simulation to executable JAR", JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
if (n != JOptionPane.OK_OPTION) { if (n != JOptionPane.OK_OPTION) {
@ -4425,7 +4429,7 @@ public class GUI extends Observable {
return true; return true;
} }
}; };
GUIAction startStopSimulationAction = new GUIAction("Start/Stop simulation", KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)) { GUIAction startStopSimulationAction = new GUIAction("Start simulation", KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)) {
private static final long serialVersionUID = 6750107157493939710L; private static final long serialVersionUID = 6750107157493939710L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
/* Start/Stop current simulation */ /* Start/Stop current simulation */
@ -4441,9 +4445,9 @@ public class GUI extends Observable {
} }
public void setEnabled(boolean newValue) { public void setEnabled(boolean newValue) {
if (getSimulation() == null) { if (getSimulation() == null) {
putValue(NAME, "Start/Stop simulation"); putValue(NAME, "Start simulation");
} else if (getSimulation().isRunning()) { } else if (getSimulation().isRunning()) {
putValue(NAME, "Stop simulation"); putValue(NAME, "Pause simulation");
} else { } else {
putValue(NAME, "Start simulation"); putValue(NAME, "Start simulation");
} }
@ -4524,7 +4528,7 @@ public class GUI extends Observable {
return true; return true;
} }
}; };
GUIAction showBufferSettingsAction = new GUIAction("Buffer sizes") { GUIAction showBufferSettingsAction = new GUIAction("Buffer sizes...") {
private static final long serialVersionUID = 7018661735211901837L; private static final long serialVersionUID = 7018661735211901837L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (mySimulation == null) { if (mySimulation == null) {