org.eclipse.jface.text.ITextViewerExtension2 Java Examples

The following examples show how to use org.eclipse.jface.text.ITextViewerExtension2. 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: DefaultContentViewer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void configureSourceViewer(ISourceViewer sourceViewer) {
	sourceViewer.setEditable(false);
	sourceViewer.configure(sourceViewerConfiguration);
	if (sourceViewer instanceof ITextViewerExtension6) {
		ITextViewerExtension6 textViewerExtension6 = (ITextViewerExtension6) sourceViewer;
		textViewerExtension6.setHyperlinkDetectors(null,
				sourceViewerConfiguration.getHyperlinkStateMask(sourceViewer));
	}
	if (sourceViewer instanceof ITextViewerExtension2) {
		ITextViewerExtension2 textViewerExtension2 = (ITextViewerExtension2) sourceViewer;
		String[] configuredContentTypes = sourceViewerConfiguration.getConfiguredContentTypes(sourceViewer);
		for (String contentType : configuredContentTypes) {
			textViewerExtension2.removeTextHovers(contentType);
		}
	}
}
 
Example #2
Source File: FormatterModifyTabPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected void updateShowInvisible(boolean value)
{
	if (value)
	{
		if (whitespaceCharacterPainter == null)
		{
			whitespaceCharacterPainter = new WhitespaceCharacterPainter(previewViewer);
			((ITextViewerExtension2) previewViewer).addPainter(whitespaceCharacterPainter);
		}
	}
	else
	{
		if (whitespaceCharacterPainter != null)
		{
			((ITextViewerExtension2) previewViewer).removePainter(whitespaceCharacterPainter);
			whitespaceCharacterPainter = null;
		}
	}
}
 
Example #3
Source File: IndentGuidesPainter.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private void showIndentGuides() {
    if (painter == null) {
        painter= new IndentGuidesPainter(textViewer, indentsModel);
        painter.getPreferencies();
        ((ITextViewerExtension2)textViewer).addPainter(painter);
    }
}
 
Example #4
Source File: IndentGuidesPainter.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private void hideIndentGuides() {
    if (painter != null) {
    	((ITextViewerExtension2)textViewer).removePainter(painter);
        painter.deactivate(true);
        painter.dispose();
        painter= null;
    }
}
 
Example #5
Source File: PairedBracketsPainter.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static void installToEditor( ISourceViewer isv
                                  , PairedBracketsMatcher matcher
                                  , IPreferenceStore store
                                  , String keyHighlightMatch 
                                  , String keyColor, String keyColorNoMatch ) 
{
    if (isv instanceof ITextViewerExtension2) {
        new PainterOnOffManager(isv, matcher, store, keyHighlightMatch, keyColor, keyColorNoMatch);
    }
}
 
Example #6
Source File: PairedBracketsPainter.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private void showMatching() {
    if (painter == null) {
        painter= new PairedBracketsPainter(isv, matcher);
        painter.setRgb       (getRgb(keyColor,        DEF_RGB_MATCHED), false);
        painter.setNoMatchRgb(getRgb(keyColorNoMatch, DEF_RGB_UNMATCHED), false);
        ((ITextViewerExtension2)isv).addPainter(painter);
    }
}
 
Example #7
Source File: PairedBracketsPainter.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private void hideMatching() {
    if (painter != null) {
        ((ITextViewerExtension2)isv).removePainter(painter);
        painter.deactivate(true);
        painter.dispose();
        painter= null;
    }
}
 
Example #8
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);
}
 
Example #9
Source File: ThemeableEditorExtension.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void createBackgroundPainter(ISourceViewer viewer)
{
	if (fFullLineBackgroundPainter == null)
	{
		if (viewer instanceof ITextViewerExtension2)
		{
			boolean lineHighlight = Platform.getPreferencesService().getBoolean(EditorsUI.PLUGIN_ID,
					AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true, null);
			fFullLineBackgroundPainter = new LineBackgroundPainter(viewer);
			fFullLineBackgroundPainter.setHighlightLineEnabled(lineHighlight);
			ITextViewerExtension2 extension = (ITextViewerExtension2) viewer;
			extension.addPainter(fFullLineBackgroundPainter);
		}
	}
}
 
Example #10
Source File: AbstractJavaCompletionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void repairPresentation(ITextViewer viewer) {
	if (fRememberedStyleRange != null) {
		if (viewer instanceof ITextViewerExtension2) {
			// attempts to reduce the redraw area
			ITextViewerExtension2 viewer2= (ITextViewerExtension2)viewer;
			viewer2.invalidateTextPresentation(fRememberedStyleRange.start, fRememberedStyleRange.length);
		} else
			viewer.invalidateTextPresentation();
	}
}
 
Example #11
Source File: PyCompletionPresentationUpdater.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void repairPresentation(ITextViewer viewer) {
    if (fRememberedStyleRange != null) {
        if (viewer instanceof ITextViewerExtension2) {
            // attempts to reduce the redraw area
            ITextViewerExtension2 viewer2 = (ITextViewerExtension2) viewer;
            viewer2.invalidateTextPresentation(fRememberedStyleRange.start, fRememberedStyleRange.length);
        } else {
            viewer.invalidateTextPresentation();
        }
    }
}
 
Example #12
Source File: IndentGuidesPainter.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public static void installToViewer(ITextViewer textViewer, IndentGuidesModel indentsModel) {
    if (textViewer instanceof ITextViewerExtension2) {
        new PainterOnOffManager(textViewer, indentsModel);
    }

}
 
Example #13
Source File: LineBackgroundPainter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void paint(int reason)
{
	if (fViewer == null)
	{
		return;
	}
	if (fViewer.getDocument() == null)
	{
		deactivate(false);
		return;
	}

	// initialization
	if (!fIsActive)
	{
		StyledText textWidget = fViewer.getTextWidget();
		textWidget.addLineBackgroundListener(this);
		textWidget.addPaintListener(this);
		fPositionManager.managePosition(fCurrentLine);
		fIsActive = true;
	}

	// This forces redraw of the line highlight
	if (updateHighlightLine())
	{
		// clear last line
		// Fix the background colors for tokens that didn't have the same as line!
		if (isOpaque() && !fLastLine.isDeleted() && fViewer instanceof ITextViewerExtension2)
		{
			ITextViewerExtension2 ext = (ITextViewerExtension2) fViewer;
			try
			{
				ext.invalidateTextPresentation(fLastLine.getOffset(), fLastLine.getLength());
			}
			catch (Exception e)
			{
				IdeLog.logError(CommonEditorPlugin.getDefault(), MessageFormat.format(
						"Error invalidating syntax coloring for offset {0}, length {1}", fLastLine.getOffset(), //$NON-NLS-1$
						fLastLine.getLength()), e);
			}
		}
		drawHighlightLine(fLastLine);
		// draw new line
		drawHighlightLine(fCurrentLine);
	}
}
 
Example #14
Source File: JavaSourceViewerConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
	return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
}
 
Example #15
Source File: PyEditConfiguration.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
    return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
}
 
Example #16
Source File: AbstractLangSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public final ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
	return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
}