@Override public void reset() { // need this to ensure VFS operations will not block because of storage flushing // and other maintenance IO tasks run in background HeavyProcessLatch.INSTANCE.processStarted(); try { myWasUiDisposed = false; myContext.reset(); myProjectJdksModel.reset(myProject); Configurable toSelect = null; for (Configurable each : myName2Config) { if (myUiState.lastEditedConfigurable != null && myUiState.lastEditedConfigurable.equals(each.getDisplayName())) { toSelect = each; } if (each instanceof MasterDetailsComponent) { ((MasterDetailsComponent) each).setHistory(myHistory); } each.reset(); } myHistory.clear(); if (toSelect == null && myName2Config.size() > 0) { toSelect = myName2Config.iterator().next(); } removeSelected(); navigateTo(toSelect != null ? createPlaceFor(toSelect) : null, false); if (myUiState.proportion > 0) { mySplitter.setProportion(myUiState.proportion); } } finally { HeavyProcessLatch.INSTANCE.processFinished(); } }
public void load(String path) throws IOException, InvalidDataException { getStateStore().setOptionsPath(path); getStateStore().setConfigPath(PathManager.getConfigPath()); myIsFiringLoadingEvent = true; try { fireBeforeApplicationLoaded(); } finally { myIsFiringLoadingEvent = false; } loadComponentRoamingTypes(); HeavyProcessLatch.INSTANCE.processStarted(); try { getStateStore().load(); } catch (StateStorageException e) { throw new IOException(e.getMessage()); } finally { HeavyProcessLatch.INSTANCE.processFinished(); } }
private void scheduleCacheUpdate(@NotNull final DumbModeTask task, boolean forceDumbMode) { if (ApplicationManager.getApplication().isInternal()) LOG.info("schedule " + task); final Application application = ApplicationManager.getApplication(); if (application.isUnitTestMode() || application.isHeadlessEnvironment() || !forceDumbMode && !myDumb && application.isReadAccessAllowed()) { final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { indicator.pushState(); } try { HeavyProcessLatch.INSTANCE.processStarted(); task.performInDumbMode(indicator != null ? indicator : new EmptyProgressIndicator()); } finally { HeavyProcessLatch.INSTANCE.processFinished(); if (indicator != null) { indicator.popState(); } Disposer.dispose(task); } return; } UIUtil.invokeLaterIfNeeded( new DumbAwareRunnable() { @Override public void run() { if (myProject.isDisposed()) { return; } final ProgressIndicatorBase indicator = new ProgressIndicatorBase(); myProgresses.put(task, indicator); Disposer.register( task, new Disposable() { @Override public void dispose() { application.assertIsDispatchThread(); myProgresses.remove(task); } }); // ok to test and set the flag like this, because the change is always done from // dispatch thread if (!myDumb) { // always change dumb status inside write action. // This will ensure all active read actions are completed before the app goes dumb boolean startSuccess = application.runWriteAction( new Computable<Boolean>() { @Override public Boolean compute() { myDumb = true; try { myPublisher.enteredDumbMode(); } catch (Throwable e) { LOG.error(e); } try { startBackgroundProcess(task, indicator); } catch (Throwable e) { LOG.error("Failed to start background index update task", e); return false; } return true; } }); if (!startSuccess) { updateFinished(); } } else { myUpdatesQueue.addLast(task); } } }); }