Search in sources :

Example 1 with FeatureConfiguration

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

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

the class SGenJavaValidator method checkDuplicateFeatureParameter.

@Check
public void checkDuplicateFeatureParameter(final FeatureParameterValue value) {
    FeatureConfiguration entry = (FeatureConfiguration) value.eContainer();
    Iterable<FeatureParameterValue> filter = Iterables.filter(entry.getParameterValues(), new Predicate<FeatureParameterValue>() {

        public boolean apply(FeatureParameterValue input) {
            return (input.getParameter().getName().equals(value.getParameter().getName()));
        }
    });
    if (Iterables.size(filter) > 1) {
        error(DUPLICATE_PARAMETER, SGenPackage.Literals.FEATURE_PARAMETER_VALUE__PARAMETER);
    }
}
Also used : FeatureParameterValue(org.yakindu.sct.model.sgen.FeatureParameterValue) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) Check(org.eclipse.xtext.validation.Check)

Example 3 with FeatureConfiguration

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

the class SGenJavaValidator method checkDuplicateGeneratorEntryFeature.

@Check
public void checkDuplicateGeneratorEntryFeature(final FeatureConfiguration config) {
    GeneratorEntry entry = (GeneratorEntry) config.eContainer();
    Iterable<FeatureConfiguration> filter = Iterables.filter(entry.getFeatures(), new Predicate<FeatureConfiguration>() {

        public boolean apply(FeatureConfiguration input) {
            return (input.getType().getName().equals(config.getType().getName()));
        }
    });
    if (Iterables.size(filter) > 1) {
        error(DUPLICATE_FEATURE, SGenPackage.Literals.FEATURE_CONFIGURATION__TYPE);
    }
}
Also used : GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) Check(org.eclipse.xtext.validation.Check)

Example 4 with FeatureConfiguration

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

the class WorkspaceGeneratorExecutor method getLookupRoot.

protected IProject getLookupRoot(GeneratorEntry entry) {
    IProject project = null;
    FeatureConfiguration templateConfig = entry.getFeatureConfiguration(TEMPLATE_FEATURE);
    FeatureParameterValue projectName = templateConfig.getParameterValue(GENERATOR_PROJECT);
    if (projectName != null) {
        project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName.getStringValue());
    } else {
        URI uri = entry.getElementRef().eResource().getURI();
        project = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true))).getProject();
    }
    return project;
}
Also used : Path(org.eclipse.core.runtime.Path) FeatureParameterValue(org.yakindu.sct.model.sgen.FeatureParameterValue) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject)

Example 5 with FeatureConfiguration

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

Aggregations

FeatureConfiguration (org.yakindu.sct.model.sgen.FeatureConfiguration)12 FeatureType (org.yakindu.sct.model.sgen.FeatureType)6 Check (org.eclipse.xtext.validation.Check)4 FeatureParameterValue (org.yakindu.sct.model.sgen.FeatureParameterValue)4 FeatureParameter (org.yakindu.sct.model.sgen.FeatureParameter)3 GeneratorEntry (org.yakindu.sct.model.sgen.GeneratorEntry)3 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 Path (org.eclipse.core.runtime.Path)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 Test (org.junit.Test)1 IGeneratorDescriptor (org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)1 ILibraryDescriptor (org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)1 FlowOptimizer (org.yakindu.sct.model.sexec.transformation.FlowOptimizer)1 GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)1