Java 类org.eclipse.emf.common.util.Diagnostic 实例源码

项目:time4sys    文件:ProtectionParameterGeneralPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (GrmViewsRepository.General.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:time4sys    文件:HardwareDriveTimingPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (HrmViewsRepository.Timing.TimingProperties.timings == event.getAffectedEditor()) {
                BasicDiagnostic chain = new BasicDiagnostic();
                for (Iterator iterator = ((List)event.getNewValue()).iterator(); iterator.hasNext();) {
                    chain.add(Diagnostician.INSTANCE.validate(HrmPackage.eINSTANCE.getHardwareMemory_Timings().getEAttributeType(), iterator.next()));
                }
                ret = chain;
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:time4sys    文件:WorkloadEventPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (GqamViewsRepository.General.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:time4sys    文件:ResultContainerPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * @generated
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (AnalysisViewsRepository.ResultContainer.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:SimQRI    文件:ModelPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (MetamodelViewsRepository.Model.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(MetamodelPackage.eINSTANCE.getModel_Name().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(MetamodelPackage.eINSTANCE.getModel_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:gemoc-studio-modeldebugging    文件:TracingannotationsEditor.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());
    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);
}
项目:gemoc-studio-modeldebugging    文件:TracingannotationsEditor.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.gemoc.trace.annotations.editor",
                 0,
                 getString("_UI_CreateModelError_message", resource.getURI()),
                 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.gemoc.trace.annotations.editor",
                 0,
                 getString("_UI_CreateModelError_message", resource.getURI()),
                 new Object[] { exception });
    }
    else {
        return Diagnostic.OK_INSTANCE;
    }
}
项目:neoscada    文件:ProtocolEditor.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.protocol.ngp.model.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.protocol.ngp.model.editor", //$NON-NLS-1$
                0,
                getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
项目:time4sys    文件:ReferencePropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (GqamViewsRepository.General.Properties.referenceName == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(GqamPackage.eINSTANCE.getReference_ReferenceName().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(GqamPackage.eINSTANCE.getReference_ReferenceName().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:time4sys    文件:SoftwareInterfaceGeneralPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (SrmViewsRepository.General.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:neoscada    文件:DetailViewEditor.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 () );
    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    文件:VisualInterfaceEditor.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 () );
    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    文件:ExporterProcessor.java   
/**
 * Validates a object instance and its children using the EMF core validator
 * API.
 *
 * @param element
 *            the element to validate
 * @param label
 *            the type label of the element
 * @throws IllegalStateException
 *             if validation errors are encountered
 */
protected static void validateDevice ( final EObject object, final String label )
{
    final Diagnostic diag = Diagnostician.INSTANCE.validate ( object );
    if ( diag.getSeverity () == Diagnostic.ERROR )
    {
        final StringBuilder sb = new StringBuilder ( "Invalid " + label );
        for ( final Diagnostic child : diag.getChildren () )
        {
            if ( child.getSeverity () == Diagnostic.ERROR )
            {
                sb.append ( System.lineSeparator () );
                sb.append ( child.getMessage () );
            }
        }
        throw new IllegalStateException ( sb.toString () );
    }
}
项目:time4sys    文件:HardwarePinGeneralPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (HrmViewsRepository.General.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:time4sys    文件:HrmEditor.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);
}
项目: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);
}
项目:neoscada    文件:DeploymentEditor.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 );
}
项目: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);
    }
}
项目:time4sys    文件:Time4sysEditor.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);
}
项目:time4sys    文件:DesignModelPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * @generated
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (DesignViewsRepository.DesignModel.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(DesignPackage.eINSTANCE.getDesignModel_Name().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(DesignPackage.eINSTANCE.getDesignModel_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:neoscada    文件:ProfileEditor.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 )
{
    boolean hasErrors = !resource.getErrors ().isEmpty ();
    if ( hasErrors || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.world.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.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
项目:time4sys    文件:MemoryBrokerTimingPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (SrmViewsRepository.Timing.Properties.accessPolicy == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(SrmPackage.eINSTANCE.getMemoryBroker_AccessPolicy().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(SrmPackage.eINSTANCE.getMemoryBroker_AccessPolicy().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:neoscada    文件:OsgiEditor.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 )
{
    boolean hasErrors = !resource.getErrors ().isEmpty ();
    if ( hasErrors || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.world.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.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
项目:OCCI-Studio    文件:InfrastructureEditor.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    文件: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    文件:InfrastructureEditor.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 )
{
    boolean hasErrors = !resource.getErrors ().isEmpty ();
    if ( hasErrors || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.infrastructure.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.infrastructure.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
项目:time4sys    文件:GrmEditor.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);
}
项目: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);
}
项目:time4sys    文件:RequiredProtectionParameterPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * @generated
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (AnalysisViewsRepository.RequiredProtectionParameter.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:time4sys    文件:MutualExclusionResourcePropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * @generated
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
            if (AnalysisViewsRepository.MutualExclusionResource.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue);
                }
                ret = Diagnostician.INSTANCE.validate(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:gemoc-studio    文件:GexpressionsEditor.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    文件:GlobalizeEditor.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    文件:GlobalizeEditor.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 )
{
    boolean hasErrors = !resource.getErrors ().isEmpty ();
    if ( hasErrors || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.globalization.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.globalization.editor", //$NON-NLS-1$
                0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
项目:neoscada    文件:ComponentEditor.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 )
{
    boolean hasErrors = !resource.getErrors ().isEmpty ();
    if ( hasErrors || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic = new BasicDiagnostic ( hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.eclipse.scada.configuration.component.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.component.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
项目: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;
    }
}
项目:synthea_java    文件:CCDAExporterTest.java   
@Test
public void testCCDAExport() throws Exception {
  Config.set("exporter.baseDirectory", tempFolder.newFolder().toString());
  CDAUtil.loadPackages();
  List<String> validationErrors = new ArrayList<String>();

  int numberOfPeople = 10;
  Generator generator = new Generator(numberOfPeople);
  for (int i = 0; i < numberOfPeople; i++) {
    int x = validationErrors.size();
    TestHelper.exportOff();
    Person person = generator.generatePerson(i);
    Config.set("exporter.ccda.export", "true");
    String ccdaXml = CCDAExporter.export(person, System.currentTimeMillis());
    InputStream inputStream = IOUtils.toInputStream(ccdaXml, "UTF-8");
    try {
      CDAUtil.load(inputStream, new BasicValidationHandler() {
        public void handleError(Diagnostic diagnostic) {
          System.out.println("ERROR: " + diagnostic.getMessage());
          validationErrors.add(diagnostic.getMessage());
        }
      });
    } catch (Exception e) {
      e.printStackTrace();
    }
    int y = validationErrors.size();
    if (x != y) {
      Exporter.export(person, System.currentTimeMillis());
    }
  }

  assertEquals(0, validationErrors.size());
}
项目:n4js    文件:ExceptionAwareDiagnosticConverter.java   
private void handleExceptions(org.eclipse.emf.common.util.Diagnostic diagnostic) {
    if (Diagnostic.OK == diagnostic.getSeverity()) {
        return;
    }
    if (diagnostic instanceof BasicDiagnostic) {
        List<?> data = ((BasicDiagnostic) diagnostic).getData();
        for (Object entry : data) {
            if (entry instanceof Throwable) {
                throw new AssertionError(entry);
            }
        }
    }
}
项目:smarthome-cep-demonstrator    文件:SmarthomeEditor.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) {
    boolean hasErrors = !resource.getErrors().isEmpty();
    if (hasErrors || !resource.getWarnings().isEmpty()) {
        BasicDiagnostic basicDiagnostic =
            new BasicDiagnostic
                (hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING,
                 "com.incquerylabs.smarthome.model.simple.editor",
                 0,
                 getString("_UI_CreateModelError_message", resource.getURI()),
                 new Object [] { exception == null ? (Object)resource : exception });
        basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
        return basicDiagnostic;
    }
    else if (exception != null) {
        return
            new BasicDiagnostic
                (Diagnostic.ERROR,
                 "com.incquerylabs.smarthome.model.simple.editor",
                 0,
                 getString("_UI_CreateModelError_message", resource.getURI()),
                 new Object[] { exception });
    }
    else {
        return Diagnostic.OK_INSTANCE;
    }
}
项目:time4sys    文件:DynamicUsagePropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
项目:SimQRI    文件:StorageOutputFlowPropertiesEditionComponent.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * 
 */
public Diagnostic validateValue(IPropertiesEditionEvent event) {
    Diagnostic ret = Diagnostic.OK_INSTANCE;
    if (event.getNewValue() != null) {
        try {
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}