/** * Registers our auto edit vetoer with the viewer. * * @param viewer * the viewer we want to veto ui-triggered changes within linked * positions */ private void registerAutoEditVetoer(ITextViewer viewer) { try { String[] contentTypes = getContentTypes(viewer.getDocument()); if (viewer instanceof ITextViewerExtension2) { ITextViewerExtension2 vExtension = ((ITextViewerExtension2) viewer); for (int i = 0; i < contentTypes.length; i++) { vExtension.prependAutoEditStrategy(fAutoEditVetoer, contentTypes[i]); } } else { Assert.isTrue(false); } } catch (BadPartitioningException e) { leave(ILinkedModeListener.EXIT_ALL); } }
@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); } } }
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; } } }
private void unregisterAutoEditVetoer(ITextViewer viewer) { try { String[] contentTypes = getContentTypes(viewer.getDocument()); if (viewer instanceof ITextViewerExtension2) { ITextViewerExtension2 vExtension = ((ITextViewerExtension2) viewer); for (int i = 0; i < contentTypes.length; i++) { vExtension.removeAutoEditStrategy(fAutoEditVetoer, contentTypes[i]); } } else { Assert.isTrue(false); } } catch (BadPartitioningException e) { leave(ILinkedModeListener.EXIT_ALL); } }
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); }
private void repairRepresentation(boolean redrawAll) { if (fActiveRegion == null) { return; } ISourceViewer viewer = getSourceViewer(); if (viewer != null) { resetCursor(viewer); int offset = fActiveRegion.getOffset(); int length = fActiveRegion.getLength(); // remove style if (!redrawAll && viewer instanceof ITextViewerExtension2) { ((ITextViewerExtension2) viewer).invalidateTextPresentation(offset, length); } else { viewer.invalidateTextPresentation(); } // remove underline if (viewer instanceof ITextViewerExtension5) { ITextViewerExtension5 extension = (ITextViewerExtension5) viewer; offset = extension.modelOffset2WidgetOffset(offset); } else { offset -= viewer.getVisibleRegion().getOffset(); } StyledText text = viewer.getTextWidget(); try { text.redrawRange(offset, length, true); } catch (IllegalArgumentException x) { } } fActiveRegion = null; }
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); } } }
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(); } }
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(); } } }
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); } }
@Override public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); }
@Override public final ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); }