Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Document


   * @param file
   * @param codeFormatter
   * @return
   */
  public boolean formatFile(File file) throws ExporterException {
    IDocument doc = new Document();
    try {
      String contents = new String(org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(file, null));
      doc.set(contents);
      TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, contents, 0, contents.length(), 0, null);
      if (edit != null) {
        edit.apply(doc);
      } else {       
        return false; // most likely syntax errror
      }

      // write the file
      final BufferedWriter out = new BufferedWriter(new FileWriter(file));
      try {
        out.write(doc.get());
        out.flush();
      } finally {
        try {
          out.close();
        } catch (IOException e) {
View Full Code Here


  private void addImplInterface(IType type, String cName) {
    try {
      ICompilationUnit icunit = type.getCompilationUnit();
      String source = icunit.getBuffer().getContents();
      Document document = new Document(source);
      ASTParser parser = ASTParser.newParser(AST.JLS3);
      parser.setSource(icunit);
      CompilationUnit cunit = (CompilationUnit) parser.createAST(null);
      cunit.recordModifications();
      AST ast = cunit.getAST();
      TypeDeclaration typeDec = (TypeDeclaration) cunit.types().get(0);
      List list = typeDec.superInterfaceTypes();
      Name name = ast.newName(cName);
      Type interfaceType = ast.newSimpleType(name);
      list.add(interfaceType);
      TextEdit edits = cunit.rewrite(document, icunit.getJavaProject()
          .getOptions(true));
      edits.apply(document);
      String newSource = document.get();
      icunit.getBuffer().setContents(newSource);
    } catch (Exception e) {
      ParserPlugin.getLogger().error(e);
    }
  }
View Full Code Here

                       "       Class ( )\n" + //
                       "   then\n" + //
                       "       " +//
                       "end\n\n" ;

        IDocument doc = new Document( input );
        IDocumentPartitioner partitioner = new FastPartitioner( new DRLPartionScanner(),
                                                                DRLPartionScanner.LEGAL_CONTENT_TYPES );
        partitioner.connect( doc );
        doc.setDocumentPartitioner( partitioner );
        return doc;
    }
View Full Code Here

            value = ((DroolsConsequenceAction) action).getConsequence();
        }
        if (value == null) {
            value = "";
        }
        IDocument document = new Document(value);
        actionViewer.setDocument(document);
        IDocumentPartitioner partitioner =
            new FastPartitioner(
                new DRLPartionScanner(),
                DRLPartionScanner.LEGAL_CONTENT_TYPES);
        partitioner.connect(document);
        document.setDocumentPartitioner(partitioner);
        actionViewer.getControl().addKeyListener(new KeyListener() {
            public void keyPressed(KeyEvent e) {
                if (e.character == ' ' && e.stateMask == SWT.CTRL) {
                    actionViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
                }
View Full Code Here

            value = ((DroolsConsequenceAction) action).getConsequence();
        }
        if (value == null) {
            value = "";
        }
        IDocument document = new Document(value);
        actionViewer.setDocument(document);
        IDocumentPartitioner partitioner =
            new FastPartitioner(
                new DRLPartionScanner(),
                DRLPartionScanner.LEGAL_CONTENT_TYPES);
        partitioner.connect(document);
        document.setDocumentPartitioner(partitioner);
        actionViewer.getControl().addKeyListener(new KeyListener() {
            public void keyPressed(KeyEvent e) {
                if (e.character == ' ' && e.stateMask == SWT.CTRL) {
                    actionViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
                }
View Full Code Here

   
    textViewer = new TextViewer(parent, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    textViewer.getControl().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    textViewer.getControl().setBackground(NOTE_COLOR);
    textViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    textViewer.setDocument(new Document());
    textViewer.setHyperlinkPresenter(new DefaultHyperlinkPresenter(new RGB(0, 0, 255)));
    textViewer.setHyperlinkDetectors(new IHyperlinkDetector[] { new URLHyperlinkDetector() }, SWT.MOD1);
    textViewer.setUndoManager(new TextViewerUndoManager(100));
    textViewer.setTextDoubleClickStrategy(new DefaultTextDoubleClickStrategy(), IDocument.DEFAULT_CONTENT_TYPE);
    textViewer.getDocument().addDocumentListener(new IDocumentListener() {
View Full Code Here

                    completionProcessor, IDocument.DEFAULT_CONTENT_TYPE);
                assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
                return assistant;
            }
        });
        IDocument document = new Document();
        constraintViewer.setDocument(document);
        IDocumentPartitioner partitioner =
            new FastPartitioner(
                new DRLPartionScanner(),
                DRLPartionScanner.LEGAL_CONTENT_TYPES);
        partitioner.connect(document);
        document.setDocumentPartitioner(partitioner);
        constraintViewer.getControl().addKeyListener(new KeyListener() {
            public void keyPressed(KeyEvent e) {
                if (e.character == ' ' && e.stateMask == SWT.CTRL) {
                    constraintViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
                }
View Full Code Here

            value = ((DroolsConsequenceAction) action).getConsequence();
        }
        if (value == null) {
            value = "";
        }
        IDocument document = new Document(value);
        actionViewer.setDocument(document);
        IDocumentPartitioner partitioner =
            new FastPartitioner(
                new DRLPartionScanner(),
                DRLPartionScanner.LEGAL_CONTENT_TYPES);
        partitioner.connect(document);
        document.setDocumentPartitioner(partitioner);
        actionViewer.getControl().addKeyListener(new KeyListener() {
            public void keyPressed(KeyEvent e) {
                if (e.character == ' ' && e.stateMask == SWT.CTRL) {
                    actionViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
                }
View Full Code Here

    @Override
    protected IDocument createDocument( Object element ) throws CoreException
    {
        input = getEntryEditorInput( element );
        IEntry entry = getEntryEditorInput( element ).getSharedWorkingCopy( editor );
        IDocument document = new Document();
        if ( entry != null )
        {
            setDocumentInput( document, entry );
        }
        setupDocument( document );
View Full Code Here

     */
    protected IDocument createDocument( Object element ) throws CoreException
    {
        if ( element instanceof IEditorInput )
        {
            IDocument document = new Document();
            if ( setDocumentContent( document, ( IEditorInput ) element ) )
            {
                setupDocument( document );
            }
            return document;
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.