Java 类org.eclipse.emf.ecore.resource.Resource 实例源码

项目:gemoc-studio    文件:EMFResource.java   
/**
 * 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;
}
项目:ttc2017smartGrids    文件:Task2PackageImpl.java   
/**
 * 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);
}
项目:neoscada    文件:ItemEditor.java   
/**
 * 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;
    }
}
项目:OCCI-Studio    文件:OCCIEditor.java   
/**
 * 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);
}
项目:neoscada    文件:CommonPackageHandler.java   
/**
 * 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 );
}
项目:neoscada    文件:Hive.java   
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 ();
    }
}
项目:OCCI-Studio    文件:SlaEditor.java   
/**
 * 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);
}
项目:solidity-ide    文件:SolidityImportedNamespaceAwareLocalScopeProvider.java   
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);
}
项目:neoscada    文件:ChartResourceFactoryImpl.java   
/**
 * 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;
}
项目:Saturn    文件:SqlModuleResourceFactoryImpl.java   
/**
 * 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;
}
项目:Saturn    文件:SqliteResourceResourceFactoryImpl.java   
/**
 * 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;
}
项目:Saturn    文件:ReferenceModuleResourceFactoryImpl.java   
/**
 * 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;
}
项目:OCCI-Studio    文件:CrtpEditor.java   
@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);
    }
}
项目:Saturn    文件:DataSetResourceResourceFactoryImpl.java   
/**
 * 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;
}
项目:n4js    文件:XpectN4JSES5TranspilerHelper.java   
/**
 * @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;
}
项目:Saturn    文件:QueryResourceResourceFactoryImpl.java   
/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri)
{
  XMLResource result = new QueryResourceResourceImpl(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;
}
项目:OCCI-Studio    文件:InfrastructureEditor.java   
/**
 * 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);
}
项目:neoscada    文件:ConfigurationResourceFactoryImpl.java   
/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource ( URI uri )
{
    XMLResource result = new ConfigurationResourceImpl ( 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;
}
项目:neoscada    文件:ProfileResourceFactoryImpl.java   
/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public Resource createResource ( final URI uri )
{
    final XMLResource result = new ProfileResourceImpl ( 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 );

    result.getDefaultSaveOptions ().put ( XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware () );

    return result;
}
项目:Saturn    文件:XSplitModuleResourceFactoryImpl.java   
/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri)
{
  XMLResource result = new XSplitModuleResourceImpl(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;
}
项目:rest-modeling-framework    文件:IncludeTest.java   
@Test
public void load() throws IOException {
    final Resource resource = fromClasspath("/data-type-include.raml");
    assertThat(resource.getErrors()).hasSize(0);

    final Library library = getRootObject(resource);
    final EList<AnyType> types = library.getTypes();

    assertThat(types).hasSize(1);
    assertThat(types.get(0)).isInstanceOf(ObjectType.class);

    final ObjectType personType = (ObjectType) types.get(0);

    assertThat(personType.getName()).isEqualTo("Person");
    assertThat(personType.getDisplayName()).isEqualTo("Person");
    assertThat(personType.getProperties()).hasSize(1);

    final Property ageProperty = personType.getProperties().get(0);

    assertThat(ageProperty.getName()).isEqualTo("age");
    assertThat(ageProperty.getType().getName()).isEqualTo("integer");
}
项目:smarthome-cep-demonstrator    文件:SmarthomeEditor.java   
@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);
    }
}
项目:rest-modeling-framework    文件:TypedFragmentTest.java   
@Test
public void dataType() throws IOException {
    final Resource resource = fromClasspath("/includes/data-type-fragment.raml");
    final ObjectType objectType = getRootObject(resource);

    assertThat(objectType.getName())
            .as("Name of a typed fragment")
            .isNull();

    assertThat(objectType.getDisplayName()).isEqualTo("Person");

    final EList<Property> properties = objectType.getProperties();
    assertThat(properties)
            .hasSize(1);

    final Property nameProperty = properties.get(0);
    assertThat(nameProperty.getName())
            .isEqualTo("age");
    assertThat(nameProperty.getType().getName())
            .isEqualTo("integer");
}
项目:neoscada    文件:InfrastructureEditor.java   
/**
 * This returns whether something has been persisted to the URI of the specified resource.
 * The implementation uses the URI converter from the editor's resource set to try to open an input stream.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected boolean isPersisted ( Resource resource )
{
    boolean result = false;
    try
    {
        InputStream stream = editingDomain.getResourceSet ().getURIConverter ().createInputStream ( resource.getURI () );
        if ( stream != null )
        {
            result = true;
            stream.close ();
        }
    }
    catch ( IOException e )
    {
        // Ignore
    }
    return result;
}
项目:OCCI-Studio    文件:OCCIEditor.java   
@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);
    }
}
项目:neoscada    文件:ArduinoDriverImpl.java   
@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;
}
项目:neoscada    文件:ModbusDriverImpl.java   
@Override
public Profile getProfile ()
{
    if ( this.profile == null )
    {
        final ResourceSet rs = new ResourceSetImpl ();
        final Resource r = rs.createResource ( URI.createURI ( DEFAULT_URI ), "org.eclipse.scada.configuration.world.osgi.profile" );
        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;
}
项目:OCCI-Studio    文件:MonitoringEditor.java   
/**
 * 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);
}
项目:Saturn    文件:SaturnReportResourceFactoryImpl.java   
/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override
public Resource createResource(URI uri)
{
  XMLResource result = new SaturnReportResourceImpl(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;
}
项目:neoscada    文件:ChartEditor.java   
/**
 * This returns whether something has been persisted to the URI of the
 * specified resource.
 * The implementation uses the URI converter from the editor's resource set
 * to try to open an input stream.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
protected boolean isPersisted ( final Resource resource )
{
    boolean result = false;
    try
    {
        final InputStream stream = this.editingDomain.getResourceSet ()
                .getURIConverter ().createInputStream ( resource.getURI () );
        if ( stream != null )
        {
            result = true;
            stream.close ();
        }
    }
    catch ( final IOException e )
    {
        // Ignore
    }
    return result;
}
项目:rgse.ttc17.emoflon.tgg    文件:Task1PackageImpl.java   
/**
 * 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);
}
项目:n4js    文件:N4MFStandaloneSetupGenerated.java   
public void register(Injector injector) {
    IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
    IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);

    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4mf", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4mf", serviceProvider);
}
项目:gemoc-studio    文件:StandaloneSetup.java   
public void doEMFRegistration() {
  EPackage.Registry.INSTANCE.put(
    org.eclipse.gemoc.sample.legacyfsm.fsm.FsmPackage.eNS_URI,
    org.eclipse.gemoc.sample.legacyfsm.fsm.FsmPackage.eINSTANCE
  );

  Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
    "*",
    new XMIResourceFactoryImpl()
  );
  Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(
    "melange",
    new MelangeResourceFactoryImpl()
  );
}
项目:ttc2017smartGrids    文件:GlueModelCreator.java   
private static HashSet<MMXU> getAllMMXU(Resource resource) {
    HashSet<MMXU> mmxus = new HashSet<MMXU>();
    TreeIterator<EObject> iterator = resource.getAllContents();
    while (iterator.hasNext()) {
        EObject eOb = iterator.next();
        if (eOb instanceof MMXU) {
            MMXU asset = (MMXU) eOb;
            mmxus.add(asset);
        }
    }
    return mmxus;
}
项目:Tarski    文件:ModelIO.java   
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();
  }
}
项目:neoscada    文件:WorldResourceFactoryImpl.java   
/**
 * Creates an instance of the resource.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public Resource createResource ( final URI uri )
{
    final XMIResource result = new WorldResourceImpl ( uri );

    result.getDefaultSaveOptions ().put ( XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware () );

    return result;
}
项目:n4js    文件:EagerResourceSetBasedResourceDescriptions.java   
private Map<URI, IResourceDescription> getDescriptionsMap() {
    Descriptions descriptions = getDescriptions(getResourceSet());
    if (descriptions == null) {
        descriptions = new Descriptions();
        getResourceSet().eAdapters().add(descriptions);
        List<Resource> list = new ArrayList<>(getResourceSet().getResources());
        for (Resource resource : list) {
            IResourceDescription description = computeResourceDescription(resource.getURI());
            if (description != null) {
                descriptions.map.put(resource.getURI(), description);
            }
        }
    }
    return descriptions.map;
}
项目:rest-modeling-framework    文件:RamlTckTest.java   
@Test
@UseDataProvider("allTckRamlFiles")
public void tckFilesParse(final File f) throws IOException, TckParseException {
    final Resource resource;
    final URI fileURI = URI.createURI(f.toURI().toString());
    try {
        resource = fromUri(fileURI);
    } catch (Exception e) {
        throw new TckParseException(fileURI.toString(), e);
    }
    assertThat(resource).isInstanceOf(Resource.class)
            .overridingErrorMessage("Failed to parse: " + f.toString());
}
项目:time4sys    文件:GrmEditor.java   
@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);
                }

                if (updateProblemIndication) {
                    getSite().getShell().getDisplay().asyncExec
                        (new Runnable() {
                             public void run() {
                                 updateProblemIndication();
                             }
                         });
                }
                break;
            }
        }
    }
    else {
        super.notifyChanged(notification);
    }
}
项目:neoscada    文件:ComponentEditor.java   
@Override
protected void unsetTarget ( Resource target )
{
    basicUnsetTarget ( target );
    resourceToDiagnosticMap.remove ( target );
    if ( updateProblemIndication )
    {
        getSite ().getShell ().getDisplay ().asyncExec ( new Runnable () {
            public void run ()
            {
                updateProblemIndication ();
            }
        } );
    }
}