[cooja] plugins/Visualizer: Fixed node selection in Delete menu handling
Previously if multiple motes were selected and the context menu of a non-selected mote was used to delete, not the clicked mote but the other selected ones were removed. This behavior is fixed so that if another mote is clicked only this is deleted.
This commit is contained in:
parent
6594684342
commit
3ada5671ef
|
@ -1584,21 +1584,25 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
|||
|
||||
@Override
|
||||
public String getDescription(Visualizer visualizer, Mote mote) {
|
||||
if (visualizer.getSelectedMotes().size() == 1) {
|
||||
return "Delete " + mote;
|
||||
} else {
|
||||
if (visualizer.getSelectedMotes().contains(mote) && visualizer.getSelectedMotes().size() > 1) {
|
||||
return "Delete selected Motes";
|
||||
} else {
|
||||
return "Delete " + mote;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(Visualizer visualizer, Mote mote) {
|
||||
if (visualizer.getSelectedMotes().size() == 1) {
|
||||
mote.getSimulation().removeMote(mote);
|
||||
} else {
|
||||
for (Mote m: visualizer.getSelectedMotes()) {
|
||||
mote.getSimulation().removeMote(m);
|
||||
|
||||
/* If the currently clicked mote is note in the current mote selection,
|
||||
* select it exclusively */
|
||||
if (!visualizer.getSelectedMotes().contains(mote)) {
|
||||
visualizer.getSelectedMotes().clear();
|
||||
visualizer.getSelectedMotes().add(mote);
|
||||
}
|
||||
|
||||
for (Mote m : visualizer.getSelectedMotes()) {
|
||||
mote.getSimulation().removeMote(m);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue