* It shall be of the form platform:/resource/SomePath/File (without file extention)
* @return The ModelSet representing the new Papyrus model
*/
public static ModelSet createNew(final String baseURI) {
ServicesRegistry registry = null;
ModelSet modelSet = null;
try {
registry = new ExtensionServicesRegistry(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID);
} catch (ServiceException ex) {
//Activator.log.error(ex);
return null;
}
try {
registry.startServicesByClassKeys(ModelSet.class);
} catch (ServiceException ex) {
// ignore at this point
}
try {
modelSet = registry.getService(ModelSet.class);
} catch (ServiceException ex) {
//Activator.log.error(ex);
return null;
}
final ModelSet papyrus = modelSet;
CommandStack stack = modelSet.getTransactionalEditingDomain().getCommandStack();
stack.execute(new AbstractCommand() {
@Override
public boolean canExecute() {
return true;
}
@Override
public void execute() {
URI uri = URI.createURI(baseURI);
papyrus.createModels(uri);
AbstractBaseModel notation = (AbstractBaseModel) papyrus.getModel(NotationModel.MODEL_ID);
notation.createModel(uri);
notation.getResource().getErrors().clear();
((GMFResource) notation.getResource()).setUseIDAttributes(true);
}