/*
   * @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;
  }
예제 #2
0
  /*
   * @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();
  }