use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class STextGlobalScopeProvider method getScope.
public IScope getScope(Resource context, EReference reference, Predicate<IEObjectDescription> filter) {
IScope parentScope = super.getScope(context, reference, filter);
parentScope = new SimpleScope(parentScope, filterPropertiesOfLibrary(context, reference, filter).getAllElements());
final Statechart statechart = getStatechart(context);
parentScope = new TypeSystemAwareScope(parentScope, typeSystem, qualifiedNameProvider, reference.getEReferenceType());
IScope result = new FilteringScope(parentScope, new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
String userData = input.getUserData(DomainRegistry.DOMAIN_ID);
if (userData == null)
return true;
return statechart.getDomainID().equals(userData);
}
});
result = filterAnnotations(reference, result);
return new FilteringScope(result, input -> {
String isVisible = input.getUserData(TypedResourceDescriptionStrategy.IS_VISIBLE_TYPE);
return isVisible == null || Boolean.valueOf(isVisible);
});
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class STextScopeProvider method scope_ActiveStateReferenceExpression_value.
public IScope scope_ActiveStateReferenceExpression_value(EObject context, EReference reference) {
Statechart statechart = getStatechart(context);
if (statechart == null)
return IScope.NULLSCOPE;
List<State> allStates = EcoreUtil2.getAllContentsOfType(statechart, State.class);
IScope scope = Scopes.scopeFor(allStates, nameProvider, IScope.NULLSCOPE);
return new ImportScope(getActiveStateNormalizer(context), scope, new EObjectDescriptionLookUp(Lists.newArrayList(scope.getAllElements())), reference.getEReferenceType(), false);
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class RenameElementHandler method findElementForFakeInStatechart.
private NamedElement findElementForFakeInStatechart(NamedElement fakeElement) {
Resource resource = fakeElement.eResource();
// only do something if element is really from fake resource
if (resource instanceof LazyLinkingResource) {
Statechart sct = getStatechartFromFakeResource((LazyLinkingResource) resource);
EList<Scope> scopes = sct.getScopes();
for (Scope scope : scopes) {
// check all declarations
EList<Declaration> declarations = scope.getDeclarations();
for (Declaration decl : declarations) {
if (decl.eClass().getName().equals(fakeElement.eClass().getName()) && decl.getName().equals(fakeElement.getName())) {
return decl;
}
}
// check scope itself it is a named one
if (scope instanceof NamedElement) {
NamedElement namedScope = (NamedElement) scope;
if (namedScope.eClass().getName().equals(fakeElement.eClass().getName()) && namedScope.getName().equals(fakeElement.getName())) {
return namedScope;
}
}
}
}
return fakeElement;
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class AbstractSCTLaunchConfigurationDelegate method launch.
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
String filename = configuration.getAttribute(FILE_NAME, DEFAULT_FILE_NAME);
Statechart statechart = loadStatechart(filename);
SCTDebugTarget target = createDebugTarget(launch, statechart);
launch.addDebugTarget(target);
try {
target.init();
target.start();
} catch (InitializationException e) {
// handled in AbstractExecutionFlowSimulationEngine
}
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class ResourceUtil method loadStatechart.
public static Statechart loadStatechart(String filename) {
Resource resource = loadResource(filename);
Statechart statechart = (Statechart) EcoreUtil.getObjectByType(resource.getContents(), SGraphPackage.Literals.STATECHART);
return statechart;
}
Aggregations