mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
IDEA-333308 Disable multi-selection in the Project and Packages Views
For many projects, for example Gradle ones, it causes a lot of external library nodes to be expanded just to select multiple occurrences of a library class. This is weird UX and causes performance issues. Since multi-selection was added on purpose, it may be that some specific project view panes may actually need that. So keep the default behavior in AbstractProjectViewPaneWithAsyncSupport, but override it for the Project and Packages views. GitOrigin-RevId: c82438a6cc36b5a028210aa40a571636bb56e889
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4d2c38d9e7
commit
50cff98a87
@@ -53,6 +53,11 @@ public class PackageViewPane extends AbstractProjectViewPaneWithAsyncSupport {
|
||||
super(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureAsyncSupport(@NotNull AsyncProjectViewSupport support) {
|
||||
support.setMultiSelectionEnabled(false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
|
||||
@@ -94,6 +94,7 @@ public abstract class AbstractProjectViewPaneWithAsyncSupport extends AbstractPr
|
||||
}
|
||||
myTreeStructure = createStructure();
|
||||
myAsyncSupport = new AsyncProjectViewSupport(this, myProject, myTreeStructure, createComparator());
|
||||
configureAsyncSupport(myAsyncSupport);
|
||||
myAsyncSupport.setModelTo(myTree);
|
||||
|
||||
initTree();
|
||||
@@ -120,6 +121,10 @@ public abstract class AbstractProjectViewPaneWithAsyncSupport extends AbstractPr
|
||||
return myComponent;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected void configureAsyncSupport(@NotNull AsyncProjectViewSupport support) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installComparator(@NotNull Comparator<? super NodeDescriptor<?>> comparator) {
|
||||
if (myAsyncSupport != null) {
|
||||
|
||||
@@ -48,6 +48,7 @@ public final class AsyncProjectViewSupport {
|
||||
private final ProjectFileNodeUpdater myNodeUpdater;
|
||||
private final StructureTreeModel myStructureTreeModel;
|
||||
private final AsyncTreeModel myAsyncTreeModel;
|
||||
private boolean myMultiSelectionEnabled = true;
|
||||
|
||||
public AsyncProjectViewSupport(@NotNull Disposable parent,
|
||||
@NotNull Project project,
|
||||
@@ -219,12 +220,16 @@ public final class AsyncProjectViewSupport {
|
||||
myAsyncTreeModel.accept(visitor).onProcessed(path -> myAsyncTreeModel.onValidThread(task));
|
||||
}
|
||||
|
||||
private static boolean selectPaths(@NotNull JTree tree, @NotNull List<TreePath> paths, @NotNull TreeVisitor visitor) {
|
||||
public void setMultiSelectionEnabled(boolean enabled) {
|
||||
myMultiSelectionEnabled = enabled;
|
||||
}
|
||||
|
||||
private boolean selectPaths(@NotNull JTree tree, @NotNull List<TreePath> paths, @NotNull TreeVisitor visitor) {
|
||||
if (paths.isEmpty()) {
|
||||
SelectInProjectViewImplKt.getLOG().debug("Nothing to select");
|
||||
return false;
|
||||
}
|
||||
if (paths.size() > 1) {
|
||||
if (paths.size() > 1 && myMultiSelectionEnabled) {
|
||||
if (visitor instanceof ProjectViewNodeVisitor nodeVisitor) {
|
||||
return selectPaths(tree, new SelectionDescriptor(nodeVisitor.getElement(), nodeVisitor.getFile(), paths));
|
||||
}
|
||||
@@ -232,6 +237,9 @@ public final class AsyncProjectViewSupport {
|
||||
return selectPaths(tree, new SelectionDescriptor(null, fileVisitor.getElement(), paths));
|
||||
}
|
||||
}
|
||||
if (!myMultiSelectionEnabled) {
|
||||
SelectInProjectViewImplKt.getLOG().debug("Selecting only the first path because multi-selection is disabled");
|
||||
}
|
||||
TreePath path = paths.get(0);
|
||||
tree.expandPath(path); // request to expand found path
|
||||
TreeUtil.selectPaths(tree, path); // select and scroll to center
|
||||
|
||||
@@ -44,6 +44,11 @@ public class ProjectViewPane extends AbstractProjectViewPaneWithAsyncSupport {
|
||||
super(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureAsyncSupport(@NotNull AsyncProjectViewSupport support) {
|
||||
support.setMultiSelectionEnabled(false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
|
||||
Reference in New Issue
Block a user