Search in sources :

Example 6 with FileEditorManagerEx

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

the class SplitAction method actionPerformed.

public void actionPerformed(final AnActionEvent event) {
    final Project project = event.getData(CommonDataKeys.PROJECT);
    final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
    final EditorWindow window = event.getData(EditorWindow.DATA_KEY);
    final VirtualFile file = event.getData(CommonDataKeys.VIRTUAL_FILE);
    fileEditorManager.createSplitter(myOrientation, window);
    if (myCloseSource && window != null && file != null) {
        window.closeFile(file, false, false);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 7 with FileEditorManagerEx

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

the class TabNavigationActionBase method update.

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    presentation.setEnabled(false);
    if (project == null || project.isDisposed()) {
        return;
    }
    final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
    if (windowManager.isEditorComponentActive()) {
        final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
        EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
        if (currentWindow == null) {
            editorManager.getCurrentWindow();
        }
        if (currentWindow != null) {
            final VirtualFile[] files = currentWindow.getFiles();
            presentation.setEnabled(files.length > 1);
        }
        return;
    }
    ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext);
    presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ContentManager(com.intellij.ui.content.ContentManager) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 8 with FileEditorManagerEx

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

the class TabNavigationActionBase method doNavigate.

private void doNavigate(DataContext dataContext, Project project) {
    final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
    EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
    if (currentWindow == null) {
        currentWindow = editorManager.getCurrentWindow();
    }
    VirtualFile selectedFile = currentWindow.getSelectedFile();
    if (selectedFile == null) {
        selectedFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
    }
    final VirtualFile[] files = currentWindow.getFiles();
    int index = ArrayUtil.find(files, selectedFile);
    LOG.assertTrue(index != -1);
    editorManager.openFile(files[(index + files.length + myDir) % files.length], true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 9 with FileEditorManagerEx

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

the class EditorHistoryManager method fileOpenedImpl.

/**
   * Makes file most recent one
   */
private void fileOpenedImpl(@NotNull final VirtualFile file, @Nullable final FileEditor fallbackEditor, @Nullable FileEditorProvider fallbackProvider) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    // don't add files that cannot be found via VFM (light & etc.)
    if (VirtualFileManager.getInstance().findFileByUrl(file.getUrl()) == null)
        return;
    final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(myProject);
    final Pair<FileEditor[], FileEditorProvider[]> editorsWithProviders = editorManager.getEditorsWithProviders(file);
    FileEditor[] editors = editorsWithProviders.getFirst();
    FileEditorProvider[] oldProviders = editorsWithProviders.getSecond();
    LOG.assertTrue(editors.length == oldProviders.length, "Different number of editors and providers");
    if (editors.length <= 0 && fallbackEditor != null && fallbackProvider != null) {
        editors = new FileEditor[] { fallbackEditor };
        oldProviders = new FileEditorProvider[] { fallbackProvider };
    }
    if (editors.length <= 0) {
        LOG.error("No editors for file " + file.getPresentableUrl());
    }
    FileEditor selectedEditor = editorManager.getSelectedEditor(file);
    if (selectedEditor == null) {
        selectedEditor = fallbackEditor;
    }
    LOG.assertTrue(selectedEditor != null);
    final int selectedProviderIndex = ArrayUtilRt.find(editors, selectedEditor);
    LOG.assertTrue(selectedProviderIndex != -1, "Can't find " + selectedEditor + " among " + Arrays.asList(editors));
    final HistoryEntry entry = getEntry(file);
    if (entry != null) {
        moveOnTop(entry);
    } else {
        final FileEditorState[] states = new FileEditorState[editors.length];
        final FileEditorProvider[] providers = new FileEditorProvider[editors.length];
        for (int i = states.length - 1; i >= 0; i--) {
            final FileEditorProvider provider = oldProviders[i];
            LOG.assertTrue(provider != null);
            providers[i] = provider;
            FileEditor editor = editors[i];
            if (editor.isValid()) {
                states[i] = editor.getState(FileEditorStateLevel.FULL);
            }
        }
        addEntry(HistoryEntry.createHeavy(myProject, file, providers, states, providers[selectedProviderIndex]));
        trimToSize();
    }
}
Also used : FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)

Example 10 with FileEditorManagerEx

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

the class EditorTabbedContainer method close.

@Override
public void close() {
    TabInfo selected = myTabs.getTargetInfo();
    if (selected == null)
        return;
    final VirtualFile file = (VirtualFile) selected.getObject();
    final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject);
    AsyncResult<EditorWindow> window = mgr.getActiveWindow();
    window.doWhenDone((Consumer<EditorWindow>) wnd -> {
        if (wnd != null) {
            if (wnd.findFileComposite(file) != null) {
                mgr.closeFile(file, wnd);
            }
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ShowFilePathAction(com.intellij.ide.actions.ShowFilePathAction) UIUtil(com.intellij.util.ui.UIUtil) AllIcons(com.intellij.icons.AllIcons) DragSession(com.intellij.ui.docking.DragSession) VirtualFile(com.intellij.openapi.vfs.VirtualFile) UniqueVFilePathBuilder(com.intellij.openapi.fileEditor.UniqueVFilePathBuilder) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) com.intellij.ui.tabs(com.intellij.ui.tabs) InplaceButton(com.intellij.ui.InplaceButton) Border(javax.swing.border.Border) JBUI(com.intellij.util.ui.JBUI) Map(java.util.Map) Disposer(com.intellij.openapi.util.Disposer) MouseAdapter(java.awt.event.MouseAdapter) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) AsyncResult(com.intellij.openapi.util.AsyncResult) Extensions(com.intellij.openapi.extensions.Extensions) ColorUtil(com.intellij.ui.ColorUtil) UISettingsListener(com.intellij.ide.ui.UISettingsListener) ActionCallback(com.intellij.openapi.util.ActionCallback) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) DockContainer(com.intellij.ui.docking.DockContainer) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) com.intellij.openapi.wm(com.intellij.openapi.wm) GeneralSettings(com.intellij.ide.GeneralSettings) Registry(com.intellij.openapi.util.registry.Registry) NotNull(org.jetbrains.annotations.NotNull) DockableContent(com.intellij.ui.docking.DockableContent) Consumer(com.intellij.util.Consumer) InputEvent(java.awt.event.InputEvent) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) DataFlavor(java.awt.datatransfer.DataFlavor) Transferable(java.awt.datatransfer.Transferable) NonNls(org.jetbrains.annotations.NonNls) FileDropHandler(com.intellij.openapi.fileEditor.impl.text.FileDropHandler) IdeEventQueue(com.intellij.ide.IdeEventQueue) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) Project(com.intellij.openapi.project.Project) DumbAware(com.intellij.openapi.project.DumbAware) CloseAction(com.intellij.ide.actions.CloseAction) IdeDocumentHistory(com.intellij.openapi.fileEditor.ex.IdeDocumentHistory) UISettings(com.intellij.ide.ui.UISettings) Disposable(com.intellij.openapi.Disposable) SystemInfo(com.intellij.openapi.util.SystemInfo) MouseEvent(java.awt.event.MouseEvent) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) CommandProcessor(com.intellij.openapi.command.CommandProcessor) ShadowAction(com.intellij.openapi.ui.ShadowAction) DockManager(com.intellij.ui.docking.DockManager) JBTabsImpl(com.intellij.ui.tabs.impl.JBTabsImpl) Queryable(com.intellij.openapi.ui.Queryable) TimedDeadzone(com.intellij.util.ui.TimedDeadzone) FocusEvent(java.awt.event.FocusEvent) CustomActionsSchema(com.intellij.ide.ui.customization.CustomActionsSchema) BitUtil(com.intellij.util.BitUtil) VfsUtil(com.intellij.openapi.vfs.VfsUtil) JBEditorTabs(com.intellij.ui.tabs.impl.JBEditorTabs) javax.swing(javax.swing) 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