本文整理汇总了Java中org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel类的典型用法代码示例。如果您正苦于以下问题:Java GenJDKLevel类的具体用法?Java GenJDKLevel怎么用?Java GenJDKLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenJDKLevel类属于org.eclipse.emf.codegen.ecore.genmodel包,在下文中一共展示了GenJDKLevel类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel; //导入依赖的package包/类
public static void createGenModel(final EPackage rootPackage, final IPath ecorePath, final IResource genmodelResource) {
GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
genModel.setComplianceLevel(GenJDKLevel.JDK60_LITERAL);
genModel.setModelDirectory(ecorePath.removeLastSegments(1).toString());
genModel.getForeignModel().add(ecorePath.lastSegment());
genModel.setModelName(rootPackage.getName());
genModel.setRootExtendsInterface("");
genModel.initialize(Collections.singleton(rootPackage));
GenPackage genPackage = (GenPackage) genModel.getGenPackages().get(0);
genPackage.setPrefix("");
try {
URI genModelURI = URI.createURI(genmodelResource.getLocationURI().toString());
final XMIResourceImpl genModelResource = new XMIResourceImpl(genModelURI);
genModelResource.getContents().add(genModel);
genModelResource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: generate
import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel; //导入依赖的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;
}
示例3: createGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel; //导入依赖的package包/类
private GenModel createGenModel(Resource resource, IPath ecoreLocation, String genModelName) {
// Get root package
EPackage rootPackage = (EPackage)resource.getContents().get(0);
// Create genModel and initialize with referred ecore model
GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
genModel.getForeignModel().add(ecoreLocation.lastSegment());
genModel.initialize(Collections.singleton(rootPackage));
// Set properties for GenModel
genModel.setComplianceLevel(GenJDKLevel.JDK70_LITERAL);
genModel.setCopyrightText("");
genModel.setLanguage("EN");
genModel.setModelName(genModelName + " genmodel");
genModel.setModelDirectory(project.getName() + "/src");
genModel.setModelPluginID(project.getName());
genModel.setRootExtendsInterface("");
genModel.setSuppressEMFTypes(true);
genModel.setImportOrganizing(true);
// Set properties for generated package
GenPackage genPackage = (GenPackage)genModel.getGenPackages().get(0);
genPackage.setPrefix(genModelName);
genPackage.setBasePackage(project.getName().substring(0, project.getName().lastIndexOf('.')));
genPackage.getEcorePackage().setName(""); //TODO
genPackage.getEcorePackage().setNsPrefix(""); //TODO
genPackage.getEcorePackage().setNsURI(""); //TODO
return genModel;
}
示例4: createGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel; //导入依赖的package包/类
public static GenPackage createGenModel(final EPackage rootPackage, final String ecoreLocation, String basePackage,
Collection<GenPackage> usedGenPackages) throws IOException {
GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
genModel.setComplianceLevel(GenJDKLevel.JDK80_LITERAL);
genModel.setCopyrightText(
"Copyright (c) 2015-2017 Obeo, Inria\n" +
"All rights reserved. This program and the accompanying materials\n" +
"are made available under the terms of the Eclipse Public License v1.0\n" +
"which accompanies this distribution, and is available at\n" +
"http://www.eclipse.org/legal/epl-v10.html\n" +
" \n" +
"Contributors:\n" +
"- William Piers <[email protected]>\n" +
"- Philippe Merle <[email protected]>\n"+
"- Faiez Zalila <[email protected]>"
);
// Added to generate java code corresponding to OCL constraints defined in the OCCI extension
// GenAnnotation genannotation = GenModelFactory.eINSTANCE.createGenAnnotation();
// genannotation.setSource("http://www.eclipse.org/OCL/GenModel");
// genannotation.getDetails().put("Use Delegates", "false");
// genModel.getGenAnnotations().add(genannotation);
String modelPluginId = new Path(ecoreLocation).removeLastSegments(2).lastSegment().toString();
String editPluginId = modelPluginId + ".edit";
String editorPluginId = modelPluginId + ".editor";
String testsPluginId = modelPluginId + ".tests";
genModel.setModelDirectory('/' + modelPluginId + "/src-gen");
genModel.setEditDirectory('/' + editPluginId + "/src-gen");
genModel.setEditorDirectory('/' + editorPluginId + "/src-gen");
genModel.setTestsDirectory('/' + testsPluginId + "/src");
genModel.getForeignModel().add(new Path(ecoreLocation).lastSegment());
genModel.setModelName(ConverterUtils.toU1Case(rootPackage.getName()));
genModel.setModelPluginID(modelPluginId);
genModel.setEditPluginID(editPluginId);
genModel.setEditorPluginID(editorPluginId);
genModel.setTestsPluginID(testsPluginId);
genModel.setRootExtendsInterface("org.eclipse.emf.ecore.EObject");
// Activate code generation for Ecore reflective and dynamic invocation of OCCI actions.
genModel.setOperationReflection(true);
genModel.getUsedGenPackages().addAll(usedGenPackages);
genModel.initialize(Collections.singleton(rootPackage));
GenPackage genPackage = genModel.getGenPackages().get(0);
genPackage.setPrefix(ConverterUtils.toU1Case(rootPackage.getNsPrefix()));
genPackage.setBasePackage(basePackage);
genPackage.setLoadInitialization(false);
URI genModelURI = URI
.createFileURI(new Path(ecoreLocation).removeFileExtension().addFileExtension("genmodel").toString());
final XMIResourceImpl genModelResource = new XMIResourceImpl(genModelURI);
genModelResource.getContents().add(genModel);
genModelResource.save(Collections.EMPTY_MAP);
return genPackage;
}
示例5: createPropertiesDefinition
import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel; //导入依赖的package包/类
public static String createPropertiesDefinition(Classifier classifier) throws Exception {
EPackage _package = EcoreFactory.eINSTANCE.createEPackage();
EClass propertyDefinition = EcoreFactory.eINSTANCE.createEClass();
GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
ExtendedMetaData extendedMetaData = genModel.getExtendedMetaData();
List<EStructuralFeature> features = new ArrayList<EStructuralFeature>();
String propertiesDefinition = "";
for(Property property : classifier.getAttributes()) {
// consider attributes only if they aren't members of an association
if(property.getAssociation() == null) {
EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
attribute.setName(property.getName());
attribute.setUnsettable(true);
// create an EEnum in case of enumeration
if(property.getType() instanceof Enumeration) {
Enumeration enumeration = (Enumeration) property.getType();
EEnum eenumeration = EcoreFactory.eINSTANCE.createEEnum();
eenumeration.setName(enumeration.getName());
int literalValue = 0;
for(EnumerationLiteral literal : enumeration.getOwnedLiterals()) {
EEnumLiteral eliteral = EcoreFactory.eINSTANCE.createEEnumLiteral();
eliteral.setName(literal.getName());
eliteral.setValue(literalValue);
literalValue++;
eenumeration.getELiterals().add(eliteral);
}
_package.getEClassifiers().add(eenumeration);
attribute.setEType(eenumeration);
}
else {
attribute.setEType(XMLTypePackage.eINSTANCE.getString());
}
propertyDefinition.getEStructuralFeatures().add(attribute);
extendedMetaData.setFeatureKind(attribute, ExtendedMetaData.ELEMENT_FEATURE);
features.add(attribute);
}
}
if(!features.isEmpty()) {
// first step: create an Ecore metamodel
URI uri = URI.createFileURI(new File(Path + classifier.getName() + Ecore_Model_Fragment).getAbsolutePath());
Resource resource = Resource_Set.createResource(uri);
_package.setName(classifier.getName() + "Properties");
_package.setNsPrefix(classifier.getName() + "Properties");
_package.setNsURI("http://" + classifier.getName() + "Properties");
resource.getContents().add(_package);
propertyDefinition.setName("Properties");
_package.getEClassifiers().add(propertyDefinition);
// second step: derive the GenModel from the metamodel
genModel.setComplianceLevel(GenJDKLevel.JDK70_LITERAL);
genModel.setModelDirectory("");
genModel.setModelName(_package.getName());
genModel.initialize(Collections.singleton(_package));
// third step: export the XSD from the GenModel
XSDExporter modelExporter = new XSDExporter();
modelExporter.setGenModel(genModel);
modelExporter.getEPackages().add(_package);
EPackageConvertInfo convertInfo = modelExporter.getEPackageConvertInfo(_package);
convertInfo.setConvert(true);
EPackageExportInfo exportInfo = modelExporter.getEPackageExportInfo(_package);
exportInfo.setArtifactLocation(Path + classifier.getName() + Xsd_Model_Fragment);
modelExporter.export(null);
// the name of the properties definition; it allows node types to reference it
propertiesDefinition = classifier.getName() + "Properties";
}
return propertiesDefinition;
}
示例6: setJdkLevel
import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel; //导入依赖的package包/类
/**
* Set the JDK compatibility level. The following values are valid:
* <ul>
* <li>"JDK14"</li>
* <li>"JDK50"</li>
* <li>"JDK60"</li>
* <li>"JDK70"</li>
* <li>"JDK80"</li>
* </ul>
* The default level is "JDK60".
*/
public void setJdkLevel(final String jdkLevel) {
this.jdkLevel = GenJDKLevel.getByName(jdkLevel);
if ((this.jdkLevel == null)) {
EMFGeneratorFragment2.LOG.warn(("Illegal JDK level: " + jdkLevel));
}
}
示例7: setJdkLevel
import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel; //导入依赖的package包/类
/**
* Set the JDK compatibility level. The following values are valid:
* <ul>
* <li>"JDK14"</li>
* <li>"JDK50"</li>
* <li>"JDK60"</li>
* <li>"JDK70"</li>
* <li>"JDK80"</li>
* </ul>
* The default level is "JDK60".
*
* @since 2.8
*/
public void setJdkLevel(String jdkLevel) {
GenJDKLevel l = GenJDKLevel.getByName(jdkLevel);
Assert.isNotNull(l, "Invalid JDK level");
this.jdkLevel = l;
}