IJPL-49322 Automatically select the first Project View item on show

This functionality was disabled along with the first item expansion
for the case when there's a restored state. This makes sense
for expansion, but not for selection, as the saved state doesn't
include selection anyway.

For the New Element button this became sort of a big deal,
as it makes the button disabled on startup. Fix by always selecting
the first element on first show, but not expanding anything
in case there's a restored non-empty state.

GitOrigin-RevId: 64365de4607037d9ea2951daf072edd4b4fd4daf
This commit is contained in:
Sergei Tachenov
2024-12-10 17:42:22 +00:00
committed by intellij-monorepo-bot
parent 1096e53868
commit b4ead51f27
@@ -635,7 +635,10 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
JTree tree = pane.getTree();
if (tree != null && projectView instanceof ProjectViewImpl impl && impl.firstShow) {
impl.firstShow = false;
if (!pane.myNonEmptyTreeStateRestored) {
if (pane.myNonEmptyTreeStateRestored) {
TreeUtil.promiseSelectFirst(tree);
}
else {
TreeUtil.promiseSelectFirst(tree).onSuccess(tree::expandPath);
}
}