本文整理汇总了Java中org.eclipse.emf.ecore.resource.Resource类的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于org.eclipse.emf.ecore.resource包,在下文中一共展示了Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProfile
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
@Override
public Profile getProfile ()
{
if ( this.profile == null )
{
final ResourceSet rs = new ResourceSetImpl ();
final Resource r = rs.createResource ( URI.createURI ( DEFAULT_URI ) );
try
{
r.load ( null );
}
catch ( final IOException e )
{
throw new RuntimeException ( e );
}
this.profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
if ( this.profile == null )
{
throw new IllegalStateException ( String.format ( "Resource loaded from %s does not contain an object of type %s", DEFAULT_URI, Profile.class.getName () ) );
}
}
return this.profile;
}
示例2: getIFile
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* Getting an IFile from an EMF Resource
*
* @param eObject
* @return
*/
public static IFile getIFile(Resource res) {
URI uri = res.getURI();
String filePath = uri.toPlatformString(true);
IFile ifile = ResourcesPlugin.getWorkspace().getRoot()
.getFile(new Path(filePath));
return ifile;
}
示例3: loadPackage
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* Laods the package and any sub-packages from their serialized form.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void loadPackage() {
if (isLoaded)
return;
isLoaded = true;
URL url = getClass().getResource(packageFilename);
if (url == null) {
throw new RuntimeException("Missing serialized package: " + packageFilename);
}
URI uri = URI.createURI(url.toString());
Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
try {
resource.load(null);
} catch (IOException exception) {
throw new WrappedException(exception);
}
initializeFromLoadedEPackage(this, (EPackage) resource.getContents().get(0));
createResource(eNS_URI);
}
示例4: analyzeResourceProblems
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* Returns a diagnostic describing the errors and warnings listed in the resource
* and the specified exception (if any).
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Diagnostic analyzeResourceProblems ( Resource resource, Exception exception )
{
if ( !resource.getErrors ().isEmpty () || !resource.getWarnings ().isEmpty () )
{
BasicDiagnostic basicDiagnostic =
new BasicDiagnostic
( Diagnostic.ERROR, "org.eclipse.scada.configuration.item.editor", //$NON-NLS-1$
0,
getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
new Object[] { exception == null ? (Object)resource : exception } );
basicDiagnostic.merge ( EcoreUtil.computeDiagnostic ( resource, true ) );
return basicDiagnostic;
}
else if ( exception != null )
{
return new BasicDiagnostic ( Diagnostic.ERROR, "org.eclipse.scada.configuration.item.editor", //$NON-NLS-1$
0,
getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
new Object[] { exception } );
}
else
{
return Diagnostic.OK_INSTANCE;
}
}
示例5: createModel
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* This is the method called to load a resource into the editing domain's resource set based on the editor's input.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void createModel() {
URI resourceURI = EditUIUtil.getURI(getEditorInput(), editingDomain.getResourceSet().getURIConverter());
Exception exception = null;
Resource resource = null;
try {
// Load the resource through the editing domain.
//
resource = editingDomain.getResourceSet().getResource(resourceURI, true);
}
catch (Exception e) {
exception = e;
resource = editingDomain.getResourceSet().getResource(resourceURI, false);
}
Diagnostic diagnostic = analyzeResourceProblems(resource, exception);
if (diagnostic.getSeverity() != Diagnostic.OK) {
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
}
editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
}
示例6: 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 );
}
示例7: parse
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
private static RootType parse ( final URI uri ) throws IOException
{
final ResourceSet rs = new ResourceSetImpl ();
rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ConfigurationResourceFactoryImpl () );
final Resource r = rs.createResource ( uri );
r.load ( null );
final DocumentRoot doc = (DocumentRoot)EcoreUtil.getObjectByType ( r.getContents (), ConfigurationPackage.Literals.DOCUMENT_ROOT );
if ( doc == null )
{
return null;
}
else
{
return doc.getRoot ();
}
}
示例8: getResourceScope
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
protected IScope getResourceScope(Resource res, EReference reference) {
if (reference == TypesPackage.Literals.COMPLEX_TYPE__SUPER_TYPES)
return super.getResourceScope(res, reference);
EObject context = res.getContents().get(0);
IScope globalScope = getGlobalScope(res, reference);
List<ImportNormalizer> normalizers = getSuperTypeImports(res, reference);
if (!normalizers.isEmpty()) {
globalScope = createImportScope(globalScope, normalizers, null, reference.getEReferenceType(),
isIgnoreCase(reference));
}
return getResourceScope(globalScope, context, reference);
}
示例9: createResource
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* Creates an instance of the resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource ( URI uri )
{
XMLResource result = new ChartResourceImpl ( uri );
result.getDefaultSaveOptions ().put ( XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE );
result.getDefaultLoadOptions ().put ( XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE );
result.getDefaultSaveOptions ().put ( XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE );
result.getDefaultLoadOptions ().put ( XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE );
result.getDefaultSaveOptions ().put ( XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE );
result.getDefaultLoadOptions ().put ( XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE );
return result;
}
示例10: createResource
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* Creates an instance of the resource.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource(URI uri)
{
XMLResource result = new SqlModuleResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
return result;
}
示例11: createResource
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* Creates an instance of the resource.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource(URI uri)
{
XMLResource result = new SqliteResourceResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
return result;
}
示例12: createResource
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* Creates an instance of the resource.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource(URI uri)
{
XMLResource result = new ReferenceModuleResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
return result;
}
示例13: notifyChanged
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
@Override
public void notifyChanged(Notification notification) {
if (notification.getNotifier() instanceof Resource) {
switch (notification.getFeatureID(Resource.class)) {
case Resource.RESOURCE__IS_LOADED:
case Resource.RESOURCE__ERRORS:
case Resource.RESOURCE__WARNINGS: {
Resource resource = (Resource)notification.getNotifier();
Diagnostic diagnostic = analyzeResourceProblems(resource, null);
if (diagnostic.getSeverity() != Diagnostic.OK) {
resourceToDiagnosticMap.put(resource, diagnostic);
}
else {
resourceToDiagnosticMap.remove(resource);
}
dispatchUpdateProblemIndication();
break;
}
}
}
else {
super.notifyChanged(notification);
}
}
示例14: createResource
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* Creates an instance of the resource.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource(URI uri)
{
XMLResource result = new DataSetResourceResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
return result;
}
示例15: getResources
import org.eclipse.emf.ecore.resource.Resource; //导入依赖的package包/类
/**
* @return the resources retrieved from the Xpect resource set configuration
*/
@Override
public List<Resource> getResources() {
final List<Resource> configuredResources = newArrayList();
if (configuredResourceSet != null) {
for (ResourceFactory factory : configuredResourceSet.getFactories()) {
if (factory instanceof org.eclipse.xpect.xtext.lib.setup.emf.Resource) {
org.eclipse.xpect.xtext.lib.setup.emf.Resource res = (org.eclipse.xpect.xtext.lib.setup.emf.Resource) factory;
try {
if (fileSetupCtx != null) {
Resource createdRes = res.create(fileSetupCtx, resourceSet);
configuredResources.add(createdRes);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
return configuredResources;
}