use of org.eclipse.emf.ecore.resource.ResourceSet in project Palladio-Editors-Sirius by PalladioSimulator.
the class AddHDDProcessingResourceSpecification 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 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
}
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class ResourceStorageTest method testConstantValueIsPersisted.
@Test
public void testConstantValueIsPersisted() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("static val CONSTANT = \'a\' + \'b\' + 0");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String contents = _builder.toString();
final XtendFile file = this.file(contents);
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
((ResourceStorageFacade) this.resourceStorageFacade).setStoreNodeModel(true);
Resource _eResource = file.eResource();
this.resourceStorageFacade.createResourceStorageWritable(bout).writeResource(((StorageAwareResource) _eResource));
byte[] _byteArray = bout.toByteArray();
ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(_byteArray);
final ResourceStorageLoadable in = this.resourceStorageFacade.createResourceStorageLoadable(_byteArrayInputStream);
Resource _createResource = file.eResource().getResourceSet().createResource(URI.createURI("synthetic:/test/MyClass.xtend"));
final StorageAwareResource resource = ((StorageAwareResource) _createResource);
final InMemoryURIConverter converter = new InMemoryURIConverter();
converter.addModel(resource.getURI().toString(), contents);
ResourceSet _resourceSet = resource.getResourceSet();
_resourceSet.setURIConverter(converter);
EList<Resource> _resources = file.eResource().getResourceSet().getResources();
_resources.add(resource);
resource.loadFromStorage(in);
EObject _get = resource.getContents().get(1);
final JvmGenericType jvmClass = ((JvmGenericType) _get);
JvmMember _last = IterableExtensions.<JvmMember>last(jvmClass.getMembers());
final JvmField field = ((JvmField) _last);
Assert.assertTrue(field.isConstant());
Assert.assertTrue(field.isSetConstant());
Assert.assertEquals("ab0", field.getConstantValue());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class XtendResourceSetBasedResourceDescriptionsTest method testUnloadedBidirectionalRef.
@Test
public void testUnloadedBidirectionalRef() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo class ClassA extends bar.ClassB {}");
Pair<String, String> _mappedTo = Pair.<String, String>of("foo/ClassA.xtend", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package bar class ClassB { public foo.ClassA myField }");
Pair<String, String> _mappedTo_1 = Pair.<String, String>of("bar/ClassB.xtend", _builder_1.toString());
final ResourceSet resourceSet = this.compiler.unLoadedResourceSet(_mappedTo, _mappedTo_1);
final List<? extends Resource> resources = resourceSet.getResources();
ArrayList<Resource> _arrayList = new ArrayList<Resource>(resources);
for (final Resource res : _arrayList) {
{
final List<Issue> issues = this.validator.validate(res, CheckMode.ALL, CancelIndicator.NullImpl);
Assert.assertTrue(issues.toString(), issues.isEmpty());
}
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class XtendResourceSetBasedResourceDescriptionsTest method testUnloadedInstallDerivedStateThrowsException.
@Test
public void testUnloadedInstallDerivedStateThrowsException() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo class ClassA extends bar.ClassB {}");
Pair<String, String> _mappedTo = Pair.<String, String>of("foo/ClassA.xtend", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package bar class ClassB { public foo.ClassA myField }");
Pair<String, String> _mappedTo_1 = Pair.<String, String>of("bar/ClassB.xtend", _builder_1.toString());
final ResourceSet resourceSet = this.compiler.unLoadedResourceSet(_mappedTo, _mappedTo_1);
final List<? extends Resource> resources = resourceSet.getResources();
ArrayList<Resource> _arrayList = new ArrayList<Resource>(resources);
for (final Resource res : _arrayList) {
{
Assert.assertFalse(res.isLoaded());
try {
((DerivedStateAwareResource) res).installDerivedState(true);
Assert.fail("expected exception");
} catch (final Throwable _t) {
if (_t instanceof IllegalStateException) {
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations