use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class ModelCreator method create.
public GeneratorModel create() {
GeneratorModel model = factory.createGeneratorModel();
model.setGeneratorId(descriptor.getId());
for (EObject object : eobjects) {
model.getEntries().add(createGeneratorEntry(object));
}
return model;
}
use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenNewFileWizard method createDefaultModel.
private Resource createDefaultModel(URI uri) {
List<EObject> selectedObjects = generatorConfigPage.getSelectedElements();
IGeneratorDescriptor selectedGenerator = generatorConfigPage.getSelectedGenerator();
ModelCreator creator = new ModelCreator(selectedGenerator, selectedObjects);
GeneratorModel model = creator.create();
Resource resource = resourceSet.createResource(uri);
resource.getContents().add(model);
try {
resource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
return resource;
}
use of org.yakindu.sct.model.sgen.GeneratorModel 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