Java Code Examples for org.eclipse.emf.common.util.BasicDiagnostic

The following examples show how to use org.eclipse.emf.common.util.BasicDiagnostic. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: neoscada   Source File: ProtocolEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 )
{
    if ( !resource.getErrors ().isEmpty () || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic =
                new BasicDiagnostic
                ( Diagnostic.ERROR, "org.eclipse.scada.protocol.ngp.model.editor", //$NON-NLS-1$
                        0,
                        getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                        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.eclipse.scada.protocol.ngp.model.editor", //$NON-NLS-1$
                0,
                getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 2
Source Project: neoscada   Source File: ValidationContextImpl.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void add ( final Severity severity, Object[] data, final String message, final Object... arguments )
{
    if ( data == null )
    {
        data = new Object[] { this.target };
    }

    String formattedMessage;

    if ( arguments == null || arguments.length <= 0 )
    {
        formattedMessage = message;
    }
    else
    {
        formattedMessage = MessageFormat.format ( message, arguments );
    }

    final int severityCode = severity == null ? Diagnostic.OK : severity.getSeverityCode ();
    this.result.add ( new BasicDiagnostic ( severityCode, this.source, 0, formattedMessage, data ) );
}
 
Example 3
Source Project: neoscada   Source File: ChartEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 ( final Resource resource,
        final Exception exception )
{
    if ( !resource.getErrors ().isEmpty ()
            || !resource.getWarnings ().isEmpty () )
    {
        final BasicDiagnostic basicDiagnostic = new BasicDiagnostic (
                Diagnostic.ERROR, "org.eclipse.scada.ui.chart.model.editor", //$NON-NLS-1$
                0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                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.eclipse.scada.ui.chart.model.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 4
Source Project: neoscada   Source File: DetailViewEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 )
{
    if ( !resource.getErrors ().isEmpty () || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic =
                new BasicDiagnostic
                ( Diagnostic.ERROR, "org.eclipse.scada.vi.details.model.editor", //$NON-NLS-1$
                        0,
                        getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                        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.eclipse.scada.vi.details.model.editor", //$NON-NLS-1$
                0,
                getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 5
Source Project: neoscada   Source File: VisualInterfaceEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.vi.model.editor", //$NON-NLS-1$
                0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                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.eclipse.scada.vi.model.editor", //$NON-NLS-1$
                0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 6
/**
 * Validates the MemberTypes constraint of '<em>Type Type</em>'.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validateTypeType_MemberTypes(Object typeType, DiagnosticChain diagnostics, Map<Object, Object> context) {
	if (diagnostics != null) {
		BasicDiagnostic tempDiagnostics = new BasicDiagnostic();
		if (jpdl32Package.Literals.TYPE_TYPE_MEMBER0.isInstance(typeType)) {
			if (validateTypeTypeMember0((String)typeType, tempDiagnostics, context)) return true;
		}
		if (jpdl32Package.Literals.TYPE_TYPE_MEMBER1.isInstance(typeType)) {
			if (validateTypeTypeMember1((TypeTypeMember1)typeType, tempDiagnostics, context)) return true;
		}
		for (Diagnostic diagnostic : tempDiagnostics.getChildren()) {
			diagnostics.add(diagnostic);
		}
	}
	else {
		if (jpdl32Package.Literals.TYPE_TYPE_MEMBER0.isInstance(typeType)) {
			if (validateTypeTypeMember0((String)typeType, null, context)) return true;
		}
		if (jpdl32Package.Literals.TYPE_TYPE_MEMBER1.isInstance(typeType)) {
			if (validateTypeTypeMember1((TypeTypeMember1)typeType, null, context)) return true;
		}
	}
	return false;
}
 
Example 7
Source Project: neoscada   Source File: SetupEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.configuration.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        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.eclipse.scada.configuration.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 8
Source Project: neoscada   Source File: ProfileEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.configuration.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        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.eclipse.scada.configuration.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 9
Source Project: neoscada   Source File: OsgiEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.configuration.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        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.eclipse.scada.configuration.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 10
Source Project: neoscada   Source File: WorldEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.configuration.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        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.eclipse.scada.configuration.world.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 11
Source Project: neoscada   Source File: MemoryEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.configuration.memory.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.eclipse.scada.configuration.memory.editor", 0, getString ( "_UI_CreateModelError_message", resource.getURI () ), new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 12
Source Project: neoscada   Source File: RecipeEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.configuration.recipe.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        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.eclipse.scada.configuration.recipe.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 13
Source Project: neoscada   Source File: InfrastructureEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.configuration.infrastructure.editor", //$NON-NLS-1$
                0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                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.eclipse.scada.configuration.infrastructure.editor", //$NON-NLS-1$
                0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 14
Source Project: neoscada   Source File: SecurityEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 )
{
    if ( !resource.getErrors ().isEmpty () || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic =
                new BasicDiagnostic
                ( Diagnostic.ERROR, "org.eclipse.scada.configuration.security.editor", //$NON-NLS-1$
                        0,
                        getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                        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.eclipse.scada.configuration.security.editor", //$NON-NLS-1$
                0,
                getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 15
Source Project: neoscada   Source File: GlobalizeEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.configuration.globalization.editor", //$NON-NLS-1$
                0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                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.eclipse.scada.configuration.globalization.editor", //$NON-NLS-1$
                0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 16
Source Project: neoscada   Source File: ComponentEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.eclipse.scada.configuration.component.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        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.eclipse.scada.configuration.component.editor", //$NON-NLS-1$
        0, getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
        new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 17
Source Project: neoscada   Source File: ItemEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 )
{
    if ( !resource.getErrors ().isEmpty () || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic =
                new BasicDiagnostic
                ( Diagnostic.ERROR, "org.eclipse.scada.configuration.item.editor", //$NON-NLS-1$
                        0,
                        getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                        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.eclipse.scada.configuration.item.editor", //$NON-NLS-1$
                0,
                getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 18
Source Project: neoscada   Source File: ConfigurationEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 )
{
    if ( !resource.getErrors ().isEmpty () || !resource.getWarnings ().isEmpty () )
    {
        BasicDiagnostic basicDiagnostic =
                new BasicDiagnostic
                ( Diagnostic.ERROR, "org.eclipse.scada.da.server.exec.editor", //$NON-NLS-1$
                        0,
                        getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                        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.eclipse.scada.da.server.exec.editor", //$NON-NLS-1$
                0,
                getString ( "_UI_CreateModelError_message", resource.getURI () ), //$NON-NLS-1$
                new Object[] { exception } );
    }
    else
    {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 19
Source Project: M2Doc   Source File: GenconfEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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.m2doc.genconf.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.m2doc.genconf.editor", 0,
                getString("_UI_CreateModelError_message", resource.getURI()), new Object[] {exception});
    } else {
        return Diagnostic.OK_INSTANCE;
    }
}
 
Example 20
/** Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=396726 */
@Test
public void testNoShortCircuiting() {
	CompositeEValidator compositeValidator = new CompositeEValidator();
	compositeValidator.setEqualitySupportProvider(CompositeEValidator.EValidatorEqualitySupport::new);
	assertEquals(1, compositeValidator.getContents().size());

	compositeValidator.addValidator(EcoreValidator.INSTANCE);
	assertEquals(2, compositeValidator.getContents().size());

	TestEcoreValidator testValidator = new TestEcoreValidator();
	compositeValidator.addValidator(testValidator);
	assertEquals(3, compositeValidator.getContents().size());
	
	compositeValidator.validate(EcoreFactory.eINSTANCE.createEClass(), new BasicDiagnostic(), null);
	assertTrue(testValidator.wasCalled());
}
 
Example 21
@Test public void testBug_279962() {
	EValidator validator = registry.getEValidator(pack);
	assertTrue(validator instanceof CompositeEValidator);
	CompositeEValidator composite = (CompositeEValidator) validator;
	
	int prevSize = composite.getContents().size();
	
	get(Val_279962_01.class);
	get(Val_279962_04.class);
	assertEquals(prevSize + 2, composite.getContents().size());
	assertNotNull(validator);
	Resource resource = get(XtextResource.class);
	Model model = EnumRulesTestLanguageFactory.eINSTANCE.createModel();
	resource.getContents().add(model);
	// do not expect an exception
	validator.validate(model, new BasicDiagnostic(), null);
	assertEquals(prevSize + 4, composite.getContents().size());
}
 
Example 22
@Test public void testError() {
	AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
		@Check
		public void foo(Object x) {
			error("Error Message", EcorePackage.Literals.ENAMED_ELEMENT__NAME);
		}
	};
	BasicDiagnostic chain = new BasicDiagnostic();
	test.validate(EcorePackage.eINSTANCE.getEClass(), chain, Collections.emptyMap());
	assertEquals(1, chain.getChildren().size());

	Diagnostic diag = chain.getChildren().get(0);
	assertEquals("Error Message", diag.getMessage());
	assertEquals(EcorePackage.eINSTANCE.getEClass().toString(), diag.getSource());
	assertEquals(Diagnostic.ERROR, diag.getSeverity());
}
 
Example 23
@Test public void testErrorWithSource() {
	AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
		@Check
		public void foo(Object x) {
			error(
					"Error Message", 
					EcorePackage.eINSTANCE.getEAnnotation(), 
					EcorePackage.Literals.ENAMED_ELEMENT__NAME,
					ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
		}
	};
	BasicDiagnostic chain = new BasicDiagnostic();
	test.validate(EcorePackage.eINSTANCE.getEClass(), chain, Collections.emptyMap());
	assertEquals(1, chain.getChildren().size());

	Diagnostic diag = chain.getChildren().get(0);
	assertEquals("Error Message", diag.getMessage());
	assertEquals(EcorePackage.eINSTANCE.getEAnnotation().toString(), diag.getSource());
	assertEquals(Diagnostic.ERROR, diag.getSeverity());
}
 
Example 24
@Test public void testErrorWithCode() {
	AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
		@Check
		public void foo(Object x) {
			error(
					"Error Message", 
					EcorePackage.Literals.ENAMED_ELEMENT__NAME,
					ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
					"42");
		}
	};
	BasicDiagnostic chain = new BasicDiagnostic();
	test.validate(EcorePackage.eINSTANCE.getEClass(), chain, Collections.emptyMap());
	assertEquals(1, chain.getChildren().size());

	Diagnostic diag = chain.getChildren().get(0);
	assertEquals("Error Message", diag.getMessage());
	assertEquals(0, diag.getCode());
	assertTrue(diag instanceof FeatureBasedDiagnostic);
	assertEquals("42", ((FeatureBasedDiagnostic)diag).getIssueCode());
	assertEquals(Diagnostic.ERROR, diag.getSeverity());
}
 
Example 25
@Test public void testWarning() {
	AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
		@Check
		public void foo(Object x) {
			warning("Error Message", EcorePackage.Literals.ENAMED_ELEMENT__NAME);
		}
	};
	BasicDiagnostic chain = new BasicDiagnostic();
	test.validate(EcorePackage.eINSTANCE.getEClass(), chain, Collections.emptyMap());
	assertEquals(1, chain.getChildren().size());

	Diagnostic diag = chain.getChildren().get(0);
	assertEquals("Error Message", diag.getMessage());
	assertEquals(EcorePackage.eINSTANCE.getEClass().toString(), diag.getSource());
	assertEquals(Diagnostic.WARNING, diag.getSeverity());
}
 
Example 26
@Test public void testWarningWithSource() {
	AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
		@Check
		public void foo(Object x) {
			warning(
					"Error Message", 
					EcorePackage.eINSTANCE.getEAnnotation(), 
					EcorePackage.Literals.ENAMED_ELEMENT__NAME,
					ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
		}
	};
	BasicDiagnostic chain = new BasicDiagnostic();
	test.validate(EcorePackage.eINSTANCE.getEClass(), chain, Collections.emptyMap());
	assertEquals(1, chain.getChildren().size());

	Diagnostic diag = chain.getChildren().get(0);
	assertEquals("Error Message", diag.getMessage());
	assertEquals(EcorePackage.eINSTANCE.getEAnnotation().toString(), diag.getSource());
	assertEquals(Diagnostic.WARNING, diag.getSeverity());
}
 
Example 27
@Test public void testWarningWithCode() {
	AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
		@Check
		public void foo(Object x) {
			warning(
					"Error Message", 
					EcorePackage.Literals.ENAMED_ELEMENT__NAME,
					ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
					"42");
		}
	};
	BasicDiagnostic chain = new BasicDiagnostic();
	test.validate(EcorePackage.eINSTANCE.getEClass(), chain, Collections.emptyMap());
	assertEquals(1, chain.getChildren().size());

	Diagnostic diag = chain.getChildren().get(0);
	assertEquals("Error Message", diag.getMessage());
	assertEquals(0, diag.getCode());
	assertTrue(diag instanceof FeatureBasedDiagnostic);
	assertEquals("42", ((FeatureBasedDiagnostic)diag).getIssueCode());
	assertEquals(Diagnostic.WARNING, diag.getSeverity());
}
 
Example 28
Source Project: dsl-devkit   Source File: AbstractValidationTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create an error message (if needed) based on the given input parameters.
 *
 * @param pos
 *          position in the source to associate the message with
 * @param diagnosticsOnTargetPosition
 *          diagnostics on the specifies position
 * @param issueFound
 *          specifies whether an issue has been found at the given position
 * @param expectedSeverityMatches
 *          true if expected severity equals actual one, false otherwise
 * @param actualSeverity
 *          actual severity
 * @param expectedMessageMatches
 *          expected message matches
 * @param actualMessage
 *          actual message
 */
private void createErrorMessage(final Integer pos, final BasicDiagnostic diagnosticsOnTargetPosition, final boolean issueFound, final boolean expectedSeverityMatches, final int actualSeverity, final boolean expectedMessageMatches, final String actualMessage) {
  StringBuilder errorMessage = new StringBuilder(MINIMAL_STRINGBUILDER_CAPACITY);
  if (issueMustBeFound && !issueFound) {
    errorMessage.append("Expected issue not found. Code '" + issueCode + "'\n");
  } else if (!issueMustBeFound && issueFound) {
    errorMessage.append("There should be no issue with the code '" + issueCode + DOT_AND_LINEBREAK);
  }
  if (issueFound && !expectedMessageMatches) {
    errorMessage.append("Expected message does not match. Expected: '" + message + "', Actual: '" + actualMessage + "'\n");
  }
  // If the expected issue has been found, but the actual severity does not match with expected one
  if (issueMustBeFound && issueFound && !expectedSeverityMatches) {
    errorMessage.append("Severity does not match. Expected: " + CODE_TO_NAME.get(expectedSeverity) + ". Actual: " + CODE_TO_NAME.get(actualSeverity)
        + ".\n");
  }
  // Memorize error message
  if (errorMessage.length() > 0) {
    if (!diagnosticsOnTargetPosition.getChildren().isEmpty()) {
      errorMessage.append("  All issues at this position:\n");
      errorMessage.append(diagnosticsToString(diagnosticsOnTargetPosition, false));
    }
    memorizeErrorOnPosition(pos, errorMessage.toString());
  }
}
 
Example 29
Source Project: statecharts   Source File: DomainValidator.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
	if (eObject instanceof DomainElement) {
		DomainStatus status = DomainRegistry.getDomainStatus(((DomainElement) eObject).getDomainID());
		if (status.getSeverity() == Severity.ERROR) {
			diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, "DomainValidator", 0, status.getShortMessage(),
					new Object[] { eObject }));
		} else if (status.getSeverity() == Severity.WARNING) {
			diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, "DomainValidator", 0, status.getMessage(),
					new Object[] { eObject }));
		} else if (status.getSeverity() == Severity.INFO) {
			diagnostics.add(new BasicDiagnostic(Diagnostic.INFO, "DomainValidator", 0, status.getShortMessage(),
					new Object[] { eObject }));
		}
	}
	return true;
}
 
Example 30
/**
 * {@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 (EipViewsRepository.ServiceActivator.Properties.name == event.getAffectedEditor()) {
				Object newValue = event.getNewValue();
				if (newValue instanceof String) {
					newValue = EEFConverterUtil.createFromString(EipPackage.eINSTANCE.getEndpoint_Name().getEAttributeType(), (String)newValue);
				}
				ret = Diagnostician.INSTANCE.validate(EipPackage.eINSTANCE.getEndpoint_Name().getEAttributeType(), newValue);
			}
		} catch (IllegalArgumentException iae) {
			ret = BasicDiagnostic.toDiagnostic(iae);
		} catch (WrappedException we) {
			ret = BasicDiagnostic.toDiagnostic(we);
		}
	}
	return ret;
}