Package org.eclipse.jface.text.source

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


   */
  protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {

    try {

      ISourceViewer sourceViewer= getSourceViewer();
      if (sourceViewer == null)
        return;

      String property= event.getProperty();

      if (fSourceViewerDecorationSupport != null && fOverviewRuler != null && OVERVIEW_RULER.equals(property))  {
        if (isOverviewRulerVisible())
          showOverviewRuler();
        else
          hideOverviewRuler();
        return;
      }

      if (DISABLE_OVERWRITE_MODE.equals(property)) {
        enableOverwriteMode(isOverwriteModeEnabled());
        return;
      }

      if (LINE_NUMBER_RULER.equals(property)) {
        // only handle visibility of the combined column, but not the number/change only state
        IColumnSupport columnSupport= (IColumnSupport)getAdapter(IColumnSupport.class);
        if (isLineNumberRulerVisible() && fLineColumn == null) {
          RulerColumnDescriptor lineNumberColumnDescriptor= RulerColumnRegistry.getDefault().getColumnDescriptor(LineNumberColumn.ID);
          if (lineNumberColumnDescriptor != null)
            columnSupport.setColumnVisible(lineNumberColumnDescriptor, true);
        } else if (!isLineNumberRulerVisible() && fLineColumn != null && !fLineColumn.isShowingChangeInformation()) {
          columnSupport.setColumnVisible(fLineColumn.getDescriptor(), false);
          fLineColumn= null;
        }
        return;
      }

      if (AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON.equals(property)) {
        showChangeInformation(isPrefQuickDiffAlwaysOn());
      }

      if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
        IPreferenceStore store= getPreferenceStore();
        if (store != null)
          sourceViewer.getTextWidget().setTabs(store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH));
        if (isTabsToSpacesConversionEnabled()) {
          uninstallTabsToSpacesConverter();
          installTabsToSpacesConverter();
        }
        return;
View Full Code Here


  private RutaPairMatcher bracketMatcher;

  private void configureToggleCommentAction() {
    IAction action = getAction("ToggleComment"); //$NON-NLS-1$
    if (action instanceof ToggleCommentAction) {
      ISourceViewer sourceViewer = getSourceViewer();
      SourceViewerConfiguration configuration = getSourceViewerConfiguration();
      ((ToggleCommentAction) action).configure(sourceViewer, configuration);
    }
  }
View Full Code Here

    }

    RutaSelectionParser parser = new RutaSelectionParser();
    ISourceModule unit = (ISourceModule) getInputModelElement();
    ModuleDeclaration parsed = parser.parse(unit);
    ISourceViewer sourceViewer = getSourceViewer();
    StyledText styledText = sourceViewer.getTextWidget();
    int caret = 0;
    if (sourceViewer instanceof ITextViewerExtension5) {
      ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
      caret = extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
    } else {
      int offset = sourceViewer.getVisibleRegion().getOffset();
      caret = offset + styledText.getCaretOffset();
    }
    RutaReferenceVisitor visitor1 = new RutaReferenceVisitor(caret);
    ASTNode node = null;
    try {
View Full Code Here

  /**
   * Jumps to the matching bracket.
   */
  @Override
  public void gotoMatchingBracket() {
    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("No bracket selected");
      sourceViewer.getTextWidget().getDisplay().beep();
      return;
    }

    // #26314
    int sourceCaretOffset = selection.getOffset() + selection.getLength();
    if (isSurroundedByBrackets(document, sourceCaretOffset))
      sourceCaretOffset -= selection.getLength();

    IRegion region = bracketMatcher.match(document, sourceCaretOffset);
    if (region == null) {
      setStatusLineErrorMessage("No matching bracket found");
      sourceViewer.getTextWidget().getDisplay().beep();
      return;
    }

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

    if (length < 1)
      return;

    int anchor = bracketMatcher.getAnchor();
    // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
    int targetOffset = (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1 : 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("Matching bracket is outside selected element");
      sourceViewer.getTextWidget().getDisplay().beep();
      return;
    }

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

    sourceViewer.setSelectedRange(targetOffset, selection.getLength());
    sourceViewer.revealRange(targetOffset, selection.getLength());
  }
View Full Code Here

  public void addHyperlinkProvider(IHyperlinkProvider provider){
    this.providers.add(provider);
  }
 
  public void install() {
    ISourceViewer sourceViewer= editor.getViewer();
    if (sourceViewer == null)
      return;
     
    StyledText text= sourceViewer.getTextWidget();
    if (text == null || text.isDisposed())
      return;
   
    color = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE);
//    updateColor(sourceViewer);

    sourceViewer.addTextInputListener(this);
   
    IDocument document= sourceViewer.getDocument();
    if (document != null)
      document.addDocumentListener(this);

    text.addKeyListener(this);
    text.addMouseListener(this);
View Full Code Here

    if (cursor != null) {
      cursor.dispose();
      cursor= null;
    }
   
    ISourceViewer sourceViewer= editor.getViewer();
    if (sourceViewer != null)
      sourceViewer.removeTextInputListener(this);
   
    IDocumentProvider documentProvider= editor.getDocumentProvider();
    if (documentProvider != null) {
      IDocument document= documentProvider.getDocument(editor.getEditorInput());
      if (document != null)
        document.removeDocumentListener(this);
    }
     
//    IPreferenceStore preferenceStore= getPreferenceStore();
//    if (preferenceStore != null)
//      preferenceStore.removePropertyChangeListener(this);
   
    if (sourceViewer == null)
      return;
   
    StyledText text= sourceViewer.getTextWidget();
    if (text == null || text.isDisposed())
      return;
     
    text.removeKeyListener(this);
    text.removeMouseListener(this);
View Full Code Here

   
    int offset= activeRegion.getOffset();
    int length= activeRegion.getLength();
    activeRegion= null;
     
    ISourceViewer viewer= editor.getViewer();
    if (viewer != null) {
     
      resetCursor(viewer);
     
      // Invalidate ==> remove applied text presentation
      if (!redrawAll && viewer instanceof ITextViewerExtension2)
        ((ITextViewerExtension2) viewer).invalidateTextPresentation(offset, length);
      else
        viewer.invalidateTextPresentation();
     
      // Remove underline
      if (viewer instanceof ITextViewerExtension5) {
        ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
        offset= extension.modelOffset2WidgetOffset(offset);
      } else {
        offset -= viewer.getVisibleRegion().getOffset();
      }
      try {
        StyledText text= viewer.getTextWidget();

        text.redrawRange(offset, length, false);
      } catch (IllegalArgumentException x) {
//        JavaPlugin.log(x);
      }
View Full Code Here

        return;
      // modifier was already pressed
      active = true;
    }

    ISourceViewer viewer= editor.getViewer();
    if (viewer == null) {
      deactivate();
      return;
    }
     
    StyledText text= viewer.getTextWidget();
    if (text == null || text.isDisposed()) {
      deactivate();
      return;
    }
     
View Full Code Here

       
        event.getDocument().removePosition(fRememberedPosition);
        activeRegion= new Region(fRememberedPosition.getOffset(), fRememberedPosition.getLength());
        fRememberedPosition= null;
       
        ISourceViewer viewer= editor.getViewer();
        if (viewer != null) {
          StyledText widget= viewer.getTextWidget();
          if (widget != null && !widget.isDisposed()) {
            widget.getDisplay().asyncExec(new Runnable() {
              public void run() {
                deactivate();
              }
View Full Code Here

  public void paintControl(PaintEvent event) { 
    if (activeRegion == null)
      return;

    ISourceViewer viewer= editor.getViewer();
    if (viewer == null)
      return;
     
    StyledText text= viewer.getTextWidget();
    if (text == null || text.isDisposed())
      return;
     
     
    int offset= 0;
    int length= 0;

    if (viewer instanceof ITextViewerExtension5) {
     
      ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
      IRegion widgetRange= extension.modelRange2WidgetRange(activeRegion);
      if (widgetRange == null)
        return;
       
      offset= widgetRange.getOffset();
      length= widgetRange.getLength();
     
    } else {
     
      IRegion region= viewer.getVisibleRegion();     
      if (!includes(region, activeRegion))
        return;       
     
      offset= activeRegion.getOffset() - region.getOffset();
      length= activeRegion.getLength();
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.