/** * Initializes the text widget with the visual document and * invalidates the overall presentation. */ private void initializeWidgetContents() { if (fTextWidget != null && fVisibleDocument != null) { // set widget content if (fDocumentAdapter == null) fDocumentAdapter= createDocumentAdapter(); fDocumentAdapter.setDocument(fVisibleDocument); fTextWidget.setContent(fDocumentAdapter); // invalidate presentation invalidateTextPresentation(); } }
/** * Initializes the text widget with the visual document and * invalidates the overall presentation. */ private void initializeWidgetContents() { if (fTextWidget != null && fVisibleDocument != null) { // set widget content if (fDocumentAdapter == null) fDocumentAdapter= createDocumentAdapter(); fDocumentAdapter.setDocument(fVisibleDocument); fTextWidget.setContent(fDocumentAdapter); // invalidate presentation invalidateTextPresentation(); } }
@Override protected void configureTextViewer(final TextViewer textViewer) { if (textViewer instanceof SourceViewer) { if (fColorManager == null) fColorManager = ColorManager.getDefault(); final XMLConfiguration configuration = new XMLConfiguration(fColorManager); textViewer.getControl().addDisposeListener(e -> configuration.dispose()); IPropertyChangeListener propertyChangedListener = event -> { // the configuration will test if the properties affect the presentation also, // but checking it here allows us to prevent the viewer from being invalidated // and saves some unnecessary work if (configuration.affectsColorPresentation(event) || configuration.affectsTextPresentation(event)) { configuration.adaptToPreferenceChange(event); textViewer.invalidateTextPresentation(); } }; PDEPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangedListener); if (fPropertyChangedListeners == null) fPropertyChangedListeners = new ArrayList<>(3); fPropertyChangedListeners.add(propertyChangedListener); ((SourceViewer) textViewer).configure(configuration); Font font = JFaceResources.getFont(PluginContentMergeViewer.class.getName()); if (font != null) ((SourceViewer) textViewer).getTextWidget().setFont(font); } }