fix ide start if no opened projects (regression because prepareToShow returns runnable)

GitOrigin-RevId: 198672cca104188a9f094b94bca54bd31f6f4275
This commit is contained in:
Vladimir Krivosheev
2019-07-29 18:37:56 +03:00
committed by intellij-monorepo-bot
parent 8aefc7dc87
commit 4e2e19aa45
4 changed files with 31 additions and 43 deletions
@@ -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<Object> 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<Object>() {
@Override
@@ -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) {
@@ -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));
@@ -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);