use of org.yakindu.sct.model.sgen.FeatureTypeLibrary 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);
}
}
}
use of org.yakindu.sct.model.sgen.FeatureTypeLibrary 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;
}
use of org.yakindu.sct.model.sgen.FeatureTypeLibrary 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;
}
Aggregations