org.eclipse.jface.text.CursorLinePainter Java Examples

The following examples show how to use org.eclipse.jface.text.CursorLinePainter. 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: CommonMergeViewer.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void configureTextViewer(final TextViewer textViewer)
{
	ThemePlugin.getDefault().getControlThemerFactory().apply(textViewer);

	// Force line highlight color. We need to perform this after the line painter is attached, which happens after
	// the return of this method. Scheduling async seems to work.
	UIUtils.getDisplay().asyncExec(new Runnable()
	{

		public void run()
		{
			CursorLinePainter p = getCursorLinePainterInstalled(textViewer);
			if (p != null)
			{
				p.setHighlightColor(getColorManager().getColor(getCurrentTheme().getLineHighlightAgainstBG()));
			}
		}
	});
}
 
Example #2
Source File: CommonMergeViewer.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private CursorLinePainter getCursorLinePainterInstalled(TextViewer viewer)
{
	Listener[] listeners = viewer.getTextWidget().getListeners(3001/* StyledText.LineGetBackground */);
	for (Listener listener : listeners)
	{
		if (listener instanceof TypedListener)
		{
			TypedListener typedListener = (TypedListener) listener;
			if (typedListener.getEventListener() instanceof CursorLinePainter)
			{
				return (CursorLinePainter) typedListener.getEventListener();
			}
		}
	}
	return null;
}
 
Example #3
Source File: TMPresentationReconciler.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Initialize foreground, background color, current line highlight from the
 * current theme if needed.
 *
 */
private void applyThemeEditorIfNeeded() {
	if (!initializeViewerColors) {
		StyledText styledText = viewer.getTextWidget();
		((ITheme) tokenProvider).initializeViewerColors(styledText);
		initializeViewerColors = true;
	}
	if (updateTextDecorations) {
		return;
	}
	try {
		// Ugly code to update "current line highlight" :
		// - get the PaintManager from the ITextViewer with reflection.
		// - get the list of IPainter of PaintManager with reflection
		// - loop for IPainter to retrieve CursorLinePainter which manages "current line
		// highlight".
		PaintManager paintManager = ClassHelper.getFieldValue(viewer, "fPaintManager", TextViewer.class);
		if (paintManager == null) {
			return;
		}
		List<IPainter> painters = ClassHelper.getFieldValue(paintManager, "fPainters", PaintManager.class);
		if (painters == null) {
			return;
		}
		for (IPainter painter : painters) {
			if (painter instanceof CursorLinePainter) {
				// Update current line highlight
				Color background = tokenProvider.getEditorCurrentLineHighlight();
				if (background != null) {
					((CursorLinePainter) painter).setHighlightColor(background);
				}
				updateTextDecorations = true;
			}
		}
	} catch (Exception e) {
		TMUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID, e.getMessage(), e));
	}
}
 
Example #4
Source File: LogFileViewer.java    From LogViewer with Eclipse Public License 2.0 5 votes vote down vote up
private void createCursorLinePainter() {
    cursorLinePainter = new CursorLinePainter(txtViewer);
    Color color = new Color(Display.getCurrent(),PreferenceConverter.getColor(store,ILogViewerConstants.PREF_CURSORLINE_COLOR));
    cursorLinePainter.setHighlightColor(color);
    ITextViewerExtension2 extension = (ITextViewerExtension2)txtViewer;
    extension.addPainter(cursorLinePainter);
}