當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource類代碼示例

本文整理匯總了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;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:25,代碼來源:ArduinoDriverImpl.java

示例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;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:14,代碼來源:EMFResource.java

示例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);
}
 
開發者ID:georghinkel,項目名稱:ttc2017smartGrids,代碼行數:26,代碼來源:Task2PackageImpl.java

示例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;
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:33,代碼來源:ItemEditor.java

示例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);
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:27,代碼來源:OCCIEditor.java

示例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 );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:18,代碼來源:CommonPackageHandler.java

示例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 ();
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:19,代碼來源:Hive.java

示例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);
}
 
開發者ID:Yakindu,項目名稱:solidity-ide,代碼行數:13,代碼來源:SolidityImportedNamespaceAwareLocalScopeProvider.java

示例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;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:22,代碼來源:ChartResourceFactoryImpl.java

示例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;
}
 
開發者ID:Morgan-Stanley,項目名稱:Saturn,代碼行數:21,代碼來源:SqlModuleResourceFactoryImpl.java

示例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;
}
 
開發者ID:Morgan-Stanley,項目名稱:Saturn,代碼行數:21,代碼來源:SqliteResourceResourceFactoryImpl.java

示例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;
}
 
開發者ID:Morgan-Stanley,項目名稱:Saturn,代碼行數:21,代碼來源:ReferenceModuleResourceFactoryImpl.java

示例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);
	}
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:25,代碼來源:CrtpEditor.java

示例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;
}
 
開發者ID:Morgan-Stanley,項目名稱:Saturn,代碼行數:21,代碼來源:DataSetResourceResourceFactoryImpl.java

示例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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:24,代碼來源:XpectN4JSES5TranspilerHelper.java


注:本文中的org.eclipse.emf.ecore.resource.Resource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。