protected void action() throws ActionException {
try {
Object model = ModelFactory.constructModel(constructable);
if (model == null) {
throw new ActionException("No model was created");
} else if (model instanceof Node) {
final Node node = (Node) model;
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
try {
ensureNonConflictingName(node, container);
try {
nodeCreated = container.addNodeModel(node,posX,posY);
if (nodeCreated instanceof UINodeViewable) {
if (nodeCreated instanceof ca.nengo.ui.models.nodes.UINEFEnsemble) {
// don't open NEFEnsembles
} else {
((UINodeViewable) (nodeCreated)).openViewer();
}
}
} catch (ContainerException e) {
UserMessages.showWarning("Could not add node: " + e.getMessage());
}
} catch (UserCancelledException e) {
e.defaultHandleBehavior();
}
}
});
} else {
throw new ActionException("Can not add model of the type: "
+ model.getClass().getSimpleName());
}
} catch (ConfigException e) {
e.defaultHandleBehavior();
} catch (Exception e) {
e.printStackTrace();
throw new ActionException(e.getMessage(), e);
}
}