use of org.eclipse.emf.ecore.resource.Resource in project Palladio-Editors-Sirius by PalladioSimulator.
the class AddLinkingResourceAction method execute.
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
final Object parameter = parameters.get(NEW_COMMUNICATION_LINK_RESOURCE_SPECIFICATION);
if (parameter == null || !(parameter instanceof CommunicationLinkResourceSpecification)) {
return;
}
final CommunicationLinkResourceSpecification communicationLinkResourceSpecification = (CommunicationLinkResourceSpecification) parameter;
// latency
final PCMRandomVariable latency = getRandomVariableFromStoExDialog(LATENCY_DISPLAY_TITLE);
if (latency == null) {
return;
}
communicationLinkResourceSpecification.setLatency_CommunicationLinkResourceSpecification(latency);
// throughput
final PCMRandomVariable throughput = getRandomVariableFromStoExDialog(THROUGHPUT_DISPLAY_TITLE);
if (throughput == null) {
return;
}
communicationLinkResourceSpecification.setThroughput_CommunicationLinkResourceSpecification(throughput);
// Communication Link
Session session = SessionManager.INSTANCE.getSession(communicationLinkResourceSpecification);
URI uri = URI.createURI("pathmap://PCM_MODELS/Palladio.resourcetype");
Resource palladioResources = SiriusCustomUtil.getResourceByURI(uri, session);
if (palladioResources != null) {
ResourceRepository rep = (ResourceRepository) palladioResources.getContents().iterator().next();
for (EObject o : rep.eContents()) {
if ((o instanceof CommunicationLinkResourceType) && ((CommunicationLinkResourceType) o).getEntityName().equals("LAN")) {
communicationLinkResourceSpecification.setCommunicationLinkResourceType_CommunicationLinkResourceSpecification((CommunicationLinkResourceType) o);
break;
}
}
}
}
use of org.eclipse.emf.ecore.resource.Resource in project Palladio-Editors-Sirius by PalladioSimulator.
the class SetFailureType method execute.
@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
InternalFailureOccurrenceDescription element = (InternalFailureOccurrenceDescription) parameters.get("instance");
EObjectQuery query = new EObjectQuery(element);
Collection<Resource> resources = query.getSession().getSemanticResources();
boolean found = false;
Resource resource = null;
for (Resource r : resources) {
if (r.getURI().equals(URI.createURI("pathmap://PCM_MODELS/FailureTypes.repository"))) {
found = true;
resource = r;
break;
}
}
if (found) {
Repository rep = (Repository) resource.getContents().iterator().next();
for (EObject o : rep.eContents()) {
FailureType failureType = (FailureType) o;
if (failureType.getEntityName().equals("SoftwareInducedFailure")) {
element.setSoftwareInducedFailureType__InternalFailureOccurrenceDescription(((SoftwareInducedFailureType) failureType));
break;
}
}
}
}
use of org.eclipse.emf.ecore.resource.Resource in project Palladio-Editors-Sirius by PalladioSimulator.
the class CreateModelCommand method doExecute.
@Override
protected void doExecute() {
final Resource resource = resourceSet.createResource(modelURI);
resource.getContents().add(modelObject);
try {
resource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.emf.ecore.resource.Resource 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.Resource in project xtext-xtend by eclipse.
the class ConvertJavaCode method doConvert.
private void doConvert(final Set<ICompilationUnit> compilationUnits, IProgressMonitor monitor, Map<ICompilationUnit, ConversionResult> conversionResults) throws ExecutionException, InterruptedException {
for (ICompilationUnit iCompilationUnit : compilationUnits) {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
JavaConverter converter = converterProvider.get();
ConversionResult conversionResult = converter.toXtend(iCompilationUnit);
monitor.subTask("Working with " + iCompilationUnit.getElementName());
if (!conversionResult.getProblems().iterator().hasNext()) {
IFile file = xtendFileToCreate(iCompilationUnit);
Resource resource = createResource(file, conversionResult.getXtendCode());
if (!validateResource(resource)) {
monitor.subTask("Conversion was not successfull. Re-trying with another strategy.");
conversionResult = converter.useRobustSyntax().toXtend(iCompilationUnit);
}
}
conversionResults.put(iCompilationUnit, conversionResult);
monitor.worked(1);
}
}
Aggregations