use of org.eclipse.emf.ecore.resource.ResourceSet in project Palladio-Editors-Sirius by PalladioSimulator.
the class AddProcessingResourceSpecification method getSchedulingPolicy.
private SchedulingPolicy getSchedulingPolicy(final ProcessingResourceSpecification processingResourceSpecification) {
final ResourceSet set = (processingResourceSpecification.getResourceContainer_ProcessingResourceSpecification()).eResource().getResourceSet();
// positive filter
final ArrayList<Object> filterList = new ArrayList<Object>();
// Set types to show and their super types
filterList.add(SchedulingPolicy.class);
filterList.add(ResourceRepository.class);
final ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
// set EReference that should be set (in this case: SchedulingPolicy)
additionalReferences.add(ResourceenvironmentPackage.eINSTANCE.getProcessingResourceSpecification_SchedulingPolicy());
final PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), filterList, additionalReferences, set);
dialog.setProvidedService(SchedulingPolicy.class);
dialog.open();
if (dialog.getResult() == null || !(dialog.getResult() instanceof SchedulingPolicy)) {
return null;
}
return (SchedulingPolicy) dialog.getResult();
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project Palladio-Editors-Sirius by PalladioSimulator.
the class ResourceSelectorPage method getResult.
protected EObject getResult(Session session) {
EObject result = null;
URI uri = URI.createURI(path, true);
TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
ResourceSet resourceSet = domain.getResourceSet();
try {
Resource resource = resourceSet.getResource(uri, true);
result = (EObject) resource.getContents().get(0);
} catch (WrappedException ex) {
// do nothing
}
return result;
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class ConvertJavaCode method createResource.
private Resource createResource(IFile file, String content) throws ExecutionException {
ResourceSet set = resourceSetProvider.get(file.getProject());
Resource resource = set.createResource(URI.createPlatformResourceURI(file.getFullPath().toString(), false));
try {
resource.load(new LazyStringInputStream(content, file.getCharset()), null);
} catch (CoreException e) {
handleException("Failed to read file content", e, file);
} catch (IOException e) {
handleException("Failed to load resource.", e, file);
}
return resource;
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class DispatchMethodRenameStrategy method initialize.
@Override
public boolean initialize(EObject xtendMethod, IRenameElementContext context) {
Assert.isLegal(xtendMethod instanceof XtendFunction);
Assert.isLegal(((XtendFunction) xtendMethod).isDispatch());
Assert.isLegal(context instanceof DispatchMethodRenameContext);
ResourceSet resourceSet = xtendMethod.eResource().getResourceSet();
Map<URI, IJavaElement> jvm2JavaElements = ((DispatchMethodRenameContext) context).getJvm2JavaElements();
for (URI dispatchOperationURI : jvm2JavaElements.keySet()) {
JvmOperation dispatchOperation = (JvmOperation) resourceSet.getEObject(dispatchOperationURI, true);
XtendFunction xtendDispatchMethod = associations.getXtendFunction(dispatchOperation);
if (xtendDispatchMethod != null) {
if (equal(xtendDispatchMethod.getName(), dispatchOperation.getSimpleName())) {
// synthetic dispatcher
dispatchers.add(dispatchOperation);
} else {
// xtend dispatch method
XtendDispatchMethodChildStrategy xtendChildStrategy = childStrategyProvider.get();
xtendChildStrategy.initialize(xtendDispatchMethod, context);
children.add(xtendChildStrategy);
}
} else {
// a dispatch method form a Java class
JavaDispatchMethodChildStrategy jvmChildStrategy = javaStrategyProvider.get();
jvmChildStrategy.initialize(dispatchOperation, context);
children.add(jvmChildStrategy);
}
}
return !children.isEmpty();
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class ExtractMethodUserInputPage method createSignaturePreview.
protected void createSignaturePreview(Composite composite) {
Label previewLabel = new Label(composite, SWT.NONE);
previewLabel.setText("Method signature preview:");
GridData gridData = new GridData(SWT.FILL);
gridData.horizontalSpan = 2;
previewLabel.setLayoutData(gridData);
signaturePreview = editorFactory.newEditor(new IEditedResourceProvider() {
@Override
public XtextResource createResource() {
URI resourceURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(refactoring.getXtendClass()).trimFragment();
IProject project = projectUtil.getProject(resourceURI);
ResourceSet resourceSet = resourceSetProvider.get(project);
return (XtextResource) resourceSet.getResource(resourceURI, true);
}
}).readOnly().withParent(composite);
GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL);
gridData2.horizontalSpan = 2;
signaturePreview.getViewer().getControl().setLayoutData(gridData2);
partialEditor = signaturePreview.createPartialEditor(getPartialEditorModelPrefix(), refactoring.getMethodSignature(), getPartialEditorModelSuffix(), true);
}
Aggregations