/** * {@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 (ViewsViewsRepository.ViewsRepository.Properties.repositoryKind == event.getAffectedEditor()) { BasicDiagnostic chain = new BasicDiagnostic(); for (Iterator iterator = ((List) event.getNewValue()).iterator(); iterator.hasNext(); ) { chain.add( Diagnostician.INSTANCE.validate( ViewsPackage.eINSTANCE.getViewsRepository_RepositoryKind().getEAttributeType(), iterator.next())); } ret = chain; } if (ViewsViewsRepository.ViewsRepository.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( ViewsPackage.eINSTANCE.getViewsRepository_Name().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( ViewsPackage.eINSTANCE.getViewsRepository_Name().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
/** * Validates the MemberTypes constraint of '<em>Frame Target</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public boolean validateFrameTarget_MemberTypes( Object frameTarget, DiagnosticChain diagnostics, Map<Object, Object> context) { if (diagnostics != null) { BasicDiagnostic tempDiagnostics = new BasicDiagnostic(); if (DatatypesPackage.Literals.FRAME_TARGET_MEMBER0.isInstance(frameTarget)) { if (validateFrameTargetMember0((FrameTargetMember0) frameTarget, tempDiagnostics, context)) return true; } if (DatatypesPackage.Literals.FRAME_TARGET_MEMBER1.isInstance(frameTarget)) { if (validateFrameTargetMember1((String) frameTarget, tempDiagnostics, context)) return true; } for (Diagnostic diagnostic : tempDiagnostics.getChildren()) { diagnostics.add(diagnostic); } } else { if (DatatypesPackage.Literals.FRAME_TARGET_MEMBER0.isInstance(frameTarget)) { if (validateFrameTargetMember0((FrameTargetMember0) frameTarget, null, context)) return true; } if (DatatypesPackage.Literals.FRAME_TARGET_MEMBER1.isInstance(frameTarget)) { if (validateFrameTargetMember1((String) frameTarget, null, context)) return true; } } return false; }
/** * Validates the MemberTypes constraint of '<em>Length</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public boolean validateLength_MemberTypes( Object length, DiagnosticChain diagnostics, Map<Object, Object> context) { if (diagnostics != null) { BasicDiagnostic tempDiagnostics = new BasicDiagnostic(); if (XMLTypePackage.Literals.NON_NEGATIVE_INTEGER.isInstance(length)) { if (xmlTypeValidator.validateNonNegativeInteger( (BigInteger) length, tempDiagnostics, context)) return true; } if (DatatypesPackage.Literals.LENGTH_MEMBER1.isInstance(length)) { if (validateLengthMember1((String) length, tempDiagnostics, context)) return true; } for (Diagnostic diagnostic : tempDiagnostics.getChildren()) { diagnostics.add(diagnostic); } } else { if (XMLTypePackage.Literals.NON_NEGATIVE_INTEGER.isInstance(length)) { if (xmlTypeValidator.validateNonNegativeInteger((BigInteger) length, null, context)) return true; } if (DatatypesPackage.Literals.LENGTH_MEMBER1.isInstance(length)) { if (validateLengthMember1((String) length, null, context)) return true; } } return false; }
/** * {@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 (UmlViewsRepository.LinkEndDestructionData.Properties.isDestroyDuplicates == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( UMLPackage.eINSTANCE .getLinkEndDestructionData_IsDestroyDuplicates() .getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( UMLPackage.eINSTANCE .getLinkEndDestructionData_IsDestroyDuplicates() .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 (MappingViewsRepository.Documentation.Documentation_.documentation__ == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( MappingPackage.eINSTANCE .getDocumentedElement_Documentation() .getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( MappingPackage.eINSTANCE.getDocumentedElement_Documentation().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 (ScoViewsRepository.ArtifactIdentifier.Properties.resourceName == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(ScoPackage.eINSTANCE.getArtifactIdentifier_ResourceName().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(ScoPackage.eINSTANCE.getArtifactIdentifier_ResourceName().getEAttributeType(), newValue); } if (ScoViewsRepository.ArtifactIdentifier.Properties.baselinedLineCount == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(ScoPackage.eINSTANCE.getArtifactIdentifier_BaselinedLineCount().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(ScoPackage.eINSTANCE.getArtifactIdentifier_BaselinedLineCount().getEAttributeType(), newValue); } if (ScoViewsRepository.ArtifactIdentifier.Properties.currentLineCount == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(ScoPackage.eINSTANCE.getArtifactIdentifier_CurrentLineCount().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(ScoPackage.eINSTANCE.getArtifactIdentifier_CurrentLineCount().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) */ @Override public Diagnostic validateValue(IPropertiesEditionEvent event) { Diagnostic ret = Diagnostic.OK_INSTANCE; if (event.getNewValue() != null) { try { if (DocbookViewsRepository.ItemizedList.Properties.mark == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( DocbookPackage.eINSTANCE.getItemizedList_Mark().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( DocbookPackage.eINSTANCE.getItemizedList_Mark().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
private RefactoringStatus validate(IProgressMonitor pm, EObject object) { RefactoringStatus refactoringStatus = RefactoringStatus.create(Status.OK_STATUS); EValidator.Registry validatorRegistry = extensions.getInstance(EValidator.Registry.class, object); EPackage epackage = object.eClass().getEPackage(); EValidator validator = validatorRegistry.getEValidator(epackage); BasicDiagnostic diagnostics = new BasicDiagnostic(); if (pm.isCanceled()) { refactoringStatus = RefactoringStatus.create(Status.CANCEL_STATUS); pm.done(); } else { SubMonitor sm = SubMonitor.convert(pm, "Validating re-factoring.", IProgressMonitor.UNKNOWN); validator.validate(object, diagnostics, Maps.newHashMap()); Iterator<Diagnostic> validationIterator = Iterables.filter( diagnostics.getChildren(), new Predicate<Diagnostic>() { @Override public boolean apply(Diagnostic diagnostic) { if (diagnostic instanceof FeatureBasedDiagnostic) { return FeatureBasedDiagnostic.ERROR == ((FeatureBasedDiagnostic) diagnostic).getSeverity(); } return false; } }) .iterator(); if (validationIterator.hasNext()) { Diagnostic diagnostic = validationIterator.next(); refactoringStatus = RefactoringStatus.createFatalErrorStatus(diagnostic.getMessage()); } sm.done(); } return refactoringStatus; }
/** * {@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 (SpemViewsRepository.ProcessComponent.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( SpemPackage.eINSTANCE.getProcessPackageableElement_Name().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( SpemPackage.eINSTANCE.getProcessPackageableElement_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 (SoaViewsRepository.Service.Properties.synchronization == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( SoaPackage.eINSTANCE.getService_Synchronization().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( SoaPackage.eINSTANCE.getService_Synchronization().getEAttributeType(), newValue); } if (SoaViewsRepository.Service.Properties.kind == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( SoaPackage.eINSTANCE.getService_Kind().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( SoaPackage.eINSTANCE.getService_Kind().getEAttributeType(), newValue); } if (SoaViewsRepository.Service.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( SoaPackage.eINSTANCE.getService_Name().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( SoaPackage.eINSTANCE.getService_Name().getEAttributeType(), newValue); } if (SoaViewsRepository.Service.Properties.description == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
@Override public IDecorator[] getDecorators(final PictogramElement pe) { IFeatureProvider featureProvider = getFeatureProvider(); Object bo = featureProvider.getBusinessObjectForPictogramElement(pe); Integer objectId; if (bo instanceof Method) { System.out.println("CHECKING METHOD"); objectId = System.identityHashCode(bo.getClass()); try { // generate decorator and markers if (!XcoreValidator.INSTANCE.validateMethod((Method) bo, diagnosticChain, null)) { Diagnostic lastDiagnostic = diagnosticChain.getChildren().get(diagnosticChain.getChildren().size() - 1); markers.put( objectId, AtomicDesignUtils.createMarker( lastDiagnostic.getMessage(), IMarker.SEVERITY_ERROR, ((Method) bo).getClass().getName())); return new ImageDecorator[] { AtomicDesignUtils.createImageDecorator( lastDiagnostic, lastDiagnostic.getMessage(), 20, 0) }; } else { AtomicDesignUtils.destroyMarker(markers.get(objectId)); } } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (bo instanceof ComputationUnit) { System.out.println("CHECKING CU"); if (!XcoreValidator.INSTANCE.validateComputationUnit( (ComputationUnit) bo, diagnosticChain, null)) { System.out.println("CHECKING METHOD"); } } if (bo instanceof DataElement) { System.out.println("CHECKING DATAELEMENT"); if (!XcoreValidator.INSTANCE.validateDataElement((DataElement) bo, diagnosticChain, null)) {} } if (bo instanceof Service) { System.out.println("CHECKING SERVICE"); if (!XcoreValidator.INSTANCE.validateService((Service) bo, diagnosticChain, null)) {} } if (bo instanceof Parameter) { System.out.println("CHECKING PARAMETER"); if (!XcoreValidator.INSTANCE.validateParameter((Parameter) bo, diagnosticChain, null)) {} } return super.getDecorators(pe); }
/** * {@inheritDoc} * * @see * org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) */ @Override public Diagnostic validateValue(final IPropertiesEditionEvent event) { Diagnostic ret = Diagnostic.OK_INSTANCE; if (event.getNewValue() != null) { try { if (DatabaseViewsRepository.ForeignKeyElement.Properties.comments == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( DatabasePackage.eINSTANCE.getDatabaseElement_Comments().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( DatabasePackage.eINSTANCE.getDatabaseElement_Comments().getEAttributeType(), newValue); } if (DatabaseViewsRepository.ForeignKeyElement.Properties.sourceTable == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } if (DatabaseViewsRepository.ForeignKeyElement.Properties.targetTable == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } } catch (final IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (final 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 { } 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 (StatemachineViewsRepository.Transition.Properties.description == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(), newValue); } if (StatemachineViewsRepository.Transition.Properties.keywords == event.getAffectedEditor()) { BasicDiagnostic chain = new BasicDiagnostic(); for (Iterator iterator = ((List) event.getNewValue()).iterator(); iterator.hasNext(); ) { chain.add( Diagnostician.INSTANCE.validate( EnvironmentPackage.eINSTANCE.getObeoDSMObject_Keywords().getEAttributeType(), iterator.next())); } ret = chain; } if (StatemachineViewsRepository.Transition.Properties.guard == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( StateMachinePackage.eINSTANCE.getTransition_Guard().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( StateMachinePackage.eINSTANCE.getTransition_Guard().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 (GsnViewsRepository.Solution.Properties.identifier == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( ArmPackage.eINSTANCE.getModelElement_Identifier().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( ArmPackage.eINSTANCE.getModelElement_Identifier().getEAttributeType(), newValue); } if (GsnViewsRepository.Solution.Properties.description == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( ArmPackage.eINSTANCE.getModelElement_Description().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( ArmPackage.eINSTANCE.getModelElement_Description().getEAttributeType(), newValue); } if (GsnViewsRepository.Solution.Properties.content == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( ArmPackage.eINSTANCE.getModelElement_Content().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( ArmPackage.eINSTANCE.getModelElement_Content().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 (EcoreViewsRepository.EPackage.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( EcorePackage.eINSTANCE.getENamedElement_Name().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( EcorePackage.eINSTANCE.getENamedElement_Name().getEAttributeType(), newValue); } if (EcoreViewsRepository.EPackage.Properties.nsURI == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( EcorePackage.eINSTANCE.getEPackage_NsURI().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( EcorePackage.eINSTANCE.getEPackage_NsURI().getEAttributeType(), newValue); } if (EcoreViewsRepository.EPackage.Properties.nsPrefix == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( EcorePackage.eINSTANCE.getEPackage_NsPrefix().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( EcorePackage.eINSTANCE.getEPackage_NsPrefix().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
@Override public void parserProblem( Severity problemSeverity, String problemMessage, String processingContext, int startOffset, int endOffset) { IPrsStream prsStream = getIPrsStream(); int leftToken = prsStream.getTokenIndexAtCharacter(startOffset); int rightToken = prsStream.getTokenIndexAtCharacter(endOffset); int leftTokenLoc = (leftToken > rightToken ? rightToken : leftToken); int rightTokenLoc = rightToken; int line = prsStream.getLine(leftTokenLoc) + getErrorReportLineOffset(); CustomDiagnostic diagnostic = new CustomDiagnostic( problemSeverity.getDiagnosticSeverity(), "org.eclipse.ocl", 1, problemMessage, new Object[] {processingContext}); if (line > 0) { diagnostic.setStartLine(prsStream.getLine(leftTokenLoc) + getErrorReportLineOffset()); diagnostic.setStartPosition(prsStream.getColumn(leftTokenLoc)); diagnostic.setEndPosition(prsStream.getEndColumn(rightTokenLoc)); diagnostic.setEndLine(prsStream.getEndLine(rightTokenLoc) + getErrorReportLineOffset()); } if (diagnostics == null) { diagnostics = diagnostic; } else { diagnostics.add(diagnostic); } }
public static void logDiagnostic(Diagnostic diagnostic) { if (getPlugin() != null) { getPlugin().log(BasicDiagnostic.toIStatus(diagnostic)); } else { getDefault().log(diagnostic); } }
/** * Updates the problems indication with the information described in the specified diagnostic. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ protected void updateProblemIndication() { if (updateProblemIndication) { BasicDiagnostic diagnostic = new BasicDiagnostic( Diagnostic.OK, "org.eclipse.buckminster.rmap.editor", 0, null, new Object[] {editingDomain.getResourceSet()}); for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) { if (childDiagnostic.getSeverity() != Diagnostic.OK) { diagnostic.add(childDiagnostic); } } int lastEditorPage = getPageCount() - 1; if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) { ((ProblemEditorPart) getEditor(lastEditorPage)).setDiagnostic(diagnostic); if (diagnostic.getSeverity() != Diagnostic.OK) { setActivePage(lastEditorPage); } } else if (diagnostic.getSeverity() != Diagnostic.OK) { ProblemEditorPart problemEditorPart = new ProblemEditorPart(); problemEditorPart.setDiagnostic(diagnostic); problemEditorPart.setMarkerHelper(markerHelper); try { addPage(++lastEditorPage, problemEditorPart, getEditorInput()); setPageText(lastEditorPage, problemEditorPart.getPartName()); setActivePage(lastEditorPage); showTabs(); } catch (PartInitException exception) { RmapEditorPlugin.INSTANCE.log(exception); } } if (markerHelper.hasMarkers(editingDomain.getResourceSet())) { markerHelper.deleteMarkers(editingDomain.getResourceSet()); if (diagnostic.getSeverity() != Diagnostic.OK) { try { markerHelper.createMarkers(diagnostic); } catch (CoreException exception) { RmapEditorPlugin.INSTANCE.log(exception); } } } } }
protected void handleFinishException(Shell shell, InvocationTargetException e) { Diagnostic diagnostic = BasicDiagnostic.toDiagnostic(e); // log(diagnostic); String title = "Finish Exception"; // $NON-NLS-1$ String message = "Wizard.op_error.message"; // $NON-NLS-1$ DiagnosticDialog.open(shell, title, message, diagnostic); }
/** * {@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 (DroidViewsRepository.RotateAnimation.Properties.fromAlpha == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( DroidPackage.eINSTANCE .getTerminalAnimationElements_FromAlpha() .getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( DroidPackage.eINSTANCE .getTerminalAnimationElements_FromAlpha() .getEAttributeType(), newValue); } if (DroidViewsRepository.RotateAnimation.Properties.toAlpha == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( DroidPackage.eINSTANCE .getTerminalAnimationElements_ToAlpha() .getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( DroidPackage.eINSTANCE.getTerminalAnimationElements_ToAlpha().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 (ComponentsViewsRepository.PropertiesEditionElement.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( MappingPackage.eINSTANCE.getAbstractPropertyBinding_Name().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( MappingPackage.eINSTANCE.getAbstractPropertyBinding_Name().getEAttributeType(), newValue); } if (ComponentsViewsRepository.PropertiesEditionElement.Properties.helpID == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( ComponentsPackage.eINSTANCE.getEEFElement_HelpID().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( ComponentsPackage.eINSTANCE.getEEFElement_HelpID().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) { if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) { BasicDiagnostic basicDiagnostic = new BasicDiagnostic( Diagnostic.ERROR, "org.eclipse.buckminster.rmap.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.buckminster.rmap.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] {exception}); } else { return Diagnostic.OK_INSTANCE; } }
/** * Validates the MemberTypes constraint of '<em>Color</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public boolean validateColor_MemberTypes( String color, DiagnosticChain diagnostics, Map<Object, Object> context) { if (diagnostics != null) { BasicDiagnostic tempDiagnostics = new BasicDiagnostic(); if (XMLTypePackage.Literals.NMTOKEN.isInstance(color)) { if (xmlTypeValidator.validateNMTOKEN(color, tempDiagnostics, context)) return true; } if (DatatypesPackage.Literals.COLOR_MEMBER1.isInstance(color)) { if (validateColorMember1(color, tempDiagnostics, context)) return true; } for (Diagnostic diagnostic : tempDiagnostics.getChildren()) { diagnostics.add(diagnostic); } } else { if (XMLTypePackage.Literals.NMTOKEN.isInstance(color)) { if (xmlTypeValidator.validateNMTOKEN(color, null, context)) return true; } if (DatatypesPackage.Literals.COLOR_MEMBER1.isInstance(color)) { if (validateColorMember1(color, null, context)) return true; } } return false; }
/** * Validates the MemberTypes constraint of '<em>Log Type</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public boolean validateLogType_MemberTypes( Object logType, DiagnosticChain diagnostics, Map<Object, Object> context) { if (diagnostics != null) { BasicDiagnostic tempDiagnostics = new BasicDiagnostic(); if (EsmConfigPackage.Literals.LOG_TYPE_MEMBER0.isInstance(logType)) { if (validateLogTypeMember0((Integer) logType, tempDiagnostics, context)) return true; } if (EsmConfigPackage.Literals.LOG_TYPE_MEMBER1.isInstance(logType)) { if (validateLogTypeMember1((List<?>) logType, tempDiagnostics, context)) return true; } for (Diagnostic diagnostic : tempDiagnostics.getChildren()) { diagnostics.add(diagnostic); } } else { if (EsmConfigPackage.Literals.LOG_TYPE_MEMBER0.isInstance(logType)) { if (validateLogTypeMember0((Integer) logType, null, context)) return true; } if (EsmConfigPackage.Literals.LOG_TYPE_MEMBER1.isInstance(logType)) { if (validateLogTypeMember1((List<?>) logType, null, context)) return true; } } return false; }
/** * Validates the MemberTypes constraint of '<em>Multi Length</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public boolean validateMultiLength_MemberTypes( Object multiLength, DiagnosticChain diagnostics, Map<Object, Object> context) { if (diagnostics != null) { BasicDiagnostic tempDiagnostics = new BasicDiagnostic(); if (DatatypesPackage.Literals.LENGTH.isInstance(multiLength)) { if (validateLength(multiLength, tempDiagnostics, context)) return true; } if (DatatypesPackage.Literals.MULTI_LENGTH_MEMBER1.isInstance(multiLength)) { if (validateMultiLengthMember1((String) multiLength, tempDiagnostics, context)) return true; } for (Diagnostic diagnostic : tempDiagnostics.getChildren()) { diagnostics.add(diagnostic); } } else { if (DatatypesPackage.Literals.LENGTH.isInstance(multiLength)) { if (validateLength(multiLength, null, context)) return true; } if (DatatypesPackage.Literals.MULTI_LENGTH_MEMBER1.isInstance(multiLength)) { if (validateMultiLengthMember1((String) multiLength, null, context)) return true; } } return false; }
/** * Validates the MemberTypes constraint of '<em>UR Ior Safe CURIE</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public boolean validateURIorSafeCURIE_MemberTypes( String urIorSafeCURIE, DiagnosticChain diagnostics, Map<Object, Object> context) { if (diagnostics != null) { BasicDiagnostic tempDiagnostics = new BasicDiagnostic(); if (XMLTypePackage.Literals.ANY_URI.isInstance(urIorSafeCURIE)) { if (xmlTypeValidator.validateAnyURI(urIorSafeCURIE, tempDiagnostics, context)) return true; } if (DatatypesPackage.Literals.SAFE_CURIE.isInstance(urIorSafeCURIE)) { if (validateSafeCURIE(urIorSafeCURIE, tempDiagnostics, context)) return true; } for (Diagnostic diagnostic : tempDiagnostics.getChildren()) { diagnostics.add(diagnostic); } } else { if (XMLTypePackage.Literals.ANY_URI.isInstance(urIorSafeCURIE)) { if (xmlTypeValidator.validateAnyURI(urIorSafeCURIE, null, context)) return true; } if (DatatypesPackage.Literals.SAFE_CURIE.isInstance(urIorSafeCURIE)) { if (validateSafeCURIE(urIorSafeCURIE, null, context)) return true; } } return false; }
/** * {@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 (EvidenceViewsRepository.Consistency.Properties.id == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( SACMPackage.eINSTANCE.getModelElement_Id().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( SACMPackage.eINSTANCE.getModelElement_Id().getEAttributeType(), newValue); } if (EvidenceViewsRepository.Consistency.Properties.value == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString( EvidencePackage.eINSTANCE.getConsistency_Value().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( EvidencePackage.eINSTANCE.getConsistency_Value().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }
public static void convertEcore2UML(Resource ecoreResource, Resource umlResource) { TransformationExecutor executor = new TransformationExecutor(transformationURI); ModelExtent input = new BasicModelExtent(ecoreResource.getContents()); ModelExtent output = new BasicModelExtent(); ExecutionContextImpl context = new ExecutionContextImpl(); ExecutionDiagnostic diagnostic = executor.execute(context, input, output); if (diagnostic.getSeverity() == Diagnostic.OK) { umlResource.getContents().addAll(output.getContents()); } else { IStatus status = BasicDiagnostic.toIStatus(diagnostic); InvokeActivator.getDefault().getLog().log(status); } }
/** * {@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 (UmlViewsRepository.InputPin.Properties.name == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( UMLPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( UMLPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue); } if (UmlViewsRepository.InputPin.Properties.visibility == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( UMLPackage.eINSTANCE.getNamedElement_Visibility().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( UMLPackage.eINSTANCE.getNamedElement_Visibility().getEAttributeType(), newValue); } if (UmlViewsRepository.InputPin.Properties.isLeaf == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( UMLPackage.eINSTANCE.getRedefinableElement_IsLeaf().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( UMLPackage.eINSTANCE.getRedefinableElement_IsLeaf().getEAttributeType(), newValue); } if (UmlViewsRepository.InputPin.Properties.ordering == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( UMLPackage.eINSTANCE.getObjectNode_Ordering().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( UMLPackage.eINSTANCE.getObjectNode_Ordering().getEAttributeType(), newValue); } if (UmlViewsRepository.InputPin.Properties.isControlType == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( UMLPackage.eINSTANCE.getObjectNode_IsControlType().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( UMLPackage.eINSTANCE.getObjectNode_IsControlType().getEAttributeType(), newValue); } if (UmlViewsRepository.InputPin.Properties.isOrdered == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( UMLPackage.eINSTANCE.getMultiplicityElement_IsOrdered().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( UMLPackage.eINSTANCE.getMultiplicityElement_IsOrdered().getEAttributeType(), newValue); } if (UmlViewsRepository.InputPin.Properties.isUnique == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( UMLPackage.eINSTANCE.getMultiplicityElement_IsUnique().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( UMLPackage.eINSTANCE.getMultiplicityElement_IsUnique().getEAttributeType(), newValue); } if (UmlViewsRepository.InputPin.Properties.isControl == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EcoreUtil.createFromString( UMLPackage.eINSTANCE.getPin_IsControl().getEAttributeType(), (String) newValue); } ret = Diagnostician.INSTANCE.validate( UMLPackage.eINSTANCE.getPin_IsControl().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; }