renamed getGUI() method to getCooja(), to better reflect its purpose

This commit is contained in:
Fredrik Osterlind 2013-11-19 10:30:19 +01:00
parent 625537158f
commit 2a9283884c
33 changed files with 130 additions and 136 deletions

View file

@ -221,7 +221,7 @@ public class MicaZMote extends AbstractEmulatedMote implements Mote {
if (name.equals("motetype_identifier")) { if (name.equals("motetype_identifier")) {
/* Ignored: handled by simulation */ /* Ignored: handled by simulation */
} else if (name.equals("interface_config")) { } else if (name.equals("interface_config")) {
Class<? extends MoteInterface> moteInterfaceClass = simulation.getGUI().tryLoadClass( Class<? extends MoteInterface> moteInterfaceClass = simulation.getCooja().tryLoadClass(
this, MoteInterface.class, element.getText().trim()); this, MoteInterface.class, element.getText().trim());
if (moteInterfaceClass == null) { if (moteInterfaceClass == null) {

View file

@ -241,7 +241,7 @@ public class MicaZMoteType implements MoteType {
// Source file // Source file
if (fileSource != null) { if (fileSource != null) {
element = new Element("source"); element = new Element("source");
File file = simulation.getGUI().createPortablePath(fileSource); File file = simulation.getCooja().createPortablePath(fileSource);
element.setText(file.getPath().replaceAll("\\\\", "/")); element.setText(file.getPath().replaceAll("\\\\", "/"));
config.add(element); config.add(element);
element = new Element("commands"); element = new Element("commands");
@ -251,7 +251,7 @@ public class MicaZMoteType implements MoteType {
// Firmware file // Firmware file
element = new Element("firmware"); element = new Element("firmware");
File file = simulation.getGUI().createPortablePath(fileFirmware); File file = simulation.getCooja().createPortablePath(fileFirmware);
element.setText(file.getPath().replaceAll("\\\\", "/")); element.setText(file.getPath().replaceAll("\\\\", "/"));
config.add(element); config.add(element);
@ -280,20 +280,20 @@ public class MicaZMoteType implements MoteType {
} else if (name.equals("source")) { } else if (name.equals("source")) {
fileSource = new File(element.getText()); fileSource = new File(element.getText());
if (!fileSource.exists()) { if (!fileSource.exists()) {
fileSource = simulation.getGUI().restorePortablePath(fileSource); fileSource = simulation.getCooja().restorePortablePath(fileSource);
} }
} else if (name.equals("commands")) { } else if (name.equals("commands")) {
compileCommands = element.getText(); compileCommands = element.getText();
} else if (name.equals("firmware")) { } else if (name.equals("firmware")) {
fileFirmware = new File(element.getText()); fileFirmware = new File(element.getText());
if (!fileFirmware.exists()) { if (!fileFirmware.exists()) {
fileFirmware = simulation.getGUI().restorePortablePath(fileFirmware); fileFirmware = simulation.getCooja().restorePortablePath(fileFirmware);
} }
} else if (name.equals("moteinterface")) { } else if (name.equals("moteinterface")) {
String intfClass = element.getText().trim(); String intfClass = element.getText().trim();
Class<? extends MoteInterface> moteInterfaceClass = Class<? extends MoteInterface> moteInterfaceClass =
simulation.getGUI().tryLoadClass(this, MoteInterface.class, intfClass); simulation.getCooja().tryLoadClass(this, MoteInterface.class, intfClass);
if (moteInterfaceClass == null) { if (moteInterfaceClass == null) {
logger.warn("Can't find mote interface class: " + intfClass); logger.warn("Can't find mote interface class: " + intfClass);

View file

@ -118,8 +118,8 @@ public class MRM extends AbstractRadioMedium {
}); });
/* Register plugins */ /* Register plugins */
sim.getGUI().registerPlugin(AreaViewer.class); sim.getCooja().registerPlugin(AreaViewer.class);
sim.getGUI().registerPlugin(FormulaViewer.class); sim.getCooja().registerPlugin(FormulaViewer.class);
Visualizer.registerVisualizerSkin(MRMVisualizerSkin.class); Visualizer.registerVisualizerSkin(MRMVisualizerSkin.class);
} }
@ -127,8 +127,8 @@ public class MRM extends AbstractRadioMedium {
super.removed(); super.removed();
/* Unregister plugins */ /* Unregister plugins */
sim.getGUI().unregisterPlugin(AreaViewer.class); sim.getCooja().unregisterPlugin(AreaViewer.class);
sim.getGUI().unregisterPlugin(FormulaViewer.class); sim.getCooja().unregisterPlugin(FormulaViewer.class);
Visualizer.unregisterVisualizerSkin(MRMVisualizerSkin.class); Visualizer.unregisterVisualizerSkin(MRMVisualizerSkin.class);
currentChannelModel.deleteSettingsObserver(channelModelObserver); currentChannelModel.deleteSettingsObserver(channelModelObserver);

View file

@ -421,7 +421,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
if (intfClass.equals("se.sics.cooja.mspmote.interfaces.SkySerial")) { if (intfClass.equals("se.sics.cooja.mspmote.interfaces.SkySerial")) {
intfClass = MspSerial.class.getName(); intfClass = MspSerial.class.getName();
} }
Class<? extends MoteInterface> moteInterfaceClass = simulation.getGUI().tryLoadClass( Class<? extends MoteInterface> moteInterfaceClass = simulation.getCooja().tryLoadClass(
this, MoteInterface.class, intfClass); this, MoteInterface.class, intfClass);
if (moteInterfaceClass == null) { if (moteInterfaceClass == null) {

View file

@ -202,7 +202,7 @@ public abstract class MspMoteType implements MoteType {
// Source file // Source file
if (fileSource != null) { if (fileSource != null) {
element = new Element("source"); element = new Element("source");
File file = simulation.getGUI().createPortablePath(fileSource); File file = simulation.getCooja().createPortablePath(fileSource);
element.setText(file.getPath().replaceAll("\\\\", "/")); element.setText(file.getPath().replaceAll("\\\\", "/"));
element.setAttribute("EXPORT", "discard"); element.setAttribute("EXPORT", "discard");
config.add(element); config.add(element);
@ -214,7 +214,7 @@ public abstract class MspMoteType implements MoteType {
// Firmware file // Firmware file
element = new Element("firmware"); element = new Element("firmware");
File file = simulation.getGUI().createPortablePath(fileFirmware); File file = simulation.getCooja().createPortablePath(fileFirmware);
element.setText(file.getPath().replaceAll("\\\\", "/")); element.setText(file.getPath().replaceAll("\\\\", "/"));
element.setAttribute("EXPORT", "copy"); element.setAttribute("EXPORT", "copy");
config.add(element); config.add(element);
@ -244,7 +244,7 @@ public abstract class MspMoteType implements MoteType {
} else if (name.equals("source")) { } else if (name.equals("source")) {
fileSource = new File(element.getText()); fileSource = new File(element.getText());
if (!fileSource.exists()) { if (!fileSource.exists()) {
fileSource = simulation.getGUI().restorePortablePath(fileSource); fileSource = simulation.getCooja().restorePortablePath(fileSource);
} }
} else if (name.equals("command")) { } else if (name.equals("command")) {
/* Backwards compatibility: command is now commands */ /* Backwards compatibility: command is now commands */
@ -255,7 +255,7 @@ public abstract class MspMoteType implements MoteType {
} else if (name.equals("firmware")) { } else if (name.equals("firmware")) {
fileFirmware = new File(element.getText()); fileFirmware = new File(element.getText());
if (!fileFirmware.exists()) { if (!fileFirmware.exists()) {
fileFirmware = simulation.getGUI().restorePortablePath(fileFirmware); fileFirmware = simulation.getCooja().restorePortablePath(fileFirmware);
} }
} else if (name.equals("elf")) { } else if (name.equals("elf")) {
/* Backwards compatibility: elf is now firmware */ /* Backwards compatibility: elf is now firmware */
@ -283,7 +283,7 @@ public abstract class MspMoteType implements MoteType {
} }
Class<? extends MoteInterface> moteInterfaceClass = Class<? extends MoteInterface> moteInterfaceClass =
simulation.getGUI().tryLoadClass(this, MoteInterface.class, intfClass); simulation.getCooja().tryLoadClass(this, MoteInterface.class, intfClass);
if (moteInterfaceClass == null) { if (moteInterfaceClass == null) {
logger.warn("Can't find mote interface class: " + intfClass); logger.warn("Can't find mote interface class: " + intfClass);

View file

@ -169,7 +169,7 @@ public class MspBreakpoint implements Watchpoint {
config.add(element); config.add(element);
element = new Element("codefile"); element = new Element("codefile");
File file = mspMote.getSimulation().getGUI().createPortablePath(codeFile); File file = mspMote.getSimulation().getCooja().createPortablePath(codeFile);
element.setText(file.getPath().replaceAll("\\\\", "/")); element.setText(file.getPath().replaceAll("\\\\", "/"));
config.add(element); config.add(element);
@ -204,7 +204,7 @@ public class MspBreakpoint implements Watchpoint {
for (Element element : configXML) { for (Element element : configXML) {
if (element.getName().equals("codefile")) { if (element.getName().equals("codefile")) {
File file = new File(element.getText()); File file = new File(element.getText());
file = mspMote.getSimulation().getGUI().restorePortablePath(file); file = mspMote.getSimulation().getCooja().restorePortablePath(file);
try { try {
codeFile = file.getCanonicalFile(); codeFile = file.getCanonicalFile();

View file

@ -24,7 +24,7 @@ while (counter<10) {
YIELD_THEN_WAIT_UNTIL(msg.equals("wait")); YIELD_THEN_WAIT_UNTIL(msg.equals("wait"));
/* Toggle Log Listener filter */ /* 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) { if (plugin != null) {
plugins++; plugins++;
log.log("LogListener: Setting filter: " + plugin.getFilter() + "\n"); log.log("LogListener: Setting filter: " + plugin.getFilter() + "\n");
@ -39,7 +39,7 @@ while (counter<10) {
YIELD_THEN_WAIT_UNTIL(msg.equals("wait")); YIELD_THEN_WAIT_UNTIL(msg.equals("wait"));
/* Extract PowerTracker statistics */ /* Extract PowerTracker statistics */
plugin = mote.getSimulation().getGUI().getStartedPlugin("PowerTracker"); plugin = mote.getSimulation().getCooja().getStartedPlugin("PowerTracker");
if (plugin != null) { if (plugin != null) {
plugins++; plugins++;
stats = plugin.radioStatistics(); stats = plugin.radioStatistics();
@ -56,7 +56,7 @@ while (counter<10) {
YIELD_THEN_WAIT_UNTIL(msg.equals("wait")); YIELD_THEN_WAIT_UNTIL(msg.equals("wait"));
/* Select time in Radio Logger */ /* 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) { if (plugin != null) {
plugins++; plugins++;
log.log("RadioLogger: Showing logged radio packet at mid simulation\n"); log.log("RadioLogger: Showing logged radio packet at mid simulation\n");

View file

@ -60,16 +60,13 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.StringReader; import java.io.StringReader;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.security.AccessControlException; import java.security.AccessControlException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Observable; 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 static final String WINDOW_TITLE = "Cooja: The Contiki Network Simulator";
private Cooja myGUI; private Cooja cooja;
private Simulation mySimulation; private Simulation mySimulation;
@ -370,7 +367,7 @@ public class Cooja extends Observable {
* @param desktop Desktop pane * @param desktop Desktop pane
*/ */
public Cooja(JDesktopPane desktop) { public Cooja(JDesktopPane desktop) {
myGUI = this; cooja = this;
mySimulation = null; mySimulation = null;
myDesktopPane = desktop; myDesktopPane = desktop;
@ -542,7 +539,7 @@ public class Cooja extends Observable {
public void setVisualizedInFrame(boolean visualized) { public void setVisualizedInFrame(boolean visualized) {
if (visualized) { if (visualized) {
if (!isVisualizedInFrame()) { if (!isVisualizedInFrame()) {
configureFrame(myGUI, false); configureFrame(cooja, false);
} }
} else { } else {
if (frame != null) { if (frame != null) {
@ -633,7 +630,7 @@ public class Cooja extends Observable {
private void doLoadConfigAsync(final boolean ask, final boolean quick, final File file) { private void doLoadConfigAsync(final boolean ask, final boolean quick, final File file) {
new Thread(new Runnable() { new Thread(new Runnable() {
public void run() { public void run() {
myGUI.doLoadConfig(ask, quick, file, null); cooja.doLoadConfig(ask, quick, file, null);
} }
}).start(); }).start();
} }
@ -944,7 +941,7 @@ public class Cooja extends Observable {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Object pluginClass = ((JMenuItem)e.getSource()).getClientProperty("class"); Object pluginClass = ((JMenuItem)e.getSource()).getClientProperty("class");
Object mote = ((JMenuItem)e.getSource()).getClientProperty("mote"); Object mote = ((JMenuItem)e.getSource()).getClientProperty("mote");
tryStartPlugin((Class<? extends Plugin>) pluginClass, myGUI, getSimulation(), (Mote)mote); tryStartPlugin((Class<? extends Plugin>) pluginClass, cooja, getSimulation(), (Mote)mote);
} }
}; };
private JMenuItem createMenuItem(Class<? extends Plugin> newPluginClass, int pluginType) { private JMenuItem createMenuItem(Class<? extends Plugin> newPluginClass, int pluginType) {
@ -1657,7 +1654,7 @@ public class Cooja extends Observable {
public void showPlugin(final Plugin plugin) { public void showPlugin(final Plugin plugin) {
new RunnableInEDT<Boolean>() { new RunnableInEDT<Boolean>() {
public Boolean work() { public Boolean work() {
JInternalFrame pluginFrame = plugin.getGUI(); JInternalFrame pluginFrame = plugin.getCooja();
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;
@ -1730,8 +1727,8 @@ public class Cooja extends Observable {
updateGUIComponentState(); updateGUIComponentState();
/* Dispose visualized components */ /* Dispose visualized components */
if (plugin.getGUI() != null) { if (plugin.getCooja() != null) {
plugin.getGUI().dispose(); plugin.getCooja().dispose();
} }
/* (OPTIONAL) Remove simulation if all plugins are closed */ /* (OPTIONAL) Remove simulation if all plugins are closed */
@ -1877,8 +1874,8 @@ public class Cooja extends Observable {
updateGUIComponentState(); updateGUIComponentState();
// Show plugin if visualizer type // Show plugin if visualizer type
if (activate && plugin.getGUI() != null) { if (activate && plugin.getCooja() != null) {
myGUI.showPlugin(plugin); cooja.showPlugin(plugin);
} }
return plugin; return plugin;
@ -2040,7 +2037,7 @@ public class Cooja extends Observable {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Object pluginClass = ((JMenuItem)e.getSource()).getClientProperty("class"); Object pluginClass = ((JMenuItem)e.getSource()).getClientProperty("class");
Object mote = ((JMenuItem)e.getSource()).getClientProperty("mote"); Object mote = ((JMenuItem)e.getSource()).getClientProperty("mote");
tryStartPlugin((Class<? extends Plugin>) pluginClass, myGUI, getSimulation(), (Mote)mote); tryStartPlugin((Class<? extends Plugin>) pluginClass, cooja, getSimulation(), (Mote)mote);
} }
}; };
@ -2392,10 +2389,10 @@ public class Cooja extends Observable {
do { do {
try { try {
shouldRetry = false; shouldRetry = false;
myGUI.doRemoveSimulation(false); cooja.doRemoveSimulation(false);
PROGRESS_WARNINGS.clear(); PROGRESS_WARNINGS.clear();
newSim = loadSimulationConfig(fileToLoad, quick, manualRandomSeed); newSim = loadSimulationConfig(fileToLoad, quick, manualRandomSeed);
myGUI.setSimulation(newSim, false); cooja.setSimulation(newSim, false);
/* Optionally show compilation warnings */ /* Optionally show compilation warnings */
boolean hideWarn = Boolean.parseBoolean( boolean hideWarn = Boolean.parseBoolean(
@ -2457,10 +2454,10 @@ public class Cooja extends Observable {
do { do {
try { try {
shouldRetry = false; shouldRetry = false;
myGUI.doRemoveSimulation(false); cooja.doRemoveSimulation(false);
PROGRESS_WARNINGS.clear(); PROGRESS_WARNINGS.clear();
Simulation newSim = loadSimulationConfig(root, true, new Long(randomSeed)); Simulation newSim = loadSimulationConfig(root, true, new Long(randomSeed));
myGUI.setSimulation(newSim, false); cooja.setSimulation(newSim, false);
if (autoStart) { if (autoStart) {
newSim.startSimulation(); newSim.startSimulation();
@ -2478,11 +2475,11 @@ public class Cooja extends Observable {
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
shouldRetry = showErrorDialog(frame, "Simulation reload error", e, true); shouldRetry = showErrorDialog(frame, "Simulation reload error", e, true);
myGUI.doRemoveSimulation(false); cooja.doRemoveSimulation(false);
} catch (SimulationCreationException e) { } catch (SimulationCreationException e) {
shouldRetry = showErrorDialog(frame, "Simulation reload error", e, true); shouldRetry = showErrorDialog(frame, "Simulation reload error", e, true);
myGUI.doRemoveSimulation(false); cooja.doRemoveSimulation(false);
} }
} while (shouldRetry); } while (shouldRetry);
@ -2666,7 +2663,7 @@ public class Cooja extends Observable {
Simulation newSim = new Simulation(this); Simulation newSim = new Simulation(this);
boolean createdOK = CreateSimDialog.showDialog(Cooja.getTopParentContainer(), newSim); boolean createdOK = CreateSimDialog.showDialog(Cooja.getTopParentContainer(), newSim);
if (createdOK) { 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, WINDOW_TITLE, JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE, null, options, s1); JOptionPane.WARNING_MESSAGE, null, options, s1);
if (n == JOptionPane.YES_OPTION) { if (n == JOptionPane.YES_OPTION) {
if (myGUI.doSaveConfig(true) == null) { if (cooja.doSaveConfig(true) == null) {
return; return;
} }
} else if (n == JOptionPane.CANCEL_OPTION) { } else if (n == JOptionPane.CANCEL_OPTION) {
@ -2925,10 +2922,10 @@ public class Cooja extends Observable {
private class GUIEventHandler implements ActionListener { private class GUIEventHandler implements ActionListener {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("create mote type")) { if (e.getActionCommand().equals("create mote type")) {
myGUI.doCreateMoteType((Class<? extends MoteType>) ((JMenuItem) e cooja.doCreateMoteType((Class<? extends MoteType>) ((JMenuItem) e
.getSource()).getClientProperty("class")); .getSource()).getClientProperty("class"));
} else if (e.getActionCommand().equals("add motes")) { } else if (e.getActionCommand().equals("add motes")) {
myGUI.doAddMotes((MoteType) ((JMenuItem) e.getSource()) cooja.doAddMotes((MoteType) ((JMenuItem) e.getSource())
.getClientProperty("motetype")); .getClientProperty("motetype"));
} else if (e.getActionCommand().equals("edit paths")) { } else if (e.getActionCommand().equals("edit paths")) {
ExternalToolsDialog.showDialog(Cooja.getTopParentContainer()); ExternalToolsDialog.showDialog(Cooja.getTopParentContainer());
@ -3230,7 +3227,7 @@ public class Cooja extends Observable {
if (sim == null) { if (sim == null) {
System.exit(1); System.exit(1);
} }
Cooja gui = sim.getGUI(); Cooja gui = sim.getCooja();
/* Make sure at least one test editor is controlling the simulation */ /* Make sure at least one test editor is controlling the simulation */
boolean hasEditor = false; boolean hasEditor = false;
@ -3552,8 +3549,8 @@ public class Cooja extends Observable {
} }
// If plugin is visualizer plugin, create visualization arguments // If plugin is visualizer plugin, create visualization arguments
if (startedPlugin.getGUI() != null) { if (startedPlugin.getCooja() != null) {
JInternalFrame pluginFrame = startedPlugin.getGUI(); JInternalFrame pluginFrame = startedPlugin.getCooja();
pluginSubElement = new Element("width"); pluginSubElement = new Element("width");
pluginSubElement.setText("" + pluginFrame.getSize().width); pluginSubElement.setText("" + pluginFrame.getSize().width);
@ -3683,7 +3680,7 @@ public class Cooja extends Observable {
startedPlugin.startPlugin(); startedPlugin.startPlugin();
/* If Cooja not visualized, ignore window configuration */ /* If Cooja not visualized, ignore window configuration */
if (startedPlugin.getGUI() == null) { if (startedPlugin.getCooja() == null) {
continue; continue;
} }
@ -3696,22 +3693,22 @@ public class Cooja extends Observable {
for (Element pluginSubElement : (List<Element>) pluginElement.getChildren()) { for (Element pluginSubElement : (List<Element>) pluginElement.getChildren()) {
if (pluginSubElement.getName().equals("width")) { if (pluginSubElement.getName().equals("width")) {
size.width = Integer.parseInt(pluginSubElement.getText()); size.width = Integer.parseInt(pluginSubElement.getText());
startedPlugin.getGUI().setSize(size); startedPlugin.getCooja().setSize(size);
} else if (pluginSubElement.getName().equals("height")) { } else if (pluginSubElement.getName().equals("height")) {
size.height = Integer.parseInt(pluginSubElement.getText()); size.height = Integer.parseInt(pluginSubElement.getText());
startedPlugin.getGUI().setSize(size); startedPlugin.getCooja().setSize(size);
} else if (pluginSubElement.getName().equals("z")) { } else if (pluginSubElement.getName().equals("z")) {
int zOrder = Integer.parseInt(pluginSubElement.getText()); int zOrder = Integer.parseInt(pluginSubElement.getText());
startedPlugin.getGUI().putClientProperty("zorder", zOrder); startedPlugin.getCooja().putClientProperty("zorder", zOrder);
} else if (pluginSubElement.getName().equals("location_x")) { } else if (pluginSubElement.getName().equals("location_x")) {
location.x = Integer.parseInt(pluginSubElement.getText()); location.x = Integer.parseInt(pluginSubElement.getText());
startedPlugin.getGUI().setLocation(location); startedPlugin.getCooja().setLocation(location);
} else if (pluginSubElement.getName().equals("location_y")) { } else if (pluginSubElement.getName().equals("location_y")) {
location.y = Integer.parseInt(pluginSubElement.getText()); location.y = Integer.parseInt(pluginSubElement.getText());
startedPlugin.getGUI().setLocation(location); startedPlugin.getCooja().setLocation(location);
} else if (pluginSubElement.getName().equals("minimized")) { } else if (pluginSubElement.getName().equals("minimized")) {
boolean minimized = Boolean.parseBoolean(pluginSubElement.getText()); boolean minimized = Boolean.parseBoolean(pluginSubElement.getText());
final JInternalFrame pluginGUI = startedPlugin.getGUI(); final JInternalFrame pluginGUI = startedPlugin.getCooja();
if (minimized && pluginGUI != null) { if (minimized && pluginGUI != null) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { 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)) { 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); cooja.doCreateSimulation(true);
} }
public boolean shouldBeEnabled() { public boolean shouldBeEnabled() {
return true; return true;
@ -4432,7 +4429,7 @@ public class Cooja extends Observable {
GUIAction closeSimulationAction = new GUIAction("Close simulation", KeyEvent.VK_C) { GUIAction closeSimulationAction = new GUIAction("Close simulation", KeyEvent.VK_C) {
private static final long serialVersionUID = -4783032948880161189L; private static final long serialVersionUID = -4783032948880161189L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
myGUI.doRemoveSimulation(true); cooja.doRemoveSimulation(true);
} }
public boolean shouldBeEnabled() { public boolean shouldBeEnabled() {
return getSimulation() != null; return getSimulation() != null;
@ -4446,7 +4443,7 @@ public class Cooja extends Observable {
final File file = getLastOpenedFile(); final File file = getLastOpenedFile();
new Thread(new Runnable() { new Thread(new Runnable() {
public void run() { public void run() {
myGUI.doLoadConfig(true, true, file, null); cooja.doLoadConfig(true, true, file, null);
} }
}).start(); }).start();
return; return;
@ -4476,7 +4473,7 @@ public class Cooja extends Observable {
GUIAction saveSimulationAction = new GUIAction("Save simulation as...", 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); cooja.doSaveConfig(true);
} }
public boolean shouldBeEnabled() { public boolean shouldBeEnabled() {
if (isVisualizedInApplet()) { if (isVisualizedInApplet()) {
@ -4577,7 +4574,7 @@ public class Cooja extends Observable {
GUIAction exitCoojaAction = new GUIAction("Exit", 'x') { GUIAction exitCoojaAction = new GUIAction("Exit", 'x') {
private static final long serialVersionUID = 7523822251658687665L; private static final long serialVersionUID = 7523822251658687665L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
myGUI.doQuit(true); cooja.doQuit(true);
} }
public boolean shouldBeEnabled() { public boolean shouldBeEnabled() {
if (isVisualizedInApplet()) { if (isVisualizedInApplet()) {
@ -4625,7 +4622,7 @@ public class Cooja extends Observable {
Class<Plugin> pluginClass = Class<Plugin> pluginClass =
(Class<Plugin>) ((JMenuItem) e.getSource()).getClientProperty("class"); (Class<Plugin>) ((JMenuItem) e.getSource()).getClientProperty("class");
Mote mote = (Mote) ((JMenuItem) e.getSource()).getClientProperty("mote"); Mote mote = (Mote) ((JMenuItem) e.getSource()).getClientProperty("mote");
tryStartPlugin(pluginClass, myGUI, mySimulation, mote); tryStartPlugin(pluginClass, cooja, mySimulation, mote);
} }
}).start(); }).start();
} }

View file

@ -51,7 +51,7 @@ public interface Plugin {
/** /**
* Graphical component of plugin (if any) * Graphical component of plugin (if any)
*/ */
public JInternalFrame getGUI(); public JInternalFrame getCooja();
/** /**

View file

@ -85,7 +85,7 @@ public class Simulation extends Observable implements Runnable {
private Thread simulationThread = null; private Thread simulationThread = null;
private Cooja myGUI = null; private Cooja cooja = null;
private long randomSeed = 123456; private long randomSeed = 123456;
@ -320,8 +320,8 @@ public class Simulation extends Observable implements Runnable {
/** /**
* Creates a new simulation * Creates a new simulation
*/ */
public Simulation(Cooja gui) { public Simulation(Cooja cooja) {
myGUI = gui; this.cooja = cooja;
} }
/** /**
@ -393,11 +393,8 @@ public class Simulation extends Observable implements Runnable {
startSimulation(); startSimulation();
} }
/** public Cooja getCooja() {
* @return GUI holding this simulation return cooja;
*/
public Cooja getGUI() {
return myGUI;
} }
/** /**
@ -603,7 +600,7 @@ public class Simulation extends Observable implements Runnable {
// Radio medium // Radio medium
if (element.getName().equals("radiomedium")) { if (element.getName().equals("radiomedium")) {
String radioMediumClassName = element.getText().trim(); String radioMediumClassName = element.getText().trim();
Class<? extends RadioMedium> radioMediumClass = myGUI.tryLoadClass( Class<? extends RadioMedium> radioMediumClass = cooja.tryLoadClass(
this, RadioMedium.class, radioMediumClassName); this, RadioMedium.class, radioMediumClassName);
if (radioMediumClass != null) { if (radioMediumClass != null) {
@ -648,7 +645,7 @@ public class Simulation extends Observable implements Runnable {
/* Try to recreate simulation using a different mote type */ /* Try to recreate simulation using a different mote type */
if (visAvailable) { 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( String newClass = (String) JOptionPane.showInputDialog(
Cooja.getTopParentContainer(), Cooja.getTopParentContainer(),
"The simulation is about to load '" + moteTypeClassName + "'\n" + "The simulation is about to load '" + moteTypeClassName + "'\n" +
@ -668,7 +665,7 @@ public class Simulation extends Observable implements Runnable {
} }
} }
Class<? extends MoteType> moteTypeClass = myGUI.tryLoadClass(this, Class<? extends MoteType> moteTypeClass = cooja.tryLoadClass(this,
MoteType.class, moteTypeClassName); MoteType.class, moteTypeClassName);
if (moteTypeClass == null) { if (moteTypeClass == null) {
@ -782,7 +779,7 @@ public class Simulation extends Observable implements Runnable {
invokeSimulationThread(removeMote); invokeSimulationThread(removeMote);
} }
getGUI().closeMotePlugins(mote); getCooja().closeMotePlugins(mote);
} }
/** /**

View file

@ -83,7 +83,7 @@ public abstract class VisPlugin extends JInternalFrame implements Plugin {
); );
} }
public JInternalFrame getGUI() { public JInternalFrame getCooja() {
return this; return this;
} }

View file

@ -186,7 +186,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
/* Ignored: handled by simulation */ /* Ignored: handled by simulation */
} else if (name.equals("interface_config")) { } else if (name.equals("interface_config")) {
Class<? extends MoteInterface> moteInterfaceClass = Class<? extends MoteInterface> moteInterfaceClass =
simulation.getGUI().tryLoadClass(this, MoteInterface.class, element.getText().trim()); simulation.getCooja().tryLoadClass(this, MoteInterface.class, element.getText().trim());
if (moteInterfaceClass == null) { if (moteInterfaceClass == null) {
logger.fatal("Could not load mote interface class: " + element.getText().trim()); logger.fatal("Could not load mote interface class: " + element.getText().trim());

View file

@ -210,7 +210,7 @@ public class ContikiMoteType implements MoteType {
public boolean configureAndInit(Container parentContainer, Simulation simulation, public boolean configureAndInit(Container parentContainer, Simulation simulation,
boolean visAvailable) throws MoteTypeCreationException { boolean visAvailable) throws MoteTypeCreationException {
myConfig = simulation.getGUI().getProjectConfig().clone(); myConfig = simulation.getCooja().getProjectConfig().clone();
if (visAvailable) { if (visAvailable) {
@ -1253,7 +1253,7 @@ public class ContikiMoteType implements MoteType {
config.add(element); config.add(element);
element = new Element("source"); element = new Element("source");
File file = simulation.getGUI().createPortablePath(getContikiSourceFile()); File file = simulation.getCooja().createPortablePath(getContikiSourceFile());
element.setText(file.getPath().replaceAll("\\\\", "/")); element.setText(file.getPath().replaceAll("\\\\", "/"));
config.add(element); config.add(element);
@ -1298,7 +1298,7 @@ public class ContikiMoteType implements MoteType {
} else if (name.equals("contikiapp") || name.equals("source")) { } else if (name.equals("contikiapp") || name.equals("source")) {
File file = new File(element.getText()); File file = new File(element.getText());
if (!file.exists()) { if (!file.exists()) {
file = simulation.getGUI().restorePortablePath(file); file = simulation.getCooja().restorePortablePath(file);
} }
setContikiSourceFile(file); setContikiSourceFile(file);
@ -1324,7 +1324,7 @@ public class ContikiMoteType implements MoteType {
/* Backwards compatibility: ContikiLog was removed */ /* Backwards compatibility: ContikiLog was removed */
} else { } else {
Class<? extends MoteInterface> moteInterfaceClass = Class<? extends MoteInterface> moteInterfaceClass =
simulation.getGUI().tryLoadClass( simulation.getCooja().tryLoadClass(
this, MoteInterface.class, element.getText().trim()); this, MoteInterface.class, element.getText().trim());
if (moteInterfaceClass == null) { if (moteInterfaceClass == null) {

View file

@ -135,7 +135,7 @@ public abstract class AbstractCompileDialog extends JDialog {
(Frame)parent, "Create Mote Type: Compile Contiki", ModalityType.APPLICATION_MODAL); (Frame)parent, "Create Mote Type: Compile Contiki", ModalityType.APPLICATION_MODAL);
this.simulation = simulation; this.simulation = simulation;
this.gui = simulation.getGUI(); this.gui = simulation.getCooja();
this.moteType = moteType; this.moteType = moteType;
JPanel mainPanel = new JPanel(new BorderLayout()); JPanel mainPanel = new JPanel(new BorderLayout());

View file

@ -211,7 +211,7 @@ public class AddMoteDialog extends JDialog {
label = new JLabel("Positioning"); label = new JLabel("Positioning");
label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT)); label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));
Vector<Class<? extends Positioner>> positioners = simulation.getGUI() Vector<Class<? extends Positioner>> positioners = simulation.getCooja()
.getRegisteredPositioners(); .getRegisteredPositioners();
String[] posDistributions = new String[positioners.size()]; String[] posDistributions = new String[positioners.size()];
for (int i = 0; i < posDistributions.length; i++) { for (int i = 0; i < posDistributions.length; i++) {
@ -463,7 +463,7 @@ public class AddMoteDialog extends JDialog {
// Position new motes // Position new motes
Class<? extends Positioner> positionerClass = null; Class<? extends Positioner> positionerClass = null;
for (Class<? extends Positioner> positioner : simulation.getGUI() for (Class<? extends Positioner> positioner : simulation.getCooja()
.getRegisteredPositioners()) { .getRegisteredPositioners()) {
if (Cooja.getDescriptionOf(positioner).equals( if (Cooja.getDescriptionOf(positioner).equals(
positionDistributionBox.getSelectedItem())) { positionDistributionBox.getSelectedItem())) {

View file

@ -94,7 +94,7 @@ public class CreateSimDialog extends JDialog {
* @return True if simulation configured correctly * @return True if simulation configured correctly
*/ */
public static boolean showDialog(Container parent, Simulation simulation) { 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.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.addWindowListener(new WindowAdapter() { dialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
@ -340,7 +340,7 @@ public class CreateSimDialog extends JDialog {
mySimulation.setTitle(title.getText()); mySimulation.setTitle(title.getText());
String currentRadioMediumDescription = (String) radioMediumBox.getSelectedItem(); String currentRadioMediumDescription = (String) radioMediumBox.getSelectedItem();
for (Class<? extends RadioMedium> radioMediumClass: mySimulation.getGUI().getRegisteredRadioMediums()) { for (Class<? extends RadioMedium> radioMediumClass: mySimulation.getCooja().getRegisteredRadioMediums()) {
String radioMediumDescription = Cooja.getDescriptionOf(radioMediumClass); String radioMediumDescription = Cooja.getDescriptionOf(radioMediumClass);
if (currentRadioMediumDescription.equals(radioMediumDescription)) { if (currentRadioMediumDescription.equals(radioMediumDescription)) {

View file

@ -126,7 +126,7 @@ public class ImportAppMoteDialog extends JDialog {
} else if (name.length() > 0) { } else if (name.length() > 0) {
fc.setSelectedFile(new File(new File(path), name.replace(".", "/") + ".class")); fc.setSelectedFile(new File(new File(path), name.replace(".", "/") + ".class"));
} else { } else {
File fp = simulation.getGUI() File fp = simulation.getCooja()
.restorePortablePath(new File(Cooja.getExternalToolsSetting("IMPORT_APP_LAST", .restorePortablePath(new File(Cooja.getExternalToolsSetting("IMPORT_APP_LAST",
"mymote.class"))); "mymote.class")));
if (path.length() > 0 && !fp.getAbsolutePath().startsWith(path)) { if (path.length() > 0 && !fp.getAbsolutePath().startsWith(path)) {
@ -250,7 +250,7 @@ public class ImportAppMoteDialog extends JDialog {
pathField.setText(loader.getTestClassPath().getPath()); pathField.setText(loader.getTestClassPath().getPath());
classField.setText(loader.getTestClassName()); classField.setText(loader.getTestClassName());
Cooja.setExternalToolsSetting("IMPORT_APP_LAST", Cooja.setExternalToolsSetting("IMPORT_APP_LAST",
simulation.getGUI().createPortablePath(classFile).getPath()); simulation.getCooja().createPortablePath(classFile).getPath());
return true; return true;
} }
} catch (FileNotFoundException e1) { } catch (FileNotFoundException e1) {

View file

@ -92,7 +92,7 @@ public class Mote2MoteRelations extends MoteInterface {
public Mote2MoteRelations(Mote mote) { public Mote2MoteRelations(Mote mote) {
this.mote = mote; this.mote = mote;
this.gui = mote.getSimulation().getGUI(); this.gui = mote.getSimulation().getCooja();
} }
public void added() { public void added() {

View file

@ -155,7 +155,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
/* Ignored: handled by simulation */ /* Ignored: handled by simulation */
} else if (name.equals("interface_config")) { } else if (name.equals("interface_config")) {
Class<? extends MoteInterface> moteInterfaceClass = Class<? extends MoteInterface> moteInterfaceClass =
simulation.getGUI().tryLoadClass(this, MoteInterface.class, element.getText().trim()); simulation.getCooja().tryLoadClass(this, MoteInterface.class, element.getText().trim());
if (moteInterfaceClass == null) { if (moteInterfaceClass == null) {
logger.warn("Can't find mote interface class: " + element.getText()); logger.warn("Can't find mote interface class: " + element.getText());

View file

@ -79,7 +79,7 @@ public class ImportAppMoteType extends AbstractApplicationMoteType {
if (moteClassPath != null) { if (moteClassPath != null) {
Element element = new Element("motepath"); Element element = new Element("motepath");
File file = simulation.getGUI().createPortablePath(moteClassPath); File file = simulation.getCooja().createPortablePath(moteClassPath);
element.setText(file.getPath().replaceAll("\\\\", "/")); element.setText(file.getPath().replaceAll("\\\\", "/"));
config.add(element); config.add(element);
} }
@ -103,7 +103,7 @@ public class ImportAppMoteType extends AbstractApplicationMoteType {
if (name.equals("moteclass")) { if (name.equals("moteclass")) {
moteClassName = element.getText(); moteClassName = element.getText();
} else if (name.equals("motepath")) { } 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() { private ClassLoader getParentClassLoader() {
if (simulation.getGUI().projectDirClassLoader == null) { if (simulation.getCooja().projectDirClassLoader == null) {
return ClassLoader.getSystemClassLoader(); return ClassLoader.getSystemClassLoader();
} else { } else {
return simulation.getGUI().projectDirClassLoader; return simulation.getCooja().projectDirClassLoader;
} }
} }

View file

@ -470,7 +470,7 @@ public class BufferListener extends VisPlugin {
if (d == null) { if (d == null) {
return; 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)) { } else if ("parser".equals(name)) {
String parserClassname = element.getText(); String parserClassname = element.getText();
Class<? extends Parser> parserClass = Class<? extends Parser> parserClass =
simulation.getGUI().tryLoadClass(this, Parser.class, parserClassname); simulation.getCooja().tryLoadClass(this, Parser.class, parserClassname);
if (parserClass == null) { if (parserClass == null) {
logger.warn("Could not create buffer parser: could not find class: " + parserClassname); logger.warn("Could not create buffer parser: could not find class: " + parserClassname);
} else { } else {
@ -882,7 +882,7 @@ public class BufferListener extends VisPlugin {
} else if ("buffer".equals(name)) { } else if ("buffer".equals(name)) {
String bufferClassname = element.getText(); String bufferClassname = element.getText();
Class<? extends Buffer> btClass = Class<? extends Buffer> btClass =
simulation.getGUI().tryLoadClass(this, Buffer.class, bufferClassname); simulation.getCooja().tryLoadClass(this, Buffer.class, bufferClassname);
if (btClass == null) { if (btClass == null) {
logger.warn("Could not create buffer parser: could not find class: " + bufferClassname); logger.warn("Could not create buffer parser: could not find class: " + bufferClassname);
} else { } else {
@ -1124,7 +1124,7 @@ public class BufferListener extends VisPlugin {
int model = logTable.convertRowIndexToModel(view); int model = logTable.convertRowIndexToModel(view);
long time = logs.get(model).time; long time = logs.get(model).time;
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof BufferListener)) { if (!(p instanceof BufferListener)) {
continue; continue;
@ -1147,7 +1147,7 @@ public class BufferListener extends VisPlugin {
int model = logTable.convertRowIndexToModel(view); int model = logTable.convertRowIndexToModel(view);
long time = logs.get(model).time; long time = logs.get(model).time;
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof TimeLine)) { if (!(p instanceof TimeLine)) {
continue; continue;
@ -1170,7 +1170,7 @@ public class BufferListener extends VisPlugin {
int model = logTable.convertRowIndexToModel(view); int model = logTable.convertRowIndexToModel(view);
long time = logs.get(model).time; long time = logs.get(model).time;
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof RadioLogger)) { if (!(p instanceof RadioLogger)) {
continue; continue;

View file

@ -139,8 +139,8 @@ public class EventListener extends VisPlugin {
"View interface visualizer") { "View interface visualizer") {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
MoteInterfaceViewer plugin = MoteInterfaceViewer plugin =
(MoteInterfaceViewer) mySimulation.getGUI().tryStartPlugin( (MoteInterfaceViewer) mySimulation.getCooja().tryStartPlugin(
MoteInterfaceViewer.class, mySimulation.getGUI(), mySimulation, myMote); MoteInterfaceViewer.class, mySimulation.getCooja(), mySimulation, myMote);
plugin.setSelectedInterface(Cooja.getDescriptionOf(moteInterface.getClass())); plugin.setSelectedInterface(Cooja.getDescriptionOf(moteInterface.getClass()));
} }
}); });

View file

@ -387,7 +387,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp {
if (d == null) { if (d == null) {
return; 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) { if (appendToFile) {
element = new Element("append"); element = new Element("append");
element.setText(simulation.getGUI().createPortablePath(appendStreamFile).getPath()); element.setText(simulation.getCooja().createPortablePath(appendStreamFile).getPath());
config.add(element); config.add(element);
} }
return config; return config;
@ -641,7 +641,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp {
repaintTimeColumn(); repaintTimeColumn();
} else if ("append".equals(name)) { } else if ("append".equals(name)) {
appendToFile = true; appendToFile = true;
appendStreamFile = simulation.getGUI().restorePortablePath(new File(element.getText())); appendStreamFile = simulation.getCooja().restorePortablePath(new File(element.getText()));
appendCheckBox.setSelected(true); appendCheckBox.setSelected(true);
if (!appendStreamFile.exists()) { if (!appendStreamFile.exists()) {
try { try {
@ -695,7 +695,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp {
filterTextField.setBackground(Color.red); filterTextField.setBackground(Color.red);
filterTextField.setToolTipText("Syntax error in regular expression: " + e.getMessage()); filterTextField.setToolTipText("Syntax error in regular expression: " + e.getMessage());
} }
simulation.getGUI().getDesktopPane().repaint(); simulation.getCooja().getDesktopPane().repaint();
} }
public void trySelectTime(final long time) { public void trySelectTime(final long time) {
@ -876,7 +876,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp {
int model = logTable.convertRowIndexToModel(view); int model = logTable.convertRowIndexToModel(view);
long time = logs.get(model).ev.getTime(); long time = logs.get(model).ev.getTime();
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof TimeLine)) { if (!(p instanceof TimeLine)) {
continue; continue;
@ -899,7 +899,7 @@ public class LogListener extends VisPlugin implements HasQuickHelp {
int model = logTable.convertRowIndexToModel(view); int model = logTable.convertRowIndexToModel(view);
long time = logs.get(model).ev.getTime(); long time = logs.get(model).ev.getTime();
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof RadioLogger)) { if (!(p instanceof RadioLogger)) {
continue; continue;

View file

@ -340,7 +340,7 @@ public class LogScriptEngine {
Hashtable<Object, Object> hash = new Hashtable<Object, Object>(); Hashtable<Object, Object> hash = new Hashtable<Object, Object>();
engine.put("global", hash); engine.put("global", hash);
engine.put("sim", simulation); engine.put("sim", simulation);
engine.put("gui", simulation.getGUI()); engine.put("gui", simulation.getCooja());
engine.put("msg", new String("")); engine.put("msg", new String(""));
scriptMote = new ScriptMote(); scriptMote = new ScriptMote();
@ -401,7 +401,7 @@ public class LogScriptEngine {
new Thread() { new Thread() {
public void run() { public void run() {
try { Thread.sleep(500); } catch (InterruptedException e) { } try { Thread.sleep(500); } catch (InterruptedException e) { }
simulation.getGUI().doQuit(false, exitCode); simulation.getCooja().doQuit(false, exitCode);
}; };
}.start(); }.start();
new Thread() { new Thread() {

View file

@ -113,7 +113,7 @@ public class MoteInformation extends VisPlugin implements MotePlugin {
button.setPreferredSize(size); button.setPreferredSize(size);
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { 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); smallPane.add(BorderLayout.EAST, button);
@ -134,7 +134,7 @@ public class MoteInformation extends VisPlugin implements MotePlugin {
button.setPreferredSize(size); button.setPreferredSize(size);
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { 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); smallPane.add(BorderLayout.EAST, button);

View file

@ -117,7 +117,7 @@ public class MoteInterfaceViewer extends VisPlugin implements HasQuickHelp, Mote
for (MoteInterface intf : intfs) { for (MoteInterface intf : intfs) {
if (Cooja.getDescriptionOf(intf).equals(interfaceDescription)) { if (Cooja.getDescriptionOf(intf).equals(interfaceDescription)) {
selectedMoteInterface = intf; selectedMoteInterface = intf;
mote.getSimulation().getGUI().loadQuickHelp(MoteInterfaceViewer.this); mote.getSimulation().getCooja().loadQuickHelp(MoteInterfaceViewer.this);
break; break;
} }
} }

View file

@ -887,7 +887,7 @@ public class RadioLogger extends VisPlugin {
verboseBox.setText(""); verboseBox.setText("");
setTitle("Radio messages: showing " + dataTable.getRowCount() + "/" + connections.size() + " packets"); 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, private Action createAnalyzerAction(String name, final String actionName,
@ -1010,7 +1010,7 @@ public class RadioLogger extends VisPlugin {
long time = connections.get(selectedRow).startTime; long time = connections.get(selectedRow).startTime;
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof TimeLine)) { if (!(p instanceof TimeLine)) {
continue; continue;
@ -1033,7 +1033,7 @@ public class RadioLogger extends VisPlugin {
long time = connections.get(selectedRow).startTime; long time = connections.get(selectedRow).startTime;
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof LogListener)) { if (!(p instanceof LogListener)) {
continue; continue;

View file

@ -435,7 +435,7 @@ public class ScriptRunner extends VisPlugin {
private void exportAndRun() { private void exportAndRun() {
/* Save simulation config */ /* Save simulation config */
File configFile = simulation.getGUI().doSaveConfig(true); File configFile = simulation.getCooja().doSaveConfig(true);
if (configFile == null) { if (configFile == null) {
return; return;
} }
@ -617,7 +617,7 @@ public class ScriptRunner extends VisPlugin {
if (linkedFile != null) { if (linkedFile != null) {
element = new Element("scriptfile"); element = new Element("scriptfile");
element.setText(simulation.getGUI().createPortablePath(linkedFile).getPath().replace('\\', '/')); element.setText(simulation.getCooja().createPortablePath(linkedFile).getPath().replace('\\', '/'));
config.add(element); config.add(element);
} else { } else {
element = new Element("script"); element = new Element("script");
@ -651,7 +651,7 @@ public class ScriptRunner extends VisPlugin {
updateScript(element.getText()); updateScript(element.getText());
} }
} else if ("scriptfile".equals(name)) { } 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); setLinkFile(file);
} else if ("active".equals(name)) { } else if ("active".equals(name)) {
boolean active = Boolean.parseBoolean(element.getText()); boolean active = Boolean.parseBoolean(element.getText());

View file

@ -323,7 +323,7 @@ public class SimControl extends VisPlugin implements HasQuickHelp {
}; };
private Action reloadAction = new AbstractAction("Reload") { private Action reloadAction = new AbstractAction("Reload") {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
simulation.getGUI().reloadCurrentSimulation(simulation.isRunning()); simulation.getCooja().reloadCurrentSimulation(simulation.isRunning());
} }
}; };

View file

@ -253,7 +253,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
showLogOutputs = ((JCheckBox) e.getSource()).isSelected(); showLogOutputs = ((JCheckBox) e.getSource()).isSelected();
/* Check whether there is an active log listener that is used to filter logs */ /* 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()); LogListener.class.getName());
if (showLogOutputs) { if (showLogOutputs) {
if (logEventFilterPlugin != null) { if (logEventFilterPlugin != null) {
@ -942,7 +942,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
} }
long time = (long) (popupLocation.x*currentPixelDivisor); long time = (long) (popupLocation.x*currentPixelDivisor);
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof RadioLogger)) { if (!(p instanceof RadioLogger)) {
continue; continue;
@ -962,7 +962,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
} }
long time = (long) (popupLocation.x*currentPixelDivisor); long time = (long) (popupLocation.x*currentPixelDivisor);
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof LogListener)) { if (!(p instanceof LogListener)) {
continue; continue;
@ -1270,7 +1270,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
repaintTimelineTimer.stop(); repaintTimelineTimer.stop();
if (moteHighlightObserver != null) { if (moteHighlightObserver != null) {
simulation.getGUI().deleteMoteHighlightObserver(moteHighlightObserver); simulation.getCooja().deleteMoteHighlightObserver(moteHighlightObserver);
} }
simulation.getEventCentral().removeMoteCountListener(newMotesListener); simulation.getEventCentral().removeMoteCountListener(newMotesListener);
@ -1432,7 +1432,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
showInAllAction.actionPerformed(null); showInAllAction.actionPerformed(null);
long time = (long) (popupLocation.x*currentPixelDivisor); long time = (long) (popupLocation.x*currentPixelDivisor);
Plugin[] plugins = simulation.getGUI().getStartedPlugins(); Plugin[] plugins = simulation.getCooja().getStartedPlugins();
for (Plugin p: plugins) { for (Plugin p: plugins) {
if (!(p instanceof TimeLine)) { if (!(p instanceof TimeLine)) {
continue; continue;
@ -1874,7 +1874,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
if (m == null) { if (m == null) {
return; return;
} }
simulation.getGUI().signalMoteHighlight(m); simulation.getCooja().signalMoteHighlight(m);
sortItem.setText("Sort by distance: " + m); sortItem.setText("Sort by distance: " + m);
sortItem.putClientProperty("mote", m); sortItem.putClientProperty("mote", m);

View file

@ -572,7 +572,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
continue; continue;
} }
Class<? extends VisualizerSkin> skinClass = Class<? extends VisualizerSkin> skinClass =
simulation.getGUI().tryLoadClass(this, VisualizerSkin.class, skin); simulation.getCooja().tryLoadClass(this, VisualizerSkin.class, skin);
generateAndActivateSkin(skinClass); generateAndActivateSkin(skinClass);
} }
} }
@ -640,7 +640,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
/* Add registered mote actions */ /* Add registered mote actions */
for (final Mote mote : motes) { for (final Mote mote : motes) {
menu.add(simulation.getGUI().createMotePluginsSubmenu(mote)); menu.add(simulation.getCooja().createMotePluginsSubmenu(mote));
for (Class<? extends MoteMenuAction> menuActionClass: moteMenuActions) { for (Class<? extends MoteMenuAction> menuActionClass: moteMenuActions) {
try { try {
final MoteMenuAction menuAction = menuActionClass.newInstance(); final MoteMenuAction menuAction = menuActionClass.newInstance();
@ -1018,7 +1018,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
/* Paint mote relations */ /* Paint mote relations */
if (showMoteToMoteRelations) { if (showMoteToMoteRelations) {
MoteRelation[] relations = simulation.getGUI().getMoteRelations(); MoteRelation[] relations = simulation.getCooja().getMoteRelations();
for (MoteRelation r: relations) { for (MoteRelation r: relations) {
Position sourcePos = r.source.getInterfaces().getPosition(); Position sourcePos = r.source.getInterfaces().getPosition();
Position destPos = r.dest.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()); String desc = Cooja.getDescriptionOf(mote.getInterfaces().getLED());
MoteInterfaceViewer viewer = MoteInterfaceViewer viewer =
(MoteInterfaceViewer) simulation.getGUI().tryStartPlugin( (MoteInterfaceViewer) simulation.getCooja().tryStartPlugin(
MoteInterfaceViewer.class, MoteInterfaceViewer.class,
simulation.getGUI(), simulation.getCooja(),
simulation, simulation,
mote); mote);
if (viewer == null) { if (viewer == null) {
@ -1474,9 +1474,9 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
String desc = Cooja.getDescriptionOf(serialPort); String desc = Cooja.getDescriptionOf(serialPort);
MoteInterfaceViewer viewer = MoteInterfaceViewer viewer =
(MoteInterfaceViewer) simulation.getGUI().tryStartPlugin( (MoteInterfaceViewer) simulation.getCooja().tryStartPlugin(
MoteInterfaceViewer.class, MoteInterfaceViewer.class,
simulation.getGUI(), simulation.getCooja(),
simulation, simulation,
mote); mote);
if (viewer == null) { if (viewer == null) {

View file

@ -88,7 +88,7 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
requestEdgeAnalysis(); requestEdgeAnalysis();
/* Register plugin and visualizer skin */ /* Register plugin and visualizer skin */
simulation.getGUI().registerPlugin(DGRMConfigurator.class); simulation.getCooja().registerPlugin(DGRMConfigurator.class);
Visualizer.registerVisualizerSkin(DGRMVisualizerSkin.class); Visualizer.registerVisualizerSkin(DGRMVisualizerSkin.class);
} }
@ -96,7 +96,7 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
super.removed(); super.removed();
/* Unregister plugin and visualizer skin */ /* Unregister plugin and visualizer skin */
simulation.getGUI().unregisterPlugin(DGRMConfigurator.class); simulation.getCooja().unregisterPlugin(DGRMConfigurator.class);
Visualizer.unregisterVisualizerSkin(DGRMVisualizerSkin.class); Visualizer.unregisterVisualizerSkin(DGRMVisualizerSkin.class);
} }
@ -392,7 +392,7 @@ public void simulationFinishedLoading() {
continue; continue;
} }
Class<? extends DGRMDestinationRadio> destClass = Class<? extends DGRMDestinationRadio> destClass =
simulation.getGUI().tryLoadClass(this, DGRMDestinationRadio.class, destClassName); simulation.getCooja().tryLoadClass(this, DGRMDestinationRadio.class, destClassName);
if (destClass == null) { if (destClass == null) {
throw new RuntimeException("Could not load class: " + destClassName); throw new RuntimeException("Could not load class: " + destClassName);
} }

View file

@ -111,7 +111,7 @@ public class ExecuteJAR {
s.stopSimulation(); s.stopSimulation();
try { try {
buildExecutableJAR(s.getGUI(), jar); buildExecutableJAR(s.getCooja(), jar);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.fatal(e.getMessage(), e); logger.fatal(e.getMessage(), e);
System.exit(1); System.exit(1);