From 18d9c942222a7fe98a872980ca369a187b7da501 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 9 Jan 2007 09:49:24 +0000 Subject: [PATCH] updated plugin constructors --- .../se/sics/cooja/plugins/LogListener.java | 10 +++--- .../sics/cooja/plugins/MoteInformation.java | 15 ++++---- .../cooja/plugins/MoteInterfaceViewer.java | 35 ++++++++++++------- .../cooja/plugins/MoteTypeInformation.java | 8 ++--- .../se/sics/cooja/plugins/SimControl.java | 8 ++--- .../se/sics/cooja/plugins/SimInformation.java | 8 ++--- .../sics/cooja/plugins/VariableWatcher.java | 10 +++--- .../se/sics/cooja/plugins/VisBattery.java | 8 ++--- .../java/se/sics/cooja/plugins/VisState.java | 8 ++--- .../se/sics/cooja/plugins/VisTraffic.java | 8 ++--- .../se/sics/cooja/plugins/Visualizer2D.java | 10 +++--- 11 files changed, 71 insertions(+), 57 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/LogListener.java b/tools/cooja/java/se/sics/cooja/plugins/LogListener.java index efaf05573..520688843 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/LogListener.java +++ b/tools/cooja/java/se/sics/cooja/plugins/LogListener.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: LogListener.java,v 1.3 2006/12/07 14:26:48 fros4943 Exp $ + * $Id: LogListener.java,v 1.4 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -52,7 +52,7 @@ import se.sics.cooja.interfaces.Log; * @author Fredrik Osterlind */ @ClassDescription("Log Listener") -@VisPluginType(VisPluginType.SIM_PLUGIN) +@PluginType(PluginType.SIM_PLUGIN) public class LogListener extends VisPlugin { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(LogListener.class); @@ -69,8 +69,8 @@ public class LogListener extends VisPlugin { * * @param simulationToControl Simulation to control */ - public LogListener(final Simulation simulationToControl) { - super("Log Listener - Listening on ?? mote logs"); + public LogListener(final Simulation simulationToControl, GUI gui) { + super("Log Listener - Listening on ?? mote logs", gui); simulation = simulationToControl; int nrLogs = 0; @@ -159,7 +159,7 @@ public class LogListener extends VisPlugin { return config; } - public boolean setConfigXML(Collection configXML) { + public boolean setConfigXML(Collection configXML, boolean visAvailable) { for (Element element : configXML) { if (element.getName().equals("filter")) { diff --git a/tools/cooja/java/se/sics/cooja/plugins/MoteInformation.java b/tools/cooja/java/se/sics/cooja/plugins/MoteInformation.java index 865ca428c..c5590553f 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/MoteInformation.java +++ b/tools/cooja/java/se/sics/cooja/plugins/MoteInformation.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MoteInformation.java,v 1.2 2006/09/26 13:08:05 fros4943 Exp $ + * $Id: MoteInformation.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -47,7 +47,7 @@ import se.sics.cooja.Mote.State; * @author Fredrik Osterlind */ @ClassDescription("Mote Information") -@VisPluginType(VisPluginType.MOTE_PLUGIN) +@PluginType(PluginType.MOTE_PLUGIN) public class MoteInformation extends VisPlugin { private static Logger logger = Logger.getLogger(MoteInformation.class); @@ -63,16 +63,19 @@ public class MoteInformation extends VisPlugin { private Observer stateObserver; private Vector visibleMoteInterfaces = new Vector(); + private Simulation mySimulation; + /** * Create a new mote information window. * * @param moteToView Mote to view */ - public MoteInformation(Mote moteToView) { - super("Mote Information (" + moteToView + ")"); + public MoteInformation(Mote moteToView, Simulation simulation, GUI gui) { + super("Mote Information (" + moteToView + ")", gui); mote = moteToView; - + mySimulation = simulation; + JLabel label; JPanel mainPane = new JPanel(); mainPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); @@ -89,7 +92,7 @@ public class MoteInformation extends VisPlugin { button.setActionCommand("removeMote"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - GUI.currentSimulation.removeMote(mote); + mySimulation.removeMote(mote); dispose(); } }); diff --git a/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java b/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java index e51c94d9e..6574ac1f8 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java +++ b/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MoteInterfaceViewer.java,v 1.2 2006/11/30 14:25:59 fros4943 Exp $ + * $Id: MoteInterfaceViewer.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -46,7 +46,7 @@ import se.sics.cooja.*; * @author Fredrik Osterlind */ @ClassDescription("Mote Interface Viewer") -@VisPluginType(VisPluginType.MOTE_PLUGIN) +@PluginType(PluginType.MOTE_PLUGIN) public class MoteInterfaceViewer extends VisPlugin { private static final long serialVersionUID = 1L; @@ -60,8 +60,8 @@ public class MoteInterfaceViewer extends VisPlugin { * * @param moteToView Mote to view */ - public MoteInterfaceViewer(Mote moteToView) { - super("Mote Interface Viewer (" + moteToView + ")"); + public MoteInterfaceViewer(Mote moteToView, Simulation simulation, GUI gui) { + super("Mote Interface Viewer (" + moteToView + ")", gui); mote = moteToView; JLabel label; @@ -147,12 +147,27 @@ public class MoteInterfaceViewer extends VisPlugin { } + /** + * Tries to select the interface with the given class name. + * @param description Interface description + * @return True if selected, false otherwise + */ + public boolean setSelectedInterface(String description) { + for (int i=0; i < selectInterfaceComboBox.getItemCount(); i++) { + if (selectInterfaceComboBox.getItemAt(i).equals(description)) { + selectInterfaceComboBox.setSelectedIndex(i); + return true; + } + } + return false; + } + public void closePlugin() { // Release old interface visualizer if any if (selectedMoteInterface != null && currentInterfaceVisualizer != null) selectedMoteInterface.releaseInterfaceVisualizer(currentInterfaceVisualizer); } - + public Collection getConfigXML() { Vector config = new Vector(); @@ -165,15 +180,11 @@ public class MoteInterfaceViewer extends VisPlugin { return config; } - - public boolean setConfigXML(Collection configXML) { + + public boolean setConfigXML(Collection configXML, boolean visAvailable) { for (Element element : configXML) { if (element.getName().equals("interface")) { - for (int i=0; i < selectInterfaceComboBox.getItemCount(); i++) { - if (selectInterfaceComboBox.getItemAt(i).equals(element.getText())) { - selectInterfaceComboBox.setSelectedIndex(i); - } - } + setSelectedInterface(element.getText()); } } return true; diff --git a/tools/cooja/java/se/sics/cooja/plugins/MoteTypeInformation.java b/tools/cooja/java/se/sics/cooja/plugins/MoteTypeInformation.java index 160e59e4e..d36f445c9 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/MoteTypeInformation.java +++ b/tools/cooja/java/se/sics/cooja/plugins/MoteTypeInformation.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MoteTypeInformation.java,v 1.1 2006/08/21 12:13:08 fros4943 Exp $ + * $Id: MoteTypeInformation.java,v 1.2 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -43,7 +43,7 @@ import se.sics.cooja.*; * @author Fredrik Osterlind */ @ClassDescription("Mote Type Information") -@VisPluginType(VisPluginType.SIM_PLUGIN) +@PluginType(PluginType.SIM_PLUGIN) public class MoteTypeInformation extends VisPlugin { private static Logger logger = Logger.getLogger(MoteTypeInformation.class); @@ -59,8 +59,8 @@ public class MoteTypeInformation extends VisPlugin { * * @param simulation Simulation */ - public MoteTypeInformation(Simulation simulation) { - super("Mote Type Information *frozen*"); + public MoteTypeInformation(Simulation simulation, GUI gui) { + super("Mote Type Information *frozen*", gui); mySimulation = simulation; diff --git a/tools/cooja/java/se/sics/cooja/plugins/SimControl.java b/tools/cooja/java/se/sics/cooja/plugins/SimControl.java index 92e0743d4..d845039af 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/SimControl.java +++ b/tools/cooja/java/se/sics/cooja/plugins/SimControl.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SimControl.java,v 1.2 2006/12/13 11:55:06 fros4943 Exp $ + * $Id: SimControl.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -49,7 +49,7 @@ import se.sics.cooja.*; * @author Fredrik Osterlind */ @ClassDescription("Control Panel") -@VisPluginType(VisPluginType.SIM_STANDARD_PLUGIN) +@PluginType(PluginType.SIM_STANDARD_PLUGIN) public class SimControl extends VisPlugin { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(SimControl.class); @@ -75,8 +75,8 @@ public class SimControl extends VisPlugin { * * @param simulationToControl Simulation to control */ - public SimControl(Simulation simulationToControl) { - super("Control Panel - " + simulationToControl.getTitle()); + public SimControl(Simulation simulationToControl, GUI gui) { + super("Control Panel - " + simulationToControl.getTitle(), gui); simulation = simulationToControl; diff --git a/tools/cooja/java/se/sics/cooja/plugins/SimInformation.java b/tools/cooja/java/se/sics/cooja/plugins/SimInformation.java index ad24635ae..239cc5469 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/SimInformation.java +++ b/tools/cooja/java/se/sics/cooja/plugins/SimInformation.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SimInformation.java,v 1.2 2006/09/05 14:12:48 fros4943 Exp $ + * $Id: SimInformation.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -43,7 +43,7 @@ import se.sics.cooja.*; * @author Fredrik Osterlind */ @ClassDescription("Simulation Information") -@VisPluginType(VisPluginType.SIM_PLUGIN) +@PluginType(PluginType.SIM_PLUGIN) public class SimInformation extends VisPlugin { private static final long serialVersionUID = 1L; private Simulation simulation; @@ -64,8 +64,8 @@ public class SimInformation extends VisPlugin { * * @param simulationToView Simulation to view */ - public SimInformation(Simulation simulationToView) { - super("Simulation Information"); + public SimInformation(Simulation simulationToView, GUI gui) { + super("Simulation Information", gui); simulation = simulationToView; diff --git a/tools/cooja/java/se/sics/cooja/plugins/VariableWatcher.java b/tools/cooja/java/se/sics/cooja/plugins/VariableWatcher.java index 01f654a53..f85a07054 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/VariableWatcher.java +++ b/tools/cooja/java/se/sics/cooja/plugins/VariableWatcher.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: VariableWatcher.java,v 1.2 2006/11/30 14:25:59 fros4943 Exp $ + * $Id: VariableWatcher.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -51,7 +51,7 @@ import se.sics.cooja.*; * @author Fredrik Osterlind */ @ClassDescription("Variable Watcher") -@VisPluginType(VisPluginType.MOTE_PLUGIN) +@PluginType(PluginType.MOTE_PLUGIN) public class VariableWatcher extends VisPlugin { private static final long serialVersionUID = 1L; @@ -79,8 +79,8 @@ public class VariableWatcher extends VisPlugin { * * @param moteToView Mote to view */ - public VariableWatcher(Mote moteToView) { - super("Variable Watcher (" + moteToView + ")"); + public VariableWatcher(Mote moteToView, Simulation simulation, GUI gui) { + super("Variable Watcher (" + moteToView + ")", gui); moteMemory = (SectionMoteMemory) moteToView.getMemory(); @@ -343,7 +343,7 @@ public class VariableWatcher extends VisPlugin { return config; } - public boolean setConfigXML(Collection configXML) { + public boolean setConfigXML(Collection configXML, boolean visAvailable) { lengthPane.setVisible(false); setNumberOfValues(1); varLength.setValue(1); diff --git a/tools/cooja/java/se/sics/cooja/plugins/VisBattery.java b/tools/cooja/java/se/sics/cooja/plugins/VisBattery.java index 7f736e569..8950fe69b 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/VisBattery.java +++ b/tools/cooja/java/se/sics/cooja/plugins/VisBattery.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: VisBattery.java,v 1.3 2006/10/23 16:15:12 fros4943 Exp $ + * $Id: VisBattery.java,v 1.4 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -49,7 +49,7 @@ import se.sics.cooja.interfaces.Battery; * @author Fredrik Osterlind */ @ClassDescription("Battery Visualizer") -@VisPluginType(VisPluginType.SIM_PLUGIN) +@PluginType(PluginType.SIM_PLUGIN) public class VisBattery extends Visualizer2D { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(VisBattery.class); @@ -65,8 +65,8 @@ public class VisBattery extends Visualizer2D { * @param simulationToVisualize * Simulation to visualize */ - public VisBattery(Simulation simulationToVisualize) { - super(simulationToVisualize); + public VisBattery(Simulation simulationToVisualize, GUI gui) { + super(simulationToVisualize, gui); setTitle("Battery Visualizer"); simulation = simulationToVisualize; diff --git a/tools/cooja/java/se/sics/cooja/plugins/VisState.java b/tools/cooja/java/se/sics/cooja/plugins/VisState.java index e4e4b898d..209c7d8ec 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/VisState.java +++ b/tools/cooja/java/se/sics/cooja/plugins/VisState.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: VisState.java,v 1.3 2006/10/23 16:15:16 fros4943 Exp $ + * $Id: VisState.java,v 1.4 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -49,7 +49,7 @@ import se.sics.cooja.Mote.State; * @author Fredrik Osterlind */ @ClassDescription("State Visualizer") -@VisPluginType(VisPluginType.SIM_PLUGIN) +@PluginType(PluginType.SIM_PLUGIN) public class VisState extends Visualizer2D { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(VisState.class); @@ -74,8 +74,8 @@ public class VisState extends Visualizer2D { * * @param simulationToVisualize Simulation to visualize */ - public VisState(Simulation simulationToVisualize) { - super(simulationToVisualize); + public VisState(Simulation simulationToVisualize, GUI gui) { + super(simulationToVisualize, gui); setTitle("State Visualizer"); simulation = simulationToVisualize; diff --git a/tools/cooja/java/se/sics/cooja/plugins/VisTraffic.java b/tools/cooja/java/se/sics/cooja/plugins/VisTraffic.java index 25ace60e7..189e1202c 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/VisTraffic.java +++ b/tools/cooja/java/se/sics/cooja/plugins/VisTraffic.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: VisTraffic.java,v 1.4 2006/10/11 10:38:26 fros4943 Exp $ + * $Id: VisTraffic.java,v 1.5 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -48,7 +48,7 @@ import se.sics.cooja.interfaces.Position; * @author Fredrik Osterlind */ @ClassDescription("Traffic Visualizer") -@VisPluginType(VisPluginType.SIM_PLUGIN) +@PluginType(PluginType.SIM_PLUGIN) public class VisTraffic extends Visualizer2D { protected boolean USE_ALPHA = false; @@ -74,8 +74,8 @@ public class VisTraffic extends Visualizer2D { * @param simulationToVisualize * Simulation to visualize */ - public VisTraffic(Simulation simulationToVisualize) { - super(simulationToVisualize); + public VisTraffic(Simulation simulationToVisualize, GUI gui) { + super(simulationToVisualize, gui); setTitle("Traffic Visualizer"); simulation = simulationToVisualize; diff --git a/tools/cooja/java/se/sics/cooja/plugins/Visualizer2D.java b/tools/cooja/java/se/sics/cooja/plugins/Visualizer2D.java index 0955aec9c..57d3bd831 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/Visualizer2D.java +++ b/tools/cooja/java/se/sics/cooja/plugins/Visualizer2D.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: Visualizer2D.java,v 1.2 2006/09/07 09:54:37 fros4943 Exp $ + * $Id: Visualizer2D.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -57,7 +57,7 @@ import se.sics.cooja.interfaces.*; * @author Fredrik Osterlind */ @ClassDescription("2D Mote Visualizer") -@VisPluginType(VisPluginType.SIM_PLUGIN) +@PluginType(PluginType.SIM_PLUGIN) public abstract class Visualizer2D extends VisPlugin { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(Visualizer2D.class); @@ -107,8 +107,8 @@ public abstract class Visualizer2D extends VisPlugin { * @param simulationToVisualize * Simulation to visualize */ - public Visualizer2D(Simulation simulationToVisualize) { - super("Visualizer2D"); + public Visualizer2D(Simulation simulationToVisualize, GUI gui) { + super("Visualizer2D", gui); myPlugin = this; @@ -257,7 +257,7 @@ public abstract class Visualizer2D extends VisPlugin { JMenuItem menuItem = new JMenuItem("Open mote plugin for " + mote); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - GUI.currentGUI.showMotePluginsMenu(canvas, mote, pos); + simulation.getGUI().showMotePluginsMenu(canvas, mote, pos); } }); pickMoteMenu.add(menuItem);