Search in sources :

Example 96 with BasicDiagnostic

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

the class SoaEditor method updateProblemIndication.

/**
 * Updates the problems indication with the information described in the specified diagnostic.
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void updateProblemIndication() {
    if (updateProblemIndication) {
        BasicDiagnostic diagnostic = new BasicDiagnostic(Diagnostic.OK, "org.obeonetwork.dsl.soa.editor", 0, null, new Object[] { editingDomain.getResourceSet() });
        for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) {
            if (childDiagnostic.getSeverity() != Diagnostic.OK) {
                diagnostic.add(childDiagnostic);
            }
        }
        int lastEditorPage = getPageCount() - 1;
        if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) {
            ((ProblemEditorPart) getEditor(lastEditorPage)).setDiagnostic(diagnostic);
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                setActivePage(lastEditorPage);
            }
        } else if (diagnostic.getSeverity() != Diagnostic.OK) {
            ProblemEditorPart problemEditorPart = new ProblemEditorPart();
            problemEditorPart.setDiagnostic(diagnostic);
            problemEditorPart.setMarkerHelper(markerHelper);
            try {
                addPage(++lastEditorPage, problemEditorPart, getEditorInput());
                setPageText(lastEditorPage, problemEditorPart.getPartName());
                setActivePage(lastEditorPage);
                showTabs();
            } catch (PartInitException exception) {
                SoaEditorPlugin.INSTANCE.log(exception);
            }
        }
        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
            markerHelper.deleteMarkers(editingDomain.getResourceSet());
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                try {
                    markerHelper.createMarkers(diagnostic);
                } catch (CoreException exception) {
                    SoaEditorPlugin.INSTANCE.log(exception);
                }
            }
        }
    }
}
Also used : ProblemEditorPart(org.eclipse.emf.common.ui.editor.ProblemEditorPart) CoreException(org.eclipse.core.runtime.CoreException) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Diagnostic(org.eclipse.emf.common.util.Diagnostic) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) PartInitException(org.eclipse.ui.PartInitException) Point(org.eclipse.swt.graphics.Point)

Example 97 with BasicDiagnostic

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

the class InitialStateInitialStatePropertiesEditionComponent 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.InitialState.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.InitialState.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 98 with BasicDiagnostic

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

the class StateStatePropertiesEditionComponent 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.State.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.State.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.State.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 BasicDiagnostic

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

the class TransitionTransitionPropertiesEditionComponent 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.Transition.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.Transition.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.Transition.Properties.guard == event.getAffectedEditor()) {
                Object newValue = event.getNewValue();
                if (newValue instanceof String) {
                    newValue = EEFConverterUtil.createFromString(StateMachinePackage.eINSTANCE.getTransition_Guard().getEAttributeType(), (String) newValue);
                }
                ret = Diagnostician.INSTANCE.validate(StateMachinePackage.eINSTANCE.getTransition_Guard().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 100 with BasicDiagnostic

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

the class RequirementEditor 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.requirement.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.requirement.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)

Aggregations

BasicDiagnostic (org.eclipse.emf.common.util.BasicDiagnostic)107 Diagnostic (org.eclipse.emf.common.util.Diagnostic)50 EObject (org.eclipse.emf.ecore.EObject)43 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)20 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