Search in sources :

Example 1 with IDefaultFeatureValueProvider

use of org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider in project statecharts by Yakindu.

the class SGenJavaValidator method checkParameterValue.

@Check
public void checkParameterValue(final FeatureParameterValue value) {
    if (value.getExpression() == null || value.getExpression() == null)
        return;
    GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(value);
    IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
    IDefaultFeatureValueProvider provider = LibraryExtensions.getDefaultFeatureValueProvider(generatorDescriptor.getLibraryIDs(), value.getParameter().getFeatureType().getLibrary());
    injector.injectMembers(provider);
    IStatus status = provider.validateParameterValue(value);
    createMarker(status);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IDefaultFeatureValueProvider(org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) Check(org.eclipse.xtext.validation.Check)

Example 2 with IDefaultFeatureValueProvider

use of org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider in project statecharts by Yakindu.

the class SGenQuickfixProvider method getDefaultFeatureConfiguration.

private FeatureConfiguration getDefaultFeatureConfiguration(final Issue issue, EObject element) {
    GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(element);
    IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
    Iterable<ILibraryDescriptor> libraryDescriptor = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
    for (ILibraryDescriptor desc : libraryDescriptor) {
        ResourceSet set = new ResourceSetImpl();
        Resource resource = set.getResource(desc.getURI(), true);
        FeatureTypeLibrary lib = (FeatureTypeLibrary) resource.getContents().get(0);
        EList<FeatureType> types = lib.getTypes();
        for (FeatureType featureType : types) {
            if (featureType.getName().equals(issue.getData()[0])) {
                IDefaultFeatureValueProvider valueProvider = desc.createFeatureValueProvider(SGenActivator.getInstance().getInjector(SGenActivator.ORG_YAKINDU_SCT_GENERATOR_GENMODEL_SGEN));
                if (valueProvider != null) {
                    return valueProvider.createDefaultFeatureConfiguration(featureType, element);
                }
            }
        }
    }
    return null;
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) FeatureTypeLibrary(org.yakindu.sct.model.sgen.FeatureTypeLibrary) IDefaultFeatureValueProvider(org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider) Resource(org.eclipse.emf.ecore.resource.Resource) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ILibraryDescriptor(org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)

Aggregations

IGeneratorDescriptor (org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)2 IDefaultFeatureValueProvider (org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider)2 GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)2 IStatus (org.eclipse.core.runtime.IStatus)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 Check (org.eclipse.xtext.validation.Check)1 ILibraryDescriptor (org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)1 FeatureType (org.yakindu.sct.model.sgen.FeatureType)1 FeatureTypeLibrary (org.yakindu.sct.model.sgen.FeatureTypeLibrary)1