void (final boolean shouldRefreshSelection) { final Runnable request = new Runnable() { @Override public void run() { if (!myProject.isDisposed()) { // Rely on project view to commit PSI and wait until it's updated. if (myTreeStructure.hasSomethingToCommit() ) { myUpdateAlarm.cancelAllRequests(); myUpdateAlarm.addRequest(this, 300, ModalityState.stateForComponent(myList)); return; } updateList(shouldRefreshSelection); } } }; if (!ApplicationManager.getApplication().isUnitTestMode()) { myUpdateAlarm.cancelAllRequests(); myUpdateAlarm.addRequest(request, 300, ModalityState.stateForComponent(myList)); } else { request.run(); } }