use of org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor 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.generator.core.extensions.IGeneratorDescriptor in project statecharts by Yakindu.
the class SGenWizardPage2 method createGeneratorCombo.
private void createGeneratorCombo(Composite container) {
Label lblGenerator = new Label(container, SWT.NONE);
lblGenerator.setText("Generator");
generatorCombo = new ComboViewer(container, SWT.READ_ONLY);
generatorCombo.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
generatorCombo.setLabelProvider(new GeneratorDescriptorLabelProvider());
generatorCombo.setContentProvider(new ArrayContentProvider());
List<IGeneratorDescriptor> descriptors = Lists.newArrayList(GeneratorExtensions.getGeneratorDescriptors());
Collections.sort(descriptors, CoreGenerator.generatorOrder);
generatorCombo.setInput(descriptors);
generatorCombo.getCombo().select(0);
generatorCombo.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
refreshInput();
}
});
}
use of org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor in project statecharts by Yakindu.
the class SGenWizardPage2 method loadReferencedObject.
protected EObject loadReferencedObject(IResource resource) {
URI uri = URI.createPlatformResourceURI(resource.getFullPath().toString(), true);
ResourceSet resourceSet = new ResourceSetImpl();
Resource emfResource = resourceSet.getResource(uri, true);
IGeneratorDescriptor desc = getSelectedGenerator();
String className = desc.getElementRefType();
TreeIterator<EObject> content = emfResource.getAllContents();
List<EObject> contentList = Lists.newArrayList(content);
for (EObject obj : contentList) {
if (obj.eClass().getInstanceClassName().equals(className))
return obj;
}
for (EObject obj : contentList) {
List<EClass> superClasses = obj.eClass().getEAllSuperTypes();
for (EClass superClass : superClasses) {
if (superClass.getInstanceClassName().equals(className)) {
return obj;
}
}
}
return null;
}
use of org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor in project statecharts by Yakindu.
the class SGenScopeProvider method scope_GeneratorEntry_elementRef.
protected IScope scope_GeneratorEntry_elementRef(final EObject context, final EReference reference) {
GeneratorModel generatorModel = (GeneratorModel) EcoreUtil2.getRootContainer(context);
String id = generatorModel.getGeneratorId();
final IGeneratorDescriptor desc = GeneratorExtensions.getGeneratorDescriptor(id);
if (desc == null)
return IScope.NULLSCOPE;
final String elementRefType = desc.getElementRefType();
IScope scope = new FilteringScope(getDelegate().getScope(context, reference), new Predicate<IEObjectDescription>() {
public boolean apply(IEObjectDescription input) {
EList<EClass> allSuperTypes = input.getEClass().getESuperTypes();
for (EClass eClass : allSuperTypes) {
if (elementRefType.equals(eClass.getInstanceClassName()))
return true;
}
return elementRefType.equals(input.getEClass().getInstanceClassName());
}
});
return new SimpleScope(scope.getAllElements());
}
use of org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor in project statecharts by Yakindu.
the class SGenScopeProvider method getLibraryScope.
protected SimpleScope getLibraryScope(Resource resource) {
GeneratorModel generatorModel = (GeneratorModel) EcoreUtil.getObjectByType(resource.getContents(), SGenPackage.Literals.GENERATOR_MODEL);
Assert.isNotNull(generatorModel);
String generatorId = generatorModel.getGeneratorId();
IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(generatorId);
Iterable<IEObjectDescription> allElements = Lists.newArrayList();
if (generatorDescriptor != null) {
Iterable<ILibraryDescriptor> libraryDescriptor = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
for (ILibraryDescriptor desc : libraryDescriptor) {
Resource library = resourceSet.getResource(desc.getURI(), true);
FeatureResourceDescription description = new FeatureResourceDescription(library);
injector.injectMembers(description);
allElements = Iterables.concat(allElements, description.getExportedObjects());
}
}
return new SimpleScope(allElements);
}
Aggregations