From 2a9283884cf1630bfa72df5b4d7856ac7f6117fe Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Tue, 19 Nov 2013 10:30:19 +0100 Subject: [PATCH] renamed getGUI() method to getCooja(), to better reflect its purpose --- .../src/se/sics/cooja/avrmote/MicaZMote.java | 2 +- .../se/sics/cooja/avrmote/MicaZMoteType.java | 10 +-- .../cooja/apps/mrm/java/se/sics/mrm/MRM.java | 8 +- .../src/se/sics/cooja/mspmote/MspMote.java | 2 +- .../se/sics/cooja/mspmote/MspMoteType.java | 10 +-- .../cooja/mspmote/plugins/MspBreakpoint.java | 4 +- tools/cooja/config/scripts/plugins.js | 6 +- tools/cooja/java/se/sics/cooja/Cooja.java | 77 +++++++++---------- tools/cooja/java/se/sics/cooja/Plugin.java | 2 +- .../cooja/java/se/sics/cooja/Simulation.java | 21 +++-- tools/cooja/java/se/sics/cooja/VisPlugin.java | 2 +- .../sics/cooja/contikimote/ContikiMote.java | 2 +- .../cooja/contikimote/ContikiMoteType.java | 8 +- .../cooja/dialogs/AbstractCompileDialog.java | 2 +- .../se/sics/cooja/dialogs/AddMoteDialog.java | 4 +- .../sics/cooja/dialogs/CreateSimDialog.java | 4 +- .../cooja/dialogs/ImportAppMoteDialog.java | 4 +- .../cooja/interfaces/Mote2MoteRelations.java | 2 +- .../cooja/motes/AbstractApplicationMote.java | 2 +- .../sics/cooja/motes/ImportAppMoteType.java | 8 +- .../se/sics/cooja/plugins/BufferListener.java | 12 +-- .../se/sics/cooja/plugins/EventListener.java | 4 +- .../se/sics/cooja/plugins/LogListener.java | 12 +-- .../sics/cooja/plugins/LogScriptEngine.java | 4 +- .../sics/cooja/plugins/MoteInformation.java | 4 +- .../cooja/plugins/MoteInterfaceViewer.java | 2 +- .../se/sics/cooja/plugins/RadioLogger.java | 6 +- .../se/sics/cooja/plugins/ScriptRunner.java | 6 +- .../se/sics/cooja/plugins/SimControl.java | 2 +- .../java/se/sics/cooja/plugins/TimeLine.java | 12 +-- .../se/sics/cooja/plugins/Visualizer.java | 14 ++-- .../radiomediums/DirectedGraphMedium.java | 6 +- .../java/se/sics/cooja/util/ExecuteJAR.java | 2 +- 33 files changed, 130 insertions(+), 136 deletions(-) diff --git a/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZMote.java b/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZMote.java index 9aeb85e33..94d4d24e9 100644 --- a/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZMote.java +++ b/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZMote.java @@ -221,7 +221,7 @@ public class MicaZMote extends AbstractEmulatedMote implements Mote { if (name.equals("motetype_identifier")) { /* Ignored: handled by simulation */ } else if (name.equals("interface_config")) { - Class moteInterfaceClass = simulation.getGUI().tryLoadClass( + Class moteInterfaceClass = simulation.getCooja().tryLoadClass( this, MoteInterface.class, element.getText().trim()); if (moteInterfaceClass == null) { diff --git a/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZMoteType.java b/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZMoteType.java index b82f4bf5b..020f6a8ef 100644 --- a/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZMoteType.java +++ b/tools/cooja/apps/avrora/src/se/sics/cooja/avrmote/MicaZMoteType.java @@ -241,7 +241,7 @@ public class MicaZMoteType implements MoteType { // Source file if (fileSource != null) { element = new Element("source"); - File file = simulation.getGUI().createPortablePath(fileSource); + File file = simulation.getCooja().createPortablePath(fileSource); element.setText(file.getPath().replaceAll("\\\\", "/")); config.add(element); element = new Element("commands"); @@ -251,7 +251,7 @@ public class MicaZMoteType implements MoteType { // Firmware file element = new Element("firmware"); - File file = simulation.getGUI().createPortablePath(fileFirmware); + File file = simulation.getCooja().createPortablePath(fileFirmware); element.setText(file.getPath().replaceAll("\\\\", "/")); config.add(element); @@ -280,20 +280,20 @@ public class MicaZMoteType implements MoteType { } else if (name.equals("source")) { fileSource = new File(element.getText()); if (!fileSource.exists()) { - fileSource = simulation.getGUI().restorePortablePath(fileSource); + fileSource = simulation.getCooja().restorePortablePath(fileSource); } } else if (name.equals("commands")) { compileCommands = element.getText(); } else if (name.equals("firmware")) { fileFirmware = new File(element.getText()); if (!fileFirmware.exists()) { - fileFirmware = simulation.getGUI().restorePortablePath(fileFirmware); + fileFirmware = simulation.getCooja().restorePortablePath(fileFirmware); } } else if (name.equals("moteinterface")) { String intfClass = element.getText().trim(); Class moteInterfaceClass = - simulation.getGUI().tryLoadClass(this, MoteInterface.class, intfClass); + simulation.getCooja().tryLoadClass(this, MoteInterface.class, intfClass); if (moteInterfaceClass == null) { logger.warn("Can't find mote interface class: " + intfClass); diff --git a/tools/cooja/apps/mrm/java/se/sics/mrm/MRM.java b/tools/cooja/apps/mrm/java/se/sics/mrm/MRM.java index 8ba618961..055184106 100644 --- a/tools/cooja/apps/mrm/java/se/sics/mrm/MRM.java +++ b/tools/cooja/apps/mrm/java/se/sics/mrm/MRM.java @@ -118,8 +118,8 @@ public class MRM extends AbstractRadioMedium { }); /* Register plugins */ - sim.getGUI().registerPlugin(AreaViewer.class); - sim.getGUI().registerPlugin(FormulaViewer.class); + sim.getCooja().registerPlugin(AreaViewer.class); + sim.getCooja().registerPlugin(FormulaViewer.class); Visualizer.registerVisualizerSkin(MRMVisualizerSkin.class); } @@ -127,8 +127,8 @@ public class MRM extends AbstractRadioMedium { super.removed(); /* Unregister plugins */ - sim.getGUI().unregisterPlugin(AreaViewer.class); - sim.getGUI().unregisterPlugin(FormulaViewer.class); + sim.getCooja().unregisterPlugin(AreaViewer.class); + sim.getCooja().unregisterPlugin(FormulaViewer.class); Visualizer.unregisterVisualizerSkin(MRMVisualizerSkin.class); currentChannelModel.deleteSettingsObserver(channelModelObserver); diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java index 24b233284..85c74ef5c 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java @@ -421,7 +421,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc if (intfClass.equals("se.sics.cooja.mspmote.interfaces.SkySerial")) { intfClass = MspSerial.class.getName(); } - Class moteInterfaceClass = simulation.getGUI().tryLoadClass( + Class moteInterfaceClass = simulation.getCooja().tryLoadClass( this, MoteInterface.class, intfClass); if (moteInterfaceClass == null) { diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java index 699e421c5..452bfdc00 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java @@ -202,7 +202,7 @@ public abstract class MspMoteType implements MoteType { // Source file if (fileSource != null) { element = new Element("source"); - File file = simulation.getGUI().createPortablePath(fileSource); + File file = simulation.getCooja().createPortablePath(fileSource); element.setText(file.getPath().replaceAll("\\\\", "/")); element.setAttribute("EXPORT", "discard"); config.add(element); @@ -214,7 +214,7 @@ public abstract class MspMoteType implements MoteType { // Firmware file element = new Element("firmware"); - File file = simulation.getGUI().createPortablePath(fileFirmware); + File file = simulation.getCooja().createPortablePath(fileFirmware); element.setText(file.getPath().replaceAll("\\\\", "/")); element.setAttribute("EXPORT", "copy"); config.add(element); @@ -244,7 +244,7 @@ public abstract class MspMoteType implements MoteType { } else if (name.equals("source")) { fileSource = new File(element.getText()); if (!fileSource.exists()) { - fileSource = simulation.getGUI().restorePortablePath(fileSource); + fileSource = simulation.getCooja().restorePortablePath(fileSource); } } else if (name.equals("command")) { /* Backwards compatibility: command is now commands */ @@ -255,7 +255,7 @@ public abstract class MspMoteType implements MoteType { } else if (name.equals("firmware")) { fileFirmware = new File(element.getText()); if (!fileFirmware.exists()) { - fileFirmware = simulation.getGUI().restorePortablePath(fileFirmware); + fileFirmware = simulation.getCooja().restorePortablePath(fileFirmware); } } else if (name.equals("elf")) { /* Backwards compatibility: elf is now firmware */ @@ -283,7 +283,7 @@ public abstract class MspMoteType implements MoteType { } Class moteInterfaceClass = - simulation.getGUI().tryLoadClass(this, MoteInterface.class, intfClass); + simulation.getCooja().tryLoadClass(this, MoteInterface.class, intfClass); if (moteInterfaceClass == null) { logger.warn("Can't find mote interface class: " + intfClass); diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpoint.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpoint.java index 3b421359a..73b7eef39 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpoint.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpoint.java @@ -169,7 +169,7 @@ public class MspBreakpoint implements Watchpoint { config.add(element); element = new Element("codefile"); - File file = mspMote.getSimulation().getGUI().createPortablePath(codeFile); + File file = mspMote.getSimulation().getCooja().createPortablePath(codeFile); element.setText(file.getPath().replaceAll("\\\\", "/")); config.add(element); @@ -204,7 +204,7 @@ public class MspBreakpoint implements Watchpoint { for (Element element : configXML) { if (element.getName().equals("codefile")) { File file = new File(element.getText()); - file = mspMote.getSimulation().getGUI().restorePortablePath(file); + file = mspMote.getSimulation().getCooja().restorePortablePath(file); try { codeFile = file.getCanonicalFile(); diff --git a/tools/cooja/config/scripts/plugins.js b/tools/cooja/config/scripts/plugins.js index 16963fabd..4b5f6e379 100644 --- a/tools/cooja/config/scripts/plugins.js +++ b/tools/cooja/config/scripts/plugins.js @@ -24,7 +24,7 @@ while (counter<10) { YIELD_THEN_WAIT_UNTIL(msg.equals("wait")); /* Toggle Log Listener filter */ - plugin = mote.getSimulation().getGUI().getStartedPlugin("se.sics.cooja.plugins.LogListener"); + plugin = mote.getSimulation().getCooja().getStartedPlugin("se.sics.cooja.plugins.LogListener"); if (plugin != null) { plugins++; log.log("LogListener: Setting filter: " + plugin.getFilter() + "\n"); @@ -39,7 +39,7 @@ while (counter<10) { YIELD_THEN_WAIT_UNTIL(msg.equals("wait")); /* Extract PowerTracker statistics */ - plugin = mote.getSimulation().getGUI().getStartedPlugin("PowerTracker"); + plugin = mote.getSimulation().getCooja().getStartedPlugin("PowerTracker"); if (plugin != null) { plugins++; stats = plugin.radioStatistics(); @@ -56,7 +56,7 @@ while (counter<10) { YIELD_THEN_WAIT_UNTIL(msg.equals("wait")); /* Select time in Radio Logger */ - plugin = mote.getSimulation().getGUI().getStartedPlugin("se.sics.cooja.plugins.RadioLogger"); + plugin = mote.getSimulation().getCooja().getStartedPlugin("se.sics.cooja.plugins.RadioLogger"); if (plugin != null) { plugins++; log.log("RadioLogger: Showing logged radio packet at mid simulation\n"); diff --git a/tools/cooja/java/se/sics/cooja/Cooja.java b/tools/cooja/java/se/sics/cooja/Cooja.java index f8e112d0a..f8e7b8ff0 100644 --- a/tools/cooja/java/se/sics/cooja/Cooja.java +++ b/tools/cooja/java/se/sics/cooja/Cooja.java @@ -60,16 +60,13 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.io.StringReader; -import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.net.URLClassLoader; import java.security.AccessControlException; import java.text.DecimalFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.Comparator; import java.util.Enumeration; import java.util.List; import java.util.Observable; @@ -294,7 +291,7 @@ public class Cooja extends Observable { private static final String WINDOW_TITLE = "Cooja: The Contiki Network Simulator"; - private Cooja myGUI; + private Cooja cooja; private Simulation mySimulation; @@ -370,7 +367,7 @@ public class Cooja extends Observable { * @param desktop Desktop pane */ public Cooja(JDesktopPane desktop) { - myGUI = this; + cooja = this; mySimulation = null; myDesktopPane = desktop; @@ -542,7 +539,7 @@ public class Cooja extends Observable { public void setVisualizedInFrame(boolean visualized) { if (visualized) { if (!isVisualizedInFrame()) { - configureFrame(myGUI, false); + configureFrame(cooja, false); } } else { if (frame != null) { @@ -633,7 +630,7 @@ public class Cooja extends Observable { private void doLoadConfigAsync(final boolean ask, final boolean quick, final File file) { new Thread(new Runnable() { public void run() { - myGUI.doLoadConfig(ask, quick, file, null); + cooja.doLoadConfig(ask, quick, file, null); } }).start(); } @@ -944,7 +941,7 @@ public class Cooja extends Observable { public void actionPerformed(ActionEvent e) { Object pluginClass = ((JMenuItem)e.getSource()).getClientProperty("class"); Object mote = ((JMenuItem)e.getSource()).getClientProperty("mote"); - tryStartPlugin((Class) pluginClass, myGUI, getSimulation(), (Mote)mote); + tryStartPlugin((Class) pluginClass, cooja, getSimulation(), (Mote)mote); } }; private JMenuItem createMenuItem(Class newPluginClass, int pluginType) { @@ -1657,7 +1654,7 @@ public class Cooja extends Observable { public void showPlugin(final Plugin plugin) { new RunnableInEDT() { public Boolean work() { - JInternalFrame pluginFrame = plugin.getGUI(); + JInternalFrame pluginFrame = plugin.getCooja(); if (pluginFrame == null) { logger.fatal("Failed trying to show plugin without visualizer."); return false; @@ -1730,8 +1727,8 @@ public class Cooja extends Observable { updateGUIComponentState(); /* Dispose visualized components */ - if (plugin.getGUI() != null) { - plugin.getGUI().dispose(); + if (plugin.getCooja() != null) { + plugin.getCooja().dispose(); } /* (OPTIONAL) Remove simulation if all plugins are closed */ @@ -1877,8 +1874,8 @@ public class Cooja extends Observable { updateGUIComponentState(); // Show plugin if visualizer type - if (activate && plugin.getGUI() != null) { - myGUI.showPlugin(plugin); + if (activate && plugin.getCooja() != null) { + cooja.showPlugin(plugin); } return plugin; @@ -2040,7 +2037,7 @@ public class Cooja extends Observable { public void actionPerformed(ActionEvent e) { Object pluginClass = ((JMenuItem)e.getSource()).getClientProperty("class"); Object mote = ((JMenuItem)e.getSource()).getClientProperty("mote"); - tryStartPlugin((Class) pluginClass, myGUI, getSimulation(), (Mote)mote); + tryStartPlugin((Class) pluginClass, cooja, getSimulation(), (Mote)mote); } }; @@ -2392,10 +2389,10 @@ public class Cooja extends Observable { do { try { shouldRetry = false; - myGUI.doRemoveSimulation(false); + cooja.doRemoveSimulation(false); PROGRESS_WARNINGS.clear(); newSim = loadSimulationConfig(fileToLoad, quick, manualRandomSeed); - myGUI.setSimulation(newSim, false); + cooja.setSimulation(newSim, false); /* Optionally show compilation warnings */ boolean hideWarn = Boolean.parseBoolean( @@ -2457,10 +2454,10 @@ public class Cooja extends Observable { do { try { shouldRetry = false; - myGUI.doRemoveSimulation(false); + cooja.doRemoveSimulation(false); PROGRESS_WARNINGS.clear(); Simulation newSim = loadSimulationConfig(root, true, new Long(randomSeed)); - myGUI.setSimulation(newSim, false); + cooja.setSimulation(newSim, false); if (autoStart) { newSim.startSimulation(); @@ -2478,11 +2475,11 @@ public class Cooja extends Observable { } catch (UnsatisfiedLinkError e) { shouldRetry = showErrorDialog(frame, "Simulation reload error", e, true); - myGUI.doRemoveSimulation(false); + cooja.doRemoveSimulation(false); } catch (SimulationCreationException e) { shouldRetry = showErrorDialog(frame, "Simulation reload error", e, true); - myGUI.doRemoveSimulation(false); + cooja.doRemoveSimulation(false); } } while (shouldRetry); @@ -2666,7 +2663,7 @@ public class Cooja extends Observable { Simulation newSim = new Simulation(this); boolean createdOK = CreateSimDialog.showDialog(Cooja.getTopParentContainer(), newSim); if (createdOK) { - myGUI.setSimulation(newSim, true); + cooja.setSimulation(newSim, true); } } @@ -2696,7 +2693,7 @@ public class Cooja extends Observable { WINDOW_TITLE, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, s1); if (n == JOptionPane.YES_OPTION) { - if (myGUI.doSaveConfig(true) == null) { + if (cooja.doSaveConfig(true) == null) { return; } } else if (n == JOptionPane.CANCEL_OPTION) { @@ -2925,10 +2922,10 @@ public class Cooja extends Observable { private class GUIEventHandler implements ActionListener { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("create mote type")) { - myGUI.doCreateMoteType((Class) ((JMenuItem) e + cooja.doCreateMoteType((Class) ((JMenuItem) e .getSource()).getClientProperty("class")); } else if (e.getActionCommand().equals("add motes")) { - myGUI.doAddMotes((MoteType) ((JMenuItem) e.getSource()) + cooja.doAddMotes((MoteType) ((JMenuItem) e.getSource()) .getClientProperty("motetype")); } else if (e.getActionCommand().equals("edit paths")) { ExternalToolsDialog.showDialog(Cooja.getTopParentContainer()); @@ -3230,7 +3227,7 @@ public class Cooja extends Observable { if (sim == null) { System.exit(1); } - Cooja gui = sim.getGUI(); + Cooja gui = sim.getCooja(); /* Make sure at least one test editor is controlling the simulation */ boolean hasEditor = false; @@ -3552,8 +3549,8 @@ public class Cooja extends Observable { } // If plugin is visualizer plugin, create visualization arguments - if (startedPlugin.getGUI() != null) { - JInternalFrame pluginFrame = startedPlugin.getGUI(); + if (startedPlugin.getCooja() != null) { + JInternalFrame pluginFrame = startedPlugin.getCooja(); pluginSubElement = new Element("width"); pluginSubElement.setText("" + pluginFrame.getSize().width); @@ -3683,7 +3680,7 @@ public class Cooja extends Observable { startedPlugin.startPlugin(); /* If Cooja not visualized, ignore window configuration */ - if (startedPlugin.getGUI() == null) { + if (startedPlugin.getCooja() == null) { continue; } @@ -3696,22 +3693,22 @@ public class Cooja extends Observable { for (Element pluginSubElement : (List) pluginElement.getChildren()) { if (pluginSubElement.getName().equals("width")) { size.width = Integer.parseInt(pluginSubElement.getText()); - startedPlugin.getGUI().setSize(size); + startedPlugin.getCooja().setSize(size); } else if (pluginSubElement.getName().equals("height")) { size.height = Integer.parseInt(pluginSubElement.getText()); - startedPlugin.getGUI().setSize(size); + startedPlugin.getCooja().setSize(size); } else if (pluginSubElement.getName().equals("z")) { int zOrder = Integer.parseInt(pluginSubElement.getText()); - startedPlugin.getGUI().putClientProperty("zorder", zOrder); + startedPlugin.getCooja().putClientProperty("zorder", zOrder); } else if (pluginSubElement.getName().equals("location_x")) { location.x = Integer.parseInt(pluginSubElement.getText()); - startedPlugin.getGUI().setLocation(location); + startedPlugin.getCooja().setLocation(location); } else if (pluginSubElement.getName().equals("location_y")) { location.y = Integer.parseInt(pluginSubElement.getText()); - startedPlugin.getGUI().setLocation(location); + startedPlugin.getCooja().setLocation(location); } else if (pluginSubElement.getName().equals("minimized")) { boolean minimized = Boolean.parseBoolean(pluginSubElement.getText()); - final JInternalFrame pluginGUI = startedPlugin.getGUI(); + final JInternalFrame pluginGUI = startedPlugin.getCooja(); if (minimized && pluginGUI != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -4423,7 +4420,7 @@ public class Cooja extends Observable { GUIAction newSimulationAction = new GUIAction("New simulation...", KeyEvent.VK_N, KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)) { private static final long serialVersionUID = 5053703908505299911L; public void actionPerformed(ActionEvent e) { - myGUI.doCreateSimulation(true); + cooja.doCreateSimulation(true); } public boolean shouldBeEnabled() { return true; @@ -4432,7 +4429,7 @@ public class Cooja extends Observable { GUIAction closeSimulationAction = new GUIAction("Close simulation", KeyEvent.VK_C) { private static final long serialVersionUID = -4783032948880161189L; public void actionPerformed(ActionEvent e) { - myGUI.doRemoveSimulation(true); + cooja.doRemoveSimulation(true); } public boolean shouldBeEnabled() { return getSimulation() != null; @@ -4446,7 +4443,7 @@ public class Cooja extends Observable { final File file = getLastOpenedFile(); new Thread(new Runnable() { public void run() { - myGUI.doLoadConfig(true, true, file, null); + cooja.doLoadConfig(true, true, file, null); } }).start(); return; @@ -4476,7 +4473,7 @@ public class Cooja extends Observable { GUIAction saveSimulationAction = new GUIAction("Save simulation as...", KeyEvent.VK_S) { private static final long serialVersionUID = 1132582220401954286L; public void actionPerformed(ActionEvent e) { - myGUI.doSaveConfig(true); + cooja.doSaveConfig(true); } public boolean shouldBeEnabled() { if (isVisualizedInApplet()) { @@ -4577,7 +4574,7 @@ public class Cooja extends Observable { GUIAction exitCoojaAction = new GUIAction("Exit", 'x') { private static final long serialVersionUID = 7523822251658687665L; public void actionPerformed(ActionEvent e) { - myGUI.doQuit(true); + cooja.doQuit(true); } public boolean shouldBeEnabled() { if (isVisualizedInApplet()) { @@ -4625,7 +4622,7 @@ public class Cooja extends Observable { Class pluginClass = (Class) ((JMenuItem) e.getSource()).getClientProperty("class"); Mote mote = (Mote) ((JMenuItem) e.getSource()).getClientProperty("mote"); - tryStartPlugin(pluginClass, myGUI, mySimulation, mote); + tryStartPlugin(pluginClass, cooja, mySimulation, mote); } }).start(); } diff --git a/tools/cooja/java/se/sics/cooja/Plugin.java b/tools/cooja/java/se/sics/cooja/Plugin.java index 1c2f5ef58..9d682ae44 100644 --- a/tools/cooja/java/se/sics/cooja/Plugin.java +++ b/tools/cooja/java/se/sics/cooja/Plugin.java @@ -51,7 +51,7 @@ public interface Plugin { /** * Graphical component of plugin (if any) */ - public JInternalFrame getGUI(); + public JInternalFrame getCooja(); /** diff --git a/tools/cooja/java/se/sics/cooja/Simulation.java b/tools/cooja/java/se/sics/cooja/Simulation.java index 4e26112fc..c7b81f028 100644 --- a/tools/cooja/java/se/sics/cooja/Simulation.java +++ b/tools/cooja/java/se/sics/cooja/Simulation.java @@ -85,7 +85,7 @@ public class Simulation extends Observable implements Runnable { private Thread simulationThread = null; - private Cooja myGUI = null; + private Cooja cooja = null; private long randomSeed = 123456; @@ -320,8 +320,8 @@ public class Simulation extends Observable implements Runnable { /** * Creates a new simulation */ - public Simulation(Cooja gui) { - myGUI = gui; + public Simulation(Cooja cooja) { + this.cooja = cooja; } /** @@ -393,11 +393,8 @@ public class Simulation extends Observable implements Runnable { startSimulation(); } - /** - * @return GUI holding this simulation - */ - public Cooja getGUI() { - return myGUI; + public Cooja getCooja() { + return cooja; } /** @@ -603,7 +600,7 @@ public class Simulation extends Observable implements Runnable { // Radio medium if (element.getName().equals("radiomedium")) { String radioMediumClassName = element.getText().trim(); - Class radioMediumClass = myGUI.tryLoadClass( + Class radioMediumClass = cooja.tryLoadClass( this, RadioMedium.class, radioMediumClassName); if (radioMediumClass != null) { @@ -648,7 +645,7 @@ public class Simulation extends Observable implements Runnable { /* Try to recreate simulation using a different mote type */ if (visAvailable) { - String[] availableMoteTypes = getGUI().getProjectConfig().getStringArrayValue("se.sics.cooja.Cooja.MOTETYPES"); + String[] availableMoteTypes = getCooja().getProjectConfig().getStringArrayValue("se.sics.cooja.Cooja.MOTETYPES"); String newClass = (String) JOptionPane.showInputDialog( Cooja.getTopParentContainer(), "The simulation is about to load '" + moteTypeClassName + "'\n" + @@ -668,7 +665,7 @@ public class Simulation extends Observable implements Runnable { } } - Class moteTypeClass = myGUI.tryLoadClass(this, + Class moteTypeClass = cooja.tryLoadClass(this, MoteType.class, moteTypeClassName); if (moteTypeClass == null) { @@ -782,7 +779,7 @@ public class Simulation extends Observable implements Runnable { invokeSimulationThread(removeMote); } - getGUI().closeMotePlugins(mote); + getCooja().closeMotePlugins(mote); } /** diff --git a/tools/cooja/java/se/sics/cooja/VisPlugin.java b/tools/cooja/java/se/sics/cooja/VisPlugin.java index 50a477947..406f0562c 100644 --- a/tools/cooja/java/se/sics/cooja/VisPlugin.java +++ b/tools/cooja/java/se/sics/cooja/VisPlugin.java @@ -83,7 +83,7 @@ public abstract class VisPlugin extends JInternalFrame implements Plugin { ); } - public JInternalFrame getGUI() { + public JInternalFrame getCooja() { return this; } diff --git a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMote.java b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMote.java index 98f30195d..e1277c985 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMote.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMote.java @@ -186,7 +186,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote { /* Ignored: handled by simulation */ } else if (name.equals("interface_config")) { Class moteInterfaceClass = - simulation.getGUI().tryLoadClass(this, MoteInterface.class, element.getText().trim()); + simulation.getCooja().tryLoadClass(this, MoteInterface.class, element.getText().trim()); if (moteInterfaceClass == null) { logger.fatal("Could not load mote interface class: " + element.getText().trim()); diff --git a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java index 8a3622ff8..f30938039 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java @@ -210,7 +210,7 @@ public class ContikiMoteType implements MoteType { public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable) throws MoteTypeCreationException { - myConfig = simulation.getGUI().getProjectConfig().clone(); + myConfig = simulation.getCooja().getProjectConfig().clone(); if (visAvailable) { @@ -1253,7 +1253,7 @@ public class ContikiMoteType implements MoteType { config.add(element); element = new Element("source"); - File file = simulation.getGUI().createPortablePath(getContikiSourceFile()); + File file = simulation.getCooja().createPortablePath(getContikiSourceFile()); element.setText(file.getPath().replaceAll("\\\\", "/")); config.add(element); @@ -1298,7 +1298,7 @@ public class ContikiMoteType implements MoteType { } else if (name.equals("contikiapp") || name.equals("source")) { File file = new File(element.getText()); if (!file.exists()) { - file = simulation.getGUI().restorePortablePath(file); + file = simulation.getCooja().restorePortablePath(file); } setContikiSourceFile(file); @@ -1324,7 +1324,7 @@ public class ContikiMoteType implements MoteType { /* Backwards compatibility: ContikiLog was removed */ } else { Class moteInterfaceClass = - simulation.getGUI().tryLoadClass( + simulation.getCooja().tryLoadClass( this, MoteInterface.class, element.getText().trim()); if (moteInterfaceClass == null) { diff --git a/tools/cooja/java/se/sics/cooja/dialogs/AbstractCompileDialog.java b/tools/cooja/java/se/sics/cooja/dialogs/AbstractCompileDialog.java index 8562ee18b..05bc5e7f7 100644 --- a/tools/cooja/java/se/sics/cooja/dialogs/AbstractCompileDialog.java +++ b/tools/cooja/java/se/sics/cooja/dialogs/AbstractCompileDialog.java @@ -135,7 +135,7 @@ public abstract class AbstractCompileDialog extends JDialog { (Frame)parent, "Create Mote Type: Compile Contiki", ModalityType.APPLICATION_MODAL); this.simulation = simulation; - this.gui = simulation.getGUI(); + this.gui = simulation.getCooja(); this.moteType = moteType; JPanel mainPanel = new JPanel(new BorderLayout()); diff --git a/tools/cooja/java/se/sics/cooja/dialogs/AddMoteDialog.java b/tools/cooja/java/se/sics/cooja/dialogs/AddMoteDialog.java index 8c0d7c199..df15cc473 100644 --- a/tools/cooja/java/se/sics/cooja/dialogs/AddMoteDialog.java +++ b/tools/cooja/java/se/sics/cooja/dialogs/AddMoteDialog.java @@ -211,7 +211,7 @@ public class AddMoteDialog extends JDialog { label = new JLabel("Positioning"); label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT)); - Vector> positioners = simulation.getGUI() + Vector> positioners = simulation.getCooja() .getRegisteredPositioners(); String[] posDistributions = new String[positioners.size()]; for (int i = 0; i < posDistributions.length; i++) { @@ -463,7 +463,7 @@ public class AddMoteDialog extends JDialog { // Position new motes Class positionerClass = null; - for (Class positioner : simulation.getGUI() + for (Class positioner : simulation.getCooja() .getRegisteredPositioners()) { if (Cooja.getDescriptionOf(positioner).equals( positionDistributionBox.getSelectedItem())) { diff --git a/tools/cooja/java/se/sics/cooja/dialogs/CreateSimDialog.java b/tools/cooja/java/se/sics/cooja/dialogs/CreateSimDialog.java index 8d3cdfb2a..1be8c41b9 100644 --- a/tools/cooja/java/se/sics/cooja/dialogs/CreateSimDialog.java +++ b/tools/cooja/java/se/sics/cooja/dialogs/CreateSimDialog.java @@ -94,7 +94,7 @@ public class CreateSimDialog extends JDialog { * @return True if simulation configured correctly */ public static boolean showDialog(Container parent, Simulation simulation) { - final CreateSimDialog dialog = new CreateSimDialog((Window) parent, simulation.getGUI()); + final CreateSimDialog dialog = new CreateSimDialog((Window) parent, simulation.getCooja()); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { @@ -340,7 +340,7 @@ public class CreateSimDialog extends JDialog { mySimulation.setTitle(title.getText()); String currentRadioMediumDescription = (String) radioMediumBox.getSelectedItem(); - for (Class radioMediumClass: mySimulation.getGUI().getRegisteredRadioMediums()) { + for (Class radioMediumClass: mySimulation.getCooja().getRegisteredRadioMediums()) { String radioMediumDescription = Cooja.getDescriptionOf(radioMediumClass); if (currentRadioMediumDescription.equals(radioMediumDescription)) { diff --git a/tools/cooja/java/se/sics/cooja/dialogs/ImportAppMoteDialog.java b/tools/cooja/java/se/sics/cooja/dialogs/ImportAppMoteDialog.java index f5f2715b2..3b8d6b765 100644 --- a/tools/cooja/java/se/sics/cooja/dialogs/ImportAppMoteDialog.java +++ b/tools/cooja/java/se/sics/cooja/dialogs/ImportAppMoteDialog.java @@ -126,7 +126,7 @@ public class ImportAppMoteDialog extends JDialog { } else if (name.length() > 0) { fc.setSelectedFile(new File(new File(path), name.replace(".", "/") + ".class")); } else { - File fp = simulation.getGUI() + File fp = simulation.getCooja() .restorePortablePath(new File(Cooja.getExternalToolsSetting("IMPORT_APP_LAST", "mymote.class"))); if (path.length() > 0 && !fp.getAbsolutePath().startsWith(path)) { @@ -250,7 +250,7 @@ public class ImportAppMoteDialog extends JDialog { pathField.setText(loader.getTestClassPath().getPath()); classField.setText(loader.getTestClassName()); Cooja.setExternalToolsSetting("IMPORT_APP_LAST", - simulation.getGUI().createPortablePath(classFile).getPath()); + simulation.getCooja().createPortablePath(classFile).getPath()); return true; } } catch (FileNotFoundException e1) { diff --git a/tools/cooja/java/se/sics/cooja/interfaces/Mote2MoteRelations.java b/tools/cooja/java/se/sics/cooja/interfaces/Mote2MoteRelations.java index 71b450cca..7379ea34a 100644 --- a/tools/cooja/java/se/sics/cooja/interfaces/Mote2MoteRelations.java +++ b/tools/cooja/java/se/sics/cooja/interfaces/Mote2MoteRelations.java @@ -92,7 +92,7 @@ public class Mote2MoteRelations extends MoteInterface { public Mote2MoteRelations(Mote mote) { this.mote = mote; - this.gui = mote.getSimulation().getGUI(); + this.gui = mote.getSimulation().getCooja(); } public void added() { diff --git a/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMote.java b/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMote.java index b757ce572..7deae8ec7 100644 --- a/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMote.java +++ b/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMote.java @@ -155,7 +155,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme /* Ignored: handled by simulation */ } else if (name.equals("interface_config")) { Class moteInterfaceClass = - simulation.getGUI().tryLoadClass(this, MoteInterface.class, element.getText().trim()); + simulation.getCooja().tryLoadClass(this, MoteInterface.class, element.getText().trim()); if (moteInterfaceClass == null) { logger.warn("Can't find mote interface class: " + element.getText()); diff --git a/tools/cooja/java/se/sics/cooja/motes/ImportAppMoteType.java b/tools/cooja/java/se/sics/cooja/motes/ImportAppMoteType.java index 98a0f22f3..d8d78efef 100644 --- a/tools/cooja/java/se/sics/cooja/motes/ImportAppMoteType.java +++ b/tools/cooja/java/se/sics/cooja/motes/ImportAppMoteType.java @@ -79,7 +79,7 @@ public class ImportAppMoteType extends AbstractApplicationMoteType { if (moteClassPath != null) { Element element = new Element("motepath"); - File file = simulation.getGUI().createPortablePath(moteClassPath); + File file = simulation.getCooja().createPortablePath(moteClassPath); element.setText(file.getPath().replaceAll("\\\\", "/")); config.add(element); } @@ -103,7 +103,7 @@ public class ImportAppMoteType extends AbstractApplicationMoteType { if (name.equals("moteclass")) { moteClassName = element.getText(); } else if (name.equals("motepath")) { - moteClassPath = simulation.getGUI().restorePortablePath(new File(element.getText())); + moteClassPath = simulation.getCooja().restorePortablePath(new File(element.getText())); } } @@ -214,10 +214,10 @@ public class ImportAppMoteType extends AbstractApplicationMoteType { } private ClassLoader getParentClassLoader() { - if (simulation.getGUI().projectDirClassLoader == null) { + if (simulation.getCooja().projectDirClassLoader == null) { return ClassLoader.getSystemClassLoader(); } else { - return simulation.getGUI().projectDirClassLoader; + return simulation.getCooja().projectDirClassLoader; } } diff --git a/tools/cooja/java/se/sics/cooja/plugins/BufferListener.java b/tools/cooja/java/se/sics/cooja/plugins/BufferListener.java index e3feab88b..161dcb3dd 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/BufferListener.java +++ b/tools/cooja/java/se/sics/cooja/plugins/BufferListener.java @@ -470,7 +470,7 @@ public class BufferListener extends VisPlugin { if (d == null) { return; } - simulation.getGUI().signalMoteHighlight(d.mote); + simulation.getCooja().signalMoteHighlight(d.mote); } }); @@ -873,7 +873,7 @@ public class BufferListener extends VisPlugin { } else if ("parser".equals(name)) { String parserClassname = element.getText(); Class parserClass = - simulation.getGUI().tryLoadClass(this, Parser.class, parserClassname); + simulation.getCooja().tryLoadClass(this, Parser.class, parserClassname); if (parserClass == null) { logger.warn("Could not create buffer parser: could not find class: " + parserClassname); } else { @@ -882,7 +882,7 @@ public class BufferListener extends VisPlugin { } else if ("buffer".equals(name)) { String bufferClassname = element.getText(); Class btClass = - simulation.getGUI().tryLoadClass(this, Buffer.class, bufferClassname); + simulation.getCooja().tryLoadClass(this, Buffer.class, bufferClassname); if (btClass == null) { logger.warn("Could not create buffer parser: could not find class: " + bufferClassname); } else { @@ -1124,7 +1124,7 @@ public class BufferListener extends VisPlugin { int model = logTable.convertRowIndexToModel(view); long time = logs.get(model).time; - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof BufferListener)) { continue; @@ -1147,7 +1147,7 @@ public class BufferListener extends VisPlugin { int model = logTable.convertRowIndexToModel(view); long time = logs.get(model).time; - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof TimeLine)) { continue; @@ -1170,7 +1170,7 @@ public class BufferListener extends VisPlugin { int model = logTable.convertRowIndexToModel(view); long time = logs.get(model).time; - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof RadioLogger)) { continue; diff --git a/tools/cooja/java/se/sics/cooja/plugins/EventListener.java b/tools/cooja/java/se/sics/cooja/plugins/EventListener.java index 04e5f30f7..c443622ef 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/EventListener.java +++ b/tools/cooja/java/se/sics/cooja/plugins/EventListener.java @@ -139,8 +139,8 @@ public class EventListener extends VisPlugin { "View interface visualizer") { public void actionPerformed(ActionEvent e) { MoteInterfaceViewer plugin = - (MoteInterfaceViewer) mySimulation.getGUI().tryStartPlugin( - MoteInterfaceViewer.class, mySimulation.getGUI(), mySimulation, myMote); + (MoteInterfaceViewer) mySimulation.getCooja().tryStartPlugin( + MoteInterfaceViewer.class, mySimulation.getCooja(), mySimulation, myMote); plugin.setSelectedInterface(Cooja.getDescriptionOf(moteInterface.getClass())); } }); diff --git a/tools/cooja/java/se/sics/cooja/plugins/LogListener.java b/tools/cooja/java/se/sics/cooja/plugins/LogListener.java index e1521c5ee..e36b5668d 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/LogListener.java +++ b/tools/cooja/java/se/sics/cooja/plugins/LogListener.java @@ -387,7 +387,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp { if (d == null) { return; } - simulation.getGUI().signalMoteHighlight(d.ev.getMote()); + simulation.getCooja().signalMoteHighlight(d.ev.getMote()); } }); @@ -611,7 +611,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp { } if (appendToFile) { element = new Element("append"); - element.setText(simulation.getGUI().createPortablePath(appendStreamFile).getPath()); + element.setText(simulation.getCooja().createPortablePath(appendStreamFile).getPath()); config.add(element); } return config; @@ -641,7 +641,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp { repaintTimeColumn(); } else if ("append".equals(name)) { appendToFile = true; - appendStreamFile = simulation.getGUI().restorePortablePath(new File(element.getText())); + appendStreamFile = simulation.getCooja().restorePortablePath(new File(element.getText())); appendCheckBox.setSelected(true); if (!appendStreamFile.exists()) { try { @@ -695,7 +695,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp { filterTextField.setBackground(Color.red); filterTextField.setToolTipText("Syntax error in regular expression: " + e.getMessage()); } - simulation.getGUI().getDesktopPane().repaint(); + simulation.getCooja().getDesktopPane().repaint(); } public void trySelectTime(final long time) { @@ -876,7 +876,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp { int model = logTable.convertRowIndexToModel(view); long time = logs.get(model).ev.getTime(); - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof TimeLine)) { continue; @@ -899,7 +899,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp { int model = logTable.convertRowIndexToModel(view); long time = logs.get(model).ev.getTime(); - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof RadioLogger)) { continue; diff --git a/tools/cooja/java/se/sics/cooja/plugins/LogScriptEngine.java b/tools/cooja/java/se/sics/cooja/plugins/LogScriptEngine.java index 688a6afab..e71500ff4 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/LogScriptEngine.java +++ b/tools/cooja/java/se/sics/cooja/plugins/LogScriptEngine.java @@ -340,7 +340,7 @@ public class LogScriptEngine { Hashtable hash = new Hashtable(); engine.put("global", hash); engine.put("sim", simulation); - engine.put("gui", simulation.getGUI()); + engine.put("gui", simulation.getCooja()); engine.put("msg", new String("")); scriptMote = new ScriptMote(); @@ -401,7 +401,7 @@ public class LogScriptEngine { new Thread() { public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { } - simulation.getGUI().doQuit(false, exitCode); + simulation.getCooja().doQuit(false, exitCode); }; }.start(); new Thread() { diff --git a/tools/cooja/java/se/sics/cooja/plugins/MoteInformation.java b/tools/cooja/java/se/sics/cooja/plugins/MoteInformation.java index 3c7be120a..322a91737 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/MoteInformation.java +++ b/tools/cooja/java/se/sics/cooja/plugins/MoteInformation.java @@ -113,7 +113,7 @@ public class MoteInformation extends VisPlugin implements MotePlugin { button.setPreferredSize(size); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - simulation.getGUI().tryStartPlugin(MoteTypeInformation.class, simulation.getGUI(), simulation, mote); + simulation.getCooja().tryStartPlugin(MoteTypeInformation.class, simulation.getCooja(), simulation, mote); } }); smallPane.add(BorderLayout.EAST, button); @@ -134,7 +134,7 @@ public class MoteInformation extends VisPlugin implements MotePlugin { button.setPreferredSize(size); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - simulation.getGUI().tryStartPlugin(MoteInterfaceViewer.class, simulation.getGUI(), simulation, mote); + simulation.getCooja().tryStartPlugin(MoteInterfaceViewer.class, simulation.getCooja(), simulation, mote); } }); smallPane.add(BorderLayout.EAST, button); diff --git a/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java b/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java index b7e37e158..6c28ed2ae 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java +++ b/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java @@ -117,7 +117,7 @@ public class MoteInterfaceViewer extends VisPlugin implements HasQuickHelp, Mote for (MoteInterface intf : intfs) { if (Cooja.getDescriptionOf(intf).equals(interfaceDescription)) { selectedMoteInterface = intf; - mote.getSimulation().getGUI().loadQuickHelp(MoteInterfaceViewer.this); + mote.getSimulation().getCooja().loadQuickHelp(MoteInterfaceViewer.this); break; } } diff --git a/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java b/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java index 751ad3197..15b9f2ef2 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java +++ b/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java @@ -887,7 +887,7 @@ public class RadioLogger extends VisPlugin { verboseBox.setText(""); setTitle("Radio messages: showing " + dataTable.getRowCount() + "/" + connections.size() + " packets"); - simulation.getGUI().getDesktopPane().repaint(); + simulation.getCooja().getDesktopPane().repaint(); } private Action createAnalyzerAction(String name, final String actionName, @@ -1010,7 +1010,7 @@ public class RadioLogger extends VisPlugin { long time = connections.get(selectedRow).startTime; - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof TimeLine)) { continue; @@ -1033,7 +1033,7 @@ public class RadioLogger extends VisPlugin { long time = connections.get(selectedRow).startTime; - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof LogListener)) { continue; diff --git a/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java b/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java index 7f0d04654..17e1e1c05 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java +++ b/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java @@ -435,7 +435,7 @@ public class ScriptRunner extends VisPlugin { private void exportAndRun() { /* Save simulation config */ - File configFile = simulation.getGUI().doSaveConfig(true); + File configFile = simulation.getCooja().doSaveConfig(true); if (configFile == null) { return; } @@ -617,7 +617,7 @@ public class ScriptRunner extends VisPlugin { if (linkedFile != null) { element = new Element("scriptfile"); - element.setText(simulation.getGUI().createPortablePath(linkedFile).getPath().replace('\\', '/')); + element.setText(simulation.getCooja().createPortablePath(linkedFile).getPath().replace('\\', '/')); config.add(element); } else { element = new Element("script"); @@ -651,7 +651,7 @@ public class ScriptRunner extends VisPlugin { updateScript(element.getText()); } } else if ("scriptfile".equals(name)) { - File file = simulation.getGUI().restorePortablePath(new File(element.getText().trim())); + File file = simulation.getCooja().restorePortablePath(new File(element.getText().trim())); setLinkFile(file); } else if ("active".equals(name)) { boolean active = Boolean.parseBoolean(element.getText()); diff --git a/tools/cooja/java/se/sics/cooja/plugins/SimControl.java b/tools/cooja/java/se/sics/cooja/plugins/SimControl.java index 32b8185a2..578d1a34d 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/SimControl.java +++ b/tools/cooja/java/se/sics/cooja/plugins/SimControl.java @@ -323,7 +323,7 @@ public class SimControl extends VisPlugin implements HasQuickHelp { }; private Action reloadAction = new AbstractAction("Reload") { public void actionPerformed(ActionEvent e) { - simulation.getGUI().reloadCurrentSimulation(simulation.isRunning()); + simulation.getCooja().reloadCurrentSimulation(simulation.isRunning()); } }; diff --git a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java index 122880712..2d13b03e7 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java +++ b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java @@ -253,7 +253,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp { showLogOutputs = ((JCheckBox) e.getSource()).isSelected(); /* Check whether there is an active log listener that is used to filter logs */ - logEventFilterPlugin = (LogListener) simulation.getGUI().getPlugin( + logEventFilterPlugin = (LogListener) simulation.getCooja().getPlugin( LogListener.class.getName()); if (showLogOutputs) { if (logEventFilterPlugin != null) { @@ -942,7 +942,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp { } long time = (long) (popupLocation.x*currentPixelDivisor); - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof RadioLogger)) { continue; @@ -962,7 +962,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp { } long time = (long) (popupLocation.x*currentPixelDivisor); - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof LogListener)) { continue; @@ -1270,7 +1270,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp { repaintTimelineTimer.stop(); if (moteHighlightObserver != null) { - simulation.getGUI().deleteMoteHighlightObserver(moteHighlightObserver); + simulation.getCooja().deleteMoteHighlightObserver(moteHighlightObserver); } simulation.getEventCentral().removeMoteCountListener(newMotesListener); @@ -1432,7 +1432,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp { showInAllAction.actionPerformed(null); long time = (long) (popupLocation.x*currentPixelDivisor); - Plugin[] plugins = simulation.getGUI().getStartedPlugins(); + Plugin[] plugins = simulation.getCooja().getStartedPlugins(); for (Plugin p: plugins) { if (!(p instanceof TimeLine)) { continue; @@ -1874,7 +1874,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp { if (m == null) { return; } - simulation.getGUI().signalMoteHighlight(m); + simulation.getCooja().signalMoteHighlight(m); sortItem.setText("Sort by distance: " + m); sortItem.putClientProperty("mote", m); diff --git a/tools/cooja/java/se/sics/cooja/plugins/Visualizer.java b/tools/cooja/java/se/sics/cooja/plugins/Visualizer.java index 230ee0a92..ea53493b9 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/Visualizer.java +++ b/tools/cooja/java/se/sics/cooja/plugins/Visualizer.java @@ -572,7 +572,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { continue; } Class skinClass = - simulation.getGUI().tryLoadClass(this, VisualizerSkin.class, skin); + simulation.getCooja().tryLoadClass(this, VisualizerSkin.class, skin); generateAndActivateSkin(skinClass); } } @@ -640,7 +640,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { /* Add registered mote actions */ for (final Mote mote : motes) { - menu.add(simulation.getGUI().createMotePluginsSubmenu(mote)); + menu.add(simulation.getCooja().createMotePluginsSubmenu(mote)); for (Class menuActionClass: moteMenuActions) { try { final MoteMenuAction menuAction = menuActionClass.newInstance(); @@ -1018,7 +1018,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { /* Paint mote relations */ if (showMoteToMoteRelations) { - MoteRelation[] relations = simulation.getGUI().getMoteRelations(); + MoteRelation[] relations = simulation.getCooja().getMoteRelations(); for (MoteRelation r: relations) { Position sourcePos = r.source.getInterfaces().getPosition(); Position destPos = r.dest.getInterfaces().getPosition(); @@ -1431,9 +1431,9 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { String desc = Cooja.getDescriptionOf(mote.getInterfaces().getLED()); MoteInterfaceViewer viewer = - (MoteInterfaceViewer) simulation.getGUI().tryStartPlugin( + (MoteInterfaceViewer) simulation.getCooja().tryStartPlugin( MoteInterfaceViewer.class, - simulation.getGUI(), + simulation.getCooja(), simulation, mote); if (viewer == null) { @@ -1474,9 +1474,9 @@ public class Visualizer extends VisPlugin implements HasQuickHelp { String desc = Cooja.getDescriptionOf(serialPort); MoteInterfaceViewer viewer = - (MoteInterfaceViewer) simulation.getGUI().tryStartPlugin( + (MoteInterfaceViewer) simulation.getCooja().tryStartPlugin( MoteInterfaceViewer.class, - simulation.getGUI(), + simulation.getCooja(), simulation, mote); if (viewer == null) { diff --git a/tools/cooja/java/se/sics/cooja/radiomediums/DirectedGraphMedium.java b/tools/cooja/java/se/sics/cooja/radiomediums/DirectedGraphMedium.java index 59a5ce671..6d9261b7d 100644 --- a/tools/cooja/java/se/sics/cooja/radiomediums/DirectedGraphMedium.java +++ b/tools/cooja/java/se/sics/cooja/radiomediums/DirectedGraphMedium.java @@ -88,7 +88,7 @@ public class DirectedGraphMedium extends AbstractRadioMedium { requestEdgeAnalysis(); /* Register plugin and visualizer skin */ - simulation.getGUI().registerPlugin(DGRMConfigurator.class); + simulation.getCooja().registerPlugin(DGRMConfigurator.class); Visualizer.registerVisualizerSkin(DGRMVisualizerSkin.class); } @@ -96,7 +96,7 @@ public class DirectedGraphMedium extends AbstractRadioMedium { super.removed(); /* Unregister plugin and visualizer skin */ - simulation.getGUI().unregisterPlugin(DGRMConfigurator.class); + simulation.getCooja().unregisterPlugin(DGRMConfigurator.class); Visualizer.unregisterVisualizerSkin(DGRMVisualizerSkin.class); } @@ -392,7 +392,7 @@ public void simulationFinishedLoading() { continue; } Class destClass = - simulation.getGUI().tryLoadClass(this, DGRMDestinationRadio.class, destClassName); + simulation.getCooja().tryLoadClass(this, DGRMDestinationRadio.class, destClassName); if (destClass == null) { throw new RuntimeException("Could not load class: " + destClassName); } diff --git a/tools/cooja/java/se/sics/cooja/util/ExecuteJAR.java b/tools/cooja/java/se/sics/cooja/util/ExecuteJAR.java index e0efc551a..1ce31e609 100644 --- a/tools/cooja/java/se/sics/cooja/util/ExecuteJAR.java +++ b/tools/cooja/java/se/sics/cooja/util/ExecuteJAR.java @@ -111,7 +111,7 @@ public class ExecuteJAR { s.stopSimulation(); try { - buildExecutableJAR(s.getGUI(), jar); + buildExecutableJAR(s.getCooja(), jar); } catch (RuntimeException e) { logger.fatal(e.getMessage(), e); System.exit(1);