Java Code Examples for org.eclipse.emf.common.util.Diagnostic#getSeverity()
The following examples show how to use
org.eclipse.emf.common.util.Diagnostic#getSeverity() .
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: RecipeEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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: WorldEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 3
Source File: BeansEditor.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 6 votes |
/** * 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: CoreEditor.java From ifml-editor with MIT License | 6 votes |
/** * 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 5
Source File: ModbusExporterProcessor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Validates a ModbusExporterDevice instance using the EMF core validator * API. The * contained ModbusExporterItems are also validated. * * @param device * the ModbusExporterDevice to validate * @throws IllegalStateException * if validation errors are encountered */ private void validateDevice ( final ModbusExporterDevice device ) { // Also validates contained ModbusExporterItems final Diagnostic diag = Diagnostician.INSTANCE.validate ( device ); if ( diag.getSeverity () == Diagnostic.ERROR ) { String msg = "Invalid Modbus Exporter Device"; for ( final Diagnostic child : diag.getChildren () ) { if ( child.getSeverity () == Diagnostic.ERROR ) { msg += "\n" + child.getMessage (); //$NON-NLS-1$ } } throw new IllegalStateException ( msg ); } }
Example 6
Source File: ExporterProcessor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Validates a object instance and its children using the EMF core validator * API. * * @param element * the element to validate * @param label * the type label of the element * @throws IllegalStateException * if validation errors are encountered */ protected static void validateDevice ( final EObject object, final String label ) { final Diagnostic diag = Diagnostician.INSTANCE.validate ( object ); if ( diag.getSeverity () == Diagnostic.ERROR ) { final StringBuilder sb = new StringBuilder ( "Invalid " + label ); for ( final Diagnostic child : diag.getChildren () ) { if ( child.getSeverity () == Diagnostic.ERROR ) { sb.append ( System.lineSeparator () ); sb.append ( child.getMessage () ); } } throw new IllegalStateException ( sb.toString () ); } }
Example 7
Source File: VisualInterfaceEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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: ValidationMarkerProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void createMarkers(final IFile target, final Diagnostic emfValidationStatus, final DiagramEditPart diagramEditPart) { if (emfValidationStatus.getSeverity() == Diagnostic.OK) { return; } final Diagnostic rootStatus = emfValidationStatus; final List allDiagnostics = new ArrayList(); final ProcessDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new ProcessDiagramEditorUtil.LazyElement2ViewMap( diagramEditPart.getDiagramView(), collectTargetElements(rootStatus, new HashSet<EObject>(), allDiagnostics)); for (final Iterator it = emfValidationStatus.getChildren().iterator(); it.hasNext();) { final Diagnostic nextDiagnostic = (Diagnostic) it.next(); final List data = nextDiagnostic.getData(); if (data != null && !data.isEmpty() && data.get(0) instanceof EObject) { final EObject element = (EObject) data.get(0); final View view = ProcessDiagramEditorUtil.findView( diagramEditPart, element, element2ViewMap); addMarker(diagramEditPart, null, diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view), EMFCoreUtil.getQualifiedName(element, true), nextDiagnostic.getMessage(), diagnosticToStatusSeverity(nextDiagnostic.getSeverity())); } } }
Example 9
Source File: DetailViewEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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: GlobalizeEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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: ItemEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 12
Source File: GlobalizeEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@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 13
Source File: M2DocUtils.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
/** * Appends the given {@link Diagnostic} to the given {@link XWPFParagraph}. * * @param paragraph * the {@link XWPFParagraph} * @param diagnostic * the {@link Diagnostic} * @return the maximum {@link ValidationMessageLevel} */ public static List<TemplateValidationMessage> appendDiagnosticMessage(XWPFParagraph paragraph, Diagnostic diagnostic) { final List<TemplateValidationMessage> res = new ArrayList<>(); for (Diagnostic child : diagnostic.getChildren()) { switch (child.getSeverity()) { case Diagnostic.INFO: res.add(M2DocUtils.appendMessageRun(paragraph, ValidationMessageLevel.INFO, getMessageWithException(child))); break; case Diagnostic.WARNING: res.add(M2DocUtils.appendMessageRun(paragraph, ValidationMessageLevel.WARNING, getMessageWithException(child))); break; case Diagnostic.ERROR: res.add(M2DocUtils.appendMessageRun(paragraph, ValidationMessageLevel.ERROR, getMessageWithException(child))); break; default: res.add(M2DocUtils.appendMessageRun(paragraph, ValidationMessageLevel.INFO, getMessageWithException(child))); break; } paragraph.getRuns().get(paragraph.getRuns().size() - 1).addBreak(); if (!child.getChildren().isEmpty()) { res.addAll(appendDiagnosticMessage(paragraph, child)); } } return res; }
Example 14
Source File: ProfileEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@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: AssertableDiagnostics.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public boolean apply(Diagnostic d) { if (severity != null && d.getSeverity() != severity) return false; if (code != null && !code.equals(d.getCode())) return false; if (issueCode != null && d instanceof AbstractValidationDiagnostic && !((AbstractValidationDiagnostic) d).getIssueCode().equals(issueCode)) return false; if (msg != null && d.getMessage() != null && !d.getMessage().contains(msg)) return false; return true; }
Example 16
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void diagnose(EObject object, String... expectedUnresolvedProxies) { Resource resource = object.eResource(); for (EObject content : resource.getContents()) { Diagnostic diagnostic = diagnostician.validate(content); if (diagnostic.getSeverity() != Diagnostic.OK) { URI[] expectedUnresolvedProxyURIs = new URI[expectedUnresolvedProxies.length]; for (int i = 0; i < expectedUnresolvedProxies.length; i++) { expectedUnresolvedProxyURIs[i] = URI.createURI(expectedUnresolvedProxies[i]); } diagnose(diagnostic, expectedUnresolvedProxyURIs); } } }
Example 17
Source File: WorldEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@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: EMFGeneratorFragment2.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected void doGenerate(final GenModel genModel) { final Generator generator = new Generator() { @Override public JControlModel getJControlModel() { if ((this.jControlModel == null)) { JControlModel _jControlModel = new JControlModel(); this.jControlModel = _jControlModel; this.jControlModel.initialize(null, this.options.mergeRulesURI); } return this.jControlModel; } }; GeneratorAdapterFactory.Descriptor.Registry _adapterFactoryDescriptorRegistry = generator.getAdapterFactoryDescriptorRegistry(); String _lineDelimiter = this.codeConfig.getLineDelimiter(); CvsIdFilteringGeneratorAdapterFactoryDescriptor _cvsIdFilteringGeneratorAdapterFactoryDescriptor = new CvsIdFilteringGeneratorAdapterFactoryDescriptor(_lineDelimiter); _adapterFactoryDescriptorRegistry.addDescriptor(GenModelPackage.eNS_URI, _cvsIdFilteringGeneratorAdapterFactoryDescriptor); genModel.setCanGenerate(true); generator.setInput(genModel); BasicMonitor _basicMonitor = new BasicMonitor(); final Diagnostic diagnostic = generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, _basicMonitor); int _severity = diagnostic.getSeverity(); boolean _notEquals = (_severity != Diagnostic.OK); if (_notEquals) { EMFGeneratorFragment2.LOG.warn(diagnostic); } if (this.generateEdit) { BasicMonitor _basicMonitor_1 = new BasicMonitor(); final Diagnostic editDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, _basicMonitor_1); int _severity_1 = editDiag.getSeverity(); boolean _notEquals_1 = (_severity_1 != Diagnostic.OK); if (_notEquals_1) { EMFGeneratorFragment2.LOG.warn(editDiag); } } if (this.generateEditor) { BasicMonitor _basicMonitor_2 = new BasicMonitor(); final Diagnostic editorDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDITOR_PROJECT_TYPE, _basicMonitor_2); int _severity_2 = editorDiag.getSeverity(); boolean _notEquals_2 = (_severity_2 != Diagnostic.OK); if (_notEquals_2) { EMFGeneratorFragment2.LOG.warn(editorDiag); } } }
Example 19
Source File: ItemEditor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@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 |
@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 ); } }