use of org.yakindu.sct.model.sgen.FeatureParameterValue 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;
}
use of org.yakindu.sct.model.sgen.FeatureParameterValue 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);
}
}
use of org.yakindu.sct.model.sgen.FeatureParameterValue in project statecharts by Yakindu.
the class SGenJavaValidator method checkRequiredParameters.
@Check
public void checkRequiredParameters(FeatureConfiguration configuration) {
GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(configuration);
IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
Iterable<ILibraryDescriptor> libraryDescriptors = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
Iterable<String> requiredParameters = transform(filter(concat(transform(filter(concat(transform(transform(libraryDescriptors, getFeatureTypeLibrary()), getFeatureTypes())), hasName(configuration.getType().getName())), getParameter())), isRequiredParamter()), getName());
List<String> configuredParameters = Lists.newArrayList();
for (FeatureParameterValue featureParameterValue : configuration.getParameterValues()) {
configuredParameters.add(featureParameterValue.getParameter().getName());
}
for (String string : requiredParameters) {
if (!configuredParameters.contains(string))
error(String.format(MISSING_REQUIRED_PARAMETER + " %s", string), SGenPackage.Literals.FEATURE_CONFIGURATION__TYPE);
}
}
use of org.yakindu.sct.model.sgen.FeatureParameterValue 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;
}
use of org.yakindu.sct.model.sgen.FeatureParameterValue in project statecharts by Yakindu.
the class AbstractDefaultFeatureValueProvider method createDefaultFeatureConfiguration.
public final FeatureConfiguration createDefaultFeatureConfiguration(FeatureType type, EObject contextElement) {
FeatureConfiguration config = createConfiguration(type);
EList<FeatureParameter> parameters = type.getParameters();
for (FeatureParameter parameter : parameters) {
FeatureParameterValue parameterValue = createParameterValue(type, parameter, contextElement);
if (parameterValue != null && parameterValue.getExpression() != null) {
config.getParameterValues().add(parameterValue);
}
}
return config;
}
Aggregations