Search in sources :

Example 1 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project Malai by arnobl.

the class ActionEditor 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 2 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project Malai by arnobl.

the class ActionEditor 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.malai.model.action.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) {
                ActionEditorPlugin.INSTANCE.log(exception);
            }
        }
        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
            markerHelper.deleteMarkers(editingDomain.getResourceSet());
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                try {
                    markerHelper.createMarkers(diagnostic);
                } catch (CoreException exception) {
                    ActionEditorPlugin.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 3 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project Malai by arnobl.

the class EventEditor 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 4 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project Malai by arnobl.

the class InstrumentEditor 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.malai.model.instrument.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) {
                InstrumentEditorPlugin.INSTANCE.log(exception);
            }
        }
        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
            markerHelper.deleteMarkers(editingDomain.getResourceSet());
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                try {
                    markerHelper.createMarkers(diagnostic);
                } catch (CoreException exception) {
                    InstrumentEditorPlugin.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 5 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project Malai by arnobl.

the class InteractionEditor 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.malai.model.interaction.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) {
                MalaiInteractionEditorPlugin.INSTANCE.log(exception);
            }
        }
        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
            markerHelper.deleteMarkers(editingDomain.getResourceSet());
            if (diagnostic.getSeverity() != Diagnostic.OK) {
                try {
                    markerHelper.createMarkers(diagnostic);
                } catch (CoreException exception) {
                    MalaiInteractionEditorPlugin.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

Diagnostic (org.eclipse.emf.common.util.Diagnostic)280 BasicDiagnostic (org.eclipse.emf.common.util.BasicDiagnostic)191 EObject (org.eclipse.emf.ecore.EObject)135 WrappedException (org.eclipse.emf.common.util.WrappedException)113 Test (org.junit.Test)71 CoreException (org.eclipse.core.runtime.CoreException)61 PartInitException (org.eclipse.ui.PartInitException)60 XtextResource (org.eclipse.xtext.resource.XtextResource)56 Resource (org.eclipse.emf.ecore.resource.Resource)42 IOException (java.io.IOException)36 URI (org.eclipse.emf.common.util.URI)35 IResource (org.eclipse.core.resources.IResource)31 ProblemEditorPart (org.eclipse.emf.common.ui.editor.ProblemEditorPart)30 Point (org.eclipse.swt.graphics.Point)30 AbstractValidationDiagnostic (org.eclipse.xtext.validation.AbstractValidationDiagnostic)9 Iterator (java.util.Iterator)8 List (java.util.List)8 BasicEList (org.eclipse.emf.common.util.BasicEList)8 EList (org.eclipse.emf.common.util.EList)8 File (java.io.File)6