Commit 55f00c1f authored by peter's avatar peter
Browse files

allow dumb mode for all open projects (RUBY-16985)

parent 757b8523
Showing with 24 additions and 18 deletions
+24 -18
......@@ -296,4 +296,21 @@ public abstract class DumbService {
void exitDumbMode();
}
/**
* Executes {@link #allowStartingDumbModeInside(DumbModePermission, Runnable)} for all given projects.
*/
public static void allowStartingDumbModeInside(@NotNull final DumbModePermission permission, @NotNull Project[] projects, @NotNull Runnable runnable) {
for (final Project project : projects) {
final Runnable prevRunnable = runnable;
runnable = new Runnable() {
@Override
public void run() {
getInstance(project).allowStartingDumbModeInside(permission, prevRunnable);
}
};
}
runnable.run();
}
}
......@@ -133,32 +133,19 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
selectInTree(toSelect, true);
}
Runnable showRunnable = new Runnable() {
// file chooser calls VFS refresh which might lead to rootsChanged in any open project and dumb mode that the clients don't expect.
// so if reindexing has to happen, let it happen under a modal progress and be finished before the file chooser returns.
// this hack should be gone if file chooser doesn't use VFS (https://youtrack.jetbrains.com/issue/IDEA-101218)
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_MODAL, ProjectManager.getInstance().getOpenProjects(), new Runnable() {
@Override
public void run() {
show();
}
};
// file chooser calls VFS refresh which might lead to rootsChanged in any open project and dumb mode that the clients don't expect.
// so if reindexing has to happen, let it happen under a modal progress and be finished before the file chooser returns.
// this hack should be gone if file chooser doesn't use VFS (https://youtrack.jetbrains.com/issue/IDEA-101218)
for (final Project eachProject : ProjectManager.getInstance().getOpenProjects()) {
showRunnable = allowModalDumbModeInside(showRunnable, eachProject);
}
showRunnable.run();
});
return myChosenFiles;
}
@NotNull
private static Runnable allowModalDumbModeInside(final @NotNull Runnable runnable, @NotNull final Project eachProject) {
return new Runnable() {
@Override
public void run() {
DumbService.getInstance(eachProject).allowStartingDumbModeInside(DumbModePermission.MAY_START_MODAL, runnable);
}
};
}
@NotNull
@Override
......
......@@ -114,6 +114,8 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica
@Override
public void allowStartingDumbModeInside(@NotNull DumbModePermission permission, @NotNull Runnable runnable) {
ApplicationManager.getApplication().assertIsDispatchThread();
LOG.assertTrue(!myProject.isDefault(), "Don't call allowStartingDumbModeInside for default project");
ModalityState modality = ModalityState.current();
DumbModePermission prev = myPermissions.put(modality, permission);
try {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment