From 105fe0b5dfa42b41f92d401cff4780729b1a2e42 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 19 Oct 2010 20:31:02 +0000 Subject: [PATCH] added right-click menu option to remove all motes but selected --- .../java/se/sics/cooja/plugins/TimeLine.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java index 8916a5567..cab3930a5 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java +++ b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: TimeLine.java,v 1.29 2010/10/12 10:27:26 fros4943 Exp $ + * $Id: TimeLine.java,v 1.30 2010/10/19 20:31:02 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -331,6 +331,20 @@ public class TimeLine extends VisPlugin { removeMote(m); } }; + private Action removeAllOtherMotesAction = new AbstractAction() { + private static final long serialVersionUID = 2924285037480429045L; + public void actionPerformed(ActionEvent e) { + JComponent b = (JComponent) e.getSource(); + Mote m = (Mote) b.getClientProperty("mote"); + MoteEvents[] mes = allMoteEvents.toArray(new MoteEvents[0]); + for (MoteEvents me: mes) { + if (me.mote == m) { + continue; + } + removeMote(me.mote); + } + } + }; private Action sortMoteAction = new AbstractAction() { private static final long serialVersionUID = 621116674700872058L; public void actionPerformed(ActionEvent e) { @@ -1790,6 +1804,9 @@ public class TimeLine extends VisPlugin { final JMenuItem removeItem = new JMenuItem(removeMoteAction); removeItem.setText("Remove from timeline"); popupMenu.add(removeItem); + final JMenuItem keepMoteOnlyItem = new JMenuItem(removeAllOtherMotesAction); + keepMoteOnlyItem.setText("Remove all motes from timeline but"); + popupMenu.add(keepMoteOnlyItem); addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { @@ -1805,6 +1822,8 @@ public class TimeLine extends VisPlugin { topItem.putClientProperty("mote", m); removeItem.setText("Remove from timeline: " + m); removeItem.putClientProperty("mote", m); + keepMoteOnlyItem.setText("Remove all motes from timeline but: " + m); + keepMoteOnlyItem.putClientProperty("mote", m); popupMenu.show(MoteRuler.this, e.getX(), e.getY()); } });