Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1108a6dbf913b1fe9a3a8cc58c30d1bbe3200350 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
 * Copyright (c) 2010 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.xtext.glue.concurrency;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.resource.IResourceDescription;
import org.eclipse.xtext.resource.IResourceDescription.Manager;
import org.eclipse.xtext.resource.IResourceServiceProvider;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.IDirtyResource;

/**
 * An implementation of {@link IDirtyResource} for resources without an underlying document.
 * 
 * @author koehnlein - Initial contribution and API
 */
public class SimpleDirtyResource implements IDirtyResource {

	private XtextResource resource;

	private Manager resourceDescriptionManager;

	/**
	 * This element comes from the XText/GMF integration example, and was not originally documented.
	 * @param resource 
	 * @param resourceServiceProvider 
	 */
	public SimpleDirtyResource(XtextResource resource, IResourceServiceProvider resourceServiceProvider) {
		this.resource = resource;
		this.resourceDescriptionManager = resourceServiceProvider.getResourceDescriptionManager();
	}

	public String getContents() {
		return resource.getSerializer().serialize(resource.getContents().get(0));
	}
	
	public String getActualContents() {
		return getContents();
	}

	public IResourceDescription getDescription() {
		return resourceDescriptionManager.getResourceDescription(resource);
	}

	public URI getURI() {
		return resource.getURI();
	}

	/**
	 * This element comes from the XText/GMF integration example, and was not originally documented.
	 * @return Resource
	 */
	public Resource getResource() {
		return resource;
	}

	
	
}

Back to the top