use of org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor in project xtext-eclipse by eclipse.
the class XbaseInformationControl method createContent.
/**
* Xbase - modification+ added detailPane
*/
@Override
protected void createContent(Composite parent) {
fSashForm = new SashForm(parent, parent.getStyle());
fSashForm.setOrientation(SWT.VERTICAL);
fBrowser = new Browser(fSashForm, SWT.NONE);
fBrowser.setJavascriptEnabled(false);
Display display = getShell().getDisplay();
ColorRegistry registry = JFaceResources.getColorRegistry();
// $NON-NLS-1$
Color foreground = registry.get("org.eclipse.ui.workbench.HOVER_FOREGROUND");
// $NON-NLS-1$
Color background = registry.get("org.eclipse.ui.workbench.HOVER_BACKGROUND");
if (background != null && foreground != null) {
fBrowser.setForeground(foreground);
fBrowser.setBackground(background);
} else {
fBrowser.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
fBrowser.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
}
fBrowser.addProgressListener(new ProgressAdapter() {
@Override
public void completed(ProgressEvent event) {
fCompleted = true;
}
});
fBrowser.addOpenWindowListener(new OpenWindowListener() {
@Override
public void open(WindowEvent event) {
// Cancel opening of new windows
event.required = true;
}
});
// Replace browser's built-in context menu with none
fSashForm.setMenu(new Menu(getShell(), SWT.NONE));
detailPaneComposite = createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
Layout layout = detailPaneComposite.getLayout();
if (layout instanceof GridLayout) {
GridLayout gl = (GridLayout) layout;
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.numColumns = 1;
}
if (background != null && foreground != null) {
detailPaneComposite.setForeground(foreground);
detailPaneComposite.setBackground(background);
} else {
detailPaneComposite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
detailPaneComposite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
}
resourceProvider = new HoverEditedResourceProvider();
embeddedEditor = xbaseHoverConfiguration.getEditorFactory().newEditor(resourceProvider).readOnly().processIssuesBy(new IValidationIssueProcessor() {
@Override
public void processIssues(List<Issue> issues, IProgressMonitor monitor) {
}
}).withParent(detailPaneComposite);
Control viewerControl = embeddedEditor.getViewer().getControl();
if (background != null && foreground != null) {
viewerControl.setForeground(foreground);
viewerControl.setBackground(background);
} else {
viewerControl.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
viewerControl.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
}
embeddedEditor.getDocument().setValidationJob(null);
createTextLayout();
}
use of org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor in project xtext-eclipse by eclipse.
the class EditTemplateDialog method createViewer.
protected SourceViewer createViewer(Composite parent) {
Builder editorBuilder = configuration.getEmbeddedEditorFactory().newEditor(resourceProvider);
editorBuilder.processIssuesBy(new IValidationIssueProcessor() {
@Override
public void processIssues(List<Issue> issues, IProgressMonitor monitor) {
IStatus result = Status.OK_STATUS;
StringBuilder messages = new StringBuilder();
for (Issue issue : issues) {
if (issue.getSeverity() == Severity.ERROR) {
if (messages.length() != 0)
messages.append('\n');
messages.append(issue.getMessage());
}
}
if (messages.length() != 0) {
result = createErrorStatus(messages.toString(), null);
}
final IStatus toBeUpdated = result;
getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
updateStatus(toBeUpdated);
}
});
}
});
EmbeddedEditor handle = editorBuilder.withParent(parent);
partialModelEditor = handle.createPartialEditor(getPrefix(), fTemplate.getPattern(), "", true);
return handle.getViewer();
}
use of org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor in project xtext-eclipse by eclipse.
the class ValidateActionHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor != null) {
IValidationIssueProcessor issueProcessor;
IXtextDocument xtextDocument = xtextEditor.getDocument();
IResource resource = xtextEditor.getResource();
if (resource != null)
issueProcessor = new MarkerIssueProcessor(resource, xtextEditor.getInternalSourceViewer().getAnnotationModel(), markerCreator, markerTypeProvider);
else
issueProcessor = new AnnotationIssueProcessor(xtextDocument, xtextEditor.getInternalSourceViewer().getAnnotationModel(), issueResolutionProvider);
ValidationJob validationJob = new ValidationJob(resourceValidator, xtextDocument, issueProcessor, CheckMode.ALL);
validationJob.schedule();
}
return this;
}
use of org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor in project n4js by eclipse.
the class OwnResourceValidatorAwareValidatingEditorCallback method newValidationJob.
private ValidationJob newValidationJob(final XtextEditor editor) {
final IXtextDocument document = editor.getDocument();
final IAnnotationModel annotationModel = editor.getInternalSourceViewer().getAnnotationModel();
final IssueResolutionProvider issueResolutionProvider = getService(editor, IssueResolutionProvider.class);
final MarkerTypeProvider markerTypeProvider = getService(editor, MarkerTypeProvider.class);
final MarkerCreator markerCreator = getService(editor, MarkerCreator.class);
final IValidationIssueProcessor issueProcessor = new CompositeValidationIssueProcessor(new AnnotationIssueProcessor(document, annotationModel, issueResolutionProvider), new MarkerIssueProcessor(editor.getResource(), markerCreator, markerTypeProvider));
return editor.getDocument().modify(resource -> {
final IResourceServiceProvider serviceProvider = resource.getResourceServiceProvider();
final IResourceValidator resourceValidator = serviceProvider.getResourceValidator();
return new ValidationJob(resourceValidator, editor.getDocument(), issueProcessor, ALL);
});
}
Aggregations