/** * {@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 (GrmViewsRepository.General.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * {@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 (HrmViewsRepository.Timing.TimingProperties.timings == event.getAffectedEditor()) { BasicDiagnostic chain = new BasicDiagnostic(); for (Iterator iterator = ((List)event.getNewValue()).iterator(); iterator.hasNext();) { chain.add(Diagnostician.INSTANCE.validate(HrmPackage.eINSTANCE.getHardwareMemory_Timings().getEAttributeType(), iterator.next())); } ret = chain; } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * {@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 (GqamViewsRepository.General.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) * @generated */ public Diagnostic validateValue(IPropertiesEditionEvent event) { Diagnostic ret = Diagnostic.OK_INSTANCE; if (event.getNewValue() != null) { try { if (AnalysisViewsRepository.ResultContainer.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * {@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 (MetamodelViewsRepository.Model.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(MetamodelPackage.eINSTANCE.getModel_Name().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(MetamodelPackage.eINSTANCE.getModel_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * 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); }
/** * 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.gemoc.trace.annotations.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.gemoc.trace.annotations.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception }); } else { return Diagnostic.OK_INSTANCE; } }
/** * 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; } }
/** * {@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 (GqamViewsRepository.General.Properties.referenceName == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(GqamPackage.eINSTANCE.getReference_ReferenceName().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(GqamPackage.eINSTANCE.getReference_ReferenceName().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * {@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 (SrmViewsRepository.General.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * 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 ); }
/** * 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 () ); } }
/** * {@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 (HrmViewsRepository.General.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(GrmPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * 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); }
/** * 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 ); }
@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); } dispatchUpdateProblemIndication(); break; } } } else { super.notifyChanged(notification); } }
/** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) * @generated */ public Diagnostic validateValue(IPropertiesEditionEvent event) { Diagnostic ret = Diagnostic.OK_INSTANCE; if (event.getNewValue() != null) { try { if (DesignViewsRepository.DesignModel.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(DesignPackage.eINSTANCE.getDesignModel_Name().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(DesignPackage.eINSTANCE.getDesignModel_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * 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; } }
/** * {@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 (SrmViewsRepository.Timing.Properties.accessPolicy == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(SrmPackage.eINSTANCE.getMemoryBroker_AccessPolicy().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(SrmPackage.eINSTANCE.getMemoryBroker_AccessPolicy().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * 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; } }
/** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) * @generated */ public Diagnostic validateValue(IPropertiesEditionEvent event) { Diagnostic ret = Diagnostic.OK_INSTANCE; if (event.getNewValue() != null) { try { if (AnalysisViewsRepository.RequiredProtectionParameter.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) * @generated */ public Diagnostic validateValue(IPropertiesEditionEvent event) { Diagnostic ret = Diagnostic.OK_INSTANCE; if (event.getNewValue() != null) { try { if (AnalysisViewsRepository.MutualExclusionResource.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(AnalysisPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * 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; } }
/** * 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; } }
/** * 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; } }
@Test public void testCCDAExport() throws Exception { Config.set("exporter.baseDirectory", tempFolder.newFolder().toString()); CDAUtil.loadPackages(); List<String> validationErrors = new ArrayList<String>(); int numberOfPeople = 10; Generator generator = new Generator(numberOfPeople); for (int i = 0; i < numberOfPeople; i++) { int x = validationErrors.size(); TestHelper.exportOff(); Person person = generator.generatePerson(i); Config.set("exporter.ccda.export", "true"); String ccdaXml = CCDAExporter.export(person, System.currentTimeMillis()); InputStream inputStream = IOUtils.toInputStream(ccdaXml, "UTF-8"); try { CDAUtil.load(inputStream, new BasicValidationHandler() { public void handleError(Diagnostic diagnostic) { System.out.println("ERROR: " + diagnostic.getMessage()); validationErrors.add(diagnostic.getMessage()); } }); } catch (Exception e) { e.printStackTrace(); } int y = validationErrors.size(); if (x != y) { Exporter.export(person, System.currentTimeMillis()); } } assertEquals(0, validationErrors.size()); }
private void handleExceptions(org.eclipse.emf.common.util.Diagnostic diagnostic) { if (Diagnostic.OK == diagnostic.getSeverity()) { return; } if (diagnostic instanceof BasicDiagnostic) { List<?> data = ((BasicDiagnostic) diagnostic).getData(); for (Object entry : data) { if (entry instanceof Throwable) { throw new AssertionError(entry); } } } }
/** * 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, "com.incquerylabs.smarthome.model.simple.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, "com.incquerylabs.smarthome.model.simple.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception }); } else { return Diagnostic.OK_INSTANCE; } }
/** * {@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 { } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }