Package org.eclipse.jface.text.source

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


  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

    private CharacterPairing[] fInserters = new CharacterPairing[0];
    private ICompletionListener fCompletionListener;
    private boolean fIsCompleting = false;

    public void installCompletionListener() {
      ISourceViewer viewer = getSourceViewer();
      if (viewer instanceof StructuredTextViewer) {
        fCompletionListener = new ICompletionListener() {

          public void assistSessionStarted(ContentAssistEvent event) {
            fIsCompleting = true;
View Full Code Here

    /**
     * Perform cleanup on the character pair inserters
     */
    void dispose() {
      ISourceViewer viewer = getSourceViewer();
      if (viewer instanceof StructuredTextViewer) {
        ContentAssistantFacade facade = ((StructuredTextViewer) viewer).getContentAssistFacade();
        if (facade != null)
          facade.removeCompletionListener(fCompletionListener);
      }
View Full Code Here

          return;
      }
    }

    private boolean pair(VerifyEvent event, AbstractCharacterPairInserter inserter, Set partitions) {
      final ISourceViewer viewer = getSourceViewer();
      final IDocument document = getSourceViewer().getDocument();
      if (document != null) {
        try {
          final Point selection = viewer.getSelectedRange();
          final int offset = selection.x;
          final ITypedRegion partition = document.getPartition(offset);
          if (partitions.contains(partition.getType())) {
            // Don't modify if the editor input cannot be changed
            if (!validateEditorInputState())
View Full Code Here

    private CharacterPairing[] fInserters = new CharacterPairing[0];
    private ICompletionListener fCompletionListener;
    private boolean fIsCompleting = false;

    public void installCompletionListener() {
      ISourceViewer viewer = getSourceViewer();
      if (viewer instanceof StructuredTextViewer) {
        fCompletionListener = new ICompletionListener() {

          public void assistSessionStarted(ContentAssistEvent event) {
            fIsCompleting = true;
View Full Code Here

    /**
     * Perform cleanup on the character pair inserters
     */
    void dispose() {
      ISourceViewer viewer = getSourceViewer();
      if (viewer instanceof StructuredTextViewer) {
        ContentAssistantFacade facade = ((StructuredTextViewer) viewer).getContentAssistFacade();
        if (facade != null)
          facade.removeCompletionListener(fCompletionListener);
      }
View Full Code Here

          return;
      }
    }

    private boolean pair(VerifyEvent event, AbstractCharacterPairInserter inserter, Set partitions) {
      final ISourceViewer viewer = getSourceViewer();
      final IDocument document = getSourceViewer().getDocument();
      if (document != null) {
        try {
          final Point selection = viewer.getSelectedRange();
          final int offset = selection.x;
          final ITypedRegion partition = document.getPartition(offset);
          if (partitions.contains(partition.getType())) {
            // Don't modify if the editor input cannot be changed
            if (!validateEditorInputState())
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.