Setup project view toolwindow actions during initialization, fix IDEA-312339

GitOrigin-RevId: 62e0d4ea787dfefad649c176d015461e0bd974e0
This commit is contained in:
Evgeniy.Stepanov
2023-02-08 16:19:21 +01:00
committed by intellij-monorepo-bot
parent bd87bfdaf2
commit 4a220a70b5

View File

@@ -938,6 +938,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
});
viewSelectionChanged();
setupToolwindowActions(toolWindow);
Object multicaster = EditorFactory.getInstance().getEventMulticaster();
if (multicaster instanceof EditorEventMulticasterEx ex) {
@@ -971,6 +972,20 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
private void setupToolwindowActions(@NotNull ToolWindow toolWindow) {
List<AnAction> titleActions = new ArrayList<>();
createTitleActions(titleActions);
if (!titleActions.isEmpty()) {
toolWindow.setTitleActions(titleActions);
}
List<AnAction> tabActions = new ArrayList<>();
createTabActions(tabActions);
if (!tabActions.isEmpty()) {
((ToolWindowEx)toolWindow).setTabActions(tabActions.toArray(AnAction[]::new));
}
}
private synchronized void reloadPanes() {
if (myProject.isDisposed() || !myExtensionsLoaded.get()) return; // panes will be loaded later
@@ -1061,24 +1076,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
pane.addToolbarActions(myActionGroup);
List<AnAction> titleActions = new ArrayList<>();
createTitleActions(titleActions);
if (!titleActions.isEmpty()) {
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PROJECT_VIEW);
if (window != null) {
window.setTitleActions(titleActions);
}
}
List<AnAction> tabActions = new ArrayList<>();
createTabActions(tabActions);
if (!tabActions.isEmpty()) {
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PROJECT_VIEW);
if (window instanceof ToolWindowEx) {
((ToolWindowEx)window).setTabActions(tabActions.toArray(AnAction[]::new));
}
}
}
protected void createTitleActions(@NotNull List<? super AnAction> titleActions) {