// Get the name of the automation we want to load
String name = attributes.getNamedItem("name").getNodeValue();
// Check if an automation already exists with the same name:
Automation automation = getAutomation( name );
// If already exists:
if( automation!=null )
{
// display a dialog and ask the user what to do:
ErrorMessage dialog = new ErrorMessage(2);
dialog.append("An automation called \""+name+"\" already exists. Do you want to overwrite the existing automation or to keep it ?");
dialog.setButton(0,"Overwrite");
dialog.setButton(1,"Keep existing");
dialog.setTitle("Importing automation \""+name+"\"");
dialog.setVisible(true);
// if the user does not want to overwrite the existing
// automation, skip and continue with the other automations
if( dialog.getButton() != 0 )
{
continue;
}
// otherwise, replace the content of the existing automation
// with the new settings:
automation.loadAttributes(attributes);
// remove the existing generators before loading
// the new ones:
automation.removeAllGenerators();
}
// no automation with this name exists:
else
{
automation = new Automation( attributes );
}
// finally, load the generators (whether a new automation is created
// an existing automation is overwritten).
automation.loadGenerators( automationNode.getChildNodes(), generatorFactory );
addAutomation(automation);
}
}