From a0bf017e2f7924be8f1489e182aa23ecfd486f3e Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 28 Oct 2008 14:09:25 +0000 Subject: [PATCH] removed passive/active interfaces notion. --- .../cooja/plugins/MoteInterfaceViewer.java | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java b/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java index 6574ac1f8..5eee15913 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.3 2007/01/09 09:49:24 fros4943 Exp $ + * $Id: MoteInterfaceViewer.java,v 1.4 2008/10/28 14:09:25 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -41,9 +41,9 @@ import org.jdom.Element; import se.sics.cooja.*; /** - * MoteInterfaceViewer allows a user to select and view information about a node's interfaces. + * Mote Interface Viewer views information about a specific mote interface. * - * @author Fredrik Osterlind + * @author Fredrik Österlind */ @ClassDescription("Mote Interface Viewer") @PluginType(PluginType.MOTE_PLUGIN) @@ -53,7 +53,7 @@ public class MoteInterfaceViewer extends VisPlugin { private Mote mote; private MoteInterface selectedMoteInterface = null; private JPanel currentInterfaceVisualizer = null; - private JComboBox selectInterfaceComboBox = null; + private JComboBox selectInterfaceComboBox = null; /** * Create a new mote interface viewer. @@ -78,31 +78,28 @@ public class MoteInterfaceViewer extends VisPlugin { selectInterfaceComboBox = new JComboBox(); final JPanel interfacePanel = new JPanel(); - for (int i=0; i < mote.getInterfaces().getAllActiveInterfaces().size(); i++) { - selectInterfaceComboBox.addItem(GUI.getDescriptionOf(mote.getInterfaces().getAllActiveInterfaces().get(i))); + Vector intfs = mote.getInterfaces().getInterfaces(); + for (MoteInterface intf : intfs) { + selectInterfaceComboBox.addItem(GUI.getDescriptionOf(intf)); } - for (int i=0; i < mote.getInterfaces().getAllPassiveInterfaces().size(); i++) { - selectInterfaceComboBox.addItem(GUI.getDescriptionOf(mote.getInterfaces().getAllPassiveInterfaces().get(i))); - } - + selectInterfaceComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Release old interface visualizer if any - if (selectedMoteInterface != null && currentInterfaceVisualizer != null) + if (selectedMoteInterface != null && currentInterfaceVisualizer != null) { selectedMoteInterface.releaseInterfaceVisualizer(currentInterfaceVisualizer); - + } + // View selected interface if any interfacePanel.removeAll(); String interfaceDescription = (String) selectInterfaceComboBox.getSelectedItem(); selectedMoteInterface = null; - for (int i=0; i < mote.getInterfaces().getAllActiveInterfaces().size(); i++) { - if (GUI.getDescriptionOf(mote.getInterfaces().getAllActiveInterfaces().get(i)).equals(interfaceDescription)) - selectedMoteInterface = mote.getInterfaces().getAllActiveInterfaces().get(i); - } - for (int i=0; i < mote.getInterfaces().getAllPassiveInterfaces().size(); i++) { - if (GUI.getDescriptionOf(mote.getInterfaces().getAllPassiveInterfaces().get(i)).equals(interfaceDescription)) - selectedMoteInterface = mote.getInterfaces().getAllPassiveInterfaces().get(i); + Vector intfs = mote.getInterfaces().getInterfaces(); + for (MoteInterface intf : intfs) { + if (GUI.getDescriptionOf(intf).equals(interfaceDescription)) { + selectedMoteInterface = intf; + } } currentInterfaceVisualizer = selectedMoteInterface.getInterfaceVisualizer(); if (currentInterfaceVisualizer != null) { @@ -110,10 +107,10 @@ public class MoteInterfaceViewer extends VisPlugin { interfacePanel.add(BorderLayout.CENTER, currentInterfaceVisualizer); currentInterfaceVisualizer.setVisible(true); } else { - interfacePanel.add(new JLabel("No interface visualizer exists!")); + interfacePanel.add(new JLabel("No interface visualizer")); currentInterfaceVisualizer = null; } - setSize(getSize()); + setSize(getSize()); } }); selectInterfaceComboBox.setSelectedIndex(0); @@ -161,16 +158,17 @@ public class MoteInterfaceViewer extends VisPlugin { } return false; } - + public void closePlugin() { // Release old interface visualizer if any - if (selectedMoteInterface != null && currentInterfaceVisualizer != null) + if (selectedMoteInterface != null && currentInterfaceVisualizer != null) { selectedMoteInterface.releaseInterfaceVisualizer(currentInterfaceVisualizer); + } } public Collection getConfigXML() { Vector config = new Vector(); - + Element element; // Selected variable name @@ -180,14 +178,14 @@ public class MoteInterfaceViewer extends VisPlugin { return config; } - + public boolean setConfigXML(Collection configXML, boolean visAvailable) { for (Element element : configXML) { if (element.getName().equals("interface")) { setSelectedInterface(element.getText()); - } + } } return true; } - + }