当前位置: 首页>>代码示例>>Java>>正文


Java Resource.save方法代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.resource.Resource.save方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.save方法的具体用法?Java Resource.save怎么用?Java Resource.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.ecore.resource.Resource的用法示例。


在下文中一共展示了Resource.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertERDSLtoXMI

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public static void convertERDSLtoXMI(String inputM, String outputM) {
	Injector injector = new QueryITStandaloneSetup().createInjectorAndDoEMFRegistration();

	XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);


	URI uri = URI.createURI(inputM);
	

	Resource xtextResource = resourceSet.getResource(uri, true);

	EcoreUtil.resolveAll(xtextResource);

	Resource xmiResource = resourceSet.createResource(URI.createURI(outputM));
	xmiResource.getContents().add(xtextResource.getContents().get(0));
	try {
		xmiResource.save(null);
		System.out.println("Saved " + outputM);
    	System.out.println("QueryIT file converted successfully to XMI");
    	System.out.println("-------------------------------------");
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:TodorovicNikola,项目名称:SurveyDSL,代码行数:25,代码来源:QueryITToXMIConverter.java

示例2: patchProfile

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * Inject the CA bootstrap property to the profile
 *
 * @param file
 *            the profile.xml file in the package target
 * @throws IOException
 */
protected void patchProfile ( final String appName, final File file ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( URI.createFileURI ( file.toString () ) );
    r.load ( null );

    final Profile profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
    Profiles.addSystemProperty ( profile, "org.eclipse.scada.ca.file.provisionJsonUrl", "file:///usr/share/eclipsescada/ca.bootstrap/bootstrap." + appName + ".json" );
    r.save ( null );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:CommonPackageHandler.java

示例3: saveResources

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public static void saveResources(final List<EObject> root, final URI uri) {
  final ResourceSet resourceSet = new ResourceSetImpl();
  resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
      .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMLResourceFactoryImpl());
  final Resource resource = resourceSet.createResource(uri);
  resource.getContents().addAll(root);

  final Map options = new HashMap();
  options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
  try {
    resource.save(options);
  } catch (final IOException e) {
    e.printStackTrace();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:17,代码来源:EcoreUtilities.java

示例4: saveCompany

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * Save a company EObject both in .xmi and .xml file
 */
public static void saveCompany(Company c, String s) throws IOException {
	
	ResourceSet resourceSet = getResourceSet();

	// Use XMI resource
	Resource xmiResource = resourceSet.createResource(URI.createFileURI(s + ".xmi"));
	xmiResource.getContents().add(c);
	xmiResource.save(null);

	// Use XML resource instead
	Resource xmlResource = resourceSet.createResource(URI.createFileURI(s + ".xml"));
	xmlResource.getContents().add(c);
	xmlResource.save(null);
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:18,代码来源:Serialization.java

示例5: doSave

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private void doSave ( final String file ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();

    rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMLResourceFactoryImpl () ); //$NON-NLS-1$
    final URI fileUri = URI.createFileURI ( file );
    final Resource resource = rs.createResource ( fileUri );
    resource.getContents ().add ( this.chart );

    final Map<Object, Object> options = new HashMap<Object, Object> ();
    //             options.put ( XMIResource., value )
    resource.save ( options );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:14,代码来源:ChartActionBarContributor.java

示例6: saveState

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@Override
public void saveState ( final IMemento memento )
{
    super.saveState ( memento );
    if ( memento == null )
    {
        return;
    }

    final Resource resource = new XMIResourceFactoryImpl ().createResource ( null );
    resource.getContents ().add ( this.configuration );

    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream ();

    final Map<?, ?> options = new HashMap<Object, Object> ();

    try
    {
        resource.save ( outputStream, options );
        final IMemento child = memento.createChild ( CHILD_CONFIGURATION );

        child.putTextData ( StringUtils.newStringUtf8 ( Base64.encodeBase64 ( outputStream.toByteArray (), true ) ) );
    }
    catch ( final Exception e )
    {
        StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.LOG );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:29,代码来源:ChartView.java

示例7: save

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
protected static Resource save ( final ResourceSet rs, final URI base, final String localName, final EObject content, final String contentType ) throws IOException
{
    final Resource resource = rs.createResource ( base.appendSegments ( localName.split ( "\\/" ) ), contentType );
    resource.getContents ().add ( content );
    resource.save ( null );
    return resource;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:8,代码来源:CreateProjectOperation.java

示例8: processProfile

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private void processProfile ( final File output ) throws IOException
{
    final Profile profile = makeProfile ( this.app );

    final File profileFile = new File ( output, this.app.getName () + ".profile.xml" ); //$NON-NLS-1$

    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( URI.createFileURI ( profileFile.toString () ) );
    r.getContents ().add ( EcoreUtil.copy ( profile ) );

    final Map<Object, Object> options = new HashMap<> ();
    options.put ( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$

    r.save ( options );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:16,代码来源:P2ProfileProcessor.java

示例9: store

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public void store ( final URI uri ) throws IOException
{
    logger.debug ( "Storing model to: {}", uri );

    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( uri );
    r.getContents ().add ( this.content );
    r.save ( null );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:10,代码来源:ModelWriter.java

示例10: merge

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private void merge(EList<Resource> resources, URI outputURI) throws IOException {
	ResourceSet rs = new ResourceSetImpl();
	Resource uniqueResource = rs.createResource(outputURI);
	for(Resource r : resources) 
	{
		uniqueResource.getContents().addAll(r.getContents());
	}
	for(IBeforeSavingAction action : _context.getBeforeSavingActions()) {
		ActionContext c = new ActionContext(uniqueResource);
		action.run(c);
	}
	uniqueResource.save(null);
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:14,代码来源:ResourceMerger.java

示例11: deleteEObject

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public boolean deleteEObject(String sigType, String relativeObjectURI)
    throws IOException, TraceException {
  EObject eObject = findEObject(sigType, relativeObjectURI);
  if (eObject != null) {
    Resource eResource = eObject.eResource();
    EcoreUtil.delete(eObject);
    eResource.save(null);
    return true;
  }
  return false;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:12,代码来源:TraceManager.java

示例12: write

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public void write(final URI uri, final T obj) {
  final Resource resource = this.getResourceSet().createResource(uri);

  resource.getContents().add(obj);

  final HashMap<Object, Object> options = new HashMap<>();
  try {
    resource.save(options);
  } catch (final IOException e) {
    e.printStackTrace();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:13,代码来源:ModelIO.java

示例13: save

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public static void save(ResourceSet resourceSet, EObject rootElement, String path) throws IOException {
	Resource resource = resourceSet.createResource(URI.createURI(path));
	resource.getContents().add(rootElement);
	Map<String, String> options = new HashMap<String, String>();
	options.put(XMIResource.OPTION_ENCODING, "UTF-8");
	resource.save(options);
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:8,代码来源:ConverterUtils.java

示例14: doSaveDocument

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@Override
protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite)
		throws CoreException {
	try {
		//System.out.println("doSaveDocument ");
		ResourceSet resourceSet = createResourceSet();
		XtextResource xtextResource = (XtextResource) resourceSet.createResource(URI.createURI("temp.occi"));
		InputStream is = new ByteArrayInputStream(document.get().getBytes());
		xtextResource.load(is, Collections.EMPTY_MAP);
		is.close();
		URI uri = URI.createPlatformResourceURI(
				((org.eclipse.ui.part.FileEditorInput) element).getFile().getFullPath().toString(), true);
		//resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
		//System.out.println("uriii "+uri);
		Resource xmiResource = resourceSet.getResource(uri, true);
		((XMLResource) xmiResource).getDefaultSaveOptions().put(XMLResource.OPTION_URI_HANDLER,
				new URIHandlerImpl.PlatformSchemeAware());
		xmiResource.getContents().clear();
		xmiResource.getContents().addAll(xtextResource.getContents());
		// SUPER IMPORTANT to avoid to have references to temp.occi
		EcoreUtil.resolveAll(xmiResource);			
		xmiResource.save(Collections.EMPTY_MAP);
	} catch (IOException e) {
		throw new CoreException(
				new Status(IStatus.ERROR, "org.occiware.clouddesigner.occi.xtext.ui", "Failed to save", e));
	}
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:28,代码来源:OCCIDocumentProvider.java

示例15: generateDesignTestProject

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private void generateDesignTestProject(IProject project, String extensionName, final IProgressMonitor monitor)
		throws CoreException, IOException, WorkbenchException {
	/*
	 * Create design test project
	 */
	IProject testProject = DesignerGeneratorUtils.genDesignTestProject(project, monitor);

	/*
	 * Create design representation
	 */
	final Resource resource = resourceSet.createResource(URI.createURI(
			"platform:/resource/" + testProject.getFullPath() + "/sample." + extensionName.toLowerCase()));
	resource.getContents().add(OCCIFactory.eINSTANCE.createConfiguration());
	resource.save(Collections.EMPTY_MAP);

	// switch perspective
	PlatformUI.getWorkbench().showPerspective("org.eclipse.sirius.ui.tools.perspective.modeling",
			PlatformUI.getWorkbench().getActiveWorkbenchWindow());

	final Session session = ModelingProject.asModelingProject(testProject).get().getSession();
	session.getTransactionalEditingDomain().getCommandStack()
			.execute(new RecordingCommand(session.getTransactionalEditingDomain()) {
				@Override
				protected void doExecute() {
					session.addSemanticResource(resource.getURI(), monitor);
				}
			});

	WizardUtils.enableViewpoint(session,
			"viewpoint:/" + project.getName() + '/' + ConverterUtils.toU1Case(extensionName) + "Configuration");
	String diagramInstanceName = "Sample " + extensionName;
	EObject root = WizardUtils.getRoot(session, resource.getURI());
	WizardUtils.openDiagram(monitor, testProject, "Configuration Diagram", diagramInstanceName, root);

	project.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:37,代码来源:DesignerGeneratorAction.java


注:本文中的org.eclipse.emf.ecore.resource.Resource.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。