本文整理汇总了Java中org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage类的典型用法代码示例。如果您正苦于以下问题:Java GenModelPackage类的具体用法?Java GenModelPackage怎么用?Java GenModelPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenModelPackage类属于org.eclipse.emf.codegen.ecore.genmodel包,在下文中一共展示了GenModelPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadGenmodel
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
private GenModel loadGenmodel(String path) {
try {
if (!EPackage.Registry.INSTANCE.containsKey(GenModelPackage.eNS_URI))
EPackage.Registry.INSTANCE.put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("genmodel", new XMIResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
URI uri = URI.createURI(path);
Resource pkg = rs.getResource(uri, true);
return (GenModel) pkg.getContents().get(0);
} catch (Exception e) {
// ...
}
return null;
}
示例2: setUp
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
resourceSet = new XtextResourceSet();
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this);
resourceSet.setClasspathURIContext(getClasspathURIContext());
}
示例3: main
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
ResourceSet rs = new ResourceSetImpl();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
// GenModelPackage.eINSTANCE
rs.getPackageRegistry().put(GenModelPackage.eINSTANCE.getNsURI(), GenModelPackage.eINSTANCE);
Resource r3 = rs.getResource(URI.createURI("file:///home/jesus/projects/anatlyzer/plugins/anatlyzer.atl.typing/model/generated/merged.genmodel"), true);
VisitorOptions options = new VisitorOptions ();
// options.setBaseDir("tmp_");
options.setBaseDir("/home/jesus/projects/anatlyzer/plugins/anatlyzer.atl.typing/src-gen");
options.setPackagePrefix("anatlyzer.atlext.processing");
VisitorCreator compiler = new VisitorCreator();
compiler.compile(r3, options);
}
示例4: main
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
ResourceSet rs = new ResourceSetImpl();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
// GenModelPackage.eINSTANCE
rs.getPackageRegistry().put(GenModelPackage.eINSTANCE.getNsURI(), GenModelPackage.eINSTANCE);
Resource r = rs.getResource(URI.createURI("file:///home/jesus/projects/anatlyzer/plugins/anatlyzer.atl.typing/model/original/ATLStatic.ecore"), true);
// Resource r2 = rs.getResource(URI.createURI("file:///home/jesus/projects/genericity/compiler/genericity.compiler.atl.typing/model/ATLExt.ecore"), true);
Resource r3 = rs.getResource(URI.createURI("file:///home/jesus/projects/anatlyzer/plugins/anatlyzer.atl.typing/model/generated/merged.genmodel"), true);
CopierOptions options = new CopierOptions ();
// options.setBaseDir("tmp_");
options.setBaseDir("/home/jesus/projects/anatlyzer/plugins/anatlyzer.atl.typing/src-gen");
options.setPackagePrefix("anatlyzer.atlext.processing");
options.setCopierClass("AbstractDynamicToStaticCopier");
options.setMatcher(new CopierForModifiedATL());
CopierCreator compiler = new CopierCreator();
compiler.compile(r, r3, options);
}
示例5: loadEcore
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
/**
*
* @param ePath
* the path to the ecore file
* @return The Epackage from the ecore file
* @throws BadFileFormatException
* if the file is not a ecore file
*/
public static EPackage loadEcore(final String ePath)
throws BadFileFormatException {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*",
new XMIResourceFactoryImpl());
final GenModelPackage modelgenInstance = GenModelPackage.eINSTANCE;
modelgenInstance.toString();
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getURIConverter().getURIMap().putAll(
EcorePlugin.computePlatformURIMap(true));
final URI ecoreURI = URI.createFileURI(ePath);
final Resource ecoreResource = resourceSet.getResource(ecoreURI, true);
if (!(ecoreResource.getContents().get(0) instanceof EPackage)) {
throw new BadFileFormatException("File is not .ecore");
}
return (EPackage) ecoreResource.getContents().get(0);
}
示例6: loadGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
/**
*
* @param gmPath
* the path to genModel File
* @return The genmodel from The genmodel file
* @throws BadFileFormatException
* if the file is not a GenModel one.
*/
public static GenModel loadGenModel(final String gmPath)
throws BadFileFormatException {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*",
new XMIResourceFactoryImpl());
final GenModelPackage modelgenInstance = GenModelPackage.eINSTANCE;
modelgenInstance.toString();
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getURIConverter().getURIMap().putAll(
EcorePlugin.computePlatformURIMap(true));
final URI genModelURI = URI.createFileURI(gmPath);
final Resource genModelResource = resourceSet.getResource(genModelURI,
true);
if (!(genModelResource.getContents().get(0) instanceof GenModel)) {
throw new BadFileFormatException("File is not .GenModel");
}
final GenModel genModel = (GenModel) genModelResource.getContents()
.get(0);
return genModel;
}
示例7: main
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
ResourceSet rs = new ResourceSetImpl();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
// GenModelPackage.eINSTANCE
rs.getPackageRegistry().put(GenModelPackage.eINSTANCE.getNsURI(), GenModelPackage.eINSTANCE);
Resource r3 = rs.getResource(URI.createURI("file:///home/jesus/projects/genericity/plugins/genericity.language.gbind/metamodel/gbind.genmodel"), true);
VisitorOptions options = new VisitorOptions ();
// options.setBaseDir("tmp_");
options.setBaseDir("/home/jesus/projects/genericity/plugins/bento.adapter.atl/src-gen");
options.setPackagePrefix("bento.adapter.gbind.visitors");
options.setVisitorClass("GBindVisitor");
VisitorCreator compiler = new VisitorCreator();
compiler.compile(r3, options);
}
示例8: generate
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
public void generate(GenModel genModel) {
// Generate Code
genModel.setCanGenerate(true);
GeneratorAdapterFactory.Descriptor.Registry.INSTANCE.addDescriptor(
GenModelPackage.eNS_URI,
GenModelGeneratorAdapterFactory.DESCRIPTOR);
// Create the generator and set the model-level input object.
Generator generator = new Generator();
generator.setInput(genModel);
// Generator model code.
Diagnostic d = generator.generate(genModel,
GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE,
new BasicMonitor.Printing(System.out));
System.out.println(d.getMessage());
}
示例9: setUp
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
resourceSet = new XtextResourceSet();
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this);
}
示例10: initialize
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
@Override
public void initialize(final Injector injector) {
super.initialize(injector);
boolean _containsKey = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("genmodel");
boolean _not = (!_containsKey);
if (_not) {
Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
EcoreResourceFactoryImpl _ecoreResourceFactoryImpl = new EcoreResourceFactoryImpl();
_extensionToFactoryMap.put("genmodel", _ecoreResourceFactoryImpl);
}
GenModelPackage.eINSTANCE.getGenAnnotation();
}
示例11: setUp
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
resourceSet = new XtextResourceSet();
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this);
resourceSet.setClasspathURIContext(getClasspathURIContext());
}
示例12: generate
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
public VirtualFile generate(VirtualFile basedir) throws DatabaseException {
GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
genModel.setRuntimeVersion(GenRuntimeVersion.EMF25);
genModel.setComplianceLevel(GenJDKLevel.JDK60_LITERAL);
genModel.setFeatureDelegation(GenDelegationKind.REFLECTIVE_LITERAL);
genModel.setRootExtendsClass("org.bimserver.emf.IdEObjectImpl");
genModel.setRootExtendsInterface("org.bimserver.emf.IdEObject");
genModel.setSuppressContainment(true);
genModel.setCodeFormatting(true);
genModel.setCopyrightText(StringUtils.readFromFile(new File("copyright.txt")));
genModel.setCanGenerate(true);
genModel.setModelDirectory("test");
genModel.setModelName("model name");
genModel.setForceOverwrite(true);
genModel.setSuppressNotification(false);
genModel.setContainmentProxies(false);
genModel.setBinaryCompatibleReflectiveMethods(false);
genModel.setPublicConstructors(false);
genModel.setMinimalReflectiveMethods(true); // More code, but faster
genModel.setUpdateClasspath(false);
genModel.initialize(schema.getEPackages());
GeneratorAdapterFactory.Descriptor.Registry.INSTANCE.addDescriptor(GenModelPackage.eNS_URI, GenModelGeneratorAdapterFactory.DESCRIPTOR);
Generator generator = new Generator();
generator.setInput(genModel);
generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, new BasicMonitor.Printing(System.out));
// List<GenPackage> genPackages = createGenPackages(genModel, basedir);
// generatePackages(genModel, genPackages, basedir);
return basedir;
}
示例13: ensureResourceCanBeLoaded
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
private void ensureResourceCanBeLoaded(final URI loadedResource, final ResourceSet resourceSet) {
String _fileExtension = loadedResource.fileExtension();
if (_fileExtension != null) {
switch (_fileExtension) {
case "genmodel":
GenModelPackage.eINSTANCE.getEFactoryInstance();
final IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(loadedResource);
if ((resourceServiceProvider == null)) {
try {
final Class<?> genModelSupport = Class.forName("org.eclipse.emf.codegen.ecore.xtext.GenModelSupport");
final Object instance = genModelSupport.newInstance();
genModelSupport.getDeclaredMethod("createInjectorAndDoEMFRegistration").invoke(instance);
} catch (final Throwable _t) {
if (_t instanceof ClassNotFoundException) {
XtextGeneratorResourceSetInitializer.LOG.debug("org.eclipse.emf.codegen.ecore.xtext.GenModelSupport not found, GenModels will not be indexed");
} else if (_t instanceof Exception) {
final Exception e_1 = (Exception)_t;
XtextGeneratorResourceSetInitializer.LOG.error("Couldn\'t initialize GenModel support.", e_1);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
break;
case "ecore":
final IResourceServiceProvider resourceServiceProvider_1 = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(loadedResource);
if ((resourceServiceProvider_1 == null)) {
try {
final Class<?> ecore = Class.forName("org.eclipse.xtext.ecore.EcoreSupportStandaloneSetup");
ecore.getDeclaredMethod("setup", new Class[] {}).invoke(null);
} catch (final Throwable _t_1) {
if (_t_1 instanceof ClassNotFoundException) {
final ClassNotFoundException e_2 = (ClassNotFoundException)_t_1;
XtextGeneratorResourceSetInitializer.LOG.error("Couldn\'t initialize Ecore support. Is \'org.eclipse.xtext.ecore\' on the classpath?");
XtextGeneratorResourceSetInitializer.LOG.debug(e_2.getMessage(), e_2);
} else if (_t_1 instanceof Exception) {
final Exception e_3 = (Exception)_t_1;
XtextGeneratorResourceSetInitializer.LOG.error("Couldn\'t initialize Ecore support.", e_3);
} else {
throw Exceptions.sneakyThrow(_t_1);
}
}
}
break;
case "xcore":
final IResourceServiceProvider resourceServiceProvider_2 = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(loadedResource);
if ((resourceServiceProvider_2 == null)) {
try {
final Class<?> xcore = Class.forName("org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup");
xcore.getDeclaredMethod("doSetup", new Class[] {}).invoke(null);
} catch (final Throwable _t_2) {
if (_t_2 instanceof ClassNotFoundException) {
final ClassNotFoundException e_4 = (ClassNotFoundException)_t_2;
XtextGeneratorResourceSetInitializer.LOG.error("Couldn\'t initialize Xcore support. Is it on the classpath?");
XtextGeneratorResourceSetInitializer.LOG.debug(e_4.getMessage(), e_4);
} else if (_t_2 instanceof Exception) {
final Exception e_5 = (Exception)_t_2;
XtextGeneratorResourceSetInitializer.LOG.error("Couldn\'t initialize Xcore support.", e_5);
} else {
throw Exceptions.sneakyThrow(_t_2);
}
}
}
final URI xcoreLangURI = URI.createPlatformResourceURI("/org.eclipse.emf.ecore.xcore.lib/model/XcoreLang.xcore", true);
try {
resourceSet.getResource(xcoreLangURI, true);
} catch (final Throwable _t_3) {
if (_t_3 instanceof WrappedException) {
final WrappedException e_6 = (WrappedException)_t_3;
XtextGeneratorResourceSetInitializer.LOG.error("Could not load XcoreLang.xcore.", e_6);
final Resource brokenResource = resourceSet.getResource(xcoreLangURI, false);
resourceSet.getResources().remove(brokenResource);
} else {
throw Exceptions.sneakyThrow(_t_3);
}
}
break;
}
}
}
示例14: doGenerate
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
protected void doGenerate(final GenModel genModel) {
final Generator generator = new Generator() {
@Override
public JControlModel getJControlModel() {
if ((this.jControlModel == null)) {
JControlModel _jControlModel = new JControlModel();
this.jControlModel = _jControlModel;
this.jControlModel.initialize(null, this.options.mergeRulesURI);
}
return this.jControlModel;
}
};
GeneratorAdapterFactory.Descriptor.Registry _adapterFactoryDescriptorRegistry = generator.getAdapterFactoryDescriptorRegistry();
String _lineDelimiter = this.codeConfig.getLineDelimiter();
CvsIdFilteringGeneratorAdapterFactoryDescriptor _cvsIdFilteringGeneratorAdapterFactoryDescriptor = new CvsIdFilteringGeneratorAdapterFactoryDescriptor(_lineDelimiter);
_adapterFactoryDescriptorRegistry.addDescriptor(GenModelPackage.eNS_URI, _cvsIdFilteringGeneratorAdapterFactoryDescriptor);
genModel.setCanGenerate(true);
generator.setInput(genModel);
BasicMonitor _basicMonitor = new BasicMonitor();
final Diagnostic diagnostic = generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, _basicMonitor);
int _severity = diagnostic.getSeverity();
boolean _notEquals = (_severity != Diagnostic.OK);
if (_notEquals) {
EMFGeneratorFragment2.LOG.warn(diagnostic);
}
if (this.generateEdit) {
BasicMonitor _basicMonitor_1 = new BasicMonitor();
final Diagnostic editDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, _basicMonitor_1);
int _severity_1 = editDiag.getSeverity();
boolean _notEquals_1 = (_severity_1 != Diagnostic.OK);
if (_notEquals_1) {
EMFGeneratorFragment2.LOG.warn(editDiag);
}
}
if (this.generateEditor) {
BasicMonitor _basicMonitor_2 = new BasicMonitor();
final Diagnostic editorDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDITOR_PROJECT_TYPE, _basicMonitor_2);
int _severity_2 = editorDiag.getSeverity();
boolean _notEquals_2 = (_severity_2 != Diagnostic.OK);
if (_notEquals_2) {
EMFGeneratorFragment2.LOG.warn(editorDiag);
}
}
}
示例15: doGenerate
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; //导入依赖的package包/类
@Override
protected void doGenerate(final GenModel genModel) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("generating EMF code for " + genModel.eResource().getURI()); //$NON-NLS-1$
}
Generator generator = new Generator() {
@Override
public JControlModel getJControlModel() {
return new JControlModel() {
@Override
public boolean canMerge() {
return false;
}
};
}
};
genModel.setNonNLSMarkers(generateNonNLSMarkers);
generator.getAdapterFactoryDescriptorRegistry().addDescriptor(GenModelPackage.eNS_URI, new GeneratorAdapterDescriptor(getTypeMapper()));
generator.setInput(genModel);
Diagnostic diagnostic = generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, new BasicMonitor());
if (diagnostic.getSeverity() != Diagnostic.OK) {
LOGGER.info(diagnostic);
}
if (isGenerateEdit()) {
Diagnostic editDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, new BasicMonitor());
if (editDiag.getSeverity() != Diagnostic.OK) {
LOGGER.info(editDiag);
}
}
if (isGenerateEditor()) {
Diagnostic editorDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDITOR_PROJECT_TYPE, new BasicMonitor());
if (editorDiag.getSeverity() != Diagnostic.OK) {
LOGGER.info(editorDiag);
}
}
}