use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class SoaEditor 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.soa.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) {
SoaEditorPlugin.INSTANCE.log(exception);
}
}
if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
markerHelper.deleteMarkers(editingDomain.getResourceSet());
if (diagnostic.getSeverity() != Diagnostic.OK) {
try {
markerHelper.createMarkers(diagnostic);
} catch (CoreException exception) {
SoaEditorPlugin.INSTANCE.log(exception);
}
}
}
}
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class InitialStateInitialStatePropertiesEditionComponent 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 (StatemachineViewsRepository.InitialState.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.InitialState.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;
}
} 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 StateStatePropertiesEditionComponent 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 (StatemachineViewsRepository.State.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.State.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.State.Properties.name == event.getAffectedEditor()) {
Object newValue = event.getNewValue();
if (newValue instanceof String) {
newValue = EEFConverterUtil.createFromString(StateMachinePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), (String) newValue);
}
ret = Diagnostician.INSTANCE.validate(StateMachinePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
}
} 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 TransitionTransitionPropertiesEditionComponent 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 (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;
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class RequirementEditor method analyzeResourceProblems.
/**
* 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.obeonetwork.dsl.requirement.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.obeonetwork.dsl.requirement.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception });
} else {
return Diagnostic.OK_INSTANCE;
}
}
Aggregations