org.eclipse.emf.mwe.core.ConfigurationException Java Examples
The following examples show how to use
org.eclipse.emf.mwe.core.ConfigurationException.
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: EcoreGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.0 */ @Deprecated protected void registerReferencedGenModels() { try { if (getReferencedGenModels() != null && getReferencedGenModels().length() > 0) { ResourceSet rs = new XtextResourceSet(); GenModelHelper gmh = new GenModelHelper(); for (String uriStr : getReferencedGenModels().split(",")) { URI uri = URI.createURI(uriStr.trim()); gmh.registerGenModel(rs, uri); } } } catch (ConfigurationException ce) { throw ce; } catch (Exception e) { log.error(e, e); } }
Example #2
Source File: EMFGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.0 */ protected GenModel getSaveAndReconcileGenModel(ResourceSet rs, Grammar grammar, XpandExecutionContext ctx, List<EPackage> packs) throws ConfigurationException { GenModel genModel = getGenModel(rs, grammar, ctx, packs); genModel.initialize(packs); for (GenPackage genPackage : genModel.getGenPackages()) { genPackage.setBasePackage(getBasePackage(grammar)); if (isSuppressLoadInitialization()) { genPackage.setLoadInitialization(false); } if (getFileExtensions() != null && packs.contains(genPackage.getEcorePackage())) { genPackage.setFileExtensions(getFileExtensions()); } } Set<EPackage> referencedEPackages = getReferencedEPackages(packs); List<GenPackage> usedGenPackages = getGenPackagesForPackages(genModel, referencedEPackages); reconcileMissingGenPackagesInUsedModels(usedGenPackages); genModel.getUsedGenPackages().addAll(usedGenPackages); try { saveResource(genModel.eResource()); } catch (IOException e) { throw new WrappedException(e); } new GenModelHelper().registerGenModel(genModel); return genModel; }
Example #3
Source File: LazyStandaloneSetup.java From openhab-core with Eclipse Public License 2.0 | 6 votes |
private void addRegisterGeneratedEPackage(String interfacename) { Class<?> clazz = ResourceLoaderFactory.createResourceLoader().loadClass(interfacename); if (clazz == null) { throw new ConfigurationException("Couldn't find an interface " + interfacename); } try { EPackage pack = (EPackage) clazz.getDeclaredField("eINSTANCE").get(null); if (registry.get(pack.getNsURI()) == null) { registry.put(pack.getNsURI(), pack); logger.info("Adding generated EPackage '{}'", interfacename); } } catch (Exception e) { throw new ConfigurationException("Couldn't register " + interfacename + ". Is it the generated EPackage interface? : " + e.getMessage()); } }
Example #4
Source File: LazyStandaloneSetup.java From openhab-core with Eclipse Public License 2.0 | 6 votes |
private void addRegisterEcoreFile(String fileName) throws IllegalArgumentException, SecurityException { Resource res = resourceSet.getResource(createURI(fileName), true); if (res == null) { throw new ConfigurationException("Couldn't find resource under " + fileName); } if (!res.isLoaded()) { try { res.load(null); } catch (IOException e) { throw new ConfigurationException("Couldn't load resource under " + fileName + " : " + e.getMessage()); } } List<EObject> result = res.getContents(); for (EObject object : result) { if (object instanceof EPackage) { registerPackage(fileName, object); } for (final TreeIterator<EObject> it = object.eAllContents(); it.hasNext();) { EObject child = it.next(); if (child instanceof EPackage) { registerPackage(fileName, child); } } } }
Example #5
Source File: LazyStandaloneSetup.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private void addRegisterGeneratedEPackage(String interfacename) { Class<?> clazz = ResourceLoaderFactory.createResourceLoader().loadClass(interfacename); if (clazz == null) { throw new ConfigurationException("Couldn't find an interface " + interfacename); } try { EPackage pack = (EPackage) clazz.getDeclaredField("eINSTANCE").get(null); if (registry.get(pack.getNsURI()) == null) { registry.put(pack.getNsURI(), pack); log.info("Adding generated EPackage '" + interfacename + "'"); } } catch (Exception e) { throw new ConfigurationException("Couldn't register " + interfacename + ". Is it the generated EPackage interface? : " + e.getMessage()); } }
Example #6
Source File: LazyStandaloneSetup.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private void addRegisterEcoreFile(String fileName) throws IllegalArgumentException, SecurityException { Resource res = resourceSet.getResource(createURI(fileName), true); if (res == null) { throw new ConfigurationException("Couldn't find resource under " + fileName); } if (!res.isLoaded()) { try { res.load(null); } catch (IOException e) { throw new ConfigurationException("Couldn't load resource under " + fileName + " : " + e.getMessage()); } } List<EObject> result = res.getContents(); for (EObject object : result) { if (object instanceof EPackage) { registerPackage(fileName, object); } for (final TreeIterator<EObject> it = object.eAllContents(); it.hasNext();) { EObject child = it.next(); if (child instanceof EPackage) { registerPackage(fileName, child); } } } }
Example #7
Source File: EMFGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
private void registerUsedGenModel(URIConverter converter) { if (genModel == null) return; URI genModelUri = URI.createURI(genModel); genModelUri = toPlatformResourceURI(genModelUri); if (converter.exists(genModelUri, null)) { try { new GenModelHelper().registerGenModel(new XtextResourceSet(), genModelUri); } catch (ConfigurationException ce) { throw ce; } catch (Exception e) { log.error(e, e); } } }
Example #8
Source File: EMFGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
private List<Object> getParameters(Grammar grammar, XpandExecutionContext ctx) { try { File projectRootFile = new File(ctx.getOutput().getOutlet(org.eclipse.xtext.generator.Generator.PLUGIN_RT).getPath()); String projectRoot = projectRootFile.getCanonicalPath(); URI genmodelURI = getGenModelUri(grammar, ctx); if (genmodelURI.toFileString().startsWith(projectRoot)) { URI relative = genmodelURI.deresolve(URI.createFileURI(projectRoot).appendSegment("")); String genModelPath = relative.toString(); return Lists.<Object>newArrayList(getBasePackage(grammar), genModelPath); } throw new ConfigurationException("Invalid configuration of genmodel location: " + genmodelURI + " and project root: " + projectRoot); } catch(IOException e) { throw new RuntimeException(e); } }