updated plugin constructors

This commit is contained in:
fros4943 2007-01-09 09:49:24 +00:00
parent bf7ed8eb41
commit 18d9c94222
11 changed files with 71 additions and 57 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -52,7 +52,7 @@ import se.sics.cooja.interfaces.Log;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("Log Listener") @ClassDescription("Log Listener")
@VisPluginType(VisPluginType.SIM_PLUGIN) @PluginType(PluginType.SIM_PLUGIN)
public class LogListener extends VisPlugin { public class LogListener extends VisPlugin {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(LogListener.class); private static Logger logger = Logger.getLogger(LogListener.class);
@ -69,8 +69,8 @@ public class LogListener extends VisPlugin {
* *
* @param simulationToControl Simulation to control * @param simulationToControl Simulation to control
*/ */
public LogListener(final Simulation simulationToControl) { public LogListener(final Simulation simulationToControl, GUI gui) {
super("Log Listener - Listening on ?? mote logs"); super("Log Listener - Listening on ?? mote logs", gui);
simulation = simulationToControl; simulation = simulationToControl;
int nrLogs = 0; int nrLogs = 0;
@ -159,7 +159,7 @@ public class LogListener extends VisPlugin {
return config; return config;
} }
public boolean setConfigXML(Collection<Element> configXML) { public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
for (Element element : configXML) { for (Element element : configXML) {
if (element.getName().equals("filter")) { if (element.getName().equals("filter")) {

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -47,7 +47,7 @@ import se.sics.cooja.Mote.State;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("Mote Information") @ClassDescription("Mote Information")
@VisPluginType(VisPluginType.MOTE_PLUGIN) @PluginType(PluginType.MOTE_PLUGIN)
public class MoteInformation extends VisPlugin { public class MoteInformation extends VisPlugin {
private static Logger logger = Logger.getLogger(MoteInformation.class); private static Logger logger = Logger.getLogger(MoteInformation.class);
@ -63,15 +63,18 @@ public class MoteInformation extends VisPlugin {
private Observer stateObserver; private Observer stateObserver;
private Vector<JPanel> visibleMoteInterfaces = new Vector<JPanel>(); private Vector<JPanel> visibleMoteInterfaces = new Vector<JPanel>();
private Simulation mySimulation;
/** /**
* Create a new mote information window. * Create a new mote information window.
* *
* @param moteToView Mote to view * @param moteToView Mote to view
*/ */
public MoteInformation(Mote moteToView) { public MoteInformation(Mote moteToView, Simulation simulation, GUI gui) {
super("Mote Information (" + moteToView + ")"); super("Mote Information (" + moteToView + ")", gui);
mote = moteToView; mote = moteToView;
mySimulation = simulation;
JLabel label; JLabel label;
JPanel mainPane = new JPanel(); JPanel mainPane = new JPanel();
@ -89,7 +92,7 @@ public class MoteInformation extends VisPlugin {
button.setActionCommand("removeMote"); button.setActionCommand("removeMote");
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
GUI.currentSimulation.removeMote(mote); mySimulation.removeMote(mote);
dispose(); dispose();
} }
}); });

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -46,7 +46,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("Mote Interface Viewer") @ClassDescription("Mote Interface Viewer")
@VisPluginType(VisPluginType.MOTE_PLUGIN) @PluginType(PluginType.MOTE_PLUGIN)
public class MoteInterfaceViewer extends VisPlugin { public class MoteInterfaceViewer extends VisPlugin {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -60,8 +60,8 @@ public class MoteInterfaceViewer extends VisPlugin {
* *
* @param moteToView Mote to view * @param moteToView Mote to view
*/ */
public MoteInterfaceViewer(Mote moteToView) { public MoteInterfaceViewer(Mote moteToView, Simulation simulation, GUI gui) {
super("Mote Interface Viewer (" + moteToView + ")"); super("Mote Interface Viewer (" + moteToView + ")", gui);
mote = moteToView; mote = moteToView;
JLabel label; JLabel label;
@ -147,6 +147,21 @@ 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() { public void closePlugin() {
// Release old interface visualizer if any // Release old interface visualizer if any
if (selectedMoteInterface != null && currentInterfaceVisualizer != null) if (selectedMoteInterface != null && currentInterfaceVisualizer != null)
@ -166,14 +181,10 @@ public class MoteInterfaceViewer extends VisPlugin {
return config; return config;
} }
public boolean setConfigXML(Collection<Element> configXML) { public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
for (Element element : configXML) { for (Element element : configXML) {
if (element.getName().equals("interface")) { if (element.getName().equals("interface")) {
for (int i=0; i < selectInterfaceComboBox.getItemCount(); i++) { setSelectedInterface(element.getText());
if (selectInterfaceComboBox.getItemAt(i).equals(element.getText())) {
selectInterfaceComboBox.setSelectedIndex(i);
}
}
} }
} }
return true; return true;

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -43,7 +43,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("Mote Type Information") @ClassDescription("Mote Type Information")
@VisPluginType(VisPluginType.SIM_PLUGIN) @PluginType(PluginType.SIM_PLUGIN)
public class MoteTypeInformation extends VisPlugin { public class MoteTypeInformation extends VisPlugin {
private static Logger logger = Logger.getLogger(MoteTypeInformation.class); private static Logger logger = Logger.getLogger(MoteTypeInformation.class);
@ -59,8 +59,8 @@ public class MoteTypeInformation extends VisPlugin {
* *
* @param simulation Simulation * @param simulation Simulation
*/ */
public MoteTypeInformation(Simulation simulation) { public MoteTypeInformation(Simulation simulation, GUI gui) {
super("Mote Type Information *frozen*"); super("Mote Type Information *frozen*", gui);
mySimulation = simulation; mySimulation = simulation;

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -49,7 +49,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("Control Panel") @ClassDescription("Control Panel")
@VisPluginType(VisPluginType.SIM_STANDARD_PLUGIN) @PluginType(PluginType.SIM_STANDARD_PLUGIN)
public class SimControl extends VisPlugin { public class SimControl extends VisPlugin {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(SimControl.class); private static Logger logger = Logger.getLogger(SimControl.class);
@ -75,8 +75,8 @@ public class SimControl extends VisPlugin {
* *
* @param simulationToControl Simulation to control * @param simulationToControl Simulation to control
*/ */
public SimControl(Simulation simulationToControl) { public SimControl(Simulation simulationToControl, GUI gui) {
super("Control Panel - " + simulationToControl.getTitle()); super("Control Panel - " + simulationToControl.getTitle(), gui);
simulation = simulationToControl; simulation = simulationToControl;

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -43,7 +43,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("Simulation Information") @ClassDescription("Simulation Information")
@VisPluginType(VisPluginType.SIM_PLUGIN) @PluginType(PluginType.SIM_PLUGIN)
public class SimInformation extends VisPlugin { public class SimInformation extends VisPlugin {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Simulation simulation; private Simulation simulation;
@ -64,8 +64,8 @@ public class SimInformation extends VisPlugin {
* *
* @param simulationToView Simulation to view * @param simulationToView Simulation to view
*/ */
public SimInformation(Simulation simulationToView) { public SimInformation(Simulation simulationToView, GUI gui) {
super("Simulation Information"); super("Simulation Information", gui);
simulation = simulationToView; simulation = simulationToView;

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -51,7 +51,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("Variable Watcher") @ClassDescription("Variable Watcher")
@VisPluginType(VisPluginType.MOTE_PLUGIN) @PluginType(PluginType.MOTE_PLUGIN)
public class VariableWatcher extends VisPlugin { public class VariableWatcher extends VisPlugin {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -79,8 +79,8 @@ public class VariableWatcher extends VisPlugin {
* *
* @param moteToView Mote to view * @param moteToView Mote to view
*/ */
public VariableWatcher(Mote moteToView) { public VariableWatcher(Mote moteToView, Simulation simulation, GUI gui) {
super("Variable Watcher (" + moteToView + ")"); super("Variable Watcher (" + moteToView + ")", gui);
moteMemory = (SectionMoteMemory) moteToView.getMemory(); moteMemory = (SectionMoteMemory) moteToView.getMemory();
@ -343,7 +343,7 @@ public class VariableWatcher extends VisPlugin {
return config; return config;
} }
public boolean setConfigXML(Collection<Element> configXML) { public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
lengthPane.setVisible(false); lengthPane.setVisible(false);
setNumberOfValues(1); setNumberOfValues(1);
varLength.setValue(1); varLength.setValue(1);

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -49,7 +49,7 @@ import se.sics.cooja.interfaces.Battery;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("Battery Visualizer") @ClassDescription("Battery Visualizer")
@VisPluginType(VisPluginType.SIM_PLUGIN) @PluginType(PluginType.SIM_PLUGIN)
public class VisBattery extends Visualizer2D { public class VisBattery extends Visualizer2D {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(VisBattery.class); private static Logger logger = Logger.getLogger(VisBattery.class);
@ -65,8 +65,8 @@ public class VisBattery extends Visualizer2D {
* @param simulationToVisualize * @param simulationToVisualize
* Simulation to visualize * Simulation to visualize
*/ */
public VisBattery(Simulation simulationToVisualize) { public VisBattery(Simulation simulationToVisualize, GUI gui) {
super(simulationToVisualize); super(simulationToVisualize, gui);
setTitle("Battery Visualizer"); setTitle("Battery Visualizer");
simulation = simulationToVisualize; simulation = simulationToVisualize;

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -49,7 +49,7 @@ import se.sics.cooja.Mote.State;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("State Visualizer") @ClassDescription("State Visualizer")
@VisPluginType(VisPluginType.SIM_PLUGIN) @PluginType(PluginType.SIM_PLUGIN)
public class VisState extends Visualizer2D { public class VisState extends Visualizer2D {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(VisState.class); private static Logger logger = Logger.getLogger(VisState.class);
@ -74,8 +74,8 @@ public class VisState extends Visualizer2D {
* *
* @param simulationToVisualize Simulation to visualize * @param simulationToVisualize Simulation to visualize
*/ */
public VisState(Simulation simulationToVisualize) { public VisState(Simulation simulationToVisualize, GUI gui) {
super(simulationToVisualize); super(simulationToVisualize, gui);
setTitle("State Visualizer"); setTitle("State Visualizer");
simulation = simulationToVisualize; simulation = simulationToVisualize;

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -48,7 +48,7 @@ import se.sics.cooja.interfaces.Position;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("Traffic Visualizer") @ClassDescription("Traffic Visualizer")
@VisPluginType(VisPluginType.SIM_PLUGIN) @PluginType(PluginType.SIM_PLUGIN)
public class VisTraffic extends Visualizer2D { public class VisTraffic extends Visualizer2D {
protected boolean USE_ALPHA = false; protected boolean USE_ALPHA = false;
@ -74,8 +74,8 @@ public class VisTraffic extends Visualizer2D {
* @param simulationToVisualize * @param simulationToVisualize
* Simulation to visualize * Simulation to visualize
*/ */
public VisTraffic(Simulation simulationToVisualize) { public VisTraffic(Simulation simulationToVisualize, GUI gui) {
super(simulationToVisualize); super(simulationToVisualize, gui);
setTitle("Traffic Visualizer"); setTitle("Traffic Visualizer");
simulation = simulationToVisualize; simulation = simulationToVisualize;

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.plugins;
@ -57,7 +57,7 @@ import se.sics.cooja.interfaces.*;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("2D Mote Visualizer") @ClassDescription("2D Mote Visualizer")
@VisPluginType(VisPluginType.SIM_PLUGIN) @PluginType(PluginType.SIM_PLUGIN)
public abstract class Visualizer2D extends VisPlugin { public abstract class Visualizer2D extends VisPlugin {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(Visualizer2D.class); private static Logger logger = Logger.getLogger(Visualizer2D.class);
@ -107,8 +107,8 @@ public abstract class Visualizer2D extends VisPlugin {
* @param simulationToVisualize * @param simulationToVisualize
* Simulation to visualize * Simulation to visualize
*/ */
public Visualizer2D(Simulation simulationToVisualize) { public Visualizer2D(Simulation simulationToVisualize, GUI gui) {
super("Visualizer2D"); super("Visualizer2D", gui);
myPlugin = this; myPlugin = this;
@ -257,7 +257,7 @@ public abstract class Visualizer2D extends VisPlugin {
JMenuItem menuItem = new JMenuItem("Open mote plugin for " + mote); JMenuItem menuItem = new JMenuItem("Open mote plugin for " + mote);
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
GUI.currentGUI.showMotePluginsMenu(canvas, mote, pos); simulation.getGUI().showMotePluginsMenu(canvas, mote, pos);
} }
}); });
pickMoteMenu.add(menuItem); pickMoteMenu.add(menuItem);