use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class CloseEditorsActionBase method update.
public void update(final AnActionEvent event) {
final Presentation presentation = event.getPresentation();
final DataContext dataContext = event.getDataContext();
final EditorWindow editorWindow = EditorWindow.DATA_KEY.getData(dataContext);
final boolean inSplitter = editorWindow != null && editorWindow.inSplitter();
presentation.setText(getPresentationText(inSplitter));
final Project project = event.getData(CommonDataKeys.PROJECT);
boolean enabled = (project != null && isActionEnabled(project, event));
if (ActionPlaces.isPopupPlace(event.getPlace())) {
presentation.setVisible(enabled);
} else {
presentation.setEnabled(enabled);
}
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class CloseEditorsActionBase method getFilesToClose.
protected ArrayList<Pair<EditorComposite, EditorWindow>> getFilesToClose(final AnActionEvent event) {
final ArrayList<Pair<EditorComposite, EditorWindow>> res = new ArrayList<>();
final DataContext dataContext = event.getDataContext();
final Project project = event.getData(CommonDataKeys.PROJECT);
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
final EditorWindow editorWindow = EditorWindow.DATA_KEY.getData(dataContext);
final EditorWindow[] windows;
if (editorWindow != null) {
windows = new EditorWindow[] { editorWindow };
} else {
windows = editorManager.getWindows();
}
final FileStatusManager fileStatusManager = FileStatusManager.getInstance(project);
if (fileStatusManager != null) {
for (int i = 0; i != windows.length; ++i) {
final EditorWindow window = windows[i];
final EditorComposite[] editors = window.getEditors();
for (final EditorComposite editor : editors) {
if (isFileToClose(editor, window)) {
res.add(Pair.create(editor, window));
}
}
}
}
return res;
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class CloseAllEditorsAction method update.
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
final EditorWindow editorWindow = event.getData(EditorWindow.DATA_KEY);
if (editorWindow != null && editorWindow.inSplitter()) {
presentation.setText(IdeBundle.message("action.close.all.editors.in.tab.group"));
} else {
presentation.setText(IdeBundle.message("action.close.all.editors"));
}
Project project = event.getData(CommonDataKeys.PROJECT);
if (project == null) {
presentation.setEnabled(false);
return;
}
presentation.setEnabled(FileEditorManager.getInstance(project).getSelectedFiles().length > 0);
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class CloseAllEditorsButActiveAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
VirtualFile selectedFile;
final EditorWindow window = e.getData(EditorWindow.DATA_KEY);
if (window != null) {
window.closeAllExcept(e.getData(CommonDataKeys.VIRTUAL_FILE));
return;
}
selectedFile = fileEditorManager.getSelectedFiles()[0];
final VirtualFile[] siblings = fileEditorManager.getSiblings(selectedFile);
for (final VirtualFile sibling : siblings) {
if (!Comparing.equal(selectedFile, sibling)) {
fileEditorManager.closeFile(sibling);
}
}
}
use of com.intellij.openapi.fileEditor.impl.EditorWindow in project intellij-community by JetBrains.
the class PinActiveTabAction method getHandler.
protected Handler getHandler(@NotNull AnActionEvent e) {
Project project = e.getProject();
EditorWindow currentWindow = e.getData(EditorWindow.DATA_KEY);
Content content = currentWindow != null ? null : getContentFromEvent(e);
if (content != null && content.isPinnable()) {
return createHandler(content);
}
final EditorWindow window = currentWindow != null ? currentWindow : project != null ? FileEditorManagerEx.getInstanceEx(project).getCurrentWindow() : null;
VirtualFile selectedFile = window == null ? null : getFileFromEvent(e, window);
if (selectedFile != null) {
return createHandler(window, selectedFile);
}
return null;
}
Aggregations