Package org.eclipse.jface.text.source

Examples of org.eclipse.jface.text.source.ISourceViewer


  private void beginBusyStateInternal() {

    fBusyState = true;
    startBusyTimer();

    ISourceViewer viewer = getSourceViewer();
    if (viewer instanceof StructuredTextViewer) {
      ((StructuredTextViewer) viewer).beginBackgroundUpdate();

    }
    showBusy(true);
View Full Code Here


        presenter.install(getSourceViewer());
        fOutlineHandler.configure(presenter);
      }
    }
    installCharacterPairing();
    ISourceViewer viewer = getSourceViewer();
    if (viewer instanceof ITextViewerExtension) {
      ((ITextViewerExtension) viewer).appendVerifyKeyListener(fPairInserter);
      fPairInserter.installCompletionListener();
    }
View Full Code Here

      System.out.println("Total calls to getAdapter: " + adapterRequests); //$NON-NLS-1$
      System.out.println("Total time in getAdapter: " + adapterTime); //$NON-NLS-1$
      System.out.println("Average time per call: " + (adapterTime / adapterRequests)); //$NON-NLS-1$
    }

    ISourceViewer viewer = getSourceViewer();
    if (viewer instanceof ITextViewerExtension)
      ((ITextViewerExtension) viewer).removeVerifyKeyListener(fPairInserter);

    // dispose of information presenter
    if (fInformationPresenter != null) {
View Full Code Here

  private void endBusyStateInternal(byte[] result) {
    if (fBackgroundJobEnded) {
      result[0] = 1;
      showBusy(false);

      ISourceViewer viewer = getSourceViewer();
      if (viewer instanceof StructuredTextViewer) {
        ((StructuredTextViewer) viewer).endBackgroundUpdate();
      }
      fBusyState = false;
    }
View Full Code Here

  void gotoMatchingBracket() {
    ICharacterPairMatcher matcher = createCharacterPairMatcher();
    if (matcher == null)
      return;

    ISourceViewer sourceViewer = getSourceViewer();
    IDocument document = sourceViewer.getDocument();
    if (document == null)
      return;

    IRegion selection = getSignedSelection(sourceViewer);

    int selectionLength = Math.abs(selection.getLength());
    if (selectionLength > 1) {
      setStatusLineErrorMessage(SSEUIMessages.GotoMatchingBracket_error_invalidSelection);
      sourceViewer.getTextWidget().getDisplay().beep();
      return;
    }

    int sourceCaretOffset = selection.getOffset() + selection.getLength();
    IRegion region = matcher.match(document, sourceCaretOffset);
    if (region == null) {
      setStatusLineErrorMessage(SSEUIMessages.GotoMatchingBracket_error_noMatchingBracket);
      sourceViewer.getTextWidget().getDisplay().beep();
      return;
    }

    int offset = region.getOffset();
    int length = region.getLength();

    if (length < 1)
      return;

    int anchor = matcher.getAnchor();

    // go to after the match if matching to the right
    int targetOffset = (ICharacterPairMatcher.RIGHT == anchor) ? offset : offset + length;

    boolean visible = false;
    if (sourceViewer instanceof ITextViewerExtension5) {
      ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
      visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1);
    }
    else {
      IRegion visibleRegion = sourceViewer.getVisibleRegion();
      // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
      visible = (targetOffset >= visibleRegion.getOffset() && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
    }

    if (!visible) {
      setStatusLineErrorMessage(SSEUIMessages.GotoMatchingBracket_error_bracketOutsideSelectedElement);
      sourceViewer.getTextWidget().getDisplay().beep();
      return;
    }

    if (selection.getLength() < 0)
      targetOffset -= selection.getLength();

    if (sourceViewer != null) {
      sourceViewer.setSelectedRange(targetOffset, selection.getLength());
      sourceViewer.revealRange(targetOffset, selection.getLength());
    }
  }
View Full Code Here

      }
    }

    // update content assist preferences
    else if (EditorPreferenceNames.CODEASSIST_PROPOSALS_BACKGROUND.equals(property)) {
      ISourceViewer sourceViewer = getSourceViewer();
      if (sourceViewer != null) {
        SourceViewerConfiguration configuration = getSourceViewerConfiguration();
        if (configuration != null) {
          IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
          if (contentAssistant instanceof ContentAssistant) {
            ContentAssistant assistant = (ContentAssistant) contentAssistant;
            RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), EditorPreferenceNames.CODEASSIST_PROPOSALS_BACKGROUND);
            Color color = EditorUtility.getColor(rgb);
            assistant.setProposalSelectorBackground(color);
          }
        }
      }
    }

    // update content assist preferences
    else if (EditorPreferenceNames.CODEASSIST_PROPOSALS_FOREGROUND.equals(property)) {
      ISourceViewer sourceViewer = getSourceViewer();
      if (sourceViewer != null) {
        SourceViewerConfiguration configuration = getSourceViewerConfiguration();
        if (configuration != null) {
          IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
          if (contentAssistant instanceof ContentAssistant) {
            ContentAssistant assistant = (ContentAssistant) contentAssistant;
            RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), EditorPreferenceNames.CODEASSIST_PROPOSALS_FOREGROUND);
            Color color = EditorUtility.getColor(rgb);
            assistant.setProposalSelectorForeground(color);
          }
        }
      }
    }

    // update content assist preferences
    else if (EditorPreferenceNames.CODEASSIST_PARAMETERS_BACKGROUND.equals(property)) {
      ISourceViewer sourceViewer = getSourceViewer();
      if (sourceViewer != null) {
        SourceViewerConfiguration configuration = getSourceViewerConfiguration();
        if (configuration != null) {
          IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
          if (contentAssistant instanceof ContentAssistant) {
            ContentAssistant assistant = (ContentAssistant) contentAssistant;
            RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), EditorPreferenceNames.CODEASSIST_PARAMETERS_BACKGROUND);
            Color color = EditorUtility.getColor(rgb);
            assistant.setContextInformationPopupBackground(color);
            assistant.setContextSelectorBackground(color);
          }
        }
      }
    }

    // update content assist preferences
    else if (EditorPreferenceNames.CODEASSIST_PARAMETERS_FOREGROUND.equals(property)) {
      ISourceViewer sourceViewer = getSourceViewer();
      if (sourceViewer != null) {
        SourceViewerConfiguration configuration = getSourceViewerConfiguration();
        if (configuration != null) {
          IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
          if (contentAssistant instanceof ContentAssistant) {
View Full Code Here

    for (int i = 0; i < types.length; i++) {

      String t = types[i];

      ISourceViewer sourceViewer = getSourceViewer();
      if (sourceViewer instanceof ITextViewerExtension2) {
        // Remove existing hovers
        ((ITextViewerExtension2) sourceViewer).removeTextHovers(t);

        int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);

        if (stateMasks != null) {
          for (int j = 0; j < stateMasks.length; j++) {
            int stateMask = stateMasks[j];
            ITextHover textHover = configuration.getTextHover(sourceViewer, t, stateMask);
            ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, stateMask);
          }
        }
        else {
          ITextHover textHover = configuration.getTextHover(sourceViewer, t);
          ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
        }
      }
      else
        sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t);
    }
  }
View Full Code Here

    if (category == null)
      return;

    if (StructuredTextEditorActionConstants.STATUS_CATEGORY_OFFSET.equals(category)) {
      IStatusField field = getStatusField(category);
      ISourceViewer sourceViewer = getSourceViewer();
      if (field != null && sourceViewer != null) {
        Point selection = sourceViewer.getTextWidget().getSelection();
        int offset1 = widgetOffset2ModelOffset(sourceViewer, selection.x);
        int offset2 = widgetOffset2ModelOffset(sourceViewer, selection.y);
        String text = null;
        if (offset1 != offset2)
          text = "[" + offset1 + "-" + offset2 + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
View Full Code Here

   * @param addedPositions the added positions
   * @param removedPositions the removed positions
   * @return the text presentation or <code>null</code>, if reconciliation should be canceled
   */
  public TextPresentation createPresentation(List addedPositions, List removedPositions) {
    ISourceViewer sourceViewer= fSourceViewer;
    StructuredPresentationReconciler presentationReconciler= fPresentationReconciler;
    if (sourceViewer == null || presentationReconciler == null)
      return null;

    if (isCanceled())
      return null;

    IDocument document= sourceViewer.getDocument();
    if (document == null)
      return null;

    int minStart= Integer.MAX_VALUE;
    int maxEnd= Integer.MIN_VALUE;
View Full Code Here

    if (semanticHighlightingStrategy != null && document != null) {
      semanticHighlightingStrategy.reconcile(new Region(0, document.getLength()));
    }

    if ((getTextViewer() instanceof ISourceViewer)) {
      ISourceViewer sourceViewer = (ISourceViewer) getTextViewer();
      IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
      for (int i = 0; i < fReconcileListeners.length; i++) {
        fReconcileListeners[i].reconciled(document, annotationModel, false, new NullProgressMonitor());
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.source.ISourceViewer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.