use of com.intellij.openapi.fileEditor.impl.EditorComposite in project intellij-community by JetBrains.
the class CloseAllUnpinnedEditorsAction method isActionEnabled.
@Override
protected boolean isActionEnabled(final Project project, final AnActionEvent event) {
final ArrayList<Pair<EditorComposite, EditorWindow>> filesToClose = getFilesToClose(event);
if (filesToClose.isEmpty())
return false;
Set<EditorWindow> checked = new HashSet<>();
boolean hasPinned = false;
boolean hasUnpinned = false;
for (Pair<EditorComposite, EditorWindow> pair : filesToClose) {
final EditorWindow window = pair.second;
if (checked.add(window)) {
for (EditorWithProviderComposite e : window.getEditors()) {
if (e.isPinned()) {
hasPinned = true;
} else {
hasUnpinned = true;
}
}
if (/*hasPinned && */
hasUnpinned) {
return true;
}
}
}
return false;
}
use of com.intellij.openapi.fileEditor.impl.EditorComposite in project intellij-community by JetBrains.
the class CloseEditorsActionBase method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(project, () -> {
final ArrayList<Pair<EditorComposite, EditorWindow>> filesToClose = getFilesToClose(e);
for (int i = 0; i != filesToClose.size(); ++i) {
final Pair<EditorComposite, EditorWindow> we = filesToClose.get(i);
we.getSecond().closeFile(we.getFirst().getFile());
}
}, IdeBundle.message("command.close.all.unmodified.editors"), null);
}
use of com.intellij.openapi.fileEditor.impl.EditorComposite 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;
}
Aggregations