Search in sources :

Example 1 with Builder

use of org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.Builder 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();
}
Also used : IValidationIssueProcessor(org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) Issue(org.eclipse.xtext.validation.Issue) Builder(org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.Builder) EmbeddedEditor(org.eclipse.xtext.ui.editor.embedded.EmbeddedEditor)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 EmbeddedEditor (org.eclipse.xtext.ui.editor.embedded.EmbeddedEditor)1 Builder (org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.Builder)1 IValidationIssueProcessor (org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor)1 Issue (org.eclipse.xtext.validation.Issue)1