Search in sources :

Example 26 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.

the class StateMachineEditor method analyzeResourceProblems.

/**
 * 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.obeonetwork.dsl.statemachine.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.obeonetwork.dsl.statemachine.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception });
    } else {
        return Diagnostic.OK_INSTANCE;
    }
}
Also used : BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) EventObject(java.util.EventObject) EObject(org.eclipse.emf.ecore.EObject)

Example 27 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.

the class SoaEditor method analyzeResourceProblems.

/**
 * 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.obeonetwork.dsl.soa.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.obeonetwork.dsl.soa.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception });
    } else {
        return Diagnostic.OK_INSTANCE;
    }
}
Also used : BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) EventObject(java.util.EventObject) EObject(org.eclipse.emf.ecore.EObject)

Example 28 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.

the class FinalStateFinalStatePropertiesEditionComponent method validateValue.

/**
 * {@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 (StatemachineViewsRepository.FinalState.Properties.description == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), (String) newValue);
                }
                ret = Diagnostician.INSTANCE.validate(EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), newValue);
            }
            if (StatemachineViewsRepository.FinalState.Properties.keywords == event.getAffectedEditor()) {
                BasicDiagnostic chain = new BasicDiagnostic();
                for (Iterator iterator = ((List) event.getNewValue()).iterator(); iterator.hasNext(); ) {
                    chain.add(Diagnostician.INSTANCE.validate(EnvironmentPackage.eINSTANCE.getObeoDSMObject_Keywords().getEAttributeType(), iterator.next()));
                }
                ret = chain;
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
Also used : WrappedException(org.eclipse.emf.common.util.WrappedException) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Iterator(java.util.Iterator) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Diagnostic(org.eclipse.emf.common.util.Diagnostic) EObject(org.eclipse.emf.ecore.EObject) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 29 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.

the class RegionRegionPropertiesEditionComponent method validateValue.

/**
 * {@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 (StatemachineViewsRepository.Region.Properties.description == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), (String) newValue);
                }
                ret = Diagnostician.INSTANCE.validate(EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), newValue);
            }
            if (StatemachineViewsRepository.Region.Properties.keywords == event.getAffectedEditor()) {
                BasicDiagnostic chain = new BasicDiagnostic();
                for (Iterator iterator = ((List) event.getNewValue()).iterator(); iterator.hasNext(); ) {
                    chain.add(Diagnostician.INSTANCE.validate(EnvironmentPackage.eINSTANCE.getObeoDSMObject_Keywords().getEAttributeType(), iterator.next()));
                }
                ret = chain;
            }
            if (StatemachineViewsRepository.Region.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(StateMachinePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String) newValue);
                }
                ret = Diagnostician.INSTANCE.validate(StateMachinePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
Also used : WrappedException(org.eclipse.emf.common.util.WrappedException) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Iterator(java.util.Iterator) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Diagnostic(org.eclipse.emf.common.util.Diagnostic) EObject(org.eclipse.emf.ecore.EObject) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 30 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.

the class StateMachineStateMachinePropertiesEditionComponent method validateValue.

/**
 * {@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 (StatemachineViewsRepository.StateMachine_.Properties.description == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), (String) newValue);
                }
                ret = Diagnostician.INSTANCE.validate(EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), newValue);
            }
            if (StatemachineViewsRepository.StateMachine_.Properties.keywords == event.getAffectedEditor()) {
                BasicDiagnostic chain = new BasicDiagnostic();
                for (Iterator iterator = ((List) event.getNewValue()).iterator(); iterator.hasNext(); ) {
                    chain.add(Diagnostician.INSTANCE.validate(EnvironmentPackage.eINSTANCE.getObeoDSMObject_Keywords().getEAttributeType(), iterator.next()));
                }
                ret = chain;
            }
            if (StatemachineViewsRepository.StateMachine_.Properties.name == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(StateMachinePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String) newValue);
                }
                ret = Diagnostician.INSTANCE.validate(StateMachinePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
            }
        } catch (IllegalArgumentException iae) {
            ret = BasicDiagnostic.toDiagnostic(iae);
        } catch (WrappedException we) {
            ret = BasicDiagnostic.toDiagnostic(we);
        }
    }
    return ret;
}
Also used : WrappedException(org.eclipse.emf.common.util.WrappedException) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Iterator(java.util.Iterator) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Diagnostic(org.eclipse.emf.common.util.Diagnostic) EObject(org.eclipse.emf.ecore.EObject) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Aggregations

BasicDiagnostic (org.eclipse.emf.common.util.BasicDiagnostic)103 Diagnostic (org.eclipse.emf.common.util.Diagnostic)48 EObject (org.eclipse.emf.ecore.EObject)41 EventObject (java.util.EventObject)30 CoreException (org.eclipse.core.runtime.CoreException)30 ProblemEditorPart (org.eclipse.emf.common.ui.editor.ProblemEditorPart)30 Point (org.eclipse.swt.graphics.Point)30 PartInitException (org.eclipse.ui.PartInitException)30 Test (org.junit.Test)16 List (java.util.List)13 Iterator (java.util.Iterator)8 BasicEList (org.eclipse.emf.common.util.BasicEList)8 EList (org.eclipse.emf.common.util.EList)8 WrappedException (org.eclipse.emf.common.util.WrappedException)8 Diagnostic (org.eclipse.emf.ecore.resource.Resource.Diagnostic)5 ExceptionDiagnostic (org.eclipse.xtext.diagnostics.ExceptionDiagnostic)5 Severity (org.eclipse.xtext.diagnostics.Severity)5 IDiagnosticConverter (org.eclipse.xtext.validation.IDiagnosticConverter)5 Issue (org.eclipse.xtext.validation.Issue)5 ResourceValidatorImpl (org.eclipse.xtext.validation.ResourceValidatorImpl)5