Search in sources :

Example 81 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class XDebuggerSmartStepIntoHandler method perform.

@Override
protected void perform(@NotNull XDebugSession session, DataContext dataContext) {
    XSmartStepIntoHandler<?> handler = session.getDebugProcess().getSmartStepIntoHandler();
    XSourcePosition position = session.getTopFramePosition();
    if (position == null || handler == null)
        return;
    FileEditor editor = FileEditorManager.getInstance(session.getProject()).getSelectedEditor(position.getFile());
    if (editor instanceof TextEditor) {
        doSmartStepInto(handler, position, session, ((TextEditor) editor).getEditor());
    }
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) XSourcePosition(com.intellij.xdebugger.XSourcePosition)

Example 82 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class XDebuggerInlayUtil method createInlay.

public static void createInlay(@NotNull Project project, @NotNull VirtualFile file, int offset, String inlayText) {
    UIUtil.invokeLaterIfNeeded(() -> {
        FileEditor editor = FileEditorManager.getInstance(project).getSelectedEditor(file);
        if (editor instanceof TextEditor) {
            Editor e = ((TextEditor) editor).getEditor();
            CharSequence text = e.getDocument().getImmutableCharSequence();
            int insertOffset = offset;
            while (insertOffset < text.length() && Character.isJavaIdentifierPart(text.charAt(insertOffset))) insertOffset++;
            List<Inlay> existing = e.getInlayModel().getInlineElementsInRange(insertOffset, insertOffset);
            for (Inlay inlay : existing) {
                if (inlay.getRenderer() instanceof MyRenderer) {
                    Disposer.dispose(inlay);
                }
            }
            e.getInlayModel().addInlineElement(insertOffset, new MyRenderer(inlayText));
        }
    });
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Inlay(com.intellij.openapi.editor.Inlay) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor)

Example 83 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class UndoRedoAction method update.

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
    // do not allow global undo in dialogs
    if (editor == null) {
        final Boolean isModalContext = PlatformDataKeys.IS_MODAL_CONTEXT.getData(dataContext);
        if (isModalContext != null && isModalContext) {
            presentation.setEnabled(false);
            return;
        }
    }
    UndoManager undoManager = getUndoManager(editor, dataContext);
    if (undoManager == null) {
        presentation.setEnabled(false);
        return;
    }
    presentation.setEnabled(isAvailable(editor, undoManager));
    Pair<String, String> pair = getActionNameAndDescription(editor, undoManager);
    presentation.setText(pair.first);
    presentation.setDescription(pair.second);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) FileEditor(com.intellij.openapi.fileEditor.FileEditor) UndoManager(com.intellij.openapi.command.undo.UndoManager) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 84 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class UndoRedoAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
    UndoManager undoManager = getUndoManager(editor, dataContext);
    perform(editor, undoManager);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) FileEditor(com.intellij.openapi.fileEditor.FileEditor) UndoManager(com.intellij.openapi.command.undo.UndoManager)

Example 85 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class DiffSideView method setEditorSource.

public void setEditorSource(final Project project, final EditorSource source) {
    MyState state = new MyState();
    myEditorSource = source;
    myLineMarker.attach(myEditorSource);
    Editor editor = myEditorSource.getEditor();
    final FileEditor fileEditor = myEditorSource.getFileEditor();
    if (editor == null) {
        insertComponent(fileEditor == null ? MOCK_COMPONENT : fileEditor.getComponent());
        DataManager.registerDataProvider(myPanel, new DataProvider() {

            @Override
            public Object getData(@NonNls String dataId) {
                if (CommonDataKeys.PROJECT.is(dataId)) {
                    return project;
                }
                if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
                    return fileEditor;
                }
                return null;
            }
        });
        if (fileEditor != null) {
            ScrollUtil.scrollVertically(fileEditor.getComponent(), 0);
            ScrollUtil.scrollHorizontally(fileEditor.getComponent(), 0);
            UIUtil.removeScrollBorder(fileEditor.getComponent());
        }
    } else {
        DataManager.removeDataProvider(myPanel);
        editor.getScrollingModel().scrollHorizontally(0);
        insertComponent(editor.getComponent());
        applyHighlighter();
        setMouseListeners(source);
        MyEditorFocusListener.install(this);
        UIUtil.removeScrollBorder(editor.getComponent());
        state.restore();
    }
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) LabeledEditor(com.intellij.openapi.diff.impl.util.LabeledEditor)

Aggregations

FileEditor (com.intellij.openapi.fileEditor.FileEditor)140 TextEditor (com.intellij.openapi.fileEditor.TextEditor)54 VirtualFile (com.intellij.openapi.vfs.VirtualFile)53 Editor (com.intellij.openapi.editor.Editor)41 Project (com.intellij.openapi.project.Project)34 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)27 DataContext (com.intellij.openapi.actionSystem.DataContext)20 Nullable (org.jetbrains.annotations.Nullable)19 PsiFile (com.intellij.psi.PsiFile)16 Document (com.intellij.openapi.editor.Document)14 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)14 NotNull (org.jetbrains.annotations.NotNull)13 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)9 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)8 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)6 StructureViewComponent (com.intellij.ide.structureView.newStructureView.StructureViewComponent)6 StructureViewComposite (com.intellij.ide.structureView.impl.StructureViewComposite)5 FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)5 PsiElement (com.intellij.psi.PsiElement)5 List (java.util.List)5