Search in sources :

Example 76 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project xtext-eclipse by eclipse.

the class DiagnosticTreeIterableTest method testIteratorIsNotConsumed.

@Test
public void testIteratorIsNotConsumed() {
    BasicDiagnostic root = new BasicDiagnostic();
    root.add(new BasicDiagnostic());
    AssertableDiagnostics diagnostics = new AssertableDiagnostics(root);
    Iterable<Diagnostic> allDiagnostics = diagnostics.getAllDiagnostics();
    Iterator<Diagnostic> first = allDiagnostics.iterator();
    while (first.hasNext()) {
        first.next();
    }
    Assert.assertTrue(allDiagnostics.iterator().hasNext());
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Diagnostic(org.eclipse.emf.common.util.Diagnostic) Test(org.junit.Test)

Example 77 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project xtext-eclipse by eclipse.

the class ValidatorTester method validator.

public T validator() {
    State s = validator.setMessageAcceptor(validator).getState();
    if (s.chain == null)
        s.chain = new BasicDiagnostic();
    validatorCalled = true;
    return validator;
}
Also used : State(org.eclipse.xtext.validation.AbstractDeclarativeValidator.State) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic)

Example 78 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project iobserve-analysis by research-iobserve.

the class cloudprofileEditor 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.iobserve.planning.cloudprofile.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) {
                CloudProfileEditorPlugin.INSTANCE.log(exception);
            }
        }
        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
            markerHelper.deleteMarkers(editingDomain.getResourceSet());
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                try {
                    markerHelper.createMarkers(diagnostic);
                } catch (CoreException exception) {
                    CloudProfileEditorPlugin.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 79 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project iobserve-analysis by research-iobserve.

the class systemadaptationEditor 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, "planning.systemadaptation.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) {
                systemadaptationEditorPlugin.INSTANCE.log(exception);
            }
        }
        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
            markerHelper.deleteMarkers(editingDomain.getResourceSet());
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                try {
                    markerHelper.createMarkers(diagnostic);
                } catch (CoreException exception) {
                    systemadaptationEditorPlugin.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 80 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project mylyn.docs by eclipse.

the class Publication method validateMetadata.

/**
 * Validates the data model contents.
 *
 * @return a list of EMF diagnostics
 */
public List<Diagnostic> validateMetadata() {
    EValidator.Registry.INSTANCE.put(OPFPackage.eINSTANCE, new OPFValidator());
    BasicDiagnostic diagnostics = new BasicDiagnostic();
    for (EObject eo : opfPackage.eContents()) {
        Map<Object, Object> context = new HashMap<Object, Object>();
        Diagnostician.INSTANCE.validate(eo, diagnostics, context);
    }
    return diagnostics.getChildren();
}
Also used : HashMap(java.util.HashMap) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) OPFValidator(org.eclipse.mylyn.docs.epub.opf.util.OPFValidator) EObject(org.eclipse.emf.ecore.EObject) EObject(org.eclipse.emf.ecore.EObject)

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