[cooja] plugins/Visualizer: Deselect motes when removing

This also fixes visualization issues such as
remaining transmission range underlays for removed motes
This commit is contained in:
Enrico Joerns 2014-06-10 15:59:33 +02:00
parent 8b1bf449ee
commit d8cf0d1349

View file

@ -67,6 +67,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -456,8 +457,11 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
for (Mote m : Visualizer.this.getSelectedMotes()) { Iterator<Mote> iter = Visualizer.this.getSelectedMotes().iterator();
while (iter.hasNext()) {
Mote m = iter.next();
m.getSimulation().removeMote(m); m.getSimulation().removeMote(m);
iter.remove();
} }
} }
}); });
@ -1654,16 +1658,15 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
@Override @Override
public void doAction(Visualizer visualizer, Mote mote) { public void doAction(Visualizer visualizer, Mote mote) {
/* If the currently clicked mote is note in the current mote selection, /* If the currently clicked mote is not in the current mote selection,
* select it exclusively */ * select it exclusively */
if (!visualizer.getSelectedMotes().contains(mote)) { if (!visualizer.getSelectedMotes().contains(mote)) {
visualizer.getSelectedMotes().clear(); visualizer.getSelectedMotes().clear();
visualizer.getSelectedMotes().add(mote); visualizer.getSelectedMotes().add(mote);
} }
for (Mote m : visualizer.getSelectedMotes()) { /* Invoke 'delete_motes' action */
mote.getSimulation().removeMote(m); visualizer.canvas.getActionMap().get("delete_motes").actionPerformed(null);
}
} }
}; };