get[Started]Plugin method returns plugins that end with argument + added sim and gui variables accessible from test scripts

This commit is contained in:
Fredrik Osterlind 2011-03-14 19:54:58 +01:00
parent bdc42d8e64
commit 0829e50f4b
2 changed files with 16 additions and 3 deletions

View file

@ -1882,20 +1882,31 @@ public class GUI extends Observable {
}
/**
* Returns started plugin with given class name, if any.
* Returns started plugin that ends with given class name, if any.
*
* @param classname Class name
* @return Plugin instance
*/
public Plugin getStartedPlugin(String classname) {
public Plugin getPlugin(String classname) {
for (Plugin p: startedPlugins) {
if (p.getClass().getName().equals(classname)) {
if (p.getClass().getName().endsWith(classname)) {
return p;
}
}
return null;
}
/**
* Returns started plugin with given class name, if any.
*
* @param classname Class name
* @return Plugin instance
* @deprecated
*/
public Plugin getStartedPlugin(String classname) {
return getPlugin(classname);
}
public Plugin[] getStartedPlugins() {
return startedPlugins.toArray(new Plugin[0]);
}

View file

@ -434,6 +434,8 @@ public class LogScriptEngine {
Hashtable<Object, Object> hash = new Hashtable<Object, Object>();
engine.put("global", hash);
engine.put("sim", simulation);
engine.put("gui", simulation.getGUI());
scriptMote = new ScriptMote();
engine.put("node", scriptMote);