/** * Install the semantic highlighting on the given editor infrastructure * * @param editor The Java editor * @param sourceViewer The source viewer * @param colorManager The color manager * @param preferenceStore The preference store * @param manager */ public void install( ColoredCompilationUnitEditor editor, JavaSourceViewer sourceViewer, IColorManager colorManager, IPreferenceStore preferenceStore, JDTColorManagerBridge compUnitColorManager) { fEditor = editor; fSourceViewer = sourceViewer; // fColorManager = colorManager; fPreferenceStore = preferenceStore; this.compUnitColorManager = compUnitColorManager; if (fEditor != null) { fConfiguration = new JavaSourceViewerConfiguration( colorManager, preferenceStore, editor, IJavaPartitions.JAVA_PARTITIONING); fPresentationReconciler = (JavaPresentationReconciler) fConfiguration.getPresentationReconciler(sourceViewer); } else { fConfiguration = null; fPresentationReconciler = null; } fPreferenceStore.addPropertyChangeListener(this); if (isEnabled()) enable(); }
/** * Handle the given property change event * * @param event The event */ private void handlePropertyChangeEvent(PropertyChangeEvent event) { if (fPreferenceStore == null) return; // Uninstalled during event notification if (fConfiguration != null) fConfiguration.handlePropertyChangeEvent(event); if (SemanticHighlightings.affectsEnablement(fPreferenceStore, event)) { if (isEnabled()) enable(); else disable(); } if (!isEnabled()) return; boolean refreshNeeded = false; /* * for (int i= 0, n= fSemanticHighlightings.length; i < n; i++) { * SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i]; * * String colorKey= * SemanticHighlightings.getColorPreferenceKey(semanticHighlighting); if * (colorKey.equals(event.getProperty())) { * adaptToTextForegroundChange(fHighlightings[i], event); * fPresenter.highlightingStyleChanged(fHighlightings[i]); * refreshNeeded= true; continue; } * * String boldKey= * SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting); if * (boldKey.equals(event.getProperty())) { * adaptToTextStyleChange(fHighlightings[i], event, SWT.BOLD); * fPresenter.highlightingStyleChanged(fHighlightings[i]); * refreshNeeded= true; continue; } * * String italicKey= * SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting); * if (italicKey.equals(event.getProperty())) { * adaptToTextStyleChange(fHighlightings[i], event, SWT.ITALIC); * fPresenter.highlightingStyleChanged(fHighlightings[i]); * refreshNeeded= true; continue; } * * String strikethroughKey= * SemanticHighlightings.getStrikethroughPreferenceKey * (semanticHighlighting); if * (strikethroughKey.equals(event.getProperty())) { * adaptToTextStyleChange(fHighlightings[i], event, * TextAttribute.STRIKETHROUGH); * fPresenter.highlightingStyleChanged(fHighlightings[i]); * refreshNeeded= true; continue; } * * String underlineKey= * SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting * ); if (underlineKey.equals(event.getProperty())) { * adaptToTextStyleChange(fHighlightings[i], event, * TextAttribute.UNDERLINE); * fPresenter.highlightingStyleChanged(fHighlightings[i]); * refreshNeeded= true; continue; } * * String enabledKey= * SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting); * if (enabledKey.equals(event.getProperty())) { * adaptToEnablementChange(fHighlightings[i], event); * fPresenter.highlightingStyleChanged(fHighlightings[i]); * refreshNeeded= true; continue; } } */ if (refreshNeeded && fReconciler != null) fReconciler.refresh(); }