From 5a053d7d4e725082950628cbbd7428681de49f89 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 30 Jun 2009 12:46:26 +0000 Subject: [PATCH] added quick help --- tools/cooja/java/se/sics/cooja/VisPlugin.java | 11 ++++----- .../cooja/plugins/MoteInterfaceViewer.java | 24 +++++++++++++++++-- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/VisPlugin.java b/tools/cooja/java/se/sics/cooja/VisPlugin.java index 167ba9ef2..a812ba1ae 100644 --- a/tools/cooja/java/se/sics/cooja/VisPlugin.java +++ b/tools/cooja/java/se/sics/cooja/VisPlugin.java @@ -26,13 +26,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: VisPlugin.java,v 1.9 2009/04/03 17:03:42 fros4943 Exp $ + * $Id: VisPlugin.java,v 1.10 2009/06/30 12:46:26 fros4943 Exp $ */ package se.sics.cooja; import java.util.Collection; import javax.swing.JInternalFrame; +import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; import org.jdom.Element; @@ -67,21 +68,17 @@ public abstract class VisPlugin extends JInternalFrame implements Plugin { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addInternalFrameListener(new InternalFrameListener() { + addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { gui.removePlugin(VisPlugin.this, true); } - public void internalFrameClosed(InternalFrameEvent e) { } - public void internalFrameOpened(InternalFrameEvent e) { } - public void internalFrameIconified(InternalFrameEvent e) { } - public void internalFrameDeiconified(InternalFrameEvent e) { } public void internalFrameActivated(InternalFrameEvent e) { /* Highlight mote in COOJA */ if (VisPlugin.this.tag != null && tag instanceof Mote) { gui.signalMoteHighlight((Mote) tag); } + gui.loadQuickHelp(VisPlugin.this); } - public void internalFrameDeactivated(InternalFrameEvent e) { } } ); } diff --git a/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java b/tools/cooja/java/se/sics/cooja/plugins/MoteInterfaceViewer.java index 22b94a83a..f6a665c82 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.6 2009/03/23 13:26:43 nifi Exp $ + * $Id: MoteInterfaceViewer.java,v 1.7 2009/06/30 12:46:26 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -52,6 +52,7 @@ import se.sics.cooja.MoteInterface; import se.sics.cooja.PluginType; import se.sics.cooja.Simulation; import se.sics.cooja.VisPlugin; +import se.sics.cooja.GUI.HasQuickHelp; /** * Mote Interface Viewer views information about a specific mote interface. @@ -60,7 +61,7 @@ import se.sics.cooja.VisPlugin; */ @ClassDescription("Mote Interface Viewer") @PluginType(PluginType.MOTE_PLUGIN) -public class MoteInterfaceViewer extends VisPlugin { +public class MoteInterfaceViewer extends VisPlugin implements HasQuickHelp { private static final long serialVersionUID = 1L; private Mote mote; @@ -114,6 +115,8 @@ public class MoteInterfaceViewer extends VisPlugin { for (MoteInterface intf : intfs) { if (GUI.getDescriptionOf(intf).equals(interfaceDescription)) { selectedMoteInterface = intf; + mote.getSimulation().getGUI().loadQuickHelp(MoteInterfaceViewer.this); + break; } } currentInterfaceVisualizer = selectedMoteInterface.getInterfaceVisualizer(); @@ -215,4 +218,21 @@ public class MoteInterfaceViewer extends VisPlugin { return true; } + public String getQuickHelp() { + String help = "" + GUI.getDescriptionOf(this) + ""; + help += "

Lists mote interfaces, and allows mote inspection and interaction via mote interface visualizers."; + + MoteInterface intf = selectedMoteInterface; + if (intf != null) { + if (intf instanceof HasQuickHelp) { + help += "

" + ((HasQuickHelp)intf).getQuickHelp(); + } else { + help += "

" + GUI.getDescriptionOf(intf) + ""; + help += "

No help available"; + } + } + + return help; + } + }