Search in sources :

Example 91 with BasicDiagnostic

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

the class EntityEditor 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.entity.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) {
                EntityEditorPlugin.INSTANCE.log(exception);
            }
        }
        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
            markerHelper.deleteMarkers(editingDomain.getResourceSet());
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                try {
                    markerHelper.createMarkers(diagnostic);
                } catch (CoreException exception) {
                    EntityEditorPlugin.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 92 with BasicDiagnostic

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

the class EntityEditor 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.entity.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.entity.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)

Example 93 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project metalib by softlang.

the class FsmlEditor 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.softlang.metalib.emf.fsml.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) {
                FsmlEditorPlugin.INSTANCE.log(exception);
            }
        }
        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
            markerHelper.deleteMarkers(editingDomain.getResourceSet());
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                try {
                    markerHelper.createMarkers(diagnostic);
                } catch (CoreException exception) {
                    FsmlEditorPlugin.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 94 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project metalib by softlang.

the class FsmlEditor 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.softlang.metalib.emf.fsml.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.softlang.metalib.emf.fsml.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)

Example 95 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project metalib by softlang.

the class FsmlEditor 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.softlang.metalib.sirius.fsml.model.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) {
                FsmlEditorPlugin.INSTANCE.log(exception);
            }
        }
        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
            markerHelper.deleteMarkers(editingDomain.getResourceSet());
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                try {
                    markerHelper.createMarkers(diagnostic);
                } catch (CoreException exception) {
                    FsmlEditorPlugin.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)

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