Java Code Examples for org.eclipse.emf.codegen.ecore.genmodel.GenPackage#getEcorePackage()
The following examples show how to use
org.eclipse.emf.codegen.ecore.genmodel.GenPackage#getEcorePackage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EMFGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.0 */ protected List<GenPackage> getGenPackagesForPackages(GenModel existingGenModel, Collection<EPackage> packs) { List<GenPackage> result = Lists.newArrayList(); for (EPackage pkg : packs) { boolean found = false; for (GenPackage gp : existingGenModel.getGenPackages()) if (gp.getEcorePackage() != null && gp.getEcorePackage().getNsURI() != null && gp.getEcorePackage().getNsURI().equals(pkg.getNsURI())) found = true; if (!found) result.add(GenModelAccess.getGenPackage(pkg, existingGenModel.eResource().getResourceSet())); } Collections.sort(result, new Comparator<GenPackage>() { @Override public int compare(GenPackage o1, GenPackage o2) { return EcoreUtil.getURI(o1).toString().compareTo(EcoreUtil.getURI(o2).toString()); } }); return result; }
Example 2
Source File: EPackageChooser.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected List<EPackageInfo> createEPackageInfosFromGenModel(URI genModelURI) { ResourceSet resourceSet = createResourceSet(genModelURI); Resource resource = resourceSet.getResource(genModelURI, true); List<EPackageInfo> ePackageInfos = Lists.newArrayList(); for (TreeIterator<EObject> i = resource.getAllContents(); i.hasNext();) { EObject next = i.next(); if (next instanceof GenPackage) { GenPackage genPackage = (GenPackage) next; EPackage ePackage = genPackage.getEcorePackage(); URI importURI; if(ePackage.eResource() == null) { importURI = URI.createURI(ePackage.getNsURI()); } else { importURI = ePackage.eResource().getURI(); } EPackageInfo ePackageInfo = new EPackageInfo(ePackage, importURI, genModelURI, genPackage .getQualifiedPackageInterfaceName(), genPackage.getGenModel().getModelPluginID()); ePackageInfos.add(ePackageInfo); } else if (!(next instanceof GenModel)) { i.prune(); } } return ePackageInfos; }
Example 3
Source File: EMFGeneratorFragment2.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected List<GenPackage> getGenPackagesForPackages(final GenModel existingGenModel, final Collection<EPackage> packs) { final ArrayList<GenPackage> result = CollectionLiterals.<GenPackage>newArrayList(); for (final EPackage pkg : packs) { final Function1<GenPackage, Boolean> _function = (GenPackage it) -> { EPackage _ecorePackage = it.getEcorePackage(); String _nsURI = null; if (_ecorePackage!=null) { _nsURI=_ecorePackage.getNsURI(); } String _nsURI_1 = pkg.getNsURI(); return Boolean.valueOf(Objects.equal(_nsURI, _nsURI_1)); }; boolean _exists = IterableExtensions.<GenPackage>exists(existingGenModel.getGenPackages(), _function); boolean _not = (!_exists); if (_not) { result.add(GenModelUtil2.getGenPackage(pkg, existingGenModel.eResource().getResourceSet())); } } final Comparator<GenPackage> _function_1 = (GenPackage o1, GenPackage o2) -> { return EcoreUtil.getURI(o1).toString().compareTo(EcoreUtil.getURI(o2).toString()); }; Collections.<GenPackage>sort(result, _function_1); return result; }
Example 4
Source File: EMFGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
private GenPackage findGenPackageByNsURI(GenModel genModel, String nsURI) { List<GenPackage> allGenPackages = genModel.getAllGenUsedAndStaticGenPackagesWithClassifiers(); for(GenPackage genPackage: allGenPackages) { EPackage ecorePackage = genPackage.getEcorePackage(); if (ecorePackage == null || ecorePackage.eIsProxy()) { throw new RuntimeException("Unresolved proxy: " + ecorePackage + " in " + genModel.eResource().getURI()); } if (nsURI.equals(ecorePackage.getNsURI())) { return genPackage; } } throw new RuntimeException("No GenPackage for NsURI " + nsURI + " found in " + genModel.eResource().getURI()); }