Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Document


  }

  @Override
  protected boolean updateReplacementString(IDocument document, char trigger, int offset)
          throws CoreException, BadLocationException {
    final IDocument buffer = new Document(document.get());
    int index = offset - 1;
    while (index >= 0 && Character.isJavaIdentifierPart(buffer.getChar(index)))
      index--;
    final int length = offset - index - 1;
    buffer.replace(index + 1, length, " "); //$NON-NLS-1$
    return true;
  }
View Full Code Here


  }

  protected String convertToHTML(String header) {
    StringBuffer result = new StringBuffer();
    // result.append("<p>\n");
    Document d = new Document(header);
    for (int line = 0;; line++) {
      try {
        String str = getLine(d, line).trim();
        if (str == null)
          break;
View Full Code Here

      String contents = buf.getContents();

      String result = "";

      Document doc = new Document(contents);
      try {
        int line = doc.getLineOfOffset(start);
        line--;
        if (line < 0)
          return null;
        boolean emptyEnd = true;
        while (line >= 0) {
View Full Code Here

  @Override
  protected String convertToHTML(String header) {
    StringBuffer result = new StringBuffer();
    // result.append("<p>\n");
    Document d = new Document(header);
    for (int line = 0;; line++) {
      try {
        String str = getLine(d, line).trim();
        if (str == null)
          break;
View Full Code Here

  public void setInformation(String content) {
    if (content == null) {
      viewer.setInput(null);
      return;
    }
    IDocument doc = new Document(content);
    IDLTKUILanguageToolkit uiToolkit = DLTKUILanguageManager.getLanguageToolkit(RutaLanguageToolkit
            .getDefault().getNatureId());
    ScriptTextTools textTools = uiToolkit.getTextTools();
    if (textTools != null) {
      textTools.setupDocumentPartitioner(doc, uiToolkit.getPartitioningId());
View Full Code Here

   * @param c
   */
  private void smartPaste(IDocument d, DocumentCommand c) {
    try {
      String content = d.get(0, c.offset) + c.text;
      Document temp = new Document(content);
      DocumentRewriteSession session = temp
              .startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
      installStuff(temp);
      int offset = c.offset;
      int line = temp.getLineOfOffset(offset);
      String lastIndent = getLineIndent(temp, line);
      int firstLineOffset = temp.getLineOffset(line);
      String commonIndent = temp.get(firstLineOffset, c.offset - firstLineOffset);
      if (StringUtils.isNotBlank(commonIndent)) {
        // do not copy non whitespace content as indent
        // and only use leading white spaces
        String notWSContent = commonIndent.replaceAll("^\\s+", "");
        commonIndent = StringUtils.removeEnd(commonIndent, notWSContent);
      }
      line++;
      try {
        while (getDocumentLine(temp, line).trim().length() == 0)
          line++;
        offset = temp.getLineOffset(line);
      } catch (BadLocationException e) {
        offset = temp.getLength();
      }
      while (offset < temp.getLength()) {
        String resultIndent = calcLineIndent(temp, line, false, temp.getLineOffset(line));
        String currentIndent = getLineIndent(temp, line);
        if (resultIndent == null) {
          resultIndent = commonIndent + currentIndent;
          // TODO commented to retain indent of pasted blocks
          // if (getPhysicalLength(resultIndent) > getPhysicalLength(lastIndent))
          // resultIndent = lastIndent;
        }
        temp.replace(offset, currentIndent.length(), resultIndent);
        String currentLine = getDocumentLine(temp, line);
        if (currentLine.trim().length() > 0 && (!currentLine.trim().startsWith("//"))) {
          lastIndent = resultIndent;
        }

        if (temp.getLineOffset(line) + temp.getLineLength(line) == temp.getLength())
          break;
        line++;
        offset = temp.getLineOffset(line);
      }
      temp.stopRewriteSession(session);
      removeStuff(temp);
      c.text = temp.get(c.offset, temp.getLength() - c.offset);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }

  }
View Full Code Here

            return Arrays.asList((Change) result);
        return new ArrayList<Change>();
    }

    private Change[] processFile(IFile file, final String label) throws Exception {
        Document document = new Document();
        String text = IOUtils.readStream(file.getContents());
        document.set(text);

        List<Change> changes = new ArrayList<Change>();

        int offset = 0;   // TODO in forms use "\" + varName + "\"
        MultiTextEdit multiEdit = new MultiTextEdit();
        int len = variableName.length();
        while (offset > -1) {
            offset = document.search(offset, variableName, true, true, true);
            if (offset == -1) {
                break;
            }
            ReplaceEdit replaceEdit = new ReplaceEdit(offset, len, replacement);
            multiEdit.addChild(replaceEdit);
View Full Code Here

  public void testQWickieJavaHyperlink() {
    long start = System.nanoTime();

    IFile file = project.getFile("src/main/java/org/qwickie/test/project/issue54/Issue54Page.java");
    InputStream contents;
    Document document = null;
    try {
      contents = file.getContents(true);
      byte[] b = new byte[contents.available()];
      contents.read(b);
      contents.close();
      document = new Document(new String(b));
    } catch (Exception e1) {
    }
    QWickieJavaHyperlinkDetector detector = new QWickieJavaHyperlinkDetector();
    assertNull(detector.detectHyperlinks(null, null, false));
View Full Code Here

  public void testQWickieJavaHyperlinkDetector() {
    long start = System.nanoTime();

    IFile file = project.getFile("src/main/java/org/qwickie/test/project/issue45/mobile/RegistrationPage.java");
    InputStream contents;
    Document document = null;
    try {
      contents = file.getContents(true);
      byte[] b = new byte[contents.available()];
      contents.read(b);
      contents.close();
      document = new Document(new String(b));
    } catch (Exception e1) {
    }
    QWickieJavaHyperlinkDetector detector = new QWickieJavaHyperlinkDetector();
    assertNull(detector.detectHyperlinks(null, null, false));
View Full Code Here

  public void testQWickieJavaWicketComponent() {
    long start = System.nanoTime();

    IFile file = project.getFile("/src/main/java/org/qwickie/test/project/refactor/RefPage.java");
    InputStream contents;
    Document document = null;
    try {
      contents = file.getContents(true);
      byte[] b = new byte[contents.available()];
      contents.read(b);
      contents.close();
      document = new Document(new String(b));
    } catch (Exception e1) {
    }
    QWickieJavaHyperlinkDetector detector = new QWickieJavaHyperlinkDetector();
    assertNull(detector.detectHyperlinks(null, null, false));
View Full Code Here

TOP

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

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.