automatically close mote plugins when mote is removed
This commit is contained in:
parent
ddcda4582e
commit
89a062aa06
2 changed files with 31 additions and 2 deletions
|
@ -24,7 +24,7 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: GUI.java,v 1.71 2008/02/18 08:18:01 fros4943 Exp $
|
||||
* $Id: GUI.java,v 1.72 2008/03/17 08:35:10 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -1647,6 +1647,32 @@ public class GUI {
|
|||
myDesktopPane.moveToFront(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close all mote plugins for given mote.
|
||||
*
|
||||
* @param mote Mote
|
||||
*/
|
||||
public void closeMotePlugins(Mote mote) {
|
||||
Vector<Plugin> pluginsToRemove = new Vector<Plugin>();
|
||||
|
||||
for (Plugin startedPlugin : startedPlugins) {
|
||||
int pluginType = startedPlugin.getClass().getAnnotation(PluginType.class).value();
|
||||
|
||||
if (pluginType != PluginType.MOTE_PLUGIN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Mote pluginMote = (Mote) startedPlugin.getTag();
|
||||
if (pluginMote == mote) {
|
||||
pluginsToRemove.add(startedPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
for (Plugin pluginToRemove: pluginsToRemove) {
|
||||
removePlugin(pluginToRemove, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plugin from working area.
|
||||
*
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: Simulation.java,v 1.20 2008/02/12 15:31:22 fros4943 Exp $
|
||||
* $Id: Simulation.java,v 1.21 2008/03/17 08:35:10 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -543,6 +543,7 @@ public class Simulation extends Observable implements Runnable {
|
|||
* Mote to remove
|
||||
*/
|
||||
public void removeMote(Mote mote) {
|
||||
|
||||
if (isRunning()) {
|
||||
stopSimulation();
|
||||
motes.remove(mote);
|
||||
|
@ -551,7 +552,9 @@ public class Simulation extends Observable implements Runnable {
|
|||
motes.remove(mote);
|
||||
}
|
||||
|
||||
myGUI.closeMotePlugins(mote);
|
||||
currentRadioMedium.unregisterMote(mote, this);
|
||||
|
||||
this.setChanged();
|
||||
this.notifyObservers(this);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue