mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[service-view] reselect items after update only if selected paths changed
GitOrigin-RevId: 9a6696a3359236414f49a8c19654b04b094efeb5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
492ea47776
commit
7ee7b84af1
@@ -177,15 +177,20 @@ class ServiceTreeView extends ServiceView {
|
||||
@Override
|
||||
public void rootsChanged() {
|
||||
AppUIUtil.invokeOnEdt(() -> {
|
||||
List<ServiceViewItem> selectedItems = getSelectedItems();
|
||||
TreePath[] currentPaths = myTree.getSelectionPaths();
|
||||
List<TreePath> selectedPaths =
|
||||
currentPaths == null || currentPaths.length == 0 ? Collections.emptyList() : Arrays.asList(currentPaths);
|
||||
myTreeModel.rootsChanged();
|
||||
if (selectedItems.isEmpty()) return;
|
||||
if (selectedPaths.isEmpty()) return;
|
||||
|
||||
myTreeModel.getInvoker().invokeLater(() -> {
|
||||
List<Promise<TreePath>> pathPromises =
|
||||
ContainerUtil.map(selectedItems, item -> myTreeModel.findPath(item.getValue(), item.getRootContributor().getClass()));
|
||||
ContainerUtil.mapNotNull(selectedPaths, path -> {
|
||||
ServiceViewItem item = ObjectUtils.tryCast(path.getLastPathComponent(), ServiceViewItem.class);
|
||||
return item == null ? null : myTreeModel.findPath(item.getValue(), item.getRootContributor().getClass());
|
||||
});
|
||||
Promises.collectResults(pathPromises, true).onProcessed(paths -> {
|
||||
if (paths != null) {
|
||||
if (paths != null && !paths.isEmpty() && !paths.equals(selectedPaths)) {
|
||||
TreeUtil.promiseSelect(myTree, paths.stream().map(PathSelectionVisitor::new));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user