From 0b85cc182fb27d1b44832f67fa6f0207a72152db Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 9 Nov 2013 17:14:00 +0100 Subject: [PATCH] trying to make project opening progress information more meaningful (IDEA-115130) --- .../module/impl/ModuleManagerComponent.java | 2 +- .../roots/impl/DirectoryIndexImpl.java | 1 + .../fileEditor/impl/OpenFilesActivity.java | 10 ++++++++++ .../openapi/project/impl/ProjectImpl.java | 14 +++++++++++--- .../module/impl/ModuleManagerImpl.java | 19 ++++++++++++------- .../impl/PushedFilePropertiesUpdater.java | 3 ++- 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java index 0d12404f746e..e71317065cb9 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java @@ -152,7 +152,7 @@ public class ModuleManagerComponent extends ModuleManagerImpl { ProgressIndicator progressIndicator = myProgressManager.getProgressIndicator(); if (progressIndicator == null) { - myProgressManager.runProcessWithProgressSynchronously(runnableWithProgress, "Loading modules", false, myProject); + myProgressManager.runProcessWithProgressSynchronously(runnableWithProgress, "Initializing modules...", false, myProject); } else { runnableWithProgress.run(); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java index b01b058c2ac5..8c2948ffce22 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java @@ -1421,6 +1421,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { fillMapWithOrderEntries(depEntries, libClassRootEntries, libSourceRootEntries, progress); internDirectoryInfos(); + progress.popState(); } private void internDirectoryInfos() { diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java index 62866d357dde..94d0883c325c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java @@ -16,6 +16,8 @@ package com.intellij.openapi.fileEditor.impl; import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupActivity; @@ -42,7 +44,15 @@ public class OpenFilesActivity implements StartupActivity, DumbAware { } }; if (Registry.is("ide.open.editors.asynchronously")) { + ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); + if (indicator != null) { + indicator.pushState(); + indicator.setText("Preparing editors to open..."); + } runnable.run(); + if (indicator != null) { + indicator.popState(); + } } else { UIUtil.invokeLaterIfNeeded(runnable); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java index 2d62c8d3b801..7e6a04cb86b9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java @@ -41,6 +41,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressIndicatorProvider; import com.intellij.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectBundle; @@ -207,9 +208,9 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx { if (!service) { ProgressIndicator indicator = getProgressIndicator(); if (indicator != null) { - indicator.setText2(getComponentName(component)); - // indicator.setIndeterminate(false); - // indicator.setFraction(myComponentsRegistry.getPercentageOfComponentsLoaded()); + // indicator.setText2(getComponentName(component)); + indicator.setIndeterminate(false); + indicator.setFraction(getPercentageOfComponentsLoaded()); } } @@ -308,7 +309,14 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx { public void init() { long start = System.currentTimeMillis(); // ProfilingUtil.startCPUProfiling(); + final ProgressIndicator progressIndicator = isDefault() ? null : ProgressIndicatorProvider.getGlobalProgressIndicator(); + if (progressIndicator != null) { + progressIndicator.pushState(); + } super.init(); + if (progressIndicator != null) { + progressIndicator.popState(); + } // ProfilingUtil.captureCPUSnapshot(); long time = System.currentTimeMillis() - start; LOG.info(getComponentConfigurations().length + " project components initialized in " + time + " ms"); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java index c1e860cd29e3..c8ac87e0155f 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java @@ -253,9 +253,13 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project final List modulesWithUnknownTypes = new ArrayList(); List errors = new ArrayList(); - for (final ModulePath modulePath : myModulePaths) { + for (int i = 0; i < myModulePaths.size(); i++) { + ModulePath modulePath = myModulePaths.get(i); + if (progressIndicator != null) { + progressIndicator.setFraction((double) i / myModulePaths.size()); + } try { - final Module module = moduleModel.loadModuleInternal(modulePath.getPath(), progressIndicator); + final Module module = moduleModel.loadModuleInternal(modulePath.getPath()); if (isUnknownModuleType(module)) { modulesWithUnknownTypes.add(module); } @@ -283,6 +287,10 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project fireErrors(errors); showUnknownModuleTypeNotification(modulesWithUnknownTypes); + + if (progressIndicator != null) { + progressIndicator.setIndeterminate(true); + } } protected boolean isUnknownModuleType(Module module) { @@ -732,14 +740,14 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project public Module loadModule(@NotNull String filePath) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists { assertWritable(); try { - return loadModuleInternal(filePath, null); + return loadModuleInternal(filePath); } catch (StateStorageException e) { throw new IOException(ProjectBundle.message("module.corrupted.file.error", FileUtil.toSystemDependentName(filePath), e.getMessage())); } } - private Module loadModuleInternal(String filePath, @Nullable ProgressIndicator progressIndicator) + private Module loadModuleInternal(String filePath) throws ModuleWithNameAlreadyExists, IOException, StateStorageException { final VirtualFile moduleFile = StandardFileSystems.local().findFileByPath(resolveShortWindowsName(filePath)); @@ -748,9 +756,6 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project } final String name = moduleFile.getName(); - if (progressIndicator != null) { - progressIndicator.setText2(FileUtil.getNameWithoutExtension(name)); - } if (name.endsWith(IML_EXTENSION)) { final String moduleName = name.substring(0, name.length() - 4); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java index 29d742731b59..c22363656b87 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java @@ -150,6 +150,7 @@ public class PushedFilePropertiesUpdater { public void pushAll(final FilePropertyPusher... pushers) { ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { + indicator.pushState(); indicator.setText("Updating file properties..."); } Module[] modules = ModuleManager.getInstance(myProject).getModules(); @@ -175,7 +176,7 @@ public class PushedFilePropertiesUpdater { } } if (indicator != null) { - indicator.setText(""); + indicator.popState(); } }