org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.Builder Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.Builder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GamlEditTemplateDialog.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
protected SourceViewer createViewer(final Composite parent) {
	final Builder editorBuilder = configuration.getEmbeddedEditorFactory().newEditor(resourceProvider);
	editorBuilder.processIssuesBy((issues, monitor) -> {
		IStatus result = Status.OK_STATUS;
		final StringBuilder messages = new StringBuilder();
		for (final 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(() -> updateStatus(toBeUpdated));
	});
	final EmbeddedEditor handle = editorBuilder.withParent(parent);
	partialModelEditor = handle.createPartialEditor(getPrefix(), data.getTemplate().getPattern(), "", true);
	return handle.getViewer();
}
 
Example #2
Source File: EditTemplateDialog.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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();
}