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

ico
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")) {
/* Ignored: handled by simulation */
} 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());
if (moteInterfaceClass == null) {

View File

@ -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<? extends MoteInterface> 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);

View File

@ -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);

View File

@ -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<? extends MoteInterface> moteInterfaceClass = simulation.getGUI().tryLoadClass(
Class<? extends MoteInterface> moteInterfaceClass = simulation.getCooja().tryLoadClass(
this, MoteInterface.class, intfClass);
if (moteInterfaceClass == null) {

View File

@ -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<? extends MoteInterface> 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);

View File

@ -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();

View File

@ -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");

View File

@ -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<? 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) {
@ -1657,7 +1654,7 @@ public class Cooja extends Observable {
public void showPlugin(final Plugin plugin) {
new RunnableInEDT<Boolean>() {
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<? 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 {
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<? extends MoteType>) ((JMenuItem) e
cooja.doCreateMoteType((Class<? extends MoteType>) ((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<Element>) 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<Plugin> pluginClass =
(Class<Plugin>) ((JMenuItem) e.getSource()).getClientProperty("class");
Mote mote = (Mote) ((JMenuItem) e.getSource()).getClientProperty("mote");
tryStartPlugin(pluginClass, myGUI, mySimulation, mote);
tryStartPlugin(pluginClass, cooja, mySimulation, mote);
}
}).start();
}

View File

@ -51,7 +51,7 @@ public interface Plugin {
/**
* 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 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<? extends RadioMedium> radioMediumClass = myGUI.tryLoadClass(
Class<? extends RadioMedium> 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<? extends MoteType> moteTypeClass = myGUI.tryLoadClass(this,
Class<? extends MoteType> 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);
}
/**

View File

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

View File

@ -186,7 +186,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
/* Ignored: handled by simulation */
} else if (name.equals("interface_config")) {
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) {
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,
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<? extends MoteInterface> moteInterfaceClass =
simulation.getGUI().tryLoadClass(
simulation.getCooja().tryLoadClass(
this, MoteInterface.class, element.getText().trim());
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);
this.simulation = simulation;
this.gui = simulation.getGUI();
this.gui = simulation.getCooja();
this.moteType = moteType;
JPanel mainPanel = new JPanel(new BorderLayout());

View File

@ -211,7 +211,7 @@ public class AddMoteDialog extends JDialog {
label = new JLabel("Positioning");
label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));
Vector<Class<? extends Positioner>> positioners = simulation.getGUI()
Vector<Class<? extends Positioner>> 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<? extends Positioner> positionerClass = null;
for (Class<? extends Positioner> positioner : simulation.getGUI()
for (Class<? extends Positioner> positioner : simulation.getCooja()
.getRegisteredPositioners()) {
if (Cooja.getDescriptionOf(positioner).equals(
positionDistributionBox.getSelectedItem())) {

View File

@ -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<? extends RadioMedium> radioMediumClass: mySimulation.getGUI().getRegisteredRadioMediums()) {
for (Class<? extends RadioMedium> radioMediumClass: mySimulation.getCooja().getRegisteredRadioMediums()) {
String radioMediumDescription = Cooja.getDescriptionOf(radioMediumClass);
if (currentRadioMediumDescription.equals(radioMediumDescription)) {

View File

@ -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) {

View File

@ -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() {

View File

@ -155,7 +155,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
/* Ignored: handled by simulation */
} else if (name.equals("interface_config")) {
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) {
logger.warn("Can't find mote interface class: " + element.getText());

View File

@ -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;
}
}

View File

@ -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<? extends Parser> 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<? extends Buffer> 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;

View File

@ -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()));
}
});

View File

@ -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;

View File

@ -340,7 +340,7 @@ public class LogScriptEngine {
Hashtable<Object, Object> hash = new Hashtable<Object, Object>();
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() {

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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());

View File

@ -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());
}
};

View File

@ -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);

View File

@ -572,7 +572,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
continue;
}
Class<? extends VisualizerSkin> 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<? extends MoteMenuAction> 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) {

View File

@ -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<? extends DGRMDestinationRadio> 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);
}

View File

@ -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);