use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class RequirementEditor 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.requirement.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) {
RequirementEditorPlugin.INSTANCE.log(exception);
}
}
if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
markerHelper.deleteMarkers(editingDomain.getResourceSet());
if (diagnostic.getSeverity() != Diagnostic.OK) {
try {
markerHelper.createMarkers(diagnostic);
} catch (CoreException exception) {
RequirementEditorPlugin.INSTANCE.log(exception);
}
}
}
}
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class ApplicationEditor 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.application.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) {
ApplicationEditorPlugin.INSTANCE.log(exception);
}
}
if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
markerHelper.deleteMarkers(editingDomain.getResourceSet());
if (diagnostic.getSeverity() != Diagnostic.OK) {
try {
markerHelper.createMarkers(diagnostic);
} catch (CoreException exception) {
ApplicationEditorPlugin.INSTANCE.log(exception);
}
}
}
}
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class ApplicationEditor 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.application.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.application.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception });
} else {
return Diagnostic.OK_INSTANCE;
}
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class ValidateRequirementsHandler method executeValidation.
private void executeValidation(Collection<EObject> selectedEObjects) {
ValidationDelegateClientSelector.running = true;
IBatchValidator validator = ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
// include live constraints, also, in batch validation
validator.setOption(IBatchValidator.OPTION_INCLUDE_LIVE_CONSTRAINTS, true);
final IStatus status = validator.validate(selectedEObjects);
ValidationDelegateClientSelector.running = false;
// Markers creation
EclipseResourcesUtil eclipseResourcesUtil = new EclipseResourcesUtil();
eclipseResourcesUtil.deleteMarkers(resourceSet);
BasicDiagnostic parentDiagnostic = new BasicDiagnostic(EObjectValidator.DIAGNOSTIC_SOURCE, 0, EMFEditUIPlugin.INSTANCE.getString("_UI_DiagnosisOfNObjects_message", new String[] { Integer.toString(selectedEObjects.size()) }), selectedEObjects.toArray());
for (IStatus childStatus : status.getChildren()) {
EObject target = (EObject) ((IConstraintStatus) childStatus).getTarget();
Diagnostic childDiagnostic = new BasicDiagnostic(// Severity
childStatus.getSeverity(), // Source
childStatus.getPlugin(), // Code
childStatus.getCode(), // Message
childStatus.getMessage(), // Data
new Object[] { ((IConstraintStatus) childStatus).getTarget() });
parentDiagnostic.add(childDiagnostic);
eclipseResourcesUtil.createMarkers(target.eResource(), childDiagnostic);
}
if (parentDiagnostic.getChildren().isEmpty()) {
MessageDialog.openInformation(shell, "No errors during validation", "No errors found when validating requirements ");
} else {
DiagnosticDialog.open(shell, "Errors during validation", "Errors have been encountered during validation", parentDiagnostic);
}
ValidationDelegateClientSelector.running = false;
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project InformationSystem by ObeoNetwork.
the class DatabaseEditor 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.database.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) {
DatabaseEditorPlugin.INSTANCE.log(exception);
}
}
if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
markerHelper.deleteMarkers(editingDomain.getResourceSet());
if (diagnostic.getSeverity() != Diagnostic.OK) {
try {
markerHelper.createMarkers(diagnostic);
} catch (CoreException exception) {
DatabaseEditorPlugin.INSTANCE.log(exception);
}
}
}
}
}
Aggregations