Examples of ITextSelection


Examples of org.eclipse.jface.text.ITextSelection

    File jsFile = editorInput.getFile().getLocation().toFile();
    testCases.addAll(finder.getTestCases(jsFile));
  }

  private int updateTestCasesFromSelection(List<String> testCases, AbstractTextEditor textEditor) {
    ITextSelection selection = (ITextSelection) textEditor.getSelectionProvider().getSelection();
    int startLine = selection.getStartLine();
    String selectionString = selection.getText();
    if (selectionString != null && !"".equals(selectionString.trim())) {
      testCases.addAll(finder.getTestCases(selectionString));
    }
    return startLine;
  }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

            }
        }

        String typeName = ""; //$NON-NLS-1$

        ITextSelection selection = getCurrentTextSelection();
        if (selection != null) {
            String text = selection.getText();
            if (text != null && validateJavaTypeName(text, project).isOK()) {
                typeName = text;
            }
        }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

    if (selection instanceof IStructuredSelection) {
      IStructuredSelection ss = (IStructuredSelection) selection;
      showItems(ss.toArray());
    }
    if (selection instanceof ITextSelection) {
      ITextSelection ts = (ITextSelection) selection;
      showText(ts.getText());
    }
    if (selection instanceof IMarkSelection) {
      IMarkSelection ms = (IMarkSelection) selection;
      try {
        showText(ms.getDocument().get(ms.getOffset(), ms.getLength()));
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

            // int offset = doc.getLineOffset(numberOfLines);

            ISelectionProvider selectionProvider = getSelectionProvider();
            ISelection selection = selectionProvider.getSelection();
            if (selection instanceof ITextSelection) {
                ITextSelection textSelection = (ITextSelection) selection;
                int offset = textSelection.getOffset();
                doc.replace(offset, 0, path);
            }
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

        // outputConsole.clearConsole();

        String text = null;
        ISelection selection = getSelectionProvider().getSelection();
        if (selection instanceof ITextSelection) {
            ITextSelection textSelection = (ITextSelection) selection;
            if (!textSelection.isEmpty()) {
                text = textSelection.getText();

                if (text.trim().length() > 0 && !text.trim().startsWith("import")) {
                    // something in the middle was selected, we need to add the imports
                    StringBuilder sb = new StringBuilder();
                    List<String> defaultImports = Keywords.getValues(Keywords.IMPORTS);
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

   */
  public int selectionOffsetOf(IEditorPart editor) {
    ISelectionProvider selectionProvider = ((ITextEditor) editor).getSelectionProvider();
    ISelection selection = selectionProvider.getSelection();
    if (selection instanceof ITextSelection) {
      ITextSelection textSelection = (ITextSelection) selection;
      return textSelection.getOffset();
    }
    return -1;
  }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

      if (ruler == null)
        lastLine= -1;
      else
        lastLine= ruler.getLineOfLastMouseButtonActivity();
    } else {
      ITextSelection selection= getSelection();
      if (selection == null)
        lastLine= -1;
      else
        lastLine= selection.getEndLine();
    }
    return lastLine;
  }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

   */
  public boolean computeEnablement() {
    if (!super.computeEnablement())
      return false;

    ITextSelection selection= getSelection();
    if (selection == null)
      return false;
    fStartLine= selection.getStartLine();
    fEndLine= selection.getEndLine();
    // only enable if mouse activity is inside line range
    int activityLine= getLastLine();
    if (activityLine == -1 || activityLine < fStartLine || activityLine > fEndLine + 1)
      // + 1 to cover the case where the selection goes to the offset of the next line
      return false;
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

    // get selection
    Point p= viewer.getSelectedRange();
    if (p == null)
      return;

    ITextSelection sel= new TextSelection(document, p.x, p.y);

    ITextSelection skippedLine= getSkippedLine(document, sel);
    if (skippedLine == null)
      return;

    try {

      ITextSelection movingArea= getMovingSelection(document, sel, viewer);

      // if either the skipped line or the moving lines are outside the widget's
      // visible area, bail out
      if (!containedByVisibleRegion(movingArea, viewer) || !containedByVisibleRegion(skippedLine, viewer))
        return;

      // get the content to be moved around: the moving (selected) area and the skipped line
      String moving= movingArea.getText();
      String skipped= skippedLine.getText();
      if (moving == null || skipped == null || document.getLength() == 0)
        return;

      String delim;
      String insertion;
      int offset, deviation;
      if (fUpwards) {
        delim= document.getLineDelimiter(skippedLine.getEndLine());
        if (fCopy) {
          delim= TextUtilities.getDefaultLineDelimiter(document);
          insertion= moving + delim;
          offset= movingArea.getOffset();
          deviation= 0;
        } else {
          Assert.isNotNull(delim);
          insertion= moving + delim + skipped;
          offset= skippedLine.getOffset();
          deviation= -skippedLine.getLength() - delim.length();
        }
      } else {
        delim= document.getLineDelimiter(movingArea.getEndLine());
        if (fCopy) {
          if (delim == null) {
            delim= TextUtilities.getDefaultLineDelimiter(document);
            insertion= delim + moving;
          } else {
            insertion= moving + delim;
          }
          offset= skippedLine.getOffset();
          deviation= movingArea.getLength() + delim.length();
        } else {
          Assert.isNotNull(delim);
          insertion= skipped + delim + moving;
          offset= movingArea.getOffset();
          deviation= skipped.length() + delim.length();
        }
      }

      // modify the document
      beginCompoundEdit();
      if (fCopy) {
//        fDescription= new EditDescription(offset, 0, insertion.length());
        document.replace(offset, 0, insertion);
      } else {
//        fDescription= new EditDescription(offset, insertion.length(), insertion.length());
        document.replace(offset, insertion.length(), insertion);
      }

      // move the selection along
      int selOffset= movingArea.getOffset() + deviation;
      int selLength= movingArea.getLength() + (fAddDelimiter ? delim.length() : 0);
      if (! (viewer instanceof ITextViewerExtension5))
        selLength= Math.min(selLength, viewer.getVisibleRegion().getOffset() + viewer.getVisibleRegion().getLength() - selOffset);
      else {
        // TODO need to check what is necessary in the projection case
      }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

   */
  public void selectionChanged(SelectionChangedEvent e) {
    boolean ignore= false;
    ISelection selection= e.getSelection();
    if (selection instanceof ITextSelection) {
      ITextSelection textSelection= (ITextSelection)selection;
      Point range= getSelection();
      ignore= textSelection.getOffset() + textSelection.getLength() == range.x + range.y;
    }
    if (!fSearching && !ignore)
      leave();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.