/**
   * Sets the preference store on this viewer.
   *
   * @param store the preference store
   * @since 3.0
   */
  public void setPreferenceStore(IPreferenceStore store) {
    if (fIsConfigured && fPreferenceStore != null)
      fPreferenceStore.removePropertyChangeListener(this);

    fPreferenceStore = store;

    if (fIsConfigured && fPreferenceStore != null) {
      fPreferenceStore.addPropertyChangeListener(this);
      initializeViewerColors();
    }
  }
 /*
  * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
  */
 @Override
 public void propertyChange(PropertyChangeEvent event) {
   String property = event.getProperty();
   if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
       || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property)
       || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property)
       || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
       || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR.equals(
           property)
       || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR
           .equals(property)
       || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR.equals(
           property)
       || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR
           .equals(property)) {
     initializeViewerColors();
   }
 }
  /*
   * @see ISourceViewer#configure(SourceViewerConfiguration)
   */
  @Override
  public void configure(SourceViewerConfiguration configuration) {

    /*
     * Prevent access to colors disposed in unconfigure(), see:
     *   https://bugs.eclipse.org/bugs/show_bug.cgi?id=53641
     *   https://bugs.eclipse.org/bugs/show_bug.cgi?id=86177
     */
    StyledText textWidget = getTextWidget();
    if (textWidget != null && !textWidget.isDisposed()) {
      Color foregroundColor = textWidget.getForeground();
      if (foregroundColor != null && foregroundColor.isDisposed()) textWidget.setForeground(null);
      Color backgroundColor = textWidget.getBackground();
      if (backgroundColor != null && backgroundColor.isDisposed()) textWidget.setBackground(null);
    }

    super.configure(configuration);
    if (configuration instanceof JavaSourceViewerConfiguration) {
      JavaSourceViewerConfiguration javaSVCconfiguration =
          (JavaSourceViewerConfiguration) configuration;
      fOutlinePresenter = javaSVCconfiguration.getOutlinePresenter(this, false);
      if (fOutlinePresenter != null) fOutlinePresenter.install(this);

      fStructurePresenter = javaSVCconfiguration.getOutlinePresenter(this, true);
      if (fStructurePresenter != null) fStructurePresenter.install(this);

      fHierarchyPresenter = javaSVCconfiguration.getHierarchyPresenter(this, true);
      if (fHierarchyPresenter != null) fHierarchyPresenter.install(this);
    }

    if (fPreferenceStore != null) {
      fPreferenceStore.addPropertyChangeListener(this);
      initializeViewerColors();
    }

    fIsConfigured = true;
  }