Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Document


                    module = (IErlModule) e;
                }
                if (document == null) {
                    try {
                        s = readString(f.getContents());
                        document = new Document(s);
                    } catch (final CoreException e1) {
                    }
                }
            }
        } else if (document == null && element instanceof IStreamContentAccessor) {
            try {
                final InputStream contents = ((IStreamContentAccessor) element)
                        .getContents();
                try {
                    s = readString(contents);
                } finally {
                    try {
                        contents.close();
                    } catch (final IOException e) {
                    }
                }
                document = new Document(s);
            } catch (final CoreException ex) {
            }
        } else if (document != null) {
            s = document.get();
        }
View Full Code Here


        if (reentry) {
            return;
        }
        reentry = true;
        final DocumentTemplateContext context = new DocumentTemplateContext(
                ErlangSourceContextTypeModule.getDefault(), new Document(
                        fTemplate.getPattern()), 0, fTemplate.getPattern().length());
        TemplateBuffer tb;
        try {
            tb = context.evaluate(fTemplate);
            variable.setValue(tb.getString());
View Full Code Here

                    .getTemplateStore()
                    .getTemplateData("org.erlide.ui.erlangsource.functioncomment")
                    .getTemplate();

            DocumentTemplateContext commentContext = new DocumentTemplateContext(
                    ErlangSourceContextTypeLayout.getDefault(), new Document(
                            commentTemplate.getPattern()), 0, commentTemplate
                            .getPattern().length());
            TemplateBuffer tb = null;
            try {
                tb = commentContext.evaluate(commentTemplate);
            } catch (final BadLocationException e) {
                ErlLogger.warn(e);
                buff.append("Error: " + e.getMessage());
            } catch (final TemplateException e) {
                ErlLogger.warn(e);
                buff.append("Error: " + commentTemplate.getName()
                        + " could not be validated!");
            }

            if (tb != null) {
                buff.append(tb.getString() + "\n");
            }

            final Template template = ErlangSourceContextTypeComment.getDefault()
                    .getTemplateStore()
                    .getTemplateData("org.erlide.ui.erlangsource.functionlayout")
                    .getTemplate();

            commentContext = new DocumentTemplateContext(
                    ErlangSourceContextTypeLayout.getDefault(), new Document(
                            template.getPattern()), 0, template.getPattern().length());
            try {
                tb = commentContext.evaluate(template);
            } catch (final BadLocationException e) {
                ErlLogger.warn(e);
View Full Code Here

        TemplateBuffer tb = null;

        try {
            final DocumentTemplateContext context = new DocumentTemplateContext(
                    contextType, new Document(template.getPattern()), 0, template
                            .getPattern().length());
            tb = context.evaluate(template);
        } catch (final BadLocationException e) {
            ErlLogger.warn(e);
        } catch (final TemplateException e) {
View Full Code Here

        // new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL
        // | SWT.H_SCROLL);
        // final SourceViewerConfiguration configuration= new
        // SourceViewerConfiguration();
        // viewer.configure(configuration);
        final IDocument document = new Document();
        viewer.setDocument(document);
        return viewer;
    }
View Full Code Here

                : new ChainedPreferenceStore(new IPreferenceStore[] { topStore,
                        generalTextStore });

        final SourceViewer viewer = new SourceViewer(parent, null, null, false,
                SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
        final IDocument document = new Document(content);
        viewer.setDocument(document);

        final ErlangDocumentSetupParticipant setupParticipant = new ErlangDocumentSetupParticipant();
        setupParticipant.setup(document);
View Full Code Here

            fOldValue = ""; //$NON-NLS-1$

            fViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL
                    | SWT.H_SCROLL | SWT.LEFT_TO_RIGHT);
            fViewer.setInput(parent);
            final IDocument document = new Document();
            fViewer.setDocumentPartitioning(IErlangPartitions.ERLANG_PARTITIONING);
            // setDocumentPartitioning
            // JDIDebugUIPlugin.getDefault().getJavaTextTools()
            // .setupJavaDocumentPartitioner(document,
            // IJavaPartitions.JAVA_PARTITIONING);
            // we can only do code assist if there is an associated type
            // final IResource r = fBreakpoint.getMarker().getResource();
            // if (r != null) {
            // final IErlModel model = ErlangCore.getModel();
            // final IErlElement element = model.findElement(r);
            // if (element!= null && element.getKind() ==
            // IErlElement.Kind.MODULE) {
            // final int lineNumber = fBreakpoint.getMarker()
            // .getAttribute(IMarker.LINE_NUMBER, -1);
            // IJavaDebugContentAssistContext context = null;
            // final IType type = BreakpointUtils.getType(fBreakpoint);
            // if (type == null) {
            // context = new TypeContext(null, -1);
            // } else {
            // try {
            // String source = null;
            // final ICompilationUnit compilationUnit = type
            // .getCompilationUnit();
            // if (compilationUnit != null
            // && compilationUnit.getJavaProject().getProject()
            // .exists()) {
            // source = compilationUnit.getSource();
            // } else {
            // final IClassFile classFile = type.getClassFile();
            // if (classFile != null) {
            // source = classFile.getSource();
            // }
            // }
            // final int lineNumber = fBreakpoint.getMarker()
            // .getAttribute(IMarker.LINE_NUMBER, -1);
            // int position = -1;
            // if (source != null && lineNumber != -1) {
            // try {
            // position = new Document(source)
            // .getLineOffset(lineNumber - 1);
            // } catch (final BadLocationException e) {
            // JDIDebugUIPlugin.log(e);
            // }
            // }
            // context = new TypeContext(type, position);
            // } catch (final CoreException e) {
            // JDIDebugUIPlugin.log(e);
            // }
            // }
            // fCompletionProcessor = new
            // JavaDebugContentAssistProcessor(context);
            // fViewer.configure(new DisplayViewerConfiguration() {
            // public IContentAssistProcessor getContentAssistantProcessor() {
            // return fCompletionProcessor;
            // }
            // });
            fViewer.setEditable(true);
            // if we don't check upstream tracing can throw assertion exceptions
            // see bug 181914
            document.set(condition == null ? "" : condition); //$NON-NLS-1$
            fViewer.setDocument(document);
            fViewer.setUndoManager(new TextViewerUndoManager(10));
            fViewer.getUndoManager().connect(fViewer);
            fDocumentListener = new IDocumentListener() {
                @Override
View Full Code Here

     * @param file
     *            corresponding file
     * @return document
     */
    static public IDocument getDocument(final IFile file) {
        return new Document(getFileContent(file));
    }
View Full Code Here

        String builderSource = buffer.getContents();
     
        TextEdit text = ToolFactory.createCodeFormatter(null).format(CodeFormatter.K_COMPILATION_UNIT, builderSource, 0, builderSource.length(), 0, "\n");
        // text is null if source cannot be formatted
        if (text != null) {
          Document simpleDocument = new Document(builderSource);
          text.apply(simpleDocument);
          buffer.setContents(simpleDocument.get());
        }
      } else {
        buffer.replace(pos, 0, sw.toString())
      }
    } catch (JavaModelException e) {
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.