use of org.eclipse.emf.common.util.BasicDiagnostic in project metalib by softlang.
the class FSMStateImpl method isReachable.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
public boolean isReachable(DiagnosticChain diagnostics, Map<Object, Object> context) {
FSM fsm = (FSM) eContainer();
Set<FSMState> reachable = new HashSet<>();
Stack<FSMState> currents = new Stack<FSMState>();
currents.addAll(fsm.getStates().stream().filter(x -> x.isInitial()).collect(Collectors.toSet()));
while (!currents.isEmpty()) {
FSMState current = currents.pop();
if (current == this)
return true;
if (reachable.contains(current))
continue;
reachable.add(current);
for (FSMTransition transition : current.getTransitions()) if (transition.getTarget() != null)
currents.push(transition.getTarget());
}
if (diagnostics != null) {
diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, FsmlValidator.DIAGNOSTIC_SOURCE, FsmlValidator.FSM_STATE__IS_REACHABLE, EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "isReachable", EObjectValidator.getObjectLabel(this, context) }), new Object[] { this }));
}
return false;
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project statecharts by Yakindu.
the class SGraphJavaValidationTest method assertError.
protected void assertError(BasicDiagnostic diag, String message) {
Diagnostic d = issueByName(diag, message);
assertNotNull("Issue '" + message + "' does not exist.", issueByName(diag, message));
assertEquals("Issue '" + message + "' is no error.", Diagnostic.ERROR, d.getSeverity());
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project statecharts by Yakindu.
the class SGraphJavaValidationTest method setUp.
@Before
public void setUp() throws Exception {
diagnostics = new BasicDiagnostic();
factory = SGraphFactory.eINSTANCE;
sTextFactory = StextFactory.eINSTANCE;
statechart = factory.createStatechart();
statechart.setName("SC");
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class ColumnPropertiesEditionComponent method validateValue.
/**
* {@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 (DatabaseViewsRepository.Column.Properties.name == 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.Column.Properties.NullablePkAndUnique.nullable == event.getAffectedEditor()) {
Object newValue = event.getNewValue();
if (newValue instanceof String) {
newValue = EEFConverterUtil.createFromString(DatabasePackage.eINSTANCE.getColumn_Nullable().getEAttributeType(), (String) newValue);
}
ret = Diagnostician.INSTANCE.validate(DatabasePackage.eINSTANCE.getColumn_Nullable().getEAttributeType(), newValue);
}
if (DatabaseViewsRepository.Column.Properties.NullablePkAndUnique.primaryKey == event.getAffectedEditor()) {
Object newValue = event.getNewValue();
if (newValue instanceof String) {
newValue = EEFConverterUtil.createFromString(DatabasePackage.eINSTANCE.getColumn_InPrimaryKey().getEAttributeType(), (String) newValue);
}
ret = Diagnostician.INSTANCE.validate(DatabasePackage.eINSTANCE.getColumn_InPrimaryKey().getEAttributeType(), newValue);
}
if (DatabaseViewsRepository.Column.Properties.NullablePkAndUnique.unique == event.getAffectedEditor()) {
Object newValue = event.getNewValue();
if (newValue instanceof String) {
newValue = EEFConverterUtil.createFromString(DatabasePackage.eINSTANCE.getColumn_Unique().getEAttributeType(), (String) newValue);
}
ret = Diagnostician.INSTANCE.validate(DatabasePackage.eINSTANCE.getColumn_Unique().getEAttributeType(), newValue);
}
if (DatabaseViewsRepository.Column.Properties.Sequence.autoincrement == event.getAffectedEditor()) {
Object newValue = event.getNewValue();
if (newValue instanceof String) {
newValue = EEFConverterUtil.createFromString(DatabasePackage.eINSTANCE.getColumn_Autoincrement().getEAttributeType(), (String) newValue);
}
ret = Diagnostician.INSTANCE.validate(DatabasePackage.eINSTANCE.getColumn_Autoincrement().getEAttributeType(), newValue);
}
if (DatabaseViewsRepository.Column.Properties.defaultValue == event.getAffectedEditor()) {
Object newValue = event.getNewValue();
if (newValue instanceof String) {
newValue = EEFConverterUtil.createFromString(DatabasePackage.eINSTANCE.getColumn_DefaultValue().getEAttributeType(), (String) newValue);
}
ret = Diagnostician.INSTANCE.validate(DatabasePackage.eINSTANCE.getColumn_DefaultValue().getEAttributeType(), newValue);
}
if (DatabaseViewsRepository.Column.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.Column.Properties.TypeAttributes.length == event.getAffectedEditor()) {
Object newValue = event.getNewValue();
if (newValue instanceof String) {
newValue = EEFConverterUtil.createFromString(TypesLibraryPackage.eINSTANCE.getTypeInstance_Length().getEAttributeType(), (String) newValue);
}
ret = Diagnostician.INSTANCE.validate(TypesLibraryPackage.eINSTANCE.getTypeInstance_Length().getEAttributeType(), newValue);
}
if (DatabaseViewsRepository.Column.Properties.TypeAttributes.precision == event.getAffectedEditor()) {
Object newValue = event.getNewValue();
if (newValue instanceof String) {
newValue = EEFConverterUtil.createFromString(TypesLibraryPackage.eINSTANCE.getTypeInstance_Precision().getEAttributeType(), (String) newValue);
}
ret = Diagnostician.INSTANCE.validate(TypesLibraryPackage.eINSTANCE.getTypeInstance_Precision().getEAttributeType(), newValue);
}
if (DatabaseViewsRepository.Column.Properties.literals == event.getAffectedEditor()) {
BasicDiagnostic chain = new BasicDiagnostic();
for (Iterator iterator = ((List) event.getNewValue()).iterator(); iterator.hasNext(); ) {
chain.add(Diagnostician.INSTANCE.validate(TypesLibraryPackage.eINSTANCE.getTypeInstance_Literals().getEAttributeType(), iterator.next()));
}
ret = chain;
}
} catch (IllegalArgumentException iae) {
ret = BasicDiagnostic.toDiagnostic(iae);
} catch (WrappedException we) {
ret = BasicDiagnostic.toDiagnostic(we);
}
}
return ret;
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class StateMachineEditor method updateProblemIndication.
/**
* 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.obeonetwork.dsl.statemachine.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) {
StateMachineEditorPlugin.INSTANCE.log(exception);
}
}
if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
markerHelper.deleteMarkers(editingDomain.getResourceSet());
if (diagnostic.getSeverity() != Diagnostic.OK) {
try {
markerHelper.createMarkers(diagnostic);
} catch (CoreException exception) {
StateMachineEditorPlugin.INSTANCE.log(exception);
}
}
}
}
}
Aggregations