Java Code Examples for org.eclipse.emf.common.util.Diagnostic#OK

The following examples show how to use org.eclipse.emf.common.util.Diagnostic#OK . 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 check out the related API usage on the sidebar.
Example 1
Source File: ComponentEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 (), editingDomain.getResourceSet ().getURIConverter () );
    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 );
}
 
Example 2
Source File: ValidateAction.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private static void createMarkers(IFile target, Diagnostic emfValidationStatus, DiagramEditPart diagramEditPart) {
	if (emfValidationStatus.getSeverity() == Diagnostic.OK) {
		return;
	}
	final Diagnostic rootStatus = emfValidationStatus;
	List allDiagnostics = new ArrayList();
	CrossflowDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new CrossflowDiagramEditorUtil.LazyElement2ViewMap(
			diagramEditPart.getDiagramView(),
			collectTargetElements(rootStatus, new HashSet<EObject>(), allDiagnostics));
	for (Iterator it = emfValidationStatus.getChildren().iterator(); it.hasNext();) {
		Diagnostic nextDiagnostic = (Diagnostic) it.next();
		List data = nextDiagnostic.getData();
		if (data != null && !data.isEmpty() && data.get(0) instanceof EObject) {
			EObject element = (EObject) data.get(0);
			View view = CrossflowDiagramEditorUtil.findView(diagramEditPart, element, element2ViewMap);
			addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view),
					EMFCoreUtil.getQualifiedName(element, true), nextDiagnostic.getMessage(),
					diagnosticToStatusSeverity(nextDiagnostic.getSeverity()));
		}
	}
}
 
Example 3
Source File: ConfigurationEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 );
}
 
Example 4
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void diagnose(Diagnostic diagnostic, URI[] expectedUnresolvedProxies) {
	if (diagnostic.getChildren().isEmpty()) {
		if (diagnostic.getSeverity() != Diagnostic.OK) {
			if (diagnostic.getCode() == EObjectValidator.EOBJECT__EVERY_PROXY_RESOLVES) {
				EObject proxy = (EObject) diagnostic.getData().get(2); // magic number ...
				if (org.eclipse.xtext.util.Arrays.contains(expectedUnresolvedProxies, EcoreUtil.getURI(proxy))) {
					return;
				}
			}
			assertEquals(String.valueOf(diagnostic), diagnostic.getSeverity() == Diagnostic.OK);
		}
	} else {
		for (Diagnostic child : diagnostic.getChildren()) {
			diagnose(child, expectedUnresolvedProxies);
		}
	}
}
 
Example 5
Source File: ItemEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 );
}
 
Example 6
Source File: DeploymentEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 (), editingDomain.getResourceSet ().getURIConverter () );
    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 );
}
 
Example 7
Source File: VisualInterfaceEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 );
}
 
Example 8
Source File: CrossflowEditor.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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(), editingDomain.getResourceSet().getURIConverter());
	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);
}
 
Example 9
Source File: DetailViewEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 );
}
 
Example 10
Source File: MemoryEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 (), editingDomain.getResourceSet ().getURIConverter () );
    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 );
}
 
Example 11
Source File: BeansEditor.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyChanged(Notification notification) {
	if (notification.getNotifier() instanceof Resource) {
		switch (notification.getFeatureID(Resource.class)) {
			case Resource.RESOURCE__IS_LOADED:
			case Resource.RESOURCE__ERRORS:
			case Resource.RESOURCE__WARNINGS: {
				Resource resource = (Resource)notification.getNotifier();
				Diagnostic diagnostic = analyzeResourceProblems(resource, null);
				if (diagnostic.getSeverity() != Diagnostic.OK) {
					resourceToDiagnosticMap.put(resource, diagnostic);
				}
				else {
					resourceToDiagnosticMap.remove(resource);
				}

				if (updateProblemIndication) {
					getSite().getShell().getDisplay().asyncExec
						(new Runnable() {
							 public void run() {
								 updateProblemIndication();
							 }
						 });
				}
				break;
			}
		}
	}
	else {
		super.notifyChanged(notification);
	}
}
 
Example 12
Source File: ChartEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 ()
{
    final URI resourceURI = EditUIUtil.getURI ( getEditorInput () );
    Exception exception = null;
    Resource resource = null;
    try
    {
        // Load the resource through the editing domain.
        //
        resource = this.editingDomain.getResourceSet ().getResource ( resourceURI,
                true );
    }
    catch ( final Exception e )
    {
        exception = e;
        resource = this.editingDomain.getResourceSet ().getResource ( resourceURI,
                false );
    }

    final Diagnostic diagnostic = analyzeResourceProblems ( resource, exception );
    if ( diagnostic.getSeverity () != Diagnostic.OK )
    {
        this.resourceToDiagnosticMap.put ( resource,
                analyzeResourceProblems ( resource, exception ) );
    }
    this.editingDomain.getResourceSet ().eAdapters ()
            .add ( this.problemIndicationAdapter );
}
 
Example 13
Source File: XtextValidator.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private void propageValidationResult(Diagnostic diagnostic, GeneratedMetamodel metamodel, ValidationMessageAcceptor acceptor) {
	if (diagnostic.getSeverity() != Diagnostic.OK) {
		if (diagnostic.getCode() != 0) {
			List<?> data = diagnostic.getData();
			if (!data.isEmpty() && data.get(0) instanceof EObject) {
				doPropagateValidationResult(diagnostic, metamodel, acceptor);
			}
		}
		for(Diagnostic child: diagnostic.getChildren())
			propageValidationResult(child, metamodel, acceptor);
	}
}
 
Example 14
Source File: ProfileEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void notifyChanged ( Notification notification )
{
    if ( notification.getNotifier () instanceof Resource )
    {
        switch ( notification.getFeatureID ( Resource.class ) )
        {
            case Resource.RESOURCE__IS_LOADED:
            case Resource.RESOURCE__ERRORS:
            case Resource.RESOURCE__WARNINGS:
            {
                Resource resource = (Resource)notification.getNotifier ();
                Diagnostic diagnostic = analyzeResourceProblems ( resource, null );
                if ( diagnostic.getSeverity () != Diagnostic.OK )
                {
                    resourceToDiagnosticMap.put ( resource, diagnostic );
                }
                else
                {
                    resourceToDiagnosticMap.remove ( resource );
                }

                if ( updateProblemIndication )
                {
                    getSite ().getShell ().getDisplay ().asyncExec ( new Runnable () {
                        public void run ()
                        {
                            updateProblemIndication ();
                        }
                    } );
                }
                break;
            }
        }
    }
    else
    {
        super.notifyChanged ( notification );
    }
}
 
Example 15
Source File: EipEditor.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyChanged(Notification notification) {
   if (notification.getNotifier() instanceof Resource) {
      switch (notification.getFeatureID(Resource.class)) {
         case Resource.RESOURCE__IS_LOADED:
         case Resource.RESOURCE__ERRORS:
         case Resource.RESOURCE__WARNINGS: {
            Resource resource = (Resource)notification.getNotifier();
            Diagnostic diagnostic = analyzeResourceProblems(resource, null);
            if (diagnostic.getSeverity() != Diagnostic.OK) {
               resourceToDiagnosticMap.put(resource, diagnostic);
            }
            else {
               resourceToDiagnosticMap.remove(resource);
            }

            if (updateProblemIndication) {
               getSite().getShell().getDisplay().asyncExec
                  (new Runnable() {
                      public void run() {
                         updateProblemIndication();
                      }
                   });
            }
            break;
         }
      }
   }
   else {
      super.notifyChanged(notification);
   }
}
 
Example 16
Source File: ModelImpl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public void validate() throws MigrationException {
	final BasicDiagnostic chain = new BasicDiagnostic();
	for (final ModelResource modelResource : getResources()) {
		for (final Instance root : modelResource.getRootInstances()) {
			root.validate(chain);
		}
	}
	if (chain.getSeverity() != Diagnostic.OK) {
		throw new MigrationException(new DiagnosticException("Model not valid", chain)); //$NON-NLS-1$
	}
}
 
Example 17
Source File: GlobalizeEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void notifyChanged ( Notification notification )
{
    if ( notification.getNotifier () instanceof Resource )
    {
        switch ( notification.getFeatureID ( Resource.class ) )
        {
            case Resource.RESOURCE__IS_LOADED:
            case Resource.RESOURCE__ERRORS:
            case Resource.RESOURCE__WARNINGS:
            {
                Resource resource = (Resource)notification.getNotifier ();
                Diagnostic diagnostic = analyzeResourceProblems ( resource, null );
                if ( diagnostic.getSeverity () != Diagnostic.OK )
                {
                    resourceToDiagnosticMap.put ( resource, diagnostic );
                }
                else
                {
                    resourceToDiagnosticMap.remove ( resource );
                }

                if ( updateProblemIndication )
                {
                    getSite ().getShell ().getDisplay ().asyncExec ( new Runnable () {
                        public void run ()
                        {
                            updateProblemIndication ();
                        }
                    } );
                }
                break;
            }
        }
    }
    else
    {
        super.notifyChanged ( notification );
    }
}
 
Example 18
Source File: ValidationMarkerProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private static int diagnosticToStatusSeverity(final int diagnosticSeverity) {
    if (diagnosticSeverity == Diagnostic.OK) {
        return IStatus.OK;
    } else if (diagnosticSeverity == Diagnostic.INFO) {
        return IStatus.INFO;
    } else if (diagnosticSeverity == Diagnostic.WARNING) {
        return IStatus.WARNING;
    } else if (diagnosticSeverity == Diagnostic.ERROR
            || diagnosticSeverity == Diagnostic.CANCEL) {
        return IStatus.ERROR;
    }
    return IStatus.INFO;
}
 
Example 19
Source File: SecurityEditor.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void notifyChanged ( Notification notification )
{
    if ( notification.getNotifier () instanceof Resource )
    {
        switch ( notification.getFeatureID ( Resource.class ) )
        {
            case Resource.RESOURCE__IS_LOADED:
            case Resource.RESOURCE__ERRORS:
            case Resource.RESOURCE__WARNINGS:
            {
                Resource resource = (Resource)notification.getNotifier ();
                Diagnostic diagnostic = analyzeResourceProblems ( resource, null );
                if ( diagnostic.getSeverity () != Diagnostic.OK )
                {
                    resourceToDiagnosticMap.put ( resource, diagnostic );
                }
                else
                {
                    resourceToDiagnosticMap.remove ( resource );
                }

                if ( updateProblemIndication )
                {
                    getSite ().getShell ().getDisplay ().asyncExec
                            ( new Runnable ()
                            {
                                public void run ()
                                {
                                    updateProblemIndication ();
                                }
                            } );
                }
                break;
            }
        }
    }
    else
    {
        super.notifyChanged ( notification );
    }
}
 
Example 20
Source File: ConfigurationEditor.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void notifyChanged ( Notification notification )
{
    if ( notification.getNotifier () instanceof Resource )
    {
        switch ( notification.getFeatureID ( Resource.class ) )
        {
            case Resource.RESOURCE__IS_LOADED:
            case Resource.RESOURCE__ERRORS:
            case Resource.RESOURCE__WARNINGS:
            {
                Resource resource = (Resource)notification.getNotifier ();
                Diagnostic diagnostic = analyzeResourceProblems ( resource, null );
                if ( diagnostic.getSeverity () != Diagnostic.OK )
                {
                    resourceToDiagnosticMap.put ( resource, diagnostic );
                }
                else
                {
                    resourceToDiagnosticMap.remove ( resource );
                }

                if ( updateProblemIndication )
                {
                    getSite ().getShell ().getDisplay ().asyncExec
                            ( new Runnable ()
                            {
                                public void run ()
                                {
                                    updateProblemIndication ();
                                }
                            } );
                }
                break;
            }
        }
    }
    else
    {
        super.notifyChanged ( notification );
    }
}