int response = JOptionPane.showConfirmDialog(UIEnvironment
.getInstance(),
"Are you sure you want to remove all objects from Nengo?",
"Clear all?", JOptionPane.YES_NO_OPTION);
if (response == 0) {
NengoGraphics nengo = NengoGraphics.getInstance();
Iterable<WorldObject> modelsToRemove = nengo.getWorld().getGround().getChildren();
Iterator<WorldObject> iter = modelsToRemove.iterator();
List<WorldObject> copy = new ArrayList<WorldObject>();
while (iter.hasNext())
copy.add(iter.next());
for (WorldObject modelToRemove : copy) {
nengo.removeNodeModel((Node) ((ModelObject) modelToRemove).getModel());
}
//clear script console
nengo.getScriptConsole().reset(false);
} else {
throw new UserCancelledException();
}
}