use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class CloseAllEditorsButActiveAction method update.
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
Project project = event.getData(CommonDataKeys.PROJECT);
if (project == null) {
presentation.setEnabled(false);
return;
}
FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
VirtualFile selectedFile;
final EditorWindow window = event.getData(EditorWindow.DATA_KEY);
if (window != null) {
presentation.setEnabled(window.getFiles().length > 1);
return;
} else {
if (fileEditorManager.getSelectedFiles().length == 0) {
presentation.setEnabled(false);
return;
}
selectedFile = fileEditorManager.getSelectedFiles()[0];
}
VirtualFile[] siblings = fileEditorManager.getSiblings(selectedFile);
presentation.setEnabled(siblings.length > 1);
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class CloseEditorAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
FileEditorManagerEx editorManager = getEditorManager(project);
EditorWindow window = e.getData(EditorWindow.DATA_KEY);
VirtualFile file = null;
if (window == null) {
window = editorManager.getCurrentWindow();
if (window != null) {
file = window.getSelectedFile();
}
} else {
file = e.getData(CommonDataKeys.VIRTUAL_FILE);
}
if (file != null) {
editorManager.closeFile(file, window);
}
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class FileEditorManagerTest method testWindowClosingRetainsOtherWindows.
public void testWindowClosingRetainsOtherWindows() throws Exception {
VirtualFile file = getFile("/src/1.txt");
assertNotNull(file);
myManager.openFile(file, false);
EditorWindow primaryWindow = myManager.getCurrentWindow();
assertNotNull(primaryWindow);
myManager.createSplitter(SwingConstants.VERTICAL, primaryWindow);
EditorWindow secondaryWindow = myManager.getNextWindow(primaryWindow);
assertNotNull(secondaryWindow);
myManager.createSplitter(SwingConstants.VERTICAL, secondaryWindow);
myManager.closeFile(file, primaryWindow);
assertEquals(2, myManager.getWindows().length);
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class QuickEditHandler method closeEditor.
private void closeEditor() {
boolean unsplit = false;
if (mySplittedWindow != null && !mySplittedWindow.isDisposed()) {
final EditorWithProviderComposite[] editors = mySplittedWindow.getEditors();
if (editors.length == 1 && Comparing.equal(editors[0].getFile(), myNewVirtualFile)) {
unsplit = true;
}
}
FileEditorManager.getInstance(myProject).closeFile(myNewVirtualFile);
if (unsplit) {
for (EditorWindow editorWindow : mySplittedWindow.findSiblings()) {
editorWindow.unsplit(true);
}
}
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ActiveTabHighlighterPlugin by tobszarny.
the class CustomEditorTabColorProvider method getEditorTabColor.
@Nullable
@Override
public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile virtualFile) {
final FileEditorManagerEx fileEditorManagerEx = FileEditorManagerEx.getInstanceEx(project);
FileColorManager fileColorManager = FileColorManager.getInstance(project);
HighlighterSettingsConfig highlighterSettingsConfig = HighlighterSettingsConfig.getInstance();
if (highlighterSettingsConfig.isBackgroundColorUsed()) {
EditorWindow activeWindow = fileEditorManagerEx.getCurrentWindow();
if (activeWindow != null) {
final EditorWithProviderComposite selectedEditor = activeWindow.getSelectedEditor();
if (selectedEditor != null && selectedEditor.getFile() != null && selectedEditor.getFile().equals(virtualFile)) {
return highlighterSettingsConfig.getBackgroundColor();
}
}
}
return fileColorManager.getFileColor(virtualFile);
}
Aggregations