本文整理汇总了Java中org.eclipse.emf.codegen.ecore.genmodel.GenPackage.setPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java GenPackage.setPrefix方法的具体用法?Java GenPackage.setPrefix怎么用?Java GenPackage.setPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.codegen.ecore.genmodel.GenPackage
的用法示例。
在下文中一共展示了GenPackage.setPrefix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入方法依赖的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: createGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入方法依赖的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;
}
示例3: createGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入方法依赖的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;
}
示例4: createGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入方法依赖的package包/类
public void createGenModel(String ecorepath, String outputPath) {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"ecore",
new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"genmodel",
new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
IPath ecorePath = new Path(ecorepath);
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getURIConverter().getURIMap()
.putAll(EcorePlugin.computePlatformURIMap());
URI ecoreURI = URI.createFileURI(ecorePath.toString());
Resource resource = resourceSet.getResource(ecoreURI, true);
EPackage ePackage = (EPackage) resource.getContents().get(0);
IPath genModelPath = ecorePath.removeFileExtension().addFileExtension(
"genmodel");
URI genModelURI = URI.createFileURI(genModelPath.toString());
Resource genModelResource = Resource.Factory.Registry.INSTANCE
.getFactory(genModelURI).createResource(genModelURI);
GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
genModelResource.getContents().add(genModel);
resourceSet.getResources().add(genModelResource);
genModel.setModelDirectory("/" + outputPath + "/src");
genModel.getForeignModel().add(ecorePath.toString());
genModel.initialize(Collections.singleton(ePackage));
GenPackage genPackage = (GenPackage) genModel.getGenPackages().get(0);
genModel.setModelName(genModelURI.trimFileExtension().lastSegment());
genPackage.setPrefix(genPackage.getNSName());
genPackage.setBasePackage("");
File f = new File(outputPath);
deleteDirectory(f);
f.mkdir();
EcorePlugin.getPlatformResourceMap().put(outputPath,
URI.createFileURI(f.getAbsolutePath() + "/"));
this.generate(genModel);
}