use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ideavim by JetBrains.
the class FileGroup method closeFile.
/**
* Close the current editor
*
* @param context The data context
*/
public void closeFile(@NotNull Editor editor, @NotNull DataContext context) {
final Project project = PlatformDataKeys.PROJECT.getData(context);
if (project != null) {
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
final EditorWindow window = fileEditorManager.getCurrentWindow();
final EditorTabbedContainer tabbedPane = window.getTabbedPane();
if (tabbedPane != null) {
if (tabbedPane.getTabCount() > 1) {
final int index = tabbedPane.getSelectedIndex();
tabbedPane.removeTabAt(index, index + 1);
} else {
tabbedPane.close();
}
} else {
VirtualFile virtualFile = EditorData.getVirtualFile(editor);
if (virtualFile != null) {
fileEditorManager.closeFile(virtualFile);
}
}
}
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow 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);
}
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow 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());
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow 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);
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class CloseAllEditorsAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(project, () -> {
final EditorWindow window = e.getData(EditorWindow.DATA_KEY);
if (window != null) {
final VirtualFile[] files = window.getFiles();
for (final VirtualFile file : files) {
window.closeFile(file);
}
return;
}
FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
VirtualFile selectedFile = fileEditorManager.getSelectedFiles()[0];
VirtualFile[] openFiles = fileEditorManager.getSiblings(selectedFile);
for (final VirtualFile openFile : openFiles) {
fileEditorManager.closeFile(openFile);
}
}, IdeBundle.message("command.close.all.editors"), null);
}
Aggregations