trying to make project opening progress information more meaningful (IDEA-115130)

This commit is contained in:
peter
2013-11-09 17:20:06 +01:00
parent 35af155f74
commit 0b85cc182f
6 changed files with 37 additions and 12 deletions
@@ -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();
@@ -1421,6 +1421,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
fillMapWithOrderEntries(depEntries, libClassRootEntries, libSourceRootEntries, progress);
internDirectoryInfos();
progress.popState();
}
private void internDirectoryInfos() {
@@ -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);
@@ -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");
@@ -253,9 +253,13 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
final List<Module> modulesWithUnknownTypes = new ArrayList<Module>();
List<ModuleLoadingErrorDescription> errors = new ArrayList<ModuleLoadingErrorDescription>();
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);
@@ -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();
}
}