Search in sources :

Example 51 with BasicDiagnostic

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

the class systemadaptationEditor 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, "planning.systemadaptation.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, "planning.systemadaptation.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 52 with BasicDiagnostic

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

the class cloudprofileEditor 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.iobserve.planning.cloudprofile.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.iobserve.planning.cloudprofile.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 53 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project statecharts by Yakindu.

the class AbstractSTextValidationTest method setup.

@Before
public void setup() {
    factory = SGraphFactory.eINSTANCE;
    resource = new StextResource(URI.createURI(""));
    injector.injectMembers(resource);
    statechart = factory.createStatechart();
    resource.getContents().add(statechart);
    diagnostics = new BasicDiagnostic();
    tester = new ValidatorTester<STextJavaValidator>(validator, injector);
}
Also used : StextResource(org.yakindu.sct.model.stext.resource.StextResource) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) STextJavaValidator(org.yakindu.sct.model.stext.validation.STextJavaValidator) Before(org.junit.Before)

Example 54 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project statecharts by Yakindu.

the class SGraphJavaValidationTest method initialEntryWithMultipleOutgoingTransition.

/**
 * An entry should not have more than one outgoing transition
 */
@Test
public void initialEntryWithMultipleOutgoingTransition() {
    prepareStateTest();
    Entry entry = factory.createEntry();
    region.getVertices().add(entry);
    createTransition(entry, state);
    createTransition(entry, state);
    assertEquals(EntryKind.INITIAL, entry.getKind());
    assertFalse(validator.validate(entry, diagnostics, new HashMap<Object, Object>()));
    assertError(diagnostics, ISSUE_ENTRY_WITH_MULTIPLE_OUT_TRANS);
    entry.setKind(EntryKind.SHALLOW_HISTORY);
    diagnostics = new BasicDiagnostic();
    assertFalse(validator.validate(entry, diagnostics, new HashMap<Object, Object>()));
    assertError(diagnostics, ISSUE_ENTRY_WITH_MULTIPLE_OUT_TRANS);
    entry.setKind(EntryKind.DEEP_HISTORY);
    diagnostics = new BasicDiagnostic();
    assertFalse(validator.validate(entry, diagnostics, new HashMap<Object, Object>()));
    assertError(diagnostics, ISSUE_ENTRY_WITH_MULTIPLE_OUT_TRANS);
}
Also used : Entry(org.yakindu.sct.model.sgraph.Entry) HashMap(java.util.HashMap) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Test(org.junit.Test)

Example 55 with BasicDiagnostic

use of org.eclipse.emf.common.util.BasicDiagnostic in project statecharts by Yakindu.

the class SGraphJavaValidationTest method assertWarning.

protected void assertWarning(BasicDiagnostic diag, String message) {
    Diagnostic d = issueByName(diag, message);
    assertNotNull("Issue '" + message + "' does not exist.", issueByName(diag, message));
    assertEquals("Issue '" + message + "' is no warning.", Diagnostic.WARNING, d.getSeverity());
}
Also used : BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Diagnostic(org.eclipse.emf.common.util.Diagnostic)

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