@Override public void unselected(ITextViewer viewer) { if (fTextPresentationListener != null) { ((ITextViewerExtension4)viewer).removeTextPresentationListener(fTextPresentationListener); fTextPresentationListener= null; } repairPresentation(viewer); fRememberedStyleRange= null; }
@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); } }
if (extension4.moveFocusToWidgetToken()) return;
@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); } }
public void run() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) { if (fTextOperationAction.isEnabled()) fTextOperationAction.run(); return; } if (sourceViewer instanceof ITextViewerExtension4) { ITextViewerExtension4 extension4= (ITextViewerExtension4) sourceViewer; if (extension4.moveFocusToWidgetToken()) return; } if (sourceViewer instanceof ITextViewerExtension2) { // does a text hover exist? ITextHover textHover= ((ITextViewerExtension2) sourceViewer).getCurrentTextHover(); if (textHover != null && makeTextHoverFocusable(sourceViewer, textHover)) return; } if (sourceViewer instanceof ISourceViewerExtension3) { // does an annotation hover exist? IAnnotationHover annotationHover= ((ISourceViewerExtension3) sourceViewer).getCurrentAnnotationHover(); if (annotationHover != null && makeAnnotationHoverFocusable(sourceViewer, annotationHover)) return; } // otherwise, just run the action if (fTextOperationAction.isEnabled()) fTextOperationAction.run(); }
@Override public void unselected(ITextViewer viewer) { if (fTextPresentationListener != null) { ((ITextViewerExtension4)viewer).removeTextPresentationListener(fTextPresentationListener); fTextPresentationListener= null; } repairPresentation(viewer); fRememberedStyleRange= null; }
@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 run() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) { if (fTextOperationAction.isEnabled()) fTextOperationAction.run(); return; } if (sourceViewer instanceof ITextViewerExtension4) { ITextViewerExtension4 extension4= (ITextViewerExtension4) sourceViewer; if (extension4.moveFocusToWidgetToken()) return; } if (sourceViewer instanceof ITextViewerExtension2) { // does a text hover exist? ITextHover textHover= ((ITextViewerExtension2) sourceViewer).getCurrentTextHover(); if (textHover != null && makeTextHoverFocusable(sourceViewer, textHover)) return; } if (sourceViewer instanceof ISourceViewerExtension3) { // does an annotation hover exist? IAnnotationHover annotationHover= ((ISourceViewerExtension3) sourceViewer).getCurrentAnnotationHover(); if (annotationHover != null && makeAnnotationHoverFocusable(annotationHover)) return; } // otherwise, just run the action if (fTextOperationAction.isEnabled()) fTextOperationAction.run(); }
void uninstall() { StyledText editorTextWidget = fEditorViewer.getTextWidget(); // untrack changed content of styled text of the editor if (editorTextWidget.getContent() != null) { editorTextWidget.getContent().removeTextChangeListener(this); } // untrack changed styles of styled text of the editor if (fEditorViewer instanceof ITextViewerExtension4) { ((ITextViewerExtension4) fEditorViewer).removeTextPresentationListener(this); } fEditorViewer.removeTextInputListener(this); // track changed of vertical bar scroll to update highlight // Viewport. fEditorViewer.removeViewportListener(this); editorTextWidget.removeControlListener(this); fScaledFonts.values().forEach(Font::dispose); } }
@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 run() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) { if (fTextOperationAction.isEnabled()) fTextOperationAction.run(); return; } if (sourceViewer instanceof ITextViewerExtension4) { ITextViewerExtension4 extension4= (ITextViewerExtension4) sourceViewer; if (extension4.moveFocusToWidgetToken()) return; } if (sourceViewer instanceof ITextViewerExtension2) { // does a text hover exist? ITextHover textHover= ((ITextViewerExtension2) sourceViewer).getCurrentTextHover(); if (textHover != null && makeTextHoverFocusable(sourceViewer, textHover)) return; } if (sourceViewer instanceof ISourceViewerExtension3) { // does an annotation hover exist? IAnnotationHover annotationHover= ((ISourceViewerExtension3) sourceViewer).getCurrentAnnotationHover(); if (annotationHover != null && makeAnnotationHoverFocusable(annotationHover)) return; } // otherwise, just run the action if (fTextOperationAction.isEnabled()) fTextOperationAction.run(); }
/** * Updates the annotation painter. * @since 3.0 */ private void updateAnnotationPainter() { if (fAnnotationPainter == null) return; fAnnotationPainter.paint(IPainter.CONFIGURATION); if (!fAnnotationPainter.isPaintingAnnotations()) { if (fSourceViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.removePainter(fAnnotationPainter); } if (fSourceViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fSourceViewer).removeTextPresentationListener(fAnnotationPainter); fAnnotationPainter.deactivate(true); fAnnotationPainter.dispose(); fAnnotationPainter= null; } }
/** * 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)); }
/** * Updates the annotation painter. * @since 3.0 */ private void updateAnnotationPainter() { if (fAnnotationPainter == null) return; fAnnotationPainter.paint(IPainter.CONFIGURATION); if (!fAnnotationPainter.isPaintingAnnotations()) { if (fSourceViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.removePainter(fAnnotationPainter); } if (fSourceViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fSourceViewer).removeTextPresentationListener(fAnnotationPainter); fAnnotationPainter.deactivate(true); fAnnotationPainter.dispose(); fAnnotationPainter= null; } }
/** * 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(); } }
@Override public void uninstall() { fTextViewer.removeTextInputListener(this); IDocument document= fTextViewer.getDocument(); if (document != null) document.removeDocumentListener(this); if (fColor != null) { if (fDisposeColor) fColor.dispose(); fColor= null; } if (fTextViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fTextViewer).removeTextPresentationListener(this); fTextViewer= null; if (fPreferenceStore != null) { fPreferenceStore.removePropertyChangeListener(this); fPreferenceStore= null; } }
/** * 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(); } }
/** * Updates the annotation painter. * @since 3.0 */ private void updateAnnotationPainter() { if (fAnnotationPainter == null) return; fAnnotationPainter.paint(IPainter.CONFIGURATION); if (!fAnnotationPainter.isPaintingAnnotations()) { if (fSourceViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.removePainter(fAnnotationPainter); } if (fSourceViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fSourceViewer).removeTextPresentationListener(fAnnotationPainter); fAnnotationPainter.deactivate(true); fAnnotationPainter.dispose(); fAnnotationPainter= null; } }
/** * 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(); } }
@Override public void uninstall() { fTextViewer.removeTextInputListener(this); IDocument document= fTextViewer.getDocument(); if (document != null) document.removeDocumentListener(this); if (fColor != null) { if (fDisposeColor) fColor.dispose(); fColor= null; } if (fTextViewer instanceof ITextViewerExtension4) ((ITextViewerExtension4)fTextViewer).removeTextPresentationListener(this); fTextViewer= null; if (fPreferenceStore != null) { fPreferenceStore.removePropertyChangeListener(this); fPreferenceStore= null; } }