mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-181171 Test progress should green/red according to the result of the tests
This commit is contained in:
+22
-21
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.openapi.progress.util.ColorProgressBar;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
@@ -36,16 +37,14 @@ public class DarculaProgressBarUI extends BasicProgressBarUI {
|
||||
private static final Color REMAINDER_COLOR = new JBColor(Gray.xC4, Gray.x69);
|
||||
private static final Color FINISHED_COLOR = new JBColor(Gray.x80, Gray.xA0);
|
||||
|
||||
private static final Color ERROR_COLOR = new JBColor(new Color(0xd80000), new Color(0xff4053));
|
||||
private static final Color SUCCESS_COLOR = new JBColor(new Color(0x34b171), new Color(0x008f50));
|
||||
|
||||
private static final Color START_COLOR = new JBColor(Gray.xC4, Gray.x69);
|
||||
private static final Color END_COLOR = new JBColor(Gray.x80, Gray.x83);
|
||||
|
||||
private static final Color ERROR_START_COLOR = new JBColor(new Color(0xFB8F89), new Color(0xf4a2a0));
|
||||
private static final Color ERROR_END_COLOR = ERROR_COLOR;
|
||||
private static final Color SUCCESS_START_COLOR = new JBColor(new Color(0x7EE8A5), new Color(0x5dc48f));
|
||||
private static final Color SUCCESS_END_COLOR = SUCCESS_COLOR;
|
||||
private static final Color RED = new JBColor(new Color(0xd80000), new Color(0xff4053));
|
||||
private static final Color RED_LIGHT = new JBColor(new Color(0xFB8F89), new Color(0xf4a2a0));
|
||||
|
||||
private static final Color GREEN = new JBColor(new Color(0x34b171), new Color(0x008f50));
|
||||
private static final Color GREEN_LIGHT = new JBColor(new Color(0x7EE8A5), new Color(0x5dc48f));
|
||||
|
||||
private static final int STEP = 6;
|
||||
|
||||
@@ -78,15 +77,16 @@ public class DarculaProgressBarUI extends BasicProgressBarUI {
|
||||
JBInsets.removeFrom(r, i);
|
||||
int orientation = progressBar.getOrientation();
|
||||
|
||||
// Detect gradient color
|
||||
// Use foreground color as a reference, don't use it directly. This is done for compatibility reason.
|
||||
// Colors are hardcoded in UI delegates by design. If more colors are needed contact designers.
|
||||
Color startColor, endColor;
|
||||
String type = (String)progressBar.getClientProperty("ProgressBar.color");
|
||||
if ("error".equals(type)) {
|
||||
startColor = ERROR_START_COLOR;
|
||||
endColor = ERROR_END_COLOR;
|
||||
} else if ("success".equals(type)) {
|
||||
startColor = SUCCESS_START_COLOR;
|
||||
endColor = SUCCESS_END_COLOR;
|
||||
Color foreground = progressBar.getForeground();
|
||||
if (foreground == ColorProgressBar.RED) {
|
||||
startColor = RED;
|
||||
endColor = RED_LIGHT;
|
||||
} else if (foreground == ColorProgressBar.GREEN) {
|
||||
startColor = GREEN;
|
||||
endColor = GREEN_LIGHT;
|
||||
} else {
|
||||
startColor = getStartColor();
|
||||
endColor = getEndColor();
|
||||
@@ -206,12 +206,13 @@ public class DarculaProgressBarUI extends BasicProgressBarUI {
|
||||
g2.setColor(getRemainderColor());
|
||||
g2.fill(fullShape);
|
||||
|
||||
|
||||
String type = (String)progressBar.getClientProperty("ProgressBar.color");
|
||||
if ("error".equals(type)) {
|
||||
g2.setColor(ERROR_COLOR);
|
||||
} else if ("success".equals(type)) {
|
||||
g2.setColor(SUCCESS_COLOR);
|
||||
// Use foreground color as a reference, don't use it directly. This is done for compatibility reason.
|
||||
// Colors are hardcoded in UI delegates by design. If more colors are needed contact designers.
|
||||
Color foreground = progressBar.getForeground();
|
||||
if (foreground == ColorProgressBar.RED) {
|
||||
g2.setColor(RED);
|
||||
} else if (foreground == ColorProgressBar.GREEN) {
|
||||
g2.setColor(GREEN);
|
||||
} else {
|
||||
g2.setColor(getFinishedColor());
|
||||
}
|
||||
|
||||
+12
-10
@@ -18,6 +18,7 @@ package com.intellij.openapi.wm.impl.status;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.progress.util.ColorProgressBar;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
@@ -25,6 +26,7 @@ import com.intellij.util.Alarm;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,17 +51,17 @@ public class ShowProgressTestDialogAction extends AnAction implements DumbAware
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
|
||||
panel.add(createPanel(false, null, false));
|
||||
panel.add(createPanel(false, "error", false));
|
||||
panel.add(createPanel(false, "success", false));
|
||||
panel.add(createPanel(false, ColorProgressBar.RED, false));
|
||||
panel.add(createPanel(false, ColorProgressBar.GREEN, false));
|
||||
panel.add(createPanel(false, null, true));
|
||||
panel.add(createPanel(false, "error", true));
|
||||
panel.add(createPanel(false, "success", true));
|
||||
panel.add(createPanel(false, ColorProgressBar.RED, true));
|
||||
panel.add(createPanel(false, ColorProgressBar.GREEN, true));
|
||||
panel.add(createPanel(true, null, false));
|
||||
panel.add(createPanel(true, null, true));
|
||||
panel.add(createPanel(true, "error", false));
|
||||
panel.add(createPanel(true, "success", false));
|
||||
panel.add(createPanel(true, "error", true));
|
||||
panel.add(createPanel(true, "success", true));
|
||||
panel.add(createPanel(true, ColorProgressBar.RED, false));
|
||||
panel.add(createPanel(true, ColorProgressBar.GREEN, false));
|
||||
panel.add(createPanel(true, ColorProgressBar.RED, true));
|
||||
panel.add(createPanel(true, ColorProgressBar.GREEN, true));
|
||||
|
||||
for(JProgressBar pb : pbList) {
|
||||
if (!pb.isIndeterminate()) {
|
||||
@@ -78,14 +80,14 @@ public class ShowProgressTestDialogAction extends AnAction implements DumbAware
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JComponent createPanel(boolean indeterminate, String colorType, boolean modeless) {
|
||||
private JComponent createPanel(boolean indeterminate, Color foreground, boolean modeless) {
|
||||
String text = (indeterminate ? "indeterminate" : "determinate");
|
||||
JLabel label = new JLabel(text);
|
||||
|
||||
JProgressBar progress = new JProgressBar(0, 100);
|
||||
progress.setIndeterminate(indeterminate);
|
||||
progress.setValue(0);
|
||||
progress.putClientProperty("ProgressBar.color", colorType);
|
||||
progress.setForeground(foreground);
|
||||
progress.putClientProperty("ProgressBar.modeless", Boolean.valueOf(modeless));
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
|
||||
Reference in New Issue
Block a user