Package com.intellij.openapi.editor

Examples of com.intellij.openapi.editor.Document


    private OverrideReadonlyFragmentModificationHandler() {

    }

    public void handle(ReadOnlyFragmentModificationException e) {
        Document document = e.getGuardedBlock().getDocument();
        String message = document.getUserData(GUARDED_BLOCK_REASON);
        if (message != null) {
            MessageUtil.showErrorDialog(message, "Action denied");
        } else {
            VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
            if (virtualFile instanceof SourceCodeFile || virtualFile instanceof LightVirtualFile) {
View Full Code Here


        selectionEnd = Integer.parseInt(sourceElement.getAttributeValue("selection-end"));
        verticalScrollProportion = Float.parseFloat(sourceElement.getAttributeValue("vertical-scroll-proportion"));

        Element foldingElement = sourceElement.getChild("folding");
        if (foldingElement != null) {
            Document document = DocumentUtil.getDocument(virtualFile);
            foldingState = CodeFoldingManager.getInstance(project).readFoldingState(foldingElement, document);
        }

    }
View Full Code Here

        editor.getCaretModel().moveToLogicalPosition(logicalPosition);
        selectionModel.removeSelection();
        editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
        if (verticalScrollProportion != -1F)
            EditorUtil.setVerticalScrollProportion(editor, verticalScrollProportion);
        Document document = editor.getDocument();
        if (selectionStart == selectionEnd) {
            selectionModel.removeSelection();
        } else {
            int selectionStart = Math.min(this.selectionStart, document.getTextLength());
            int selectionEnd = Math.min(this.selectionEnd, document.getTextLength());
            selectionModel.setSelection(selectionStart, selectionEnd);
        }
        ((EditorEx) editor).stopOptimizedScrolling();
        editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
View Full Code Here

    }

    public static Dimension calculatePreferredSize(Editor editor) {
        int maxLength = 0;

        Document document = editor.getDocument();
        for (int i=0; i< document.getLineCount(); i++) {
            int length = document.getLineEndOffset(i) - document.getLineStartOffset(i);
            if (length > maxLength) {
                maxLength = length;
            }
        }

        int charWidth = com.intellij.openapi.editor.ex.util.EditorUtil.getSpaceWidth(Font.PLAIN, editor);

        int width = (charWidth + 1) * maxLength; // mono spaced fonts here
        int height = (editor.getLineHeight()) * document.getLineCount();
        return new Dimension(width, height);
    }
View Full Code Here

    public static DBLCodeStyleManager getInstance(Project project) {
        return project.getComponent(DBLCodeStyleManager.class);
    }

    public void formatCase(PsiFile file) {
        Document document = DocumentUtil.getDocument(file);
        if (document != null && document.isWritable()) {
            Editor[] editors = EditorFactory.getInstance().getEditors(document);
            if (editors.length == 1) {
                Editor editor = editors[0];
                SelectionModel selectionModel = editor.getSelectionModel();
                int selectionStart = selectionModel.getSelectionStart();
View Full Code Here

        return list;
    }

    public void selectActiveConnectionForEditor(Editor editor, @Nullable ConnectionHandler connectionHandler) {
        if (editor!= null) {
            Document document = editor.getDocument();
            VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
            if (VirtualFileUtil.isLocalFileSystem(virtualFile) ) {
                boolean changed = setActiveConnection(virtualFile, connectionHandler);
                if (changed) {
                    DocumentUtil.touchDocument(editor);
View Full Code Here

        }
    }

    public void setCurrentSchemaForSelectedEditor(Editor editor, DBSchema schema) {
        if (editor!= null) {
            Document document = editor.getDocument();
            VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
            if (VirtualFileUtil.isLocalFileSystem(virtualFile) || virtualFile instanceof SQLConsoleFile) {
                boolean changed = setCurrentSchema(virtualFile, schema);
                if (changed) {
                    DocumentUtil.touchDocument(editor);
View Full Code Here

    public void computeChildren(@NotNull XCompositeNode node) {
        valuesMap = new THashMap<String, DBProgramDebugValue>();

        SourceCodeFile sourceCodeFile = DBProgramDebugUtil.getSourceCodeFile(sourcePosition);
        PSQLFile psiFile = (PSQLFile) PsiManager.getInstance(sourceCodeFile.getProject()).findFile(sourceCodeFile);
        Document document = DocumentUtil.getDocument(sourceCodeFile);
        int offset = document.getLineStartOffset(sourcePosition.getLine());
        Set<BasePsiElement> variables = psiFile.lookupVariableDefinition(offset);

        List<DBProgramDebugValue> values = new ArrayList<DBProgramDebugValue>();
        for (final BasePsiElement basePsiElement : variables) {
            String variableName = basePsiElement.getText();
View Full Code Here

    Issue issue = new Issue();
    issue.setFile(vFile);
    if (editor != null)
    {
      Document document = editor.getDocument();
      int lineStart = document.getLineNumber(editor.getSelectionModel().getSelectionStart());
      int lineEnd = document.getLineNumber(editor.getSelectionModel().getSelectionEnd());

      issue.setLineStart(lineStart);
      issue.setLineEnd(lineEnd);
      CharSequence fragment = document.getCharsSequence().subSequence(document.getLineStartOffset(lineStart),
        document.getLineEndOffset(lineEnd));
      issue.setHash(fragment.toString().hashCode());
    }
    issue.setStatus(IssueStatus.TO_RESOLVE);

    IssueDialog dialog = new IssueDialog(project, true);
View Full Code Here

    @Override
    public void navigate(boolean requestFocus) {
        Editor selectedEditor = EditorUtil.getSelectedEditor(getProject());
        if (selectedEditor != null) {
            Document document = DocumentUtil.getDocument(getContainingFile());
            Editor[] editors = EditorFactory.getInstance().getEditors(document);
            for (Editor editor : editors) {
                if (editor == selectedEditor) {
                    OpenFileDescriptor descriptor = (OpenFileDescriptor) EditSourceUtil.getDescriptor(this);
                    if (descriptor != null) {
View Full Code Here

TOP

Related Classes of com.intellij.openapi.editor.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.