/*
   * @see ITextOperationTargetExtension#enableOperation(int, boolean)
   * @since 2.0
   */
  public void enableOperation(int operation, boolean enable) {

    switch (operation) {
      case CONTENTASSIST_PROPOSALS:
      case CONTENTASSIST_CONTEXT_INFORMATION:
        {
          if (fContentAssistant == null) return;

          if (enable) {
            if (!fContentAssistantInstalled) {
              fContentAssistant.install(this);
              fContentAssistantInstalled = true;
            }
          } else if (fContentAssistantInstalled) {
            fContentAssistant.uninstall();
            fContentAssistantInstalled = false;
          }
          break;
        }
      case QUICK_ASSIST:
        {
          if (fQuickAssistAssistant == null) return;

          if (enable) {
            if (!fQuickAssistAssistantInstalled) {
              fQuickAssistAssistant.install(this);
              fQuickAssistAssistantInstalled = true;
            }
          } else if (fQuickAssistAssistantInstalled) {
            fQuickAssistAssistant.uninstall();
            fQuickAssistAssistantInstalled = false;
          }
        }
    }
  }
  /*
   * @see ISourceViewer#configure(SourceViewerConfiguration)
   */
  public void configure(SourceViewerConfiguration configuration) {

    if (getTextWidget() == null) return;

    setDocumentPartitioning(configuration.getConfiguredDocumentPartitioning(this));

    // install content type independent plug-ins
    fPresentationReconciler = configuration.getPresentationReconciler(this);
    if (fPresentationReconciler != null) fPresentationReconciler.install(this);

    fReconciler = configuration.getReconciler(this);
    if (fReconciler != null) fReconciler.install(this);

    fContentAssistant = configuration.getContentAssistant(this);
    if (fContentAssistant != null) {
      fContentAssistant.install(this);
      if (fContentAssistant instanceof IContentAssistantExtension4)
        fContentAssistantFacade = new ContentAssistantFacade(fContentAssistant);
      fContentAssistantInstalled = true;
    }

    fQuickAssistAssistant = configuration.getQuickAssistAssistant(this);
    if (fQuickAssistAssistant != null) {
      fQuickAssistAssistant.install(this);
      fQuickAssistAssistantInstalled = true;
    }

    fContentFormatter = configuration.getContentFormatter(this);

    fInformationPresenter = configuration.getInformationPresenter(this);
    if (fInformationPresenter != null) fInformationPresenter.install(this);

    setUndoManager(configuration.getUndoManager(this));

    getTextWidget().setTabs(configuration.getTabWidth(this));

    setAnnotationHover(configuration.getAnnotationHover(this));
    setOverviewRulerAnnotationHover(configuration.getOverviewRulerAnnotationHover(this));

    setHoverControlCreator(configuration.getInformationControlCreator(this));

    setHyperlinkPresenter(configuration.getHyperlinkPresenter(this));
    IHyperlinkDetector[] hyperlinkDetectors = configuration.getHyperlinkDetectors(this);
    int eventStateMask = configuration.getHyperlinkStateMask(this);
    setHyperlinkDetectors(hyperlinkDetectors, eventStateMask);

    // install content type specific plug-ins
    String[] types = configuration.getConfiguredContentTypes(this);
    for (int i = 0; i < types.length; i++) {

      String t = types[i];

      setAutoEditStrategies(configuration.getAutoEditStrategies(this, t), t);
      setTextDoubleClickStrategy(configuration.getDoubleClickStrategy(this, t), t);

      int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(this, t);
      if (stateMasks != null) {
        for (int j = 0; j < stateMasks.length; j++) {
          int stateMask = stateMasks[j];
          setTextHover(configuration.getTextHover(this, t, stateMask), t, stateMask);
        }
      } else {
        setTextHover(
            configuration.getTextHover(this, t), t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
      }

      String[] prefixes = configuration.getIndentPrefixes(this, t);
      if (prefixes != null && prefixes.length > 0) setIndentPrefixes(prefixes, t);

      prefixes = configuration.getDefaultPrefixes(this, t);
      if (prefixes != null && prefixes.length > 0) setDefaultPrefixes(prefixes, t);
    }

    activatePlugins();
  }