use of com.intellij.openapi.fileEditor.impl.EditorTabbedContainer in project ideavim by JetBrains.
the class MotionGroup method switchEditorTab.
/**
* If 'absolute' is true, then set tab index to 'value', otherwise add 'value' to tab index with wraparound.
*/
private void switchEditorTab(@Nullable EditorWindow editorWindow, int value, boolean absolute) {
if (editorWindow != null) {
final EditorTabbedContainer tabbedPane = editorWindow.getTabbedPane();
if (tabbedPane != null) {
if (absolute) {
tabbedPane.setSelectedIndex(value);
} else {
int tabIndex = (value + tabbedPane.getSelectedIndex()) % tabbedPane.getTabCount();
tabbedPane.setSelectedIndex(tabIndex < 0 ? tabIndex + tabbedPane.getTabCount() : tabIndex);
}
}
}
}
use of com.intellij.openapi.fileEditor.impl.EditorTabbedContainer 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);
}
}
}
}
Aggregations