Search in sources :

Example 26 with FileEditorManagerEx

use of com.intellij.openapi.fileEditor.ex.FileEditorManagerEx 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 27 with FileEditorManagerEx

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

the class PrevSplitAction method update.

public void update(final AnActionEvent event) {
    final Project project = event.getProject();
    final Presentation presentation = event.getPresentation();
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    presentation.setEnabled(toolWindowManager.isEditorComponentActive() && manager.isInSplitter() && manager.getCurrentWindow() != null);
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) Presentation(com.intellij.openapi.actionSystem.Presentation) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)

Example 28 with FileEditorManagerEx

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

the class PrevSplitAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    final CommandProcessor commandProcessor = CommandProcessor.getInstance();
    commandProcessor.executeCommand(project, () -> {
        final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
        manager.setCurrentWindow(manager.getPrevWindow(manager.getCurrentWindow()));
    }, IdeBundle.message("command.go.to.prev.split"), null);
}
Also used : Project(com.intellij.openapi.project.Project) CommandProcessor(com.intellij.openapi.command.CommandProcessor) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)

Example 29 with FileEditorManagerEx

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

the class UnsplitAction method actionPerformed.

public void actionPerformed(final AnActionEvent event) {
    final Project project = event.getProject();
    final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
    //VirtualFile file = fileEditorManager.getSelectedFiles()[0];
    fileEditorManager.unsplitWindow();
}
Also used : Project(com.intellij.openapi.project.Project) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)

Example 30 with FileEditorManagerEx

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

the class UnsplitAllAction method actionPerformed.

public void actionPerformed(final AnActionEvent event) {
    final Project project = event.getData(CommonDataKeys.PROJECT);
    final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
    //VirtualFile file = fileEditorManager.getSelectedFiles()[0];
    fileEditorManager.unsplitAllWindow();
}
Also used : Project(com.intellij.openapi.project.Project) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)

Aggregations

FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)37 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)19 Project (com.intellij.openapi.project.Project)18 VirtualFile (com.intellij.openapi.vfs.VirtualFile)16 FileEditor (com.intellij.openapi.fileEditor.FileEditor)5 CommandProcessor (com.intellij.openapi.command.CommandProcessor)4 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)3 NotNull (org.jetbrains.annotations.NotNull)3 Presentation (com.intellij.openapi.actionSystem.Presentation)2 Document (com.intellij.openapi.editor.Document)2 Editor (com.intellij.openapi.editor.Editor)2 TextEditor (com.intellij.openapi.fileEditor.TextEditor)2 Pair (com.intellij.openapi.util.Pair)2 EditorBoundHighlightingPass (com.intellij.codeHighlighting.EditorBoundHighlightingPass)1 HighlightingPass (com.intellij.codeHighlighting.HighlightingPass)1 TextEditorHighlightingPass (com.intellij.codeHighlighting.TextEditorHighlightingPass)1 AllIcons (com.intellij.icons.AllIcons)1 GeneralSettings (com.intellij.ide.GeneralSettings)1 IdeEventQueue (com.intellij.ide.IdeEventQueue)1 CloseAction (com.intellij.ide.actions.CloseAction)1