Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Document


            DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT,
            DefaultCodeFormatterConstants.INDENT_BY_ONE));
        options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
        options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
        options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
        Document doc = new Document(m_compilationUnit.toString());
        CodeFormatter fmtr = ToolFactory.createCodeFormatter(options);
        String text = doc.get();
        TextEdit edits = fmtr.format(CodeFormatter.K_COMPILATION_UNIT, text, 0, text.length(), 0, null);
        File gendir = m_package.getGenerateDirectory();
        if (gendir != null) {
            try {
                File file = new File(gendir, m_name + ".java");
View Full Code Here


        textViewer = new TextViewer(stackComposite, SWT.H_SCROLL | SWT.V_SCROLL);
        textViewer.setEditable(false);
        // textViewer.setHoverControlCreator(null)

        textControl = textViewer.getTextWidget();
        IDocument document = new Document("");
        textViewer.setDocument(document);

        textSelectionListener = new ISelectionChangedListener() {

            public void selectionChanged(SelectionChangedEvent event) {
View Full Code Here

                editorListener);

        }
        if (textViewer != null && textViewer.getTextWidget() != null
            && !textViewer.getTextWidget().isDisposed()) {
            IDocument document = new Document("");
            textViewer.setDocument(document);
        }
        if (tableControl != null && !tableControl.isDisposed()) {
            setVerifyTableItems(null);
        }
View Full Code Here

        }

        lastChildElement = childEl;
        if (clearOutput) {
            if (!modes.get(BCOConstants.F_SHOW_ANALYZER)) {
                IDocument document = new Document("");
                textViewer.setDocument(document);
            } else {
                setVerifyTableItems(null);
            }
        }
View Full Code Here

        setSelectionInBytecodeView();
        inputChanged = false;
    }

    private void refreshTextView(DecompiledClass result) {
        IDocument document = new Document(result.getText());
        textViewer.setDocument(document);
        // we are in verify mode but we can't show content because
        // current element is abstract, so we clean table content
        if (modes.get(BCOConstants.F_SHOW_ANALYZER)) {
            setVerifyTableItems(null);
View Full Code Here

        return fDetailDocumentListener;
    }

    protected IDocument getDetailDocument() {
        if (fDetailDocument == null) {
            fDetailDocument = new Document();
        }
        return fDetailDocument;
    }
View Full Code Here

      } else {
        this.preferences.line_separator = Util.LINE_SEPARATOR;
      }
      this.preferences.initial_indentation_level = indentationLevel;
      this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length, null);
      final CommentRegion region = createRegion(kind, new Document(source), new Position(offset, length), this.newCodeFormatter);
      if (region != null) {
        return this.newCodeFormatter.format(source, region);
      }
    }
    return new MultiTextEdit();
View Full Code Here

   * @throws IllegalArgumentException If the positions are not inside the string, a
   *  IllegalArgumentException is thrown.
   */
  public static String evaluateFormatterEdit(String string, TextEdit edit, Position[] positions) {
    try {
      Document doc= createDocument(string, positions);
      edit.apply(doc, 0);
      if (positions != null) {
        for (int i= 0; i < positions.length; i++) {
          Assert.isTrue(!positions[i].isDeleted, "Position got deleted"); //$NON-NLS-1$
        }
      }
      return doc.get();
    } catch (BadLocationException e) {
      //JavaPlugin.log(e); // bug in the formatter
      Assert.isTrue(false, "Fromatter created edits with wrong positions: " + e.getMessage()); //$NON-NLS-1$
    }
    return null;
View Full Code Here

    }
    return newEdit;
  }
   
  private static Document createDocument(String string, Position[] positions) throws IllegalArgumentException {
    Document doc= new Document(string);
    try {
      if (positions != null) {
        final String POS_CATEGORY= "myCategory"; //$NON-NLS-1$
       
        doc.addPositionCategory(POS_CATEGORY);
        doc.addPositionUpdater(new DefaultPositionUpdater(POS_CATEGORY) {
          protected boolean notDeleted() {
            int start= this.fOffset;
            int end= start + this.fLength;
            if (start < this.fPosition.offset && (this.fPosition.offset + this.fPosition.length < end)) {
              this.fPosition.offset= end; // deleted positions: set to end of remove
              return false;
            }
            return true;
          }
        });
        for (int i= 0; i < positions.length; i++) {
          try {
            doc.addPosition(POS_CATEGORY, positions[i]);
          } catch (BadLocationException e) {
            throw new IllegalArgumentException("Position outside of string. offset: " + positions[i].offset + ", length: " + positions[i].length + ", string size: " + string.length());   //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
          }
        }
      }
View Full Code Here

      ASTRewrite rewrite= sortCompilationUnit(unit, group);
      if (rewrite == null) {
        return null;
      }
     
      Document document= new Document(content);
      return rewrite.rewriteAST(document, null);
    } finally {
      done();
    }
  }
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.