added right-click menu option to remove all motes but selected

This commit is contained in:
fros4943 2010-10-19 20:31:02 +00:00
parent 842c6a018a
commit 105fe0b5df

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: 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; package se.sics.cooja.plugins;
@ -331,6 +331,20 @@ public class TimeLine extends VisPlugin {
removeMote(m); 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 Action sortMoteAction = new AbstractAction() {
private static final long serialVersionUID = 621116674700872058L; private static final long serialVersionUID = 621116674700872058L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -1790,6 +1804,9 @@ public class TimeLine extends VisPlugin {
final JMenuItem removeItem = new JMenuItem(removeMoteAction); final JMenuItem removeItem = new JMenuItem(removeMoteAction);
removeItem.setText("Remove from timeline"); removeItem.setText("Remove from timeline");
popupMenu.add(removeItem); popupMenu.add(removeItem);
final JMenuItem keepMoteOnlyItem = new JMenuItem(removeAllOtherMotesAction);
keepMoteOnlyItem.setText("Remove all motes from timeline but");
popupMenu.add(keepMoteOnlyItem);
addMouseListener(new MouseAdapter() { addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@ -1805,6 +1822,8 @@ public class TimeLine extends VisPlugin {
topItem.putClientProperty("mote", m); topItem.putClientProperty("mote", m);
removeItem.setText("Remove from timeline: " + m); removeItem.setText("Remove from timeline: " + m);
removeItem.putClientProperty("mote", 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()); popupMenu.show(MoteRuler.this, e.getX(), e.getY());
} }
}); });