Search in sources :

Example 91 with FileEditor

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

the class QuickEditHandler method navigate.

public void navigate(int injectedOffset) {
    if (myAction.isShowInBalloon()) {
        final JComponent component = myAction.createBalloonComponent(myNewFile);
        if (component != null)
            showBalloon(myEditor, myNewFile, component);
    } else {
        final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(myProject);
        final FileEditor[] editors = fileEditorManager.getEditors(myNewVirtualFile);
        if (editors.length == 0) {
            final EditorWindow curWindow = fileEditorManager.getCurrentWindow();
            mySplittedWindow = curWindow.split(SwingConstants.HORIZONTAL, false, myNewVirtualFile, true);
        }
        Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(myProject, myNewVirtualFile, injectedOffset), true);
        // fold missing values
        if (editor != null) {
            editor.putUserData(QuickEditAction.QUICK_EDIT_HANDLER, this);
            final FoldingModel foldingModel = editor.getFoldingModel();
            foldingModel.runBatchFoldingOperation(() -> {
                for (RangeMarker o : ContainerUtil.reverse(((DocumentEx) myNewDocument).getGuardedBlocks())) {
                    String replacement = o.getUserData(REPLACEMENT_KEY);
                    if (StringUtil.isEmpty(replacement))
                        continue;
                    FoldRegion region = foldingModel.addFoldRegion(o.getStartOffset(), o.getEndOffset(), replacement);
                    if (region != null)
                        region.setExpanded(false);
                }
            });
        }
        SwingUtilities.invokeLater(() -> myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE));
    }
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 92 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 93 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 94 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)

Example 95 with FileEditor

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

the class DiffSideView method getFocusableComponent.

public JComponent getFocusableComponent() {
    Editor editor = getEditor();
    if (editor != null)
        return editor.getContentComponent();
    FileEditor fileEditor = myEditorSource.getFileEditor();
    if (fileEditor != null)
        return fileEditor.getComponent();
    return MOCK_COMPONENT;
}
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