private void createVerticalRuler(IDocument newInput, Class<SourceViewer> sourceViewerClazz) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchFieldException { forceCustomAnnotationHover(); Method declaredMethod2 = sourceViewerClazz.getDeclaredMethod("getVerticalRuler"); declaredMethod2.setAccessible(true); CompositeRuler ruler = (CompositeRuler) declaredMethod2.invoke(sourceViewer); boolean hasDecorator = false; Iterator<?> iter = (ruler).getDecoratorIterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof AnnotationColumn) { hasDecorator = true; } } if (!hasDecorator) { AnnotationColumn annotationColumn = new AnnotationColumn(); annotationColumn.createControl(ruler, ruler.getControl().getParent()); ruler.addDecorator(0, annotationColumn); } }
/** * @param parent * @param ruler * @param styles */ public DiffViewer(Composite parent, IVerticalRuler ruler, int styles) { super(parent, ruler, styles); setDocument(new Document()); SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(this, null, null, EditorsUI.getSharedTextColors()); support.setCursorLinePainterPreferenceKeys( AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR); support.install(EditorsUI.getPreferenceStore()); if (ruler instanceof CompositeRuler) { lineNumberRuler = new LineNumberRulerColumn(); ((CompositeRuler) ruler).addDecorator(0, lineNumberRuler); } initListeners(); getControl() .addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { EditorsUI.getPreferenceStore().removePropertyChangeListener(editorPrefListener); PlatformUI.getWorkbench() .getThemeManager() .removePropertyChangeListener(themeListener); colors.dispose(); } }); refreshDiffColors(); styleViewer(); }
@Override protected CompositeRuler createCompositeRuler() { annotationAccess = new AnnotationMarkerAccess(); IAnnotationModel annotationModel = getDocumentProvider().getAnnotationModel(getEditorInput()); AnnotationRulerColumn annotationRulerCol = new AnnotationRulerColumn(annotationModel, 16, annotationAccess); annotationRulerCol.addAnnotationType(AlternativeAnnotation.ALTERNATIVE_TYPE); CompositeRuler compositeRuler = new CompositeRuler(); compositeRuler.setModel(annotationModel); compositeRuler.addDecorator(0, annotationRulerCol); return compositeRuler; }
@SuppressWarnings("unchecked") protected IVerticalRuler createCompositeRuler() { CompositeRuler ruler = new CompositeRuler(); ruler.addDecorator(0, new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess())); for (Iterator iter = ruler.getDecoratorIterator(); iter.hasNext(); ) { IVerticalRulerColumn col = (IVerticalRulerColumn) iter.next(); if (col instanceof AnnotationRulerColumn) { AnnotationRulerColumn column = (AnnotationRulerColumn) col; for (Iterator iter2 = fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext(); ) { AnnotationPreference preference = (AnnotationPreference) iter2.next(); column.addAnnotationType(preference.getAnnotationType()); } column.addAnnotationType(Annotation.TYPE_UNKNOWN); break; } } return ruler; }