org.eclipse.xtext.ui.util
Class ResourceUtil

java.lang.Object
  extended by org.eclipse.xtext.ui.util.ResourceUtil

public class ResourceUtil
extends java.lang.Object

Copied from org.eclipse.emf.workspace.util.WorkspaceSynchronizer to avoid dependencies to EMFT.

Author:
Jan Koehnlein - Initial contribution and API

Constructor Summary
ResourceUtil()
           
 
Method Summary
static org.eclipse.core.resources.IFile getFile(org.eclipse.emf.ecore.resource.Resource resource)
          Obtains the workspace file corresponding to the specified resource, if it has a platform-resource URI.
static org.eclipse.core.resources.IFile getUnderlyingFile(org.eclipse.emf.ecore.resource.Resource resource)
          Obtains the workspace file underlying the specified resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceUtil

public ResourceUtil()
Method Detail

getFile

public static org.eclipse.core.resources.IFile getFile(org.eclipse.emf.ecore.resource.Resource resource)
Obtains the workspace file corresponding to the specified resource, if it has a platform-resource URI. Note that the resulting file, if not null, may nonetheless not actually exist (as the file is just a handle).

Note that, if the resource is in an archive (such as a ZIP file) then it does not map to a workspace file. In this case, however, the workspace file (if any) corresponding to the containing archive can be obtained via the getUnderlyingFile(Resource) method.

Parameters:
resource - an EMF resource
Returns:
the corresponding workspace file, or null if the resource's URI is not a platform-resource URI
See Also:
getUnderlyingFile(Resource)

getUnderlyingFile

public static org.eclipse.core.resources.IFile getUnderlyingFile(org.eclipse.emf.ecore.resource.Resource resource)
Obtains the workspace file underlying the specified resource. If the resource has an archive scheme, the authority is considered instead. If the URI has a file scheme, it's looked up in the workspace, just as in the getFile(Resource) method. Otherwise, a platform scheme is assumed.

Note that the resulting file, if not null, may nonetheless not actually exist (as the file is just a handle).

Parameters:
resource - an EMF resource
Returns:
the underlying workspace file, or null if the resource's URI is not a platform-resource URI
Since:
1.2
See Also:
getFile(Resource)