Package org.eclipse.jface.internal.text

Examples of org.eclipse.jface.internal.text.SelectionProcessor


    boolean isFirst= e.time != fLastEventTime;
    fLastEventTime= e.time;
    if (isFirst) {
      wrapCompoundChange(new Runnable() {
        public void run() {
          SelectionProcessor processor= new SelectionProcessor(TextViewer.this);
          try {
            /* Use the selection instead of the event's coordinates. Is this dangerous? */
            ISelection selection= getSelection();
            int length= e.text.length();
            if (length == 0 && e.character == '\0') {
              // backspace in StyledText block selection mode...
              TextEdit edit= processor.backspace(selection);
              edit.apply(fDocument, TextEdit.UPDATE_REGIONS);
              ISelection empty= processor.makeEmpty(selection, true);
              setSelection(empty);
            } else {
              int lines= processor.getCoveredLines(selection);
              String delim= fDocument.getLegalLineDelimiters()[0];
              StringBuffer text= new StringBuffer(lines * length + (lines - 1) * delim.length());
              text.append(e.text);
              for (int i= 0; i < lines - 1; i++) {
                text.append(delim);
                text.append(e.text);
              }
              processor.doReplace(selection, text.toString());
            }
          } catch (BadLocationException x) {
            if (TRACE_ERRORS)
              System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$
          }
View Full Code Here


      fTextWidget.invokeAction(ST.DELETE_NEXT);
    } else {
      wrapCompoundChange(new Runnable(){
        public void run() {
          try {
            new SelectionProcessor(TextViewer.this).doDelete(getSelection());
          } catch (BadLocationException e) {
            if (TRACE_ERRORS)
              System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.delete")); //$NON-NLS-1$
          }
        }
View Full Code Here

    if (!fTextWidget.getBlockSelection()) {
      fTextWidget.paste();
    } else {
      wrapCompoundChange(new Runnable(){
        public void run() {
          SelectionProcessor processor= new SelectionProcessor(TextViewer.this);
          Clipboard clipboard= new Clipboard(getDisplay());
          try {
            /*
             * Paste in block selection mode. If the pasted text is not a multi-line
             * text, pasting behaves like typing, i.e. the pasted text replaces
             * the selection on each line. If the pasted text is multi-line (e.g. from
             * copying a column selection), the selection is replaced, line-by-line, by
             * the corresponding contents of the pasted text. If the selection touches
             * more lines than the pasted text, the selection on the remaining lines
             * is deleted (assuming an empty text being pasted). If the pasted
             * text contains more lines than the selection, the selection is extended
             * to the succeeding lines, or more lines are added to accommodate the
             * paste operation.
             */
            ISelection selection= getSelection();
            TextTransfer plainTextTransfer = TextTransfer.getInstance();
            String contents= (String)clipboard.getContents(plainTextTransfer, DND.CLIPBOARD);
            String toInsert;
            if (TextUtilities.indexOf(fDocument.getLegalLineDelimiters(), contents, 0)[0] != -1) {
              // multi-line insertion
              toInsert= contents;
            } else {
              // single-line insertion
              int length= contents.length();
              int lines= processor.getCoveredLines(selection);
              String delim= fDocument.getLegalLineDelimiters()[0];
              StringBuffer text= new StringBuffer(lines * length + (lines - 1) * delim.length());
              text.append(contents);
              for (int i= 0; i < lines - 1; i++) {
                text.append(delim);
                text.append(contents);
              }
              toInsert= text.toString();
            }
            processor.doReplace(selection, toInsert);
          } catch (BadLocationException x) {
            if (TRACE_ERRORS)
              System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.paste")); //$NON-NLS-1$
          } finally {
            clipboard.dispose();
View Full Code Here

   * @param textWidget the widget
   * @throws BadLocationException on document access failure
   * @since 3.5
   */
  private void deleteSelection(ITextSelection selection, StyledText textWidget) throws BadLocationException {
    new SelectionProcessor(this).doDelete(selection);
  }
View Full Code Here

   * @param textWidget the widget
   * @throws BadLocationException on document access failure
   * @since 3.5
   */
  private void deleteSelection(ITextSelection selection, StyledText textWidget) throws BadLocationException {
    new SelectionProcessor(this).doDelete(selection);
  }
View Full Code Here

   */
  public String getText() {
    IDocument document= getDocument();
    if (document != null) {
      try {
        return new SelectionProcessor(document, fTabWidth).getText(this);
      } catch (BadLocationException x) {
        // ignore and default to super implementation
      }
    }
    return super.getText();
View Full Code Here

   */
  public IRegion[] getRegions() {
    IDocument document= getDocument();
    if (document != null) {
      try {
        return new SelectionProcessor(document, fTabWidth).getRanges(this);
      } catch (BadLocationException x) {
        // default to single region behavior
      }
    }
    return new IRegion[] {new Region(getOffset(), getLength())};
View Full Code Here

    boolean isFirst= e.time != fLastEventTime;
    fLastEventTime= e.time;
    if (isFirst) {
      wrapCompoundChange(new Runnable() {
        public void run() {
          SelectionProcessor processor= new SelectionProcessor(TextViewer.this);
          try {
            /* Use the selection instead of the event's coordinates. Is this dangerous? */
            ISelection selection= getSelection();
            int length= e.text.length();
            if (length == 0 && e.character == '\0') {
              // backspace in StyledText block selection mode...
              TextEdit edit= processor.backspace(selection);
              edit.apply(fDocument, TextEdit.UPDATE_REGIONS);
              ISelection empty= processor.makeEmpty(selection, true);
              setSelection(empty);
            } else {
              int lines= processor.getCoveredLines(selection);
              String delim= fDocument.getLegalLineDelimiters()[0];
              StringBuffer text= new StringBuffer(lines * length + (lines - 1) * delim.length());
              text.append(e.text);
              for (int i= 0; i < lines - 1; i++) {
                text.append(delim);
                text.append(e.text);
              }
              processor.doReplace(selection, text.toString());
            }
          } catch (BadLocationException x) {
            if (TRACE_ERRORS)
              System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$
          }
View Full Code Here

      fTextWidget.invokeAction(ST.DELETE_NEXT);
    } else {
      wrapCompoundChange(new Runnable(){
        public void run() {
          try {
            new SelectionProcessor(TextViewer.this).doDelete(getSelection());
          } catch (BadLocationException e) {
            if (TRACE_ERRORS)
              System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.delete")); //$NON-NLS-1$
          }
        }
View Full Code Here

    if (!fTextWidget.getBlockSelection()) {
      fTextWidget.paste();
    } else {
      wrapCompoundChange(new Runnable(){
        public void run() {
          SelectionProcessor processor= new SelectionProcessor(TextViewer.this);
          Clipboard clipboard= new Clipboard(getDisplay());
          try {
            /*
             * Paste in block selection mode. If the pasted text is not a multi-line
             * text, pasting behaves like typing, i.e. the pasted text replaces
             * the selection on each line. If the pasted text is multi-line (e.g. from
             * copying a column selection), the selection is replaced, line-by-line, by
             * the corresponding contents of the pasted text. If the selection touches
             * more lines than the pasted text, the selection on the remaining lines
             * is deleted (assuming an empty text being pasted). If the pasted
             * text contains more lines than the selection, the selection is extended
             * to the succeeding lines, or more lines are added to accommodate the
             * paste operation.
             */
            ISelection selection= getSelection();
            TextTransfer plainTextTransfer = TextTransfer.getInstance();
            String contents= (String)clipboard.getContents(plainTextTransfer, DND.CLIPBOARD);
            String toInsert;
            if (TextUtilities.indexOf(fDocument.getLegalLineDelimiters(), contents, 0)[0] != -1) {
              // multi-line insertion
              toInsert= contents;
            } else {
              // single-line insertion
              int length= contents.length();
              int lines= processor.getCoveredLines(selection);
              String delim= fDocument.getLegalLineDelimiters()[0];
              StringBuffer text= new StringBuffer(lines * length + (lines - 1) * delim.length());
              text.append(contents);
              for (int i= 0; i < lines - 1; i++) {
                text.append(delim);
                text.append(contents);
              }
              toInsert= text.toString();
            }
            processor.doReplace(selection, toInsert);
          } catch (BadLocationException x) {
            if (TRACE_ERRORS)
              System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.paste")); //$NON-NLS-1$
          } finally {
            clipboard.dispose();
View Full Code Here

TOP

Related Classes of org.eclipse.jface.internal.text.SelectionProcessor

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.