mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
progress on splash
This commit is contained in:
@@ -40,6 +40,7 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.graph.CachingSemiGraph;
|
||||
import com.intellij.util.graph.DFSTBuilder;
|
||||
@@ -113,21 +114,25 @@ public class PluginManager {
|
||||
*/
|
||||
public static synchronized IdeaPluginDescriptor[] getPlugins() {
|
||||
if (ourPlugins == null) {
|
||||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
initializePlugins();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
getLogger().error(e);
|
||||
throw e;
|
||||
}
|
||||
getLogger().info(ourPlugins.length + " plugins initialized in " + (System.currentTimeMillis() - start) + " ms");
|
||||
logPlugins();
|
||||
ClassloaderUtil.clearJarURLCache();
|
||||
initPlugins(null);
|
||||
}
|
||||
return ourPlugins;
|
||||
}
|
||||
|
||||
public static void initPlugins(@Nullable Consumer<String> progress) {
|
||||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
initializePlugins(progress);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
getLogger().error(e);
|
||||
throw e;
|
||||
}
|
||||
getLogger().info(ourPlugins.length + " plugins initialized in " + (System.currentTimeMillis() - start) + " ms");
|
||||
logPlugins();
|
||||
ClassloaderUtil.clearJarURLCache();
|
||||
}
|
||||
|
||||
private static void logPlugins() {
|
||||
List<String> loaded = new ArrayList<String>();
|
||||
List<String> disabled = new ArrayList<String>();
|
||||
@@ -198,10 +203,10 @@ public class PluginManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static void initializePlugins() {
|
||||
private static void initializePlugins(Consumer<String> progress) {
|
||||
configureExtensions();
|
||||
|
||||
final IdeaPluginDescriptorImpl[] pluginDescriptors = loadDescriptors();
|
||||
final IdeaPluginDescriptorImpl[] pluginDescriptors = loadDescriptors(progress);
|
||||
|
||||
final Class callerClass = Reflection.getCallerClass(1);
|
||||
final ClassLoader parentLoader = callerClass.getClassLoader();
|
||||
@@ -523,22 +528,22 @@ public class PluginManager {
|
||||
return classLoaders.toArray(new ClassLoader[classLoaders.size()]);
|
||||
}
|
||||
|
||||
public static IdeaPluginDescriptorImpl[] loadDescriptors() {
|
||||
public static IdeaPluginDescriptorImpl[] loadDescriptors(@Nullable Consumer<String> progress) {
|
||||
if (ClassloaderUtil.isLoadingOfExternalPluginsDisabled()) {
|
||||
return IdeaPluginDescriptorImpl.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
final List<IdeaPluginDescriptorImpl> result = new ArrayList<IdeaPluginDescriptorImpl>();
|
||||
|
||||
loadDescriptors(PathManager.getPluginsPath(), result);
|
||||
loadDescriptors(PathManager.getPluginsPath(), result, progress);
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (application == null || !application.isUnitTestMode()) {
|
||||
loadDescriptors(PathManager.getPreinstalledPluginsPath(), result);
|
||||
loadDescriptors(PathManager.getPreinstalledPluginsPath(), result, progress);
|
||||
}
|
||||
|
||||
loadDescriptorsFromProperty(result);
|
||||
|
||||
loadDescriptorsFromClassPath(result);
|
||||
loadDescriptorsFromClassPath(result, progress);
|
||||
|
||||
IdeaPluginDescriptorImpl[] pluginDescriptors = result.toArray(new IdeaPluginDescriptorImpl[result.size()]);
|
||||
try {
|
||||
@@ -593,7 +598,7 @@ public class PluginManager {
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"})
|
||||
private static void loadDescriptorsFromClassPath(final List<IdeaPluginDescriptorImpl> result) {
|
||||
private static void loadDescriptorsFromClassPath(final List<IdeaPluginDescriptorImpl> result, @Nullable Consumer<String> progress) {
|
||||
try {
|
||||
final Collection<URL> urls = getClassLoaderUrls();
|
||||
final String platformPrefix = System.getProperty("idea.platform.prefix");
|
||||
@@ -624,6 +629,9 @@ public class PluginManager {
|
||||
pluginDescriptor.setUseCoreClassLoader(true);
|
||||
}
|
||||
result.add(pluginDescriptor);
|
||||
if (progress != null) {
|
||||
progress.consume("Plugin loaded: " + pluginDescriptor.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -789,13 +797,16 @@ public class PluginManager {
|
||||
}
|
||||
|
||||
|
||||
private static void loadDescriptors(String pluginsPath, List<IdeaPluginDescriptorImpl> result) {
|
||||
private static void loadDescriptors(String pluginsPath, List<IdeaPluginDescriptorImpl> result, @Nullable Consumer<String> progress) {
|
||||
final File pluginsHome = new File(pluginsPath);
|
||||
final File[] files = pluginsHome.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
final IdeaPluginDescriptorImpl descriptor = loadDescriptor(file, PLUGIN_XML);
|
||||
if (descriptor == null) continue;
|
||||
if (progress != null) {
|
||||
progress.consume(descriptor.getName());
|
||||
}
|
||||
int oldIndex = result.indexOf(descriptor);
|
||||
if (oldIndex >= 0) {
|
||||
final IdeaPluginDescriptorImpl oldDescriptor = result.get(oldIndex);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class StartupWizardModel extends WizardModel {
|
||||
add(myOtherStep);
|
||||
}
|
||||
|
||||
myAllPlugins = PluginManager.loadDescriptors();
|
||||
myAllPlugins = PluginManager.loadDescriptors(null);
|
||||
for (IdeaPluginDescriptor pluginDescriptor : myAllPlugins) {
|
||||
if (pluginDescriptor.getPluginId().getIdString().equals("com.intellij")) {
|
||||
// skip 'IDEA CORE' plugin
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CommandLineApplication {
|
||||
protected CommandLineApplication(boolean isInternal, boolean isUnitTestMode, boolean isHeadless, @NotNull @NonNls String appName) {
|
||||
LOG.assertTrue(ourInstance == null, "Only one instance allowed.");
|
||||
ourInstance = this;
|
||||
ApplicationManagerEx.createApplication(isInternal, isUnitTestMode, isHeadless, true, appName);
|
||||
ApplicationManagerEx.createApplication(isInternal, isUnitTestMode, isHeadless, true, appName, null);
|
||||
}
|
||||
|
||||
public Object getData(String dataId) {
|
||||
|
||||
@@ -76,11 +76,12 @@ public class IdeaApplication {
|
||||
else {
|
||||
System.setProperty("sun.awt.noerasebackground","true");
|
||||
patchSystem();
|
||||
Splash splash = null;
|
||||
if (myArgs.length == 0) {
|
||||
myStarter = getStarter();
|
||||
((IdeStarter)myStarter).showSplash(myArgs);
|
||||
splash = ((IdeStarter)myStarter).showSplash(myArgs);
|
||||
}
|
||||
ApplicationManagerEx.createApplication(isInternal, false, false, false, "idea");
|
||||
ApplicationManagerEx.createApplication(isInternal, false, false, false, "idea", splash);
|
||||
}
|
||||
|
||||
if (myStarter == null) {
|
||||
@@ -157,18 +158,21 @@ public class IdeaApplication {
|
||||
initLAF();
|
||||
}
|
||||
|
||||
private void showSplash(String[] args) {
|
||||
@Nullable
|
||||
private Splash showSplash(String[] args) {
|
||||
if (StartupUtil.shouldShowSplash(args)) {
|
||||
final ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
|
||||
final SplashScreen splashScreen = getSplashScreen();
|
||||
if (splashScreen == null) {
|
||||
mySplash = new Splash(appInfo.getLogoUrl(), appInfo.getLogoTextColor());
|
||||
mySplash.show();
|
||||
return mySplash;
|
||||
}
|
||||
else {
|
||||
updateSplashScreen(appInfo, splashScreen);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateSplashScreen(ApplicationInfoEx appInfo, SplashScreen splashScreen) {
|
||||
|
||||
+9
-2
@@ -21,8 +21,10 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.CachedSingletonsRegistry;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.ui.Splash;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -32,8 +34,13 @@ public class ApplicationManagerEx extends ApplicationManager {
|
||||
return (ApplicationEx) ourApplication;
|
||||
}
|
||||
|
||||
public static void createApplication(boolean internal, boolean isUnitTestMode, boolean isHeadlessMode, boolean isCommandline, @NotNull @NonNls String appName) {
|
||||
new ApplicationImpl(internal, isUnitTestMode, isHeadlessMode, isCommandline, appName);
|
||||
public static void createApplication(boolean internal,
|
||||
boolean isUnitTestMode,
|
||||
boolean isHeadlessMode,
|
||||
boolean isCommandline,
|
||||
@NotNull @NonNls String appName,
|
||||
@Nullable Splash splash) {
|
||||
new ApplicationImpl(internal, isUnitTestMode, isHeadlessMode, isCommandline, appName, splash);
|
||||
}
|
||||
|
||||
public static void setApplication(Application instance) {
|
||||
|
||||
+21
-1
@@ -51,11 +51,13 @@ import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.psi.PsiLock;
|
||||
import com.intellij.ui.Splash;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.ReflectionCache;
|
||||
@@ -98,6 +100,8 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
|
||||
private int myInEditorPaintCounter = 0;
|
||||
private long myStartTime = 0;
|
||||
@Nullable
|
||||
private Splash mySplash;
|
||||
private boolean myDoNotSave;
|
||||
private volatile boolean myDisposeInProgress = false;
|
||||
|
||||
@@ -160,7 +164,12 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return (IApplicationStore)super.getStateStore();
|
||||
}
|
||||
|
||||
public ApplicationImpl(boolean isInternal, boolean isUnitTestMode, boolean isHeadless, boolean isCommandLine, @NotNull String appName) {
|
||||
public ApplicationImpl(boolean isInternal,
|
||||
boolean isUnitTestMode,
|
||||
boolean isHeadless,
|
||||
boolean isCommandLine,
|
||||
@NotNull String appName,
|
||||
Splash splash) {
|
||||
super(null);
|
||||
|
||||
getPicoContainer().registerComponentInstance(Application.class, this);
|
||||
@@ -171,6 +180,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
Disposer.setDebugMode(true);
|
||||
}
|
||||
myStartTime = System.currentTimeMillis();
|
||||
mySplash = splash;
|
||||
myName = appName;
|
||||
ApplicationManagerEx.setApplication(this);
|
||||
|
||||
@@ -348,6 +358,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
|
||||
private void loadApplicationComponents() {
|
||||
PluginManager.initPlugins(mySplash);
|
||||
final IdeaPluginDescriptor[] plugins = PluginManager.getPlugins();
|
||||
for (IdeaPluginDescriptor plugin : plugins) {
|
||||
if (PluginManager.shouldSkipPlugin(plugin)) continue;
|
||||
@@ -485,6 +496,15 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return super.getComponentFromContainer(interfaceClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized Object createComponent(Class componentInterface) {
|
||||
Object component = super.createComponent(componentInterface);
|
||||
if (component != null && mySplash != null) {
|
||||
mySplash.consume("Component loaded: " + StringUtil.getShortName(componentInterface));
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
private static void loadComponentRoamingTypes() {
|
||||
ExtensionPoint<RoamingTypeExtensionPointBean> point = Extensions.getRootArea().getExtensionPoint("com.intellij.ComponentRoamingType");
|
||||
final RoamingTypeExtensionPointBean[] componentRoamingTypes = point.getExtensions();
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized Object createComponent(Class componentInterface) {
|
||||
protected synchronized Object createComponent(Class componentInterface) {
|
||||
final Object component = getPicoContainer().getComponentInstance(componentInterface.getName());
|
||||
assert component != null : "Can't instantiate component for: " + componentInterface;
|
||||
return component;
|
||||
|
||||
@@ -17,13 +17,14 @@ package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
public class Splash extends JDialog {
|
||||
public class Splash extends JDialog implements Consumer<String> {
|
||||
private final Icon myImage;
|
||||
private final JLabel myLabel;
|
||||
|
||||
@@ -51,23 +52,40 @@ public class Splash extends JDialog {
|
||||
myLabel.paintImmediately(0, 0, myImage.getIconWidth(), myImage.getIconHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(String message) {
|
||||
Graphics g = getGraphics();
|
||||
UIUtil.applyRenderingHints(g);
|
||||
g.setFont(new Font(UIUtil.ARIAL_FONT_NAME, Font.PLAIN, 10));
|
||||
|
||||
int y = getHeight() - 21;
|
||||
int brightness = 220;
|
||||
g.setColor(new Color(brightness, brightness, brightness));
|
||||
int x = 20;
|
||||
g.fillRect(1, y, 398, 20);
|
||||
g.setColor(Color.DARK_GRAY);
|
||||
// g.setXORMode(Color.WHITE);
|
||||
g.drawString(message, x, getHeight() - 8);
|
||||
}
|
||||
|
||||
public static boolean showLicenseeInfo(Graphics g, int x, int y, final int height, final Color textColor) {
|
||||
if (ApplicationInfoImpl.getShadowInstance().showLicenseeInfo()) {
|
||||
if (!ApplicationInfoImpl.getShadowInstance().showLicenseeInfo()) {
|
||||
return false;
|
||||
}
|
||||
LicensingFacade provider = LicensingFacade.getInstance();
|
||||
if (provider != null) {
|
||||
UIUtil.applyRenderingHints(g);
|
||||
g.setFont(new Font(UIUtil.ARIAL_FONT_NAME, Font.BOLD, 11));
|
||||
g.setColor(textColor);
|
||||
LicensingFacade provider = LicensingFacade.getInstance();
|
||||
if (provider != null) {
|
||||
final String licensedToMessage = provider.getLicensedToMessage();
|
||||
final List<String> licenseRestrictionsMessages = provider.getLicenseRestrictionsMessages();
|
||||
g.drawString(licensedToMessage, x + 21, y + height - 49);
|
||||
if (licenseRestrictionsMessages.size() > 0) {
|
||||
g.drawString(licenseRestrictionsMessages.get(0), x + 21, y + height - 33);
|
||||
}
|
||||
final String licensedToMessage = provider.getLicensedToMessage();
|
||||
final List<String> licenseRestrictionsMessages = provider.getLicenseRestrictionsMessages();
|
||||
int indent = 20;
|
||||
g.drawString(licensedToMessage, x + indent, y + height - 49);
|
||||
if (licenseRestrictionsMessages.size() > 0) {
|
||||
g.drawString(licenseRestrictionsMessages.get(0), x + indent, y + height - 33);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final class MyIcon implements Icon {
|
||||
|
||||
Reference in New Issue
Block a user