Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IRewriteTarget


        }
        final Display display = textEditor.getEditorSite().getShell().getDisplay();
        display.syncExec(new Runnable() {
            @Override
            public void run() {
                final IRewriteTarget target = (IRewriteTarget) textEditor
                        .getAdapter(IRewriteTarget.class);
                if (target != null) {
                    target.beginCompoundChange();
                    target.setRedraw(false);
                }
                try {
                    if (!document.get(selection.getOffset(), selection.getLength())
                            .equals(newText)) {
                        document.replace(selection.getOffset(), selection.getLength(),
                                newText);
                    }
                } catch (final BadLocationException e) {
                    ErlLogger.warn(e);
                }
                if (target != null) {
                    target.endCompoundChange();
                    target.setRedraw(true);
                }
            }
        });
    }
View Full Code Here


   */
  public void run() {
    ITextEditor editor= getTextEditor();
    if (editor == null || !validateEditorInputState())
      return;
    IRewriteTarget target= (IRewriteTarget)editor.getAdapter(IRewriteTarget.class);
    if (target != null)
      target.beginCompoundChange();
    runCompoundChange();
    if (target != null)
      target.endCompoundChange();

  }
View Full Code Here

    fEditInProgress= true;

    fStrategy.arm(fEditor.getSourceViewer());

    IRewriteTarget target= (IRewriteTarget)fEditor.getAdapter(IRewriteTarget.class);
    if (target != null) {
      target.beginCompoundChange();
    }
  }
View Full Code Here

   */
  private void endCompoundEdit() {
    if (!fEditInProgress || fEditor == null)
      return;

    IRewriteTarget target= (IRewriteTarget)fEditor.getAdapter(IRewriteTarget.class);
    if (target != null) {
      target.endCompoundChange();
    }

    fEditInProgress= false;
  }
View Full Code Here

    fLastCompletion= null;

    ITextEditor editor= getTextEditor();
   
    if (editor != null) {
      IRewriteTarget target= (IRewriteTarget) editor.getAdapter(IRewriteTarget.class);
      if (target != null) {
        fExitStrategy.disarm();
        target.endCompoundChange();
      }
    }

    fDocument= null;
  }
View Full Code Here

      if (suggestions.length == 1) {
        notifyUser();
        return;
      }

      IRewriteTarget target= (IRewriteTarget) getTextEditor().getAdapter(IRewriteTarget.class);
      if (target != null)
        target.beginCompoundChange();
     
      fLastCompletion= new CompletionState(suggestions, getSelectionOffset());
    }
  }
View Full Code Here

        return;

      Object adapter= editor.getAdapter(IRewriteTarget.class);
      if (adapter instanceof IRewriteTarget) {

        IRewriteTarget target= (IRewriteTarget) adapter;
        IDocument document= target.getDocument();
        if (document != null) {
          Shell shell= getTextEditor().getSite().getShell();
          ConvertRunnable runnable= new ConvertRunnable(target, fLineDelimiter);

          if (document.getNumberOfLines() < 40) {
View Full Code Here

   */
  public void run() {
    ITextEditor editor= getTextEditor();
    if (editor == null || !validateEditorInputState())
      return;
    IRewriteTarget target= (IRewriteTarget)editor.getAdapter(IRewriteTarget.class);
    if (target != null)
      target.beginCompoundChange();
    runCompoundChange();
    if (target != null)
      target.endCompoundChange();

  }
View Full Code Here

              delta= length;
            st.replaceTextRange(fSelection.x + delta, length, ""); //$NON-NLS-1$
           
            if (fTextDragAndDropToken == null) {
              // Move in same editor - end compound change
              IRewriteTarget target= (IRewriteTarget)getAdapter(IRewriteTarget.class);
              if (target != null)
                target.endCompoundChange();
            }
           
          }
        } finally {
          fTextDragAndDropToken= null;
        }
      }
    });
   
    // Install drag target
    DropTargetListener dropTargetListener= new DropTargetAdapter() {
     
      private Point fSelection;
     
      public void dragEnter(DropTargetEvent event) {
        fTextDragAndDropToken= null;
        fSelection= st.getSelection();
       
        // XXX: This is only a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=162192
        if (!fIsTextDragAndDropEnabled) {
          event.detail= DND.DROP_NONE;
          event.feedback= DND.FEEDBACK_NONE;
          return;
        }

        if (event.detail == DND.DROP_DEFAULT)
          event.detail= DND.DROP_MOVE;
      }
     
      public void dragOperationChanged(DropTargetEvent event) {
        if (!fIsTextDragAndDropEnabled) {
          event.detail= DND.DROP_NONE;
          event.feedback= DND.FEEDBACK_NONE;
          return;
        }
       
        if (event.detail == DND.DROP_DEFAULT)
          event.detail= DND.DROP_MOVE;
      }
     
      public void dragOver(DropTargetEvent event) {
       
        // XXX: This is only a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=162192
        if (!fIsTextDragAndDropEnabled) {
          event.feedback= DND.FEEDBACK_NONE;
          return;
        }
       
        event.feedback |= DND.FEEDBACK_SCROLL;
      }
     
      public void drop(DropTargetEvent event) {
        try {
          if (!fIsTextDragAndDropEnabled)
            return;
 
          if (fTextDragAndDropToken != null && event.detail == DND.DROP_MOVE) {
            // Move in same editor
            int caretOffset= st.getCaretOffset();
            if (fSelection.x <= caretOffset && caretOffset <= fSelection.y) {
              event.detail= DND.DROP_NONE;
              return;
            }
           
            // Start compound change
            IRewriteTarget target= (IRewriteTarget)getAdapter(IRewriteTarget.class);
            if (target != null)
              target.beginCompoundChange();
          }
         
          if (!validateEditorInputState()) {
            event.detail= DND.DROP_NONE;
            return;
View Full Code Here

  }

  private void endCompoundChange() {
    if (fHasOpenCompoundChange) {
      ITextViewerExtension extension= (ITextViewerExtension) fCurrentTarget.getViewer();
      IRewriteTarget target= extension.getRewriteTarget();
      target.endCompoundChange();
      fHasOpenCompoundChange= false;
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.IRewriteTarget

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.