mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-29204 "Rerun tests" notification's location and font
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.execution.runners;
|
||||
|
||||
import com.intellij.execution.impl.ConsoleViewImpl;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ExecutionConsole;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
@@ -26,21 +28,22 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.ui.GotItMessage;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.PositionTracker;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.update.UiNotifyConnector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
public class RerunTestsNotification {
|
||||
|
||||
private static final String KEY = "rerun.tests.notification.shown";
|
||||
|
||||
public static void showRerunNotification(@Nullable RunContentDescriptor contentToReuse,
|
||||
@NotNull final ExecutionConsole executionConsole) {
|
||||
@NotNull ExecutionConsole executionConsole) {
|
||||
if (contentToReuse == null) {
|
||||
return;
|
||||
}
|
||||
@@ -51,8 +54,8 @@ public class RerunTestsNotification {
|
||||
}
|
||||
}
|
||||
|
||||
private static void doShow(@NotNull final ExecutionConsole executionConsole) {
|
||||
final Alarm alarm = new Alarm();
|
||||
private static void doShow(@NotNull ExecutionConsole executionConsole) {
|
||||
Alarm alarm = new Alarm();
|
||||
alarm.addRequest(() -> {
|
||||
String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(
|
||||
ActionManager.getInstance().getAction(RerunTestsAction.ID)
|
||||
@@ -61,19 +64,27 @@ public class RerunTestsNotification {
|
||||
return;
|
||||
}
|
||||
|
||||
GotItMessage message = GotItMessage.createMessage("Rerun tests with " + shortcutText, "");
|
||||
message.setDisposable(executionConsole);
|
||||
message.setCallback(() -> PropertiesComponent.getInstance().setValue(KEY, true));
|
||||
message.setShowCallout(false);
|
||||
Dimension consoleSize = executionConsole.getComponent().getSize();
|
||||
|
||||
message.show(
|
||||
new RelativePoint(
|
||||
executionConsole.getComponent(),
|
||||
new Point(consoleSize.width - 185, consoleSize.height - 60)
|
||||
),
|
||||
Balloon.Position.below
|
||||
);
|
||||
ConsoleView consoleView = UIUtil.findComponentOfType(executionConsole.getComponent(), ConsoleViewImpl.class);
|
||||
if (consoleView != null) {
|
||||
GotItMessage message = GotItMessage.createMessage("Rerun tests with " + shortcutText, "");
|
||||
message.setDisposable(executionConsole);
|
||||
message.setCallback(() -> PropertiesComponent.getInstance().setValue(KEY, true));
|
||||
message.setShowCallout(false);
|
||||
JComponent consoleComponent = consoleView.getComponent();
|
||||
message.show(
|
||||
new PositionTracker<Balloon>(consoleComponent) {
|
||||
@Override
|
||||
public RelativePoint recalculateLocation(@NotNull Balloon balloon) {
|
||||
RelativePoint point = RelativePoint.getSouthEastOf(consoleComponent);
|
||||
Dimension balloonSize = balloon.getPreferredSize();
|
||||
int scrollBarSize = JBUI.scale(10);
|
||||
point.getPoint().translate(-balloonSize.width / 2 - scrollBarSize, -balloonSize.height / 2 - scrollBarSize);
|
||||
return point;
|
||||
}
|
||||
},
|
||||
Balloon.Position.below
|
||||
);
|
||||
}
|
||||
|
||||
Disposer.dispose(alarm);
|
||||
}, 1000);
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.PositionTracker;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -76,7 +77,11 @@ public class GotItMessage {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void show(RelativePoint point, Balloon.Position position) {
|
||||
public void show(@NotNull RelativePoint point, @NotNull Balloon.Position position) {
|
||||
show(new PositionTracker.Static<>(point), position);
|
||||
}
|
||||
|
||||
public void show(@NotNull PositionTracker<Balloon> tracker, @NotNull Balloon.Position position) {
|
||||
if (myDisposable != null && Disposer.isDisposed(myDisposable)) {
|
||||
return;
|
||||
}
|
||||
@@ -115,6 +120,6 @@ public class GotItMessage {
|
||||
}
|
||||
});
|
||||
|
||||
balloon.show(point, position);
|
||||
balloon.show(tracker, position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<size top="4" left="10" bottom="4" right="8"/>
|
||||
</border>
|
||||
<children>
|
||||
<component id="366a9" class="javax.swing.JLabel">
|
||||
<component id="366a9" class="javax.swing.JLabel" binding="myButtonLabel">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<font size="12" style="1"/>
|
||||
|
||||
@@ -17,7 +17,9 @@ package com.intellij.ui;
|
||||
|
||||
import com.intellij.ide.IdeTooltipManager;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -30,10 +32,20 @@ public class GotItPanel {
|
||||
private static final JBColor BODY_COLOR_2 = new JBColor(new Color(71, 135, 237), new Color(38, 53, 73));
|
||||
private static final JBColor BORDER_COLOR = new JBColor(new Color(71, 91, 167), new Color(78, 120, 161));
|
||||
|
||||
JPanel myButton;
|
||||
JPanel myRoot;
|
||||
JLabel myTitle;
|
||||
JEditorPane myMessage;
|
||||
JPanel myButton;
|
||||
JLabel myButtonLabel;
|
||||
|
||||
public GotItPanel() {
|
||||
scaleFont(myTitle);
|
||||
scaleFont(myButtonLabel);
|
||||
}
|
||||
|
||||
private static void scaleFont(@NotNull JComponent component) {
|
||||
component.setFont(component.getFont().deriveFont(1.0f * JBUI.scaleFontSize(component.getFont().getSize())));
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
myButton = new JPanel(new BorderLayout()) {
|
||||
@@ -46,10 +58,10 @@ public class GotItPanel {
|
||||
super.paintComponent(g);
|
||||
GraphicsUtil.setupAAPainting(g);
|
||||
((Graphics2D)g).setPaint(new GradientPaint(0, 0, BODY_COLOR_1, 0, getHeight(), BODY_COLOR_2));
|
||||
g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
|
||||
g.fillRoundRect(0, 0, getWidth() - JBUI.scale(1), getHeight() - JBUI.scale(1), JBUI.scale(5), JBUI.scale(5));
|
||||
((Graphics2D)g).setStroke(new BasicStroke(UIUtil.isUnderDarcula() ? 2f : 1f));
|
||||
g.setColor(BORDER_COLOR);
|
||||
g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
|
||||
g.drawRoundRect(0, 0, getWidth() - JBUI.scale(1), getHeight() - JBUI.scale(1), JBUI.scale(5), JBUI.scale(5));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user