use of org.yakindu.sct.model.sgraph.resource.AbstractSCTResource in project statecharts by Yakindu.
the class DomainSpecificTaskFinder method findTasks.
@Override
public List<Task> findTasks(Resource resource) {
if (resource instanceof AbstractSCTResource) {
IDomain domain = DomainRegistry.getDomain((EObject) EcoreUtil2.getObjectByType(resource.getContents(), SGraphPackage.Literals.STATECHART));
ITaskFinder taskFinder = domain.getInjector(IDomain.FEATURE_RESOURCE).getInstance(ITaskFinder.class);
if (taskFinder != null)
return taskFinder.findTasks(resource);
}
return Collections.emptyList();
}
use of org.yakindu.sct.model.sgraph.resource.AbstractSCTResource in project statecharts by Yakindu.
the class ViewBasedRefactoringTest method testRefactoring.
protected void testRefactoring(String pathToInitialSct, String pathToExpectedSct, String contextElementName) {
Statechart initial = models.loadStatechartFromResource(pathToInitialSct);
TransactionalEditingDomainImpl.FactoryImpl.INSTANCE.createEditingDomain(initial.eResource().getResourceSet());
View contextView = getViewForState(initial, contextElementName);
AbstractRefactoring<View> refactoring = getRefactoring();
refactoring.setContextObjects(Collections.singletonList(contextView));
AbstractSCTResource initialRes = (AbstractSCTResource) initial.eResource();
initialRes.setSerializerEnabled(true);
refactoring.execute();
initialRes.setSerializerEnabled(false);
Statechart expected = models.loadStatechartFromResource(pathToExpectedSct);
compareStatecharts(initial, expected);
}
use of org.yakindu.sct.model.sgraph.resource.AbstractSCTResource in project statecharts by Yakindu.
the class RenameRefactoringTest method testRenaming.
private void testRenaming(Statechart initial, Statechart expected, NamedElement elementToRename, String newName) {
RenameRefactoring refactoring = new RenameRefactoring();
refactoring.setContextObjects(Lists.newArrayList(elementToRename));
refactoring.setNewName(newName);
AbstractSCTResource initialRes = (AbstractSCTResource) initial.eResource();
initialRes.setSerializerEnabled(true);
refactoring.internalExecute();
initialRes.setSerializerEnabled(false);
compareStatecharts(initial, expected);
}
use of org.yakindu.sct.model.sgraph.resource.AbstractSCTResource in project statecharts by Yakindu.
the class StateBasedRefactoringTest method testRefactoringOnState.
protected void testRefactoringOnState(String pathToInitialSct, String pathToExpectedSct, String stateName) {
Statechart initial = models.loadStatechartFromResource(pathToInitialSct);
State state = getStateByName(initial, stateName);
AbstractRefactoring<?> refactoring = getRefactoring(state);
AbstractSCTResource initialRes = (AbstractSCTResource) initial.eResource();
initialRes.setSerializerEnabled(true);
refactoring.executeRefactoring();
initialRes.setSerializerEnabled(false);
Statechart expected = models.loadStatechartFromResource(pathToExpectedSct);
compareStatecharts(initial, expected);
}
use of org.yakindu.sct.model.sgraph.resource.AbstractSCTResource in project statecharts by Yakindu.
the class DefaultValidationJob method runInternal.
@Override
protected IStatus runInternal(final IProgressMonitor monitor) {
try {
if (!resource.isLoaded())
return Status.CANCEL_STATUS;
if (resource instanceof AbstractSCTResource) {
relinkModel(monitor, (AbstractSCTResource) resource);
}
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
TransactionalValidationRunner runner = new TransactionalValidationRunner(validator, resource, CheckMode.FAST_ONLY, new CancelIndicator() {
public boolean isCanceled() {
return monitor.isCanceled();
}
});
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resource);
if (editingDomain == null)
return Status.CANCEL_STATUS;
try {
editingDomain.runExclusive(runner);
} catch (Throwable ex) {
// Since xtext 2.8 this may throw an OperationCanceledError
return Status.CANCEL_STATUS;
}
final List<Issue> issues = runner.getResult();
if (issues == null)
return Status.CANCEL_STATUS;
validationIssueProcessor.processIssues(issues, monitor);
} catch (Exception ex) {
ex.printStackTrace();
return new Status(IStatus.ERROR, DiagramActivator.PLUGIN_ID, ex.getMessage());
}
return Status.OK_STATUS;
}
Aggregations