Examples of TextSelection


Examples of at.bestsolution.efxclipse.styledtext.TextSelection

  /*
   * @see ICompletionProposal#getSelection(IDocument)
   */
  public TextSelection getSelection(IDocument document) {
    return new TextSelection(fReplacementOffset + fCursorPosition, 0);
  }
View Full Code Here

Examples of org.apache.isis.viewer.dnd.view.text.TextSelection

        this.maxLength = content.getMaximumLength();
        this.useEmptyLines = useEmptyLines;

        textContent = new TextContent(this, 1, wrapStyle, this.useEmptyLines);
        cursor = new CursorPosition(textContent, 0, 0);
        selection = new TextSelection(textContent);
        final ObjectAdapter value = getValue();
        textContent.setText(value == null ? "" : titleString(value));
        cursor.home();
        isSaved = true;
    }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

    if (_viewer != null) {
      try {
        IDocument document = _viewer.getDocument();
        ISelection selection =_viewer.getSelectionProvider().getSelection();
        if (selection instanceof TextSelection) {
          TextSelection textSelection = (TextSelection) selection;
          int offset = textSelection.getOffset();
          IRegion region = document.getPartition(offset);
         
          boolean sameLine = document.getLineOfOffset(region.getOffset()) == document.getLineOfOffset(offset);
         
          if (document.getContentType(region.getOffset()).equals(TMLPartitionScanner.TML_TAG_START)) {
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

      cursorOffset = textSelection.getOffset() + cursorOffset;
    }
   

    doc.replace(textSelection.getOffset(), textSelection.getLength(), finalReplacement)
    editor.getEditorSite().getSelectionProvider().setSelection(new TextSelection(cursorOffset, 0));
  }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

        try {
          // search for line starting with label key
          FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(doc);
          IRegion keyRegion = finder.find(0, "^" + LabelFileEncodingHelper.saveConvert(labelKey,true).replaceAll("\\\\", "\\\\\\\\") + "\\s*=", true, false, false, true);
          if (keyRegion != null) {
            textEditor.getSelectionProvider().setSelection(new TextSelection(keyRegion.getOffset() + keyRegion.getLength(),0));
          }
        } catch (BadLocationException e) {
        }
      }
    } catch (PartInitException e) {
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

              ITextEditor textEditor = (ITextEditor) editor;
              int offset = 0;
              if (_warning.getLine() != -1) {
                offset = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()).getLineOffset(_warning.getLine()-1);
              }
              textEditor.getSelectionProvider().setSelection(new TextSelection(offset, 0));
            }
          } else {
            WorkbenchUtils.showErrorDialog(Display.getCurrent().getActiveShell(), "Unable to open tml warning hyperlink.", "Referenced tml file '" + _warning.getMedium() + "/" + _warning.getResource() + "' not found.");
          }
        } else {
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

        }
        IDocument document = getDocumentProvider()
            .getDocument(getEditorInput());
        try {
            int lineOffset = document.getLineOffset(newLine);
            return new TextSelection(lineOffset, 0);
        } catch (BadLocationException e) {
            BytecodeOutlinePlugin.log(e, IStatus.ERROR);
        }
        return null;
    }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

            sourceLine + 1, getClassFile()) + 1;
        IDocument document = getDocumentProvider()
            .getDocument(getEditorInput());
        try {
            int lineOffset = document.getLineOffset(newLine);
            return new TextSelection(lineOffset, 0);
        } catch (BadLocationException e) {
            BytecodeOutlinePlugin.log(e, IStatus.ERROR);
        }
        return null;
    }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

    return result;
  }

  @Override
  public void createSelection(int start, int end) {
    editor.getEditorSite().getSelectionProvider().setSelection(new TextSelection(start, end - start));
  }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

    protected void doRun()
    {
        Shell shell = PerlEditorPlugin.getWorkbenchWindow().getShell();

        TextSelection selection =
            ((TextSelection) getEditor().getSelectionProvider().getSelection());

        if (selection.getText().length() == 0)
        {
            MessageDialog.openInformation(shell, "No selection", "Nothing has been selected.");
            return;
        }

        InputDialog inputDialog =
            new InputDialog(shell, "Subroutine Name", "Name of Subroutine", "", null);
        int returnCode = inputDialog.open();

        // return unless the ok button was pressed
        if (returnCode != Window.OK) { return; }

        String[] result = SourceRefactor.extractMethod(inputDialog.getValue(), selection.getText(),
                getLog());

        if (result.length == 0)
        {
            MessageDialog.openInformation(shell, "Error", "Subroutine could not be generated.");
            return;
        }

        // Delete trailing \n
        if (result[0].endsWith("\n"))
        {
            result[0] = result[0].substring(0, result[0].lastIndexOf("\n"));
        }

        IDocument doc = getEditor().getDocumentProvider().getDocument(getEditor().getEditorInput());
        try
        {
            // Repace the selection with the subroutine call
            doc.replace(selection.getOffset(), selection.getLength(), result[0]);

            int offset = -1;

            FindReplaceDocumentAdapter docFind = new FindReplaceDocumentAdapter(doc);

            IRegion regionEnd =
                docFind.find(selection.getOffset(), "^__END__", true, true, false, true);
            offset = (regionEnd != null) ? regionEnd.getOffset() : doc.getLength();

            String lineSep = getLineSeparator(doc.get());

            // format and insert the new subroutine code
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.