From 4e2e19aa4565a4ee05a6fbc7d0d1a94fa9622b97 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 29 Jul 2019 17:30:04 +0200 Subject: [PATCH] fix ide start if no opened projects (regression because prepareToShow returns runnable) GitOrigin-RevId: 198672cca104188a9f094b94bca54bd31f6f4275 --- .../ui/components/labels/ActionLink.java | 18 ++------------ .../src/com/intellij/idea/IdeaApplication.kt | 22 +++++++++-------- .../impl/welcomeScreen/FlatWelcomeFrame.java | 24 ++++++++----------- .../wm/impl/welcomeScreen/WelcomeFrame.java | 10 +++++--- 4 files changed, 31 insertions(+), 43 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/ActionLink.java b/platform/platform-api/src/com/intellij/ui/components/labels/ActionLink.java index 7778d83e47f6..e3a8b1beea8e 100644 --- a/platform/platform-api/src/com/intellij/ui/components/labels/ActionLink.java +++ b/platform/platform-api/src/com/intellij/ui/components/labels/ActionLink.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// 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.ui.components.labels; import com.intellij.openapi.actionSystem.ActionPlaces; @@ -52,7 +38,7 @@ public class ActionLink extends LinkLabel implements DataProvider { this(text, icon, action, null); } - public ActionLink(String text, Icon icon, @NotNull AnAction action, @Nullable final Runnable onDone) { + public ActionLink(String text, Icon icon, @NotNull AnAction action, @Nullable Runnable onDone) { super(text, icon); setListener(new LinkListener() { @Override diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.kt b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.kt index 6b9abf164639..d1bdf997ff5d 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.kt +++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.kt @@ -26,7 +26,6 @@ import com.intellij.openapi.util.Comparing import com.intellij.openapi.util.IconLoader import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.SystemPropertyBean -import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.util.registry.RegistryKeyBean import com.intellij.openapi.wm.IdeFrame import com.intellij.openapi.wm.WindowManager @@ -348,19 +347,20 @@ open class IdeStarter : ApplicationStarter { val willOpenProject = commandLineArgs.isNotEmpty() || filesToLoad.isNotEmpty() || RecentProjectsManager.getInstance().willReopenProjectOnStart() // temporary check until the JRE implementation has been checked and bundled - if (Registry.`is`("ide.popup.enablePopupType")) { + if (java.lang.Boolean.getBoolean("ide.popup.enablePopupType")) { @Suppress("SpellCheckingInspection") System.setProperty("jbre.popupwindow.settype", "true") } val shouldShowWelcomeFrame = !willOpenProject || JetBrainsProtocolHandler.getCommand() != null - showWizardAndWelcomeFrame(when { - shouldShowWelcomeFrame -> Runnable { - WelcomeFrame.prepareToShow() - lifecyclePublisher.welcomeScreenDisplayed() - } - else -> null - }) + val doShowWelcomeFrame = if (shouldShowWelcomeFrame) WelcomeFrame.prepareToShow() else null + showWizardAndWelcomeFrame(when (doShowWelcomeFrame) { + null -> null + else -> Runnable { + doShowWelcomeFrame.run() + lifecyclePublisher.welcomeScreenDisplayed() + } + }) frameInitActivity.end() @@ -381,7 +381,9 @@ open class IdeStarter : ApplicationStarter { RecentProjectsManager.getInstance().reopenLastProjectsOnStart() } - EventQueue.invokeLater { PluginManager.reportPluginError() } + EventQueue.invokeLater { + PluginManager.reportPluginError() + } }) if (!app.isHeadlessEnvironment) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java index e42148eae468..7671ac9fa31c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java @@ -9,6 +9,7 @@ import com.intellij.ide.RecentProjectsManager; import com.intellij.ide.dnd.FileCopyPasteUtil; import com.intellij.ide.impl.ProjectUtil; import com.intellij.ide.plugins.InstalledPluginsManagerMain; +import com.intellij.idea.SplashManager; import com.intellij.jdkEx.JdkEx; import com.intellij.notification.NotificationType; import com.intellij.notification.impl.IdeNotificationArea; @@ -83,10 +84,12 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac private boolean myDisposed; public FlatWelcomeFrame() { - final JRootPane rootPane = getRootPane(); + SplashManager.hideBeforeShow(this); + + JRootPane rootPane = getRootPane(); myScreen = new FlatWelcomeScreen(); - final IdeGlassPaneImpl glassPane = new IdeGlassPaneImpl(rootPane) { + IdeGlassPaneImpl glassPane = new IdeGlassPaneImpl(rootPane) { @Override public void addNotify() { super.addNotify(); @@ -104,14 +107,15 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac setContentPane(holder.getContent()); defaultHeight+=holder.getHeaderHeight(); - } else { + } + else { setContentPane(myScreen.getWelcomePanel()); } setTitle(getWelcomeFrameTitle()); AppUIUtil.updateWindowIcon(this); - final int width = RecentProjectsManager.getInstance().getRecentProjectsActions(false).length == 0 ? 666 : MAX_DEFAULT_WIDTH; + int width = RecentProjectsManager.getInstance().getRecentProjectsActions(false).length == 0 ? 666 : MAX_DEFAULT_WIDTH; getRootPane().setPreferredSize(JBUI.size(width, defaultHeight)); setResizable(false); @@ -147,10 +151,7 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac Disposer.register(ApplicationManager.getApplication(), this); UIUtil.decorateWindowHeader(getRootPane()); - - if (this instanceof JFrame) { - UIUtil.setCustomTitleBar(this, getRootPane(), runnable -> Disposer.register(this, () -> runnable.run())); - } + UIUtil.setCustomTitleBar(this, getRootPane(), runnable -> Disposer.register(this, () -> runnable.run())); } @Override @@ -511,7 +512,7 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac icon = JBUI.scale(EmptyIcon.create(16)); } action = wrapGroups(action); - ActionLink link = new ActionLink(text, icon, action, createUsageTracker(action)); + ActionLink link = new ActionLink(text, icon, action, null); // Don't allow focus, as the containing panel is going to focusable. link.setFocusable(false); link.setPaintUnderline(false); @@ -821,11 +822,6 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac return Registry.is("welcome.screen.project.grouping.enabled"); } - private static Runnable createUsageTracker(final AnAction action) { - return () -> { - }; - } - private static JLabel createArrow(final ActionLink link) { JLabel arrow = new JLabel(AllIcons.General.ArrowDown); arrow.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java index 5744ed2dd912..3fa28b86b033 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java @@ -154,11 +154,15 @@ public final class WelcomeFrame extends JFrame implements IdeFrame, AccessibleCo @Nullable public static Runnable prepareToShow() { - if (ourInstance != null) return null; + if (ourInstance != null) { + return null; + } - final IdeFrame frame = createWelcomeFrame(); + IdeFrame frame = createWelcomeFrame(); return () -> { - if (ourInstance != null) return; + if (ourInstance != null) { + return; + } ((JFrame)frame).setVisible(true);