Package com.intellij.openapi.editor

Examples of com.intellij.openapi.editor.Document


public class BracketsInsertHandler extends BasicInsertHandler{
    public static final BracketsInsertHandler INSTANCE = new BracketsInsertHandler();

    public void handleInsert(InsertionContext insertionContext, DBLookupItem lookupElement) {
        Editor editor = insertionContext.getEditor();
        Document document = editor.getDocument();
        CaretModel caretModel = editor.getCaretModel();
        int startOffset = insertionContext.getStartOffset();
        char completionChar = insertionContext.getCompletionChar();

        int endOffset = startOffset + lookupElement.getLookupString().length();
        document.insertString(endOffset, "()");

        if (completionChar == ' ') {
            caretModel.moveCaretRelatively(3, 0, false, false, false);
        } else {
            caretModel.moveCaretRelatively(1, 0, false, false, false);
View Full Code Here


        return textEditor;
    }

    public void disposeEditor(@NotNull FileEditor editor) {
        DDLFileEditor sourceEditor = (DDLFileEditor) editor;
        Document document = sourceEditor.getEditor().getDocument();
        //DocumentUtil.removeGuardedBlock(document);
        sourceEditor.dispose();
    }
View Full Code Here

    public SourceCodeEditor(Project project, SourceCodeFile sourceCodeFile, String name) {
        super(project, sourceCodeFile, name);

        objectRef = DBObjectRef.from(sourceCodeFile.getObject());
        Document document = this.textEditor.getEditor().getDocument();
        if (document.getTextLength() > 0) {
            offsets = sourceCodeFile.getOffsets();
            int guardedBlockEndOffset = offsets.getGuardedBlockEndOffset();
            if (guardedBlockEndOffset > 0) {
                DocumentUtil.createGuardedBlock(document, 0, guardedBlockEndOffset, null
                        /*"You are not allowed to change the name of the " + object.getTypeName()*/);
 
View Full Code Here

        BasicTextEditor textEditor = isMainEditor ?
                new SourceCodeMainEditor(project, sourceCodeFile, editorName) :
                new SourceCodeEditor(project, sourceCodeFile, editorName);

        updateEditorActions(textEditor);
        Document document = textEditor.getEditor().getDocument();

        int documentTracking = document.hashCode();
        if (document.hashCode() != sourceCodeFile.getDocumentHashCode()) {
            document.addDocumentListener(sourceCodeFile);
            sourceCodeFile.setDocumentHashCode(documentTracking);
        }

        Icon icon = getIcon();
        if (icon != null) {
View Full Code Here

    }

    public static int getCaretOffset(PsiFile file) {
        PsiFile originalFile = file.getOriginalFile();
        if (originalFile != null) file = originalFile;
        Document document = DocumentUtil.getDocument(file);
        Editor[] editors = EditorFactory.getInstance().getEditors(document);

        //Editor editor = FileEditorManager.getInstance(file.getProject()).getSelectedTextEditor();

        return editors.length == 0 ? -1 : editors[0].getCaretModel().getOffset();
View Full Code Here

                "DBNavigator.Place.DataEditor.LonContentTypeEditor", true,
                new TextContentTypeComboBoxAction(this));
        actionsPanel.add(actionToolbar.getComponent(), BorderLayout.WEST);

        String text = readUserValue();
        Document document = EditorFactory.getInstance().createDocument(text == null ? "" : StringUtil.removeCharacter(text, '\r'));
        document.addDocumentListener(documentListener);

        editor = (EditorEx) EditorFactory.getInstance().createEditor(document, project, userValueHolder.getContentType().getFileType(), false);
        editor.setEmbeddedIntoDialogWrapper(true);
        editor.getContentComponent().setFocusTraversalKeysEnabled(false);
View Full Code Here

        if (project == null) {
            presentation.setEnabled(false);
            return;
        }

        Document document = editor.getDocument();
        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
        if (psiFile == null || !(psiFile instanceof HaskellFile)) {
            presentation.setEnabled(false);
            return;
        }
View Full Code Here

        if (editor == null)
            return;
        Project project = editor.getProject();
        if (project == null)
            return;
        Document document = editor.getDocument();
        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
        if (psiFile == null || !(psiFile instanceof HaskellFile))
            return;
        VirtualFile virtualFile = psiFile.getVirtualFile();
        if (virtualFile == null)
View Full Code Here

  public static PsiElement getElementAtLine(@NotNull final PsiFile file, final int line) {
    //noinspection ConstantConditions
    if (file == null) {
      return null;
    }
    final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
    PsiElement element = null;
    try {
      if (document != null) {
        final int offset = document.getLineStartOffset(line);
        element = file.getViewProvider().findElementAt(offset);
        if (element != null) {
          if (document.getLineNumber(element.getTextOffset()) != line) {
            element = element.getNextSibling();
          }
        }
      }
    } catch (@NotNull final IndexOutOfBoundsException ignore) {
View Full Code Here

        return; // no problem here
      }

      final PsiFile psiFile = bugInstanceNode.getPsiFile();
      if (psiFile != null) {
        final Document document = PsiDocumentManager.getInstance(_project).getDocument(psiFile);
        if (document != null) {
          final Editor editor = createEditor(bugInstanceNode, document);
          _parent.setPreviewEditor(editor, psiFile);
          scrollToPreviewSource(bugInstanceNode, editor);
        }
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.