@Override public void install(ITextViewer textViewer) { Assert.isNotNull(textViewer); fTextViewer= textViewer; fTextViewer.addTextInputListener(this); if (fTextViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fTextViewer).addTextPresentationListener(this); if (fPreferenceStore != null) { fIsUsingNativeLinkColor= fPreferenceStore.getBoolean(HYPERLINK_COLOR_SYSTEM_DEFAULT); if (!fIsUsingNativeLinkColor) fColor= createColorFromPreferenceStore(); fPreferenceStore.addPropertyChangeListener(this); } else if (fRGB != null) { StyledText text= fTextViewer.getTextWidget(); if (text != null && !text.isDisposed()) fColor= new Color(text.getDisplay(), fRGB); } }
@Override public void selected(final ITextViewer viewer, boolean smartToggle) { repairPresentation(viewer); fRememberedStyleRange= null; if (!insertCompletion() ^ smartToggle) { StyleRange range= createStyleRange(viewer); if (range == null) return; fRememberedStyleRange= range; if (viewer instanceof ITextViewerExtension4) { if (fTextPresentationListener == null) { fTextPresentationListener= new ITextPresentationListener() { @Override public void applyTextPresentation(TextPresentation textPresentation) { fRememberedStyleRange= createStyleRange(viewer); if (fRememberedStyleRange != null) textPresentation.mergeStyleRange(fRememberedStyleRange); } }; ((ITextViewerExtension4)viewer).addTextPresentationListener(fTextPresentationListener); } repairPresentation(viewer); } else updateStyle(viewer); } }
@Override public void install(ITextViewer textViewer) { Assert.isNotNull(textViewer); fTextViewer= textViewer; fTextViewer.addTextInputListener(this); if (fTextViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fTextViewer).addTextPresentationListener(this); if (fPreferenceStore != null) { fIsUsingNativeLinkColor= fPreferenceStore.getBoolean(HYPERLINK_COLOR_SYSTEM_DEFAULT); if (!fIsUsingNativeLinkColor) fColor= createColorFromPreferenceStore(); fPreferenceStore.addPropertyChangeListener(this); } else if (fRGB != null) { StyledText text= fTextViewer.getTextWidget(); if (text != null && !text.isDisposed()) fColor= new Color(text.getDisplay(), fRGB); } }
@Override public void selected(final ITextViewer viewer, boolean smartToggle) { repairPresentation(viewer); fRememberedStyleRange= null; if (!insertCompletion() ^ smartToggle) { StyleRange range= createStyleRange(viewer); if (range == null) return; fRememberedStyleRange= range; if (viewer instanceof ITextViewerExtension4) { if (fTextPresentationListener == null) { fTextPresentationListener= new ITextPresentationListener() { @Override public void applyTextPresentation(TextPresentation textPresentation) { fRememberedStyleRange= createStyleRange(viewer); if (fRememberedStyleRange != null) textPresentation.mergeStyleRange(fRememberedStyleRange); } }; ((ITextViewerExtension4)viewer).addTextPresentationListener(fTextPresentationListener); } repairPresentation(viewer); } else updateStyle(viewer); } }
/** * Install the inlined annotation support for the given viewer. * * @param viewer the source viewer * @param painter the annotation painter to use to draw the inlined annotations. */ public void install(ISourceViewer viewer, AnnotationPainter painter) { Assert.isNotNull(viewer); Assert.isNotNull(painter); fViewer= viewer; fPainter= painter; initPainter(); StyledText text= fViewer.getTextWidget(); if (text == null || text.isDisposed()) { return; } if (fViewer instanceof ITextViewerExtension4) { updateStylesWidth= new UpdateStylesWidth(); ((ITextViewerExtension4) fViewer).addTextPresentationListener(updateStylesWidth); } visibleLines= new VisibleLines(); text.addMouseListener(fMouseTracker); text.addMouseMoveListener(fMouseTracker); setColor(text.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); }
/** * Enables annotations in the source viewer for the given annotation type. * * @param annotationType the annotation type * @param highlighting <code>true</code> if highlighting <code>false</code> if painting squiggles * @param updatePainter if <code>true</code> update the annotation painter * @since 3.0 */ private void showAnnotations(Object annotationType, boolean highlighting, boolean updatePainter) { if (fSourceViewer instanceof ITextViewerExtension2) { if (fAnnotationPainter == null) { fAnnotationPainter= createAnnotationPainter(); if (fSourceViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fSourceViewer).addTextPresentationListener(fAnnotationPainter); ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.addPainter(fAnnotationPainter); } fAnnotationPainter.setAnnotationTypeColor(annotationType, getAnnotationTypeColor(annotationType)); if (highlighting) fAnnotationPainter.addHighlightAnnotationType(annotationType); else fAnnotationPainter.addAnnotationType(annotationType, getAnnotationDecorationType(annotationType)); if (updatePainter) updateAnnotationPainter(); } }
/** * Enables annotations in the source viewer for the given annotation type. * * @param annotationType the annotation type * @param updatePainter if <code>true</code> update the annotation painter * @since 3.0 */ private void showAnnotations(Object annotationType, boolean updatePainter) { if (fSourceViewer instanceof ITextViewerExtension2) { if (fAnnotationPainter == null) { fAnnotationPainter= createAnnotationPainter(); if (fSourceViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fSourceViewer).addTextPresentationListener(fAnnotationPainter); ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.addPainter(fAnnotationPainter); } fAnnotationPainter.setAnnotationTypeColor(annotationType, getAnnotationTypeColor(annotationType)); Object decorationType= getAnnotationDecorationType(annotationType); if (decorationType != null) fAnnotationPainter.addAnnotationType(annotationType, decorationType); else fAnnotationPainter.addHighlightAnnotationType(annotationType); if (updatePainter) updateAnnotationPainter(); } }
void install() { StyledText editorTextWidget = fEditorViewer.getTextWidget(); fScaledFonts = new HashMap<>(); // Compute scaled font Font scaledFont = getScaledFont(editorTextWidget.getFont()); fMinimapTextWidget.setFont(scaledFont); // track changed content of styled text of the editor editorTextWidget.getContent().addTextChangeListener(this); // track changed styles of styled text of the editor fMinimapTextWidget.setBackground(editorTextWidget.getBackground()); fMinimapTextWidget.setForeground(editorTextWidget.getForeground()); if (fEditorViewer instanceof ITextViewerExtension4) { ((ITextViewerExtension4) fEditorViewer).addTextPresentationListener(this); } fEditorViewer.addTextInputListener(this); // track changed of vertical bar scroll to update highlight // Viewport. fEditorViewer.addViewportListener(this); editorTextWidget.addControlListener(this); synchTextAndStyles(); }
/** * Enables annotations in the source viewer for the given annotation type. * * @param annotationType the annotation type * @param updatePainter if <code>true</code> update the annotation painter * @since 3.0 */ private void showAnnotations(Object annotationType, boolean updatePainter) { if (fSourceViewer instanceof ITextViewerExtension2) { if (fAnnotationPainter == null) { fAnnotationPainter= createAnnotationPainter(); if (fSourceViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fSourceViewer).addTextPresentationListener(fAnnotationPainter); ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.addPainter(fAnnotationPainter); if (fSourceViewer instanceof ISourceViewerExtension5) ((ISourceViewerExtension5) fSourceViewer).setCodeMiningAnnotationPainter(fAnnotationPainter); } fAnnotationPainter.setAnnotationTypeColor(annotationType, getAnnotationTypeColor(annotationType)); Object decorationType= getAnnotationDecorationType(annotationType); if (decorationType != null) fAnnotationPainter.addAnnotationType(annotationType, decorationType); else fAnnotationPainter.addHighlightAnnotationType(annotationType); if (updatePainter) updateAnnotationPainter(); } }