smooth startup progress

This commit is contained in:
Dmitry Avdeev
2011-09-14 12:42:00 +04:00
parent 5bd5946146
commit ae4a47f95b
3 changed files with 12 additions and 17 deletions
@@ -67,7 +67,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
private final ComponentManagerConfigurator myConfigurator = new ComponentManagerConfigurator(this);
private final ComponentManager myParentComponentManager;
private Boolean myHeadless;
private ComponentsRegistry myComponentsRegistry = new ComponentsRegistry();
protected ComponentsRegistry myComponentsRegistry = new ComponentsRegistry();
private final Condition myDisposedCondition = new Condition() {
public boolean value(final Object o) {
return isDisposed();
@@ -395,7 +395,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
return LOG.isDebugEnabled();
}
private class ComponentsRegistry {
protected class ComponentsRegistry {
private final Map<Class, Object> myInterfaceToLockMap = new HashMap<Class, Object>();
private final Map<Class, Class> myInterfaceToClassMap = new HashMap<Class, Class>();
private final ArrayList<Class> myComponentInterfaces = new ArrayList<Class>(); // keeps order of component's registration
@@ -95,7 +95,7 @@ public class PluginManager {
public static long startupStart;
public static final float PLUGINS_PROGRESS_MAX_VALUE = 0.8f;
public static final float PLUGINS_PROGRESS_MAX_VALUE = 0.5f;
public static class Facade extends PluginsFacade {
public IdeaPluginDescriptor getPlugin(PluginId id) {
@@ -254,6 +254,7 @@ public class PluginManager {
ourId2Index.put(result.get(i).getPluginId(), i);
}
int i = 0;
for (final IdeaPluginDescriptorImpl pluginDescriptor : result) {
if (pluginDescriptor.getPluginId().getIdString().equals(CORE_PLUGIN_ID) || pluginDescriptor.isUseCoreClassLoader()) {
pluginDescriptor.setLoader(parentLoader, true);
@@ -270,6 +271,7 @@ public class PluginManager {
}
pluginDescriptor.registerExtensions();
progress.showProgress("", 0.5f + (i++/(float )result.size()) * 0.25f);
}
ourPlugins = pluginDescriptors;
@@ -548,9 +550,6 @@ public class PluginManager {
loadDescriptorsFromProperty(result);
if (!fromSources && progress != null) {
progress.showProgress("Loading core...", PLUGINS_PROGRESS_MAX_VALUE);
}
loadDescriptorsFromClassPath(result, fromSources ? progress : null);
IdeaPluginDescriptorImpl[] pluginDescriptors = result.toArray(new IdeaPluginDescriptorImpl[result.size()]);
@@ -380,23 +380,19 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
private void loadApplicationComponents() {
PluginManager.initPlugins(mySplash);
final IdeaPluginDescriptor[] plugins = PluginManager.getPlugins();
int pluginCount = 0;
for (IdeaPluginDescriptor plugin : plugins) {
if (!PluginManager.shouldSkipPlugin(plugin)) pluginCount++;
}
int i = 0;
for (IdeaPluginDescriptor plugin : plugins) {
if (PluginManager.shouldSkipPlugin(plugin)) continue;
if (mySplash != null) {
final float p = (float)++i / pluginCount;
final float progress = p + (1 - p) * PluginManager.PLUGINS_PROGRESS_MAX_VALUE;
mySplash.showProgress(plugin.getName(), progress);
}
loadComponentsConfiguration(plugin.getAppComponents(), plugin, false);
}
}
@Override
protected synchronized Object createComponent(Class componentInterface) {
Object component = super.createComponent(componentInterface);
if (mySplash != null) {
mySplash.showProgress("Loading project...", 1.0f);
mySplash.showProgress("", (float)(0.75f + myComponentsRegistry.getPercentageOfComponentsLoaded() * 0.25f));
}
return component;
}
protected MutablePicoContainer createPicoContainer() {