use of org.eclipse.emf.transaction.TransactionalEditingDomain in project Palladio-Editors-Sirius by PalladioSimulator.
the class AllocationCreationWizard method finish.
@Override
protected void finish() {
Allocation allocation = (Allocation) modelObject;
Session session = SessionManager.INSTANCE.getSession(modelObject);
TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
String fileString = modelURI.toPlatformString(true);
IPath path = new Path(fileString);
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
List<IFile> list = new ArrayList<IFile>();
list.add(file);
AbstractTransactionalCommand command = new AbstractTransactionalCommand(domain, "Save Allocation model.", list) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
allocation.setTargetResourceEnvironment_Allocation(resourceEnvironmentSelectorpage.getSelectedResourceEnvironment(session));
allocation.setSystem_Allocation(systemSelectorPage.getSelectedSystem(session));
return CommandResult.newOKCommandResult();
}
};
try {
OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null);
} catch (ExecutionException e) {
System.out.println("Unable to save allocation model.");
e.printStackTrace();
}
}
use of org.eclipse.emf.transaction.TransactionalEditingDomain in project Palladio-Editors-Sirius by PalladioSimulator.
the class ResourceSelectorPage method resolveSelection.
/**
* checks if the selected file is a valid resource.
*/
private void resolveSelection() {
myResolvedObject = null;
URI uri = URI.createURI(mySelectionText.getText(), true);
TransactionalEditingDomain editingDomain = EditingDomainFactoryService.INSTANCE.getEditingDomainFactory().createEditingDomain();
ResourceSet resourceSet = editingDomain.getResourceSet();
try {
Resource resource = resourceSet.getResource(uri, true);
myResolvedObject = (EObject) resource.getContents().get(0);
path = mySelectionText.getText();
} catch (WrappedException ex) {
// do nothing
}
}
Aggregations