本文整理汇总了Java中org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl.save方法的典型用法代码示例。如果您正苦于以下问题:Java XMIResourceImpl.save方法的具体用法?Java XMIResourceImpl.save怎么用?Java XMIResourceImpl.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl
的用法示例。
在下文中一共展示了XMIResourceImpl.save方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if ( editor instanceof AtlEditorExt ) {
AtlEditorExt atlEditor = (AtlEditorExt) editor;
IFile file = (IFile) atlEditor.getUnderlyingResource();
AnalysisResult r = AnalysisIndex.getInstance().getAnalysis(file);
for (MetamodelNamespace ns : r.getNamespace().getMetamodels()) {
MetamodelPrunner prunner = new MetamodelPrunner(r.getATLModel(), ns);
XMIResourceImpl res = new XMIResourceImpl();
prunner.extractSource(res, ns.getName(), ns.getName() + "/prunned", ns.getName());
try {
res.save(new FileOutputStream(file.getLocation().removeLastSegments(1).append(ns.getName() + ".ecore").toOSString()), null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return null;
}
示例2: createGenModel
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的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();
}
}
示例3: makeXml
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
private String makeXml ( final Component component ) throws IOException
{
final XMIResourceImpl xmi = new XMIResourceImpl ();
xmi.getContents ().add ( EcoreUtil.copy ( component ) );
final StringWriter writer = new StringWriter ();
xmi.save ( writer, null );
return writer.toString ();
}
示例4: generateErrorSlice
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
protected void generateErrorSlice(String metamodelName,
String errorSliceMMUri) throws IOException {
XMIResourceImpl r = new XMIResourceImpl(URI.createURI(errorSliceMMUri));
new ErrorSliceGenerator(analyser, analyser.getDependencyGraph())
.generate(r);
r.save(null);
}
示例5: run
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
private void run() throws Exception {
Resource atlTrafo = AtlLoader.load(TRANSFORMATION);
AnalysisLoader loader = AnalysisLoader.fromResource(atlTrafo, new Object[] { UML_METAMODEL, JAVA_METAMODEL }, new String[] { "UML", "Java" });
AnalysisResult result = loader.analyse();
// Extract the footprint
XMIResourceImpl r = new XMIResourceImpl(URI.createURI("examples/uml2java/metamodels/UML_footprint.ecore"));
TrafoMetamodelData data = new TrafoMetamodelData(result.getATLModel(), result.getNamespace().getNamespace("UML"));
new EffectiveMetamodelBuilder(data).extractSource(r, "uml_footprint", "http://uml_footprint", "uml_footprint", "UML Footprint");
r.save(null);
}
示例6: writeGenModel
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
private void writeGenModel(GenModel genModel, final String genModelLocation) {
try {
org.eclipse.emf.common.util.URI genModelURI = URI.createFileURI(genModelLocation);
final XMIResourceImpl genModelResource = new XMIResourceImpl(genModelURI);
//genModelResource.getDefaultSaveOptions().put(XMLResource.OPTION_ENCODING, Constants.GEN_MODEL_XML_ENCODING.getValue());
genModelResource.getContents().add(genModel);
genModelResource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
MessageDialog.openError(shell, "Write Gen Model", e.getMessage());
}
}
示例7: readAndSave
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
public void readAndSave(String fileToBeParsed, String targetModelPath) throws Exception {
EObject root = read(fileToBeParsed);
ResourceSetImpl rs = new ResourceSetImpl();
XMIResourceImpl xmi = (XMIResourceImpl) rs.createResource(URI.createFileURI(targetModelPath));
xmi.getContents().add(root);
xmi.save(null);
}
示例8: persistLinksModel
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
public static void persistLinksModel(WeavingModel linksModel,
org.eclipse.emf.common.util.URI theUri) throws IOException {
XMIResourceImpl linksModelResource = new XMIResourceImpl();
linksModelResource.setURI(theUri);
linksModelResource.getContents().add(linksModel);
linksModelResource.save(null);
}
示例9: persistLinksModel
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
public void persistLinksModel(org.eclipse.emf.common.util.URI linksModelURI) {
XMIResourceImpl weavingModelResource = new XMIResourceImpl();
weavingModelResource.setURI(linksModelURI);
weavingModelResource.getContents().add(viewVirtualLinks);
try {
weavingModelResource.save(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例10: createGenModel
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的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;
}
示例11: generateEffectiveMetamodel
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
protected void generateEffectiveMetamodel(String logicalName, String outputPath) throws IOException {
XMIResourceImpl r = new XMIResourceImpl(URI.createURI(outputPath));
TrafoMetamodelData data = new TrafoMetamodelData(atlTransformation, mm.getNamespace(logicalName));
new EffectiveMetamodelBuilder(data).extractSource(r, logicalName, logicalName, logicalName, logicalName);
r.save(null);
}
示例12: saveConcept
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; //导入方法依赖的package包/类
public void saveConcept(String conceptFilename) throws IOException {
XMIResourceImpl r = new XMIResourceImpl(URI.createURI(conceptFilename));
r.getContents().addAll(conceptPkg.getResource().getContents());
r.save(null);
}