Search in sources :

Example 6 with FeatureType

use of org.yakindu.sct.model.sgen.FeatureType in project statecharts by Yakindu.

the class FeatureConfigurationItemProvider method getText.

/**
 * This returns the label text for the adapted class. <!-- begin-user-doc
 * --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public String getText(Object object) {
    FeatureConfiguration configuration = ((FeatureConfiguration) object);
    FeatureType type = configuration.getType();
    if (type != null) {
        return type.getName() + " feature";
    }
    return "";
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration)

Example 7 with FeatureType

use of org.yakindu.sct.model.sgen.FeatureType in project statecharts by Yakindu.

the class SGenJavaValidator method checkDeprecatedFeatures.

@Check
public void checkDeprecatedFeatures(GeneratorEntry entry) {
    Iterable<FeatureConfiguration> features = entry.getFeatures();
    Iterable<FeatureType> deprecatedFeatures = filter(transform(features, getFeatureType()), isDeprecated());
    for (FeatureType feature : deprecatedFeatures) {
        warning(String.format(DEPRECATED + " %s : %s", feature.getName(), feature.getComment()), SGenPackage.Literals.GENERATOR_ENTRY__ELEMENT_REF, feature.getName());
    }
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) Check(org.eclipse.xtext.validation.Check)

Example 8 with FeatureType

use of org.yakindu.sct.model.sgen.FeatureType in project statecharts by Yakindu.

the class SGenJavaValidator method checkRequiredFeatures.

@Check
public void checkRequiredFeatures(GeneratorEntry entry) {
    GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(entry);
    IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
    Iterable<ILibraryDescriptor> libraryDescriptors = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
    Iterable<FeatureType> requiredFeatures = filter(concat(transform(transform(libraryDescriptors, getFeatureTypeLibrary()), getFeatureTypes())), isRequired());
    List<String> configuredTypes = Lists.newArrayList();
    for (FeatureConfiguration featureConfiguration : entry.getFeatures()) {
        configuredTypes.add(featureConfiguration.getType().getName());
    }
    for (FeatureType featureType : requiredFeatures) {
        if (!configuredTypes.contains(featureType.getName()))
            error(String.format(MISSING_REQUIRED_FEATURE + " %s", featureType.getName()), SGenPackage.Literals.GENERATOR_ENTRY__ELEMENT_REF, CODE_REQUIRED_FEATURE, featureType.getName());
    }
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) ILibraryDescriptor(org.yakindu.sct.generator.core.extensions.ILibraryDescriptor) Check(org.eclipse.xtext.validation.Check)

Example 9 with FeatureType

use of org.yakindu.sct.model.sgen.FeatureType in project statecharts by Yakindu.

the class ModelCreator method getFeatureTypes.

public static List<FeatureType> getFeatureTypes(IGeneratorDescriptor descriptor) {
    ArrayList<FeatureType> features = Lists.newArrayList();
    Iterable<ILibraryDescriptor> libraryDescriptor = LibraryExtensions.getLibraryDescriptors(descriptor.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();
        // Only add the required features to the default model
        for (FeatureType featureType : types) {
            if (!featureType.isOptional())
                features.add(featureType);
        }
    }
    return features;
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) FeatureTypeLibrary(org.yakindu.sct.model.sgen.FeatureTypeLibrary) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ILibraryDescriptor(org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)

Example 10 with FeatureType

use of org.yakindu.sct.model.sgen.FeatureType 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

FeatureType (org.yakindu.sct.model.sgen.FeatureType)10 FeatureConfiguration (org.yakindu.sct.model.sgen.FeatureConfiguration)6 ILibraryDescriptor (org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)4 Resource (org.eclipse.emf.ecore.resource.Resource)3 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)3 IGeneratorDescriptor (org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)3 FeatureTypeLibrary (org.yakindu.sct.model.sgen.FeatureTypeLibrary)3 GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)3 Check (org.eclipse.xtext.validation.Check)2 FeatureParameter (org.yakindu.sct.model.sgen.FeatureParameter)2 GeneratorEntry (org.yakindu.sct.model.sgen.GeneratorEntry)2 ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Template (org.eclipse.jface.text.templates.Template)1 TemplateProposal (org.eclipse.jface.text.templates.TemplateProposal)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 Test (org.junit.Test)1 IDefaultFeatureValueProvider (org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider)1