diff --git a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java index 35a2895dc065..0dc20be374d2 100644 --- a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java +++ b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java @@ -172,7 +172,7 @@ public class StartupUtil { } if (!Main.isHeadless()) { - AppUIUtil.showUserAgreementAndConsentsIfNeeded(); + AppUIUtil.showUserAgreementAndConsentsIfNeeded(log); } if (newConfigFolder && !ConfigImportHelper.isConfigImported()) { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java b/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java index a7346858a6f7..d2a8cb79c8f1 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java @@ -1,18 +1,19 @@ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.statistic.updater; import com.intellij.internal.statistic.connect.StatisticsService; import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.ui.AppUIUtil; import org.jetbrains.annotations.NotNull; -public class StatisticsNotificationManager { - +final class StatisticsNotificationManager { private StatisticsNotificationManager() { } public static void showNotification(@NotNull StatisticsService statisticsService) { - if (AppUIUtil.showConsentsAgreementIfNeed()) { + if (AppUIUtil.showConsentsAgreementIfNeed(Logger.getInstance(StatisticsNotificationManager.class))) { ApplicationManager.getApplication().executeOnPooledThread((Runnable)statisticsService::send); UsageStatisticsPersistenceComponent.getInstance().setShowNotification(false); } diff --git a/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java b/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java index 85df64352b07..32f98ba69465 100644 --- a/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java +++ b/platform/platform-impl/src/com/intellij/ui/AppUIUtil.java @@ -62,11 +62,15 @@ import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; * @author yole */ public class AppUIUtil { - private static final Logger LOG = Logger.getInstance(AppUIUtil.class); private static final String VENDOR_PREFIX = "jetbrains-"; private static final boolean DEBUG_MODE = PluginManagerCore.isRunningFromSources(); private static boolean ourMacDocIconSet = false; + @NotNull + private static Logger getLogger() { + return Logger.getInstance(AppUIUtil.class); + } + public static void updateWindowIcon(@NotNull Window window) { // todo[tav] 'jbre.win.app.icon.supported' is defined by JBRE, remove when OpenJDK supports it as well if (SystemInfo.isWindows && Boolean.getBoolean("ide.native.launcher") && Boolean.getBoolean("jbre.win.app.icon.supported")) { @@ -114,7 +118,7 @@ public class AppUIUtil { SVGLoader.load(url, AppUIUtil.class.getResourceAsStream(svgIconUrl), ScaleContext.create(window), size, size); } catch (IOException e) { - LOG.info("Cannot load svg application icon from " + svgIconUrl, e); + getLogger().info("Cannot load svg application icon from " + svgIconUrl, e); } } else if (fallbackImageResourcePath != null) { @@ -215,7 +219,7 @@ public class AppUIUtil { if (fontDir == null) { URL url = AppUIUtil.class.getResource("/fonts/" + name); if (url == null) { - Logger.getInstance(AppUIUtil.class).warn("Resource missing: " + name); + getLogger().warn("Resource missing: " + name); return; } @@ -229,7 +233,7 @@ public class AppUIUtil { GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font); } catch (Throwable t) { - Logger.getInstance(AppUIUtil.class).warn("Cannot register font: " + name, t); + getLogger().warn("Cannot register font: " + name, t); } } @@ -279,7 +283,7 @@ public class AppUIUtil { return iconPath; } - public static void showUserAgreementAndConsentsIfNeeded() { + public static void showUserAgreementAndConsentsIfNeeded(@NotNull Logger log) { if (ApplicationInfoImpl.getShadowInstance().isVendorJetBrains()) { EndUserAgreement.Document agreement = EndUserAgreement.getLatestDocument(); if (!agreement.isAccepted()) { @@ -289,14 +293,14 @@ public class AppUIUtil { EndUserAgreement.setAccepted(agreement); } catch (Exception e) { - Logger.getInstance(AppUIUtil.class).warn(e); + log.warn(e); } } - showConsentsAgreementIfNeed(); + showConsentsAgreementIfNeed(log); } } - public static boolean showConsentsAgreementIfNeed() { + public static boolean showConsentsAgreementIfNeed(@NotNull Logger log) { final Pair, Boolean> consentsToShow = ConsentOptions.getInstance().getConsents(); AtomicBoolean result = new AtomicBoolean(); if (consentsToShow.second) { @@ -309,12 +313,13 @@ public class AppUIUtil { }; if (SwingUtilities.isEventDispatchThread()) { runnable.run(); - } else { + } + else { try { SwingUtilities.invokeAndWait(runnable); } catch (Exception e) { - Logger.getInstance(AppUIUtil.class).warn(e); + log.warn(e); } } }