ensure that project view refreshed before searching a node

This commit is contained in:
Sergey Malenkov
2018-12-04 20:20:42 +03:00
parent ed3f222e7c
commit 1cca7b6176
2 changed files with 7 additions and 7 deletions
@@ -51,7 +51,7 @@ class AsyncProjectViewSupport {
@NotNull JTree tree,
@NotNull AbstractTreeStructure structure,
@NotNull Comparator<NodeDescriptor> comparator) {
myStructureTreeModel = new StructureTreeModel(structure, comparator);
myStructureTreeModel = new StructureTreeModel<>(structure, comparator);
myAsyncTreeModel = new AsyncTreeModel(myStructureTreeModel, parent);
myAsyncTreeModel.setRootImmediately(myStructureTreeModel.getRootImmediately());
myNodeUpdater = new ProjectFileNodeUpdater(project, myStructureTreeModel.getInvoker()) {
@@ -165,8 +165,8 @@ class AsyncProjectViewSupport {
SmartList<TreePath> pathsToSelect = new SmartList<>();
TreeVisitor visitor = AbstractProjectViewPane.createVisitor(element, file, pathsToSelect);
if (visitor != null) {
//noinspection CodeBlock2Expr
expand(tree, promise -> {
myNodeUpdater.updateImmediately();
myAsyncTreeModel
.accept(visitor)
.onProcessed(path -> {
@@ -148,7 +148,7 @@ public abstract class ProjectFileNodeUpdater {
* Usually, it is needed to find an added file in a tree right after adding.
*/
public void updateImmediately() {
invoker.runOrInvokeLater(this::onInvokerThread);
invoker.runOrInvokeLater(() -> onInvokerThread(true));
}
/**
@@ -180,11 +180,11 @@ public abstract class ProjectFileNodeUpdater {
}
if (start) {
LOG.debug("start collecting files to update @ ", invoker);
invoker.invokeLater(this::onInvokerThread, getUpdatingDelay());
invoker.invokeLater(() -> onInvokerThread(false), getUpdatingDelay());
}
}
private void onInvokerThread() {
private void onInvokerThread(boolean now) {
Set<VirtualFile> files;
long startedAt;
boolean fromRoot;
@@ -201,7 +201,7 @@ public abstract class ProjectFileNodeUpdater {
root = false;
reference.set(null);
}
else if (size == files.size()) {
else if (now || size == files.size()) {
reference.set(null);
}
else {
@@ -210,7 +210,7 @@ public abstract class ProjectFileNodeUpdater {
}
if (restart) {
LOG.debug("continue collecting files to update @ ", invoker);
invoker.invokeLater(this::onInvokerThread, getUpdatingDelay());
invoker.invokeLater(() -> onInvokerThread(false), getUpdatingDelay());
}
else {
LOG.debug("spent ", System.currentTimeMillis() - startedAt, "ms to collect ", size, " files to update @ ", invoker);