Search in sources :

Example 1 with FeatureType

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

the class AbstractJavaGeneratorTest method createGeneratorEntry.

private GeneratorEntry createGeneratorEntry(String targetProject, String targetFolder) {
    GeneratorEntry entry = SGenFactory.eINSTANCE.createGeneratorEntry();
    entry.setContentType(CONTENT_TYPE);
    FeatureConfiguration config = SGenFactory.eINSTANCE.createFeatureConfiguration();
    FeatureType type = SGenFactory.eINSTANCE.createFeatureType();
    type.setName(OUTLET_FEATURE);
    config.setType(type);
    FeatureParameterValue project = SGenFactory.eINSTANCE.createFeatureParameterValue();
    FeatureParameter projectParameter = SGenFactory.eINSTANCE.createFeatureParameter();
    projectParameter.setName(TARGET_PROJECT);
    project.setParameter(projectParameter);
    project.setValue(targetProject);
    config.getParameterValues().add(project);
    FeatureParameterValue targetFolderValue = SGenFactory.eINSTANCE.createFeatureParameterValue();
    FeatureParameter targetParameter = SGenFactory.eINSTANCE.createFeatureParameter();
    targetParameter.setName(TARGET_FOLDER);
    targetFolderValue.setParameter(targetParameter);
    targetFolderValue.setValue(targetFolder);
    config.getParameterValues().add(targetFolderValue);
    entry.getFeatures().add(config);
    return entry;
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) FeatureParameterValue(org.yakindu.sct.model.sgen.FeatureParameterValue) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) FeatureParameter(org.yakindu.sct.model.sgen.FeatureParameter)

Example 2 with FeatureType

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

the class SGenTemplateProposalProvider method createFeatureConfigurationTemplates.

private void createFeatureConfigurationTemplates(TemplateContext templateContext, ContentAssistContext context, ITemplateAcceptor acceptor) {
    GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(context.getCurrentModel());
    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) {
            Template template = new Template(featureType.getName() + " feature", "Creates feature " + featureType.getName(), featureType.getName(), creator.createProposal(featureType, desc.createFeatureValueProvider(SGenActivator.getInstance().getInjector(SGenActivator.ORG_YAKINDU_SCT_GENERATOR_GENMODEL_SGEN)), context.getCurrentModel()), false);
            TemplateProposal proposal = createProposal(template, templateContext, context, getImage(template), getRelevance(template));
            acceptor.accept(proposal);
        }
    }
}
Also used : TemplateProposal(org.eclipse.jface.text.templates.TemplateProposal) 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) 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) Template(org.eclipse.jface.text.templates.Template)

Example 3 with FeatureType

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

the class ModelCreator method createGeneratorEntry.

private GeneratorEntry createGeneratorEntry(EObject eobject) {
    GeneratorEntry entry = factory.createGeneratorEntry();
    entry.setContentType(descriptor.getContentType());
    entry.setElementRef(eobject);
    List<FeatureType> featureTypes = getFeatureTypes(descriptor);
    for (FeatureType featureType : featureTypes) {
        FeatureConfiguration config = createFeatureConfiguration(eobject, featureType);
        if (config != null && !config.getParameterValues().isEmpty()) {
            entry.getFeatures().add(config);
        }
    }
    return entry;
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration)

Example 4 with FeatureType

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

the class FeatureConfigurationImpl method setType.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public void setType(FeatureType newType) {
    FeatureType oldType = type;
    type = newType;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, SGenPackage.FEATURE_CONFIGURATION__TYPE, oldType, type));
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 5 with FeatureType

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

the class HelpIntegrationTest method checkDocumentedFeaturesExist.

@Test
public void checkDocumentedFeaturesExist() {
    List<String> features = getDocumentedFeatures();
    ArrayList<String> generators = new ArrayList<String>(Arrays.asList(YAKINDU_JAVA, YAKINDU_C, YAKINDU_CPP, YAKINDU_GENERIC));
    for (String generator : generators) {
        Iterable<IEObjectDescription> allElements = getAllElements(generator);
        for (IEObjectDescription desc : allElements) {
            if (desc.getEClass() != SGenPackage.Literals.FEATURE_TYPE)
                continue;
            EObject o = desc.getEObjectOrProxy();
            String name = null;
            if (o instanceof FeatureConfiguration) {
                FeatureType type = ((FeatureConfiguration) o).getType();
                if (type != null) {
                    name = type.getName();
                }
            } else if (o instanceof FeatureType) {
                FeatureType type = (FeatureType) o;
                if (type != null) {
                    name = type.getName();
                }
            } else if (o instanceof FeatureParameter) {
                FeatureType type = ((FeatureParameter) o).getFeatureType();
                if (type != null) {
                    name = type.getName();
                }
            }
            if (name != null)
                name = name.toLowerCase();
            if (name != null && features.contains(name)) {
                features.remove(name);
            }
        }
    }
    if (features.size() > 0) {
        fail("There are documented features that are not implemented: " + Arrays.toString(features.toArray()));
    }
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) FeatureParameter(org.yakindu.sct.model.sgen.FeatureParameter) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

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