Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IDocument


     * @see IStructureCreator#save
     */
    @Override
    public void save(final IStructureComparator structure, final Object input) {
        if (input instanceof IEditableContent && structure instanceof ErlNode) {
            final IDocument doc = ((ErlNode) structure).getDocument();
            final IEditableContent bca = (IEditableContent) input;
            final String c = doc.get();
            bca.setContent(c.getBytes());
        }
    }
View Full Code Here


            final ISharedDocumentAdapter sharedDocumentAdapter,
            final IProgressMonitor monitor) throws CoreException {
        IErlModule module = null;
        final IErlModel model = ErlangEngine.getInstance().getModel();
        String s = "";
        IDocument document = document0;
        if (element instanceof ResourceNode) {
            final ResourceNode rn = (ResourceNode) element;
            final IResource r = rn.getResource();
            if (r instanceof IFile) {
                final IFile f = (IFile) r;
                final IErlElement e = model.findElement(r);
                if (e instanceof IErlModule) {
                    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();
        }
        if (module == null) {
            String name = "comptemp";
            if (element instanceof ITypedElement) {
                final ITypedElement typedElement = (ITypedElement) element;
View Full Code Here

        }
        return result;
    }

    public void addMessage(final int offset, final String message) {
        final IDocument document = editor.getDocumentProvider().getDocument(
                editor.getEditorInput());
        try {
            final String delimiter = document.getLineDelimiter(document
                    .getLineOfOffset(offset - 1));
            String nl = "";
            if (delimiter == null) {
                if (document instanceof IDocumentExtension4) {
                    final IDocumentExtension4 documentExtension4 = (IDocumentExtension4) document;
                    nl = documentExtension4.getDefaultLineDelimiter();
                } else {
                    final String[] delimiters = document.getLegalLineDelimiters();
                    nl = delimiters[0];
                }
            }
            final Display display = ErlideUIPlugin.getStandardDisplay();
            final String addMessage = nl + message;
            display.asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        document.replace(offset, 0, addMessage);
                    } catch (final BadLocationException e) {
                    }
                }
            });
            ErlLogger.debug("message %s", message);
View Full Code Here

    }

    protected ITextSelection getLineSelection(final ITextSelection selection0,
            final boolean beginningOfNextLine) {
        ITextSelection selection = selection0;
        final IDocument document = editor.getDocumentProvider().getDocument(
                editor.getEditorInput());
        if (selection.getLength() == 0) { // don't use isEmpty()!
            selection = ErlangAbstractHandler.extendSelectionToWholeLines(document,
                    selection);
        }
        if (beginningOfNextLine) {
            final int endLine = selection.getEndLine();
            int offset;
            try {
                offset = document.getLineOffset(endLine)
                        + document.getLineLength(endLine);
                selection = new TextSelection(offset, 0);
            } catch (final BadLocationException e) {
                offset = document.getLength();
            }
        }
        return selection;
    }
View Full Code Here

        if (region == null || textViewer == null) {
            return null;
        }

        final IDocument document = textViewer.getDocument();
        final int offset = region.getOffset();

        if (document == null) {
            return null;
        }

        IRegion lineInfo;
        String line;
        try {
            lineInfo = document.getLineInformationOfOffset(offset);
            line = document.get(lineInfo.getOffset(), lineInfo.getLength());
        } catch (final BadLocationException ex) {
            return null;
        }
        final int offsetInLine = offset - lineInfo.getOffset();
View Full Code Here

                }
                // when entering an anonymous class between the parenthesis', we
                // don't want to jump after the closing parenthesis when return
                // is pressed
                if (event.character == SWT.CR && offset > 0) {
                    final IDocument document = sourceViewer.getDocument();
                    try {
                        if (document.getChar(offset - 1) == '{') {
                            return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
                        }
                    } catch (final BadLocationException e) {
                    }
                }
View Full Code Here

            return null;
        }

        @SuppressWarnings("synthetic-access")
        private boolean isMasked(final int offset) {
            final IDocument document = sourceViewer.getDocument();
            try {
                return fEscapeCharacter == document.getChar(offset - 1);
            } catch (final BadLocationException e) {
            }
            return false;
        }
View Full Code Here

        if (module == null || selection == null) {
            return;
        }

        final IDocument document = editor.getViewer().getDocument();
        if (document == null) {
            return;
        }

        boolean hasChanged = false;
View Full Code Here

    @Override
    protected TemplateContext createContext(final ITextViewer viewer, final IRegion region) {
        final TemplateContextType contextType = getContextType(viewer, region);
        if (contextType instanceof ErlangTemplateContextType) {
            final IDocument document = viewer.getDocument();
            return new ErlangTemplateContext(contextType, document, region.getOffset(),
                    region.getLength());
        }
        return super.createContext(viewer, region);
    }
View Full Code Here

            final ITextViewer textViewer = editor.getViewer();
            if (textViewer == null) {
                return Status.CANCEL_STATUS;
            }

            final IDocument document = textViewer.getDocument();
            if (document == null) {
                return Status.CANCEL_STATUS;
            }

            final IDocumentProvider documentProvider = editor.getDocumentProvider();
View Full Code Here

TOP

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

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.