use of org.eclipse.che.ide.api.editor.annotation.AnnotationModel in project che by eclipse.
the class PublishDiagnosticsProcessor method processDiagnostics.
public void processDiagnostics(PublishDiagnosticsParamsDTO diagnosticsMessage) {
EditorPartPresenter openedEditor = editorAgent.getOpenedEditor(new Path(diagnosticsMessage.getUri()));
//TODO add markers
if (openedEditor == null) {
return;
}
if (openedEditor instanceof TextEditor) {
TextEditorConfiguration editorConfiguration = ((TextEditor) openedEditor).getConfiguration();
AnnotationModel annotationModel = editorConfiguration.getAnnotationModel();
if (annotationModel != null && annotationModel instanceof DiagnosticCollector) {
DiagnosticCollector collector = (DiagnosticCollector) annotationModel;
collector.beginReporting();
try {
for (DiagnosticDTO diagnostic : diagnosticsMessage.getDiagnostics()) {
collector.acceptDiagnostic(diagnostic);
}
} finally {
collector.endReporting();
}
}
}
}
use of org.eclipse.che.ide.api.editor.annotation.AnnotationModel in project che by eclipse.
the class OrionEditorWidget method showErrors.
public void showErrors(AnnotationModelEvent event) {
List<Annotation> addedAnnotations = event.getAddedAnnotations();
JsArray<OrionProblemOverlay> jsArray = JsArray.createArray().cast();
AnnotationModel annotationModel = event.getAnnotationModel();
OrionAnnotationSeverityProvider severityProvider = null;
if (annotationModel instanceof OrionAnnotationSeverityProvider) {
severityProvider = (OrionAnnotationSeverityProvider) annotationModel;
}
for (Annotation annotation : addedAnnotations) {
Position position = annotationModel.getPosition(annotation);
OrionProblemOverlay problem = JavaScriptObject.createObject().cast();
problem.setDescription(annotation.getText());
problem.setStart(position.getOffset());
problem.setEnd(position.getOffset() + position.getLength());
problem.setId("che-annotation");
problem.setSeverity(getSeverity(annotation.getType(), severityProvider));
jsArray.push(problem);
}
editorOverlay.showProblems(jsArray);
}
use of org.eclipse.che.ide.api.editor.annotation.AnnotationModel in project che by eclipse.
the class OrionEditorInit method configureAnnotationModel.
/**
* Configures the editor's annotation model.
* @param documentHandle the handle on the editor
*/
private void configureAnnotationModel(final DocumentHandle documentHandle) {
final AnnotationModel annotationModel = configuration.getAnnotationModel();
if (annotationModel == null) {
return;
}
// add the renderers (event handler) before the model (event source)
if (textEditor instanceof HasAnnotationRendering) {
((HasAnnotationRendering) textEditor).configure(annotationModel, documentHandle);
}
annotationModel.setDocumentHandle(documentHandle);
documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, annotationModel);
// the model listens to QueryAnnotation events
documentHandle.getDocEventBus().addHandler(QueryAnnotationsEvent.TYPE, annotationModel);
}
Aggregations