Search in sources :

Example 26 with GeneratorModel

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;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel)

Example 27 with GeneratorModel

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;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) IOException(java.io.IOException)

Example 28 with GeneratorModel

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;
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) FeatureTypeLibrary(org.yakindu.sct.model.sgen.FeatureTypeLibrary) IDefaultFeatureValueProvider(org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider) 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)

Aggregations

GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)28 EObject (org.eclipse.emf.ecore.EObject)13 AssertableDiagnostics (org.eclipse.xtext.junit4.validation.AssertableDiagnostics)11 Test (org.junit.Test)11 AbstractSGenTest (org.yakindu.sct.generator.genmodel.test.util.AbstractSGenTest)11 IGeneratorDescriptor (org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)10 Resource (org.eclipse.emf.ecore.resource.Resource)6 ILibraryDescriptor (org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)5 Check (org.eclipse.xtext.validation.Check)4 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)3 FeatureType (org.yakindu.sct.model.sgen.FeatureType)3 IResource (org.eclipse.core.resources.IResource)2 IPath (org.eclipse.core.runtime.IPath)2 IStatus (org.eclipse.core.runtime.IStatus)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)2 SimpleScope (org.eclipse.xtext.scoping.impl.SimpleScope)2 IDefaultFeatureValueProvider (org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider)2 FeatureTypeLibrary (org.yakindu.sct.model.sgen.FeatureTypeLibrary)2 PropertyDefinition (org.yakindu.sct.model.sgen.PropertyDefinition)2