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

EMFResource.java 文件源码 项目:gemoc-studio 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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;
}
Task2PackageImpl.java 文件源码 项目:ttc2017smartGrids 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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);
}
ItemEditor.java 文件源码 项目:neoscada 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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;
    }
}
OCCIEditor.java 文件源码 项目:OCCI-Studio 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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);
}
CommonPackageHandler.java 文件源码 项目:neoscada 阅读 14 收藏 0 点赞 0 评论 0
/**
 * 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 );
}
Hive.java 文件源码 项目:neoscada 阅读 21 收藏 0 点赞 0 评论 0
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 ();
    }
}
SlaEditor.java 文件源码 项目:OCCI-Studio 阅读 32 收藏 0 点赞 0 评论 0
/**
 * 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);
}
SolidityImportedNamespaceAwareLocalScopeProvider.java 文件源码 项目:solidity-ide 阅读 20 收藏 0 点赞 0 评论 0
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);
}
ChartResourceFactoryImpl.java 文件源码 项目:neoscada 阅读 15 收藏 0 点赞 0 评论 0
/**
 * 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;
}
SqlModuleResourceFactoryImpl.java 文件源码 项目:Saturn 阅读 15 收藏 0 点赞 0 评论 0
/**
 * 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;
}
SqliteResourceResourceFactoryImpl.java 文件源码 项目:Saturn 阅读 15 收藏 0 点赞 0 评论 0
/**
 * 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;
}
ReferenceModuleResourceFactoryImpl.java 文件源码 项目:Saturn 阅读 15 收藏 0 点赞 0 评论 0
/**
 * 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;
}
CrtpEditor.java 文件源码 项目:OCCI-Studio 阅读 22 收藏 0 点赞 0 评论 0
@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);
    }
}
DataSetResourceResourceFactoryImpl.java 文件源码 项目:Saturn 阅读 17 收藏 0 点赞 0 评论 0
/**
 * 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;
}
XpectN4JSES5TranspilerHelper.java 文件源码 项目:n4js 阅读 17 收藏 0 点赞 0 评论 0
/**
 * @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;
}
QueryResourceResourceFactoryImpl.java 文件源码 项目:Saturn 阅读 16 收藏 0 点赞 0 评论 0
/**
 * 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;
}
InfrastructureEditor.java 文件源码 项目:OCCI-Studio 阅读 31 收藏 0 点赞 0 评论 0
/**
 * 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);
}
ConfigurationResourceFactoryImpl.java 文件源码 项目:neoscada 阅读 14 收藏 0 点赞 0 评论 0
/**
 * 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;
}
ProfileResourceFactoryImpl.java 文件源码 项目:neoscada 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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;
}
XSplitModuleResourceFactoryImpl.java 文件源码 项目:Saturn 阅读 14 收藏 0 点赞 0 评论 0
/**
 * 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;
}
IncludeTest.java 文件源码 项目:rest-modeling-framework 阅读 24 收藏 0 点赞 0 评论 0
@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");
}
SmarthomeEditor.java 文件源码 项目:smarthome-cep-demonstrator 阅读 21 收藏 0 点赞 0 评论 0
@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);
    }
}
TypedFragmentTest.java 文件源码 项目:rest-modeling-framework 阅读 14 收藏 0 点赞 0 评论 0
@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");
}
InfrastructureEditor.java 文件源码 项目:neoscada 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 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;
}
OCCIEditor.java 文件源码 项目:OCCI-Studio 阅读 26 收藏 0 点赞 0 评论 0
@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);
    }
}
ArduinoDriverImpl.java 文件源码 项目:neoscada 阅读 17 收藏 0 点赞 0 评论 0
@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;
}
ModbusDriverImpl.java 文件源码 项目:neoscada 阅读 15 收藏 0 点赞 0 评论 0
@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;
}
MonitoringEditor.java 文件源码 项目:OCCI-Studio 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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);
}
SaturnReportResourceFactoryImpl.java 文件源码 项目:Saturn 阅读 15 收藏 0 点赞 0 评论 0
/**
 * 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;
}
ChartEditor.java 文件源码 项目:neoscada 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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;
}


问题


面经


文章

微信
公众号

扫码关注公众号