From 296b2dabffbb55b02ecf9c0cfd3340f5745ed907 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 20 Dec 2016 14:44:44 +0300 Subject: [PATCH] added internal action to show 'About' popup in debug mode In this mode it'll show rectangles around hyperlink areas so we can check that coordinates of the logo are specified in *ApplicationInfo.xml file properly. --- .../com/intellij/ide/actions/AboutAction.java | 2 +- .../com/intellij/ide/actions/AboutPopup.java | 14 +++++++-- .../ui/ShowAboutPopupInDebugModeAction.java | 31 +++++++++++++++++++ .../src/idea/PlatformActions.xml | 2 ++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/internal/ui/ShowAboutPopupInDebugModeAction.java diff --git a/platform/platform-impl/src/com/intellij/ide/actions/AboutAction.java b/platform/platform-impl/src/com/intellij/ide/actions/AboutAction.java index a05a03b9d1ab..a679b1fe285b 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/AboutAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/AboutAction.java @@ -39,6 +39,6 @@ public class AboutAction extends AnAction implements DumbAware { } public static void perform(@Nullable Project project) { - AboutPopup.show(WindowManager.getInstance().suggestParentWindow(project)); + AboutPopup.show(WindowManager.getInstance().suggestParentWindow(project), false); } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java b/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java index bc5ced7c7998..d09fb23cbd2a 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java @@ -67,13 +67,13 @@ public class AboutPopup { private static final String COPY_URL = "copy://"; private static JBPopup ourPopup; - public static void show(@Nullable Window window) { + public static void show(@Nullable Window window, boolean showDebugInfo) { ApplicationInfoEx appInfo = (ApplicationInfoEx)ApplicationInfo.getInstance(); final PopupPanel panel = new PopupPanel(new BorderLayout()); Icon image = IconLoader.getIcon(appInfo.getAboutImageUrl()); if (appInfo.showLicenseeInfo()) { - final InfoSurface infoSurface = new InfoSurface(image); + final InfoSurface infoSurface = new InfoSurface(image, showDebugInfo); infoSurface.setPreferredSize(new Dimension(image.getIconWidth(), image.getIconHeight())); panel.setInfoSurface(infoSurface); } @@ -125,6 +125,7 @@ public class AboutPopup { private final Color myColor; private final Color myLinkColor; private final Icon myImage; + private final boolean myShowDebugInfo; private Font myFont; private Font myBoldFont; private final List myLines = new ArrayList<>(); @@ -135,13 +136,14 @@ public class AboutPopup { private float myShowCopyAlpha; private Alarm myAlarm = new Alarm(); - public InfoSurface(Icon image) { + public InfoSurface(Icon image, final boolean showDebugInfo) { ApplicationInfoImpl appInfo = (ApplicationInfoImpl)ApplicationInfoEx.getInstanceEx(); myImage = image; //noinspection UseJBColor myColor = Color.white; myLinkColor = appInfo.getAboutLinkColor() != null ? appInfo.getAboutLinkColor() : UI.getColor("link.foreground"); + myShowDebugInfo = showDebugInfo; setOpaque(false); setBackground(myColor); @@ -330,6 +332,12 @@ public class AboutPopup { final int copyrightX = Registry.is("ide.new.about") ? JBUI.scale(140) : JBUI.scale(30); final int copyrightY = Registry.is("ide.new.about") ? JBUI.scale(390) : JBUI.scale(284); g2.drawString(getCopyrightText(), copyrightX, copyrightY); + if (myShowDebugInfo) { + g2.setColor(((ApplicationInfoEx)appInfo).getAboutForeground()); + for (Link link : myLinks) { + g2.drawRect(link.myRectangle.x, link.myRectangle.y, link.myRectangle.width, link.myRectangle.height); + } + } } @NotNull diff --git a/platform/platform-impl/src/com/intellij/internal/ui/ShowAboutPopupInDebugModeAction.java b/platform/platform-impl/src/com/intellij/internal/ui/ShowAboutPopupInDebugModeAction.java new file mode 100644 index 000000000000..109cc2409c54 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/ui/ShowAboutPopupInDebugModeAction.java @@ -0,0 +1,31 @@ +/* + * 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. + */ +package com.intellij.internal.ui; + +import com.intellij.ide.actions.AboutPopup; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.project.DumbAwareAction; +import com.intellij.openapi.wm.WindowManager; + +/** + * @author nik + */ +public class ShowAboutPopupInDebugModeAction extends DumbAwareAction { + @Override + public void actionPerformed(AnActionEvent e) { + AboutPopup.show(WindowManager.getInstance().suggestParentWindow(getEventProject(e)), true); + } +} diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 353e5e39d9f4..95fdcbe2d8f0 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -736,6 +736,8 @@ +