Search in sources :

Example 96 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic 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 97 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic 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 98 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic 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)

Example 99 with Diagnostic

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

the class ScaffoldEditor method createModel.

/**
 * 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);
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) IResource(org.eclipse.core.resources.IResource) Diagnostic(org.eclipse.emf.common.util.Diagnostic) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) URI(org.eclipse.emf.common.util.URI) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) IOException(java.io.IOException)

Example 100 with Diagnostic

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

the class TypesLibraryEditor method createModel.

/**
 * 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);
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) IResource(org.eclipse.core.resources.IResource) Diagnostic(org.eclipse.emf.common.util.Diagnostic) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) URI(org.eclipse.emf.common.util.URI) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) IOException(java.io.IOException)

Aggregations

Diagnostic (org.eclipse.emf.common.util.Diagnostic)354 BasicDiagnostic (org.eclipse.emf.common.util.BasicDiagnostic)223 EObject (org.eclipse.emf.ecore.EObject)148 WrappedException (org.eclipse.emf.common.util.WrappedException)113 Test (org.junit.Test)89 PartInitException (org.eclipse.ui.PartInitException)88 CoreException (org.eclipse.core.runtime.CoreException)73 Resource (org.eclipse.emf.ecore.resource.Resource)66 XtextResource (org.eclipse.xtext.resource.XtextResource)60 IOException (java.io.IOException)56 URI (org.eclipse.emf.common.util.URI)56 Point (org.eclipse.swt.graphics.Point)45 ProblemEditorPart (org.eclipse.emf.common.ui.editor.ProblemEditorPart)44 IResource (org.eclipse.core.resources.IResource)37 List (java.util.List)13 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)13 ArrayList (java.util.ArrayList)11 AbstractValidationDiagnostic (org.eclipse.xtext.validation.AbstractValidationDiagnostic)11 File (java.io.File)10 Iterator (java.util.Iterator)10