Skip to content

Commit 66c486d

Browse files
authored
Merge pull request #5742 from t-rufang/rufan/color_contrast
Fix color contrast issue
2 parents 3f52433 + 6152c2e commit 66c486d

File tree

6 files changed

+70
-19
lines changed

6 files changed

+70
-19
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/azure/hdinsight/common/DarkThemeManager.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
package com.microsoft.azure.hdinsight.common;
77

8+
import com.intellij.execution.ui.ConsoleViewContentType;
9+
import com.intellij.openapi.editor.colors.EditorColorsManager;
10+
import com.intellij.openapi.editor.colors.EditorColorsScheme;
811
import com.intellij.util.ui.UIUtil;
912

1013
import java.awt.*;
@@ -47,13 +50,18 @@ public String getWarningColor() {
4750
return Gold;
4851
}
4952

50-
public Color getErrorMessageColor() {
51-
// TODO: fix the Color with JBColor
52-
if (UIUtil.isUnderDarcula()) {
53-
return new Color(255, 80, 80);
54-
}
53+
public Color getErrorTextBackgroundColor() {
54+
final EditorColorsScheme editorColorsScheme =
55+
EditorColorsManager.getInstance().getGlobalScheme();
56+
final Color consoleBackgroundColor =
57+
editorColorsScheme.getColor(ConsoleViewContentType.CONSOLE_BACKGROUND_KEY);
58+
return consoleBackgroundColor != null
59+
? consoleBackgroundColor
60+
: editorColorsScheme.getDefaultBackground();
61+
}
5562

56-
return Color.red;
63+
public Color getErrorMessageColor() {
64+
return UIUtil.getErrorForeground();
5765
}
5866

5967
public Color getWarningMessageColor() {

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/azure/hdinsight/serverexplore/ui/AddNewClusterForm.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
</grid>
322322
</children>
323323
</grid>
324-
<component id="fab29" class="javax.swing.JTextArea" binding="validationErrorMessageField">
324+
<component id="fab29" class="com.microsoft.intellij.ui.ErrorTextArea" binding="validationErrorMessageField">
325325
<constraints>
326326
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
327327
<preferred-size width="150" height="-1"/>

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/azure/hdinsight/serverexplore/ui/AddNewClusterForm.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.microsoft.intellij.hdinsight.messages.HDInsightBundle;
3737
import com.microsoft.intellij.rxjava.IdeaSchedulers;
3838
import com.microsoft.intellij.ui.HintTextField;
39+
import com.microsoft.intellij.ui.ErrorTextArea;
3940
import com.microsoft.tooling.msservices.serviceexplorer.RefreshableNode;
4041
import org.apache.commons.lang3.StringUtils;
4142
import org.joda.time.DateTime;
@@ -69,7 +70,7 @@ public class AddNewClusterForm extends DialogWrapper implements SettableControl<
6970
protected JTextField clusterNameOrUrlField;
7071
private JPanel livyServiceCard;
7172
protected JTextField livyEndpointField;
72-
protected JTextArea validationErrorMessageField;
73+
protected ErrorTextArea validationErrorMessageField;
7374
private JPanel authComboBoxPanel;
7475
protected JComboBox<AuthType> authComboBox;
7576
protected JPanel authCardsPanel;

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/kotlin/com/microsoft/azure/hdinsight/spark/ui/SparkSubmissionContentPanel.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import com.microsoft.intellij.forms.dsl.panel
6363
import com.microsoft.intellij.lang.containsInvisibleChars
6464
import com.microsoft.intellij.lang.tagInvisibleChars
6565
import com.microsoft.intellij.rxjava.DisposableObservers
66+
import com.microsoft.intellij.ui.ErrorLabel
6667
import com.microsoft.intellij.ui.util.findFirst
6768
import org.apache.commons.lang3.StringUtils
6869
import java.awt.Dimension
@@ -102,18 +103,14 @@ open class SparkSubmissionContentPanel(private val myProject: Project, val type:
102103

103104
// All view components
104105
private val errorMessageLabels = arrayOf(
105-
JLabel(getErrorMessageClusterNameNull(isSignedIn))
106-
.apply { foreground = currentErrorColor },
107-
JLabel("Artifact should not be null!")
108-
.apply { foreground = currentErrorColor },
109-
JLabel("Could not find the local jar package for Artifact")
110-
.apply { foreground = currentErrorColor },
111-
JLabel("Main class name should not be null")
106+
ErrorLabel(getErrorMessageClusterNameNull(isSignedIn)),
107+
ErrorLabel("Artifact should not be null!"),
108+
ErrorLabel("Could not find the local jar package for Artifact"),
109+
ErrorLabel("Main class name should not be null")
112110
.apply {
113-
foreground = currentErrorColor
114111
isVisible = true
115112
},
116-
JLabel().apply { foreground = currentErrorColor }
113+
ErrorLabel()
117114
// Don't add more we won't like to add more message labels
118115
)
119116

@@ -141,9 +138,8 @@ open class SparkSubmissionContentPanel(private val myProject: Project, val type:
141138
}}
142139

143140
private val hdiReaderErrorLabel: JLabel =
144-
JLabel("No Ambari permission to submit job to the selected cluster...").apply {
141+
ErrorLabel("No Ambari permission to submit job to the selected cluster...").apply {
145142
toolTipText = "No Ambari permission to submit job to the selected cluster. Please ask the cluster owner or user access administrator to upgrade your role to HDInsight Cluster Operator in the Azure Portal, or link to the selected cluster."
146-
foreground = currentErrorColor
147143
isVisible = false
148144
}
149145

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*/
5+
6+
package com.microsoft.intellij.ui
7+
8+
import com.microsoft.azure.hdinsight.common.DarkThemeManager
9+
import org.apache.commons.lang3.StringUtils
10+
import javax.swing.JLabel
11+
12+
class ErrorLabel(text: String = ""): JLabel(text) {
13+
override fun setText(text: String?) {
14+
foreground = DarkThemeManager.getInstance().errorMessageColor
15+
background = if (StringUtils.isEmpty(text)) {
16+
null
17+
} else {
18+
DarkThemeManager.getInstance().errorTextBackgroundColor
19+
}
20+
21+
super.setText(text)
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*/
5+
6+
package com.microsoft.intellij.ui
7+
8+
import com.microsoft.azure.hdinsight.common.DarkThemeManager
9+
import org.apache.commons.lang3.StringUtils
10+
import javax.swing.JTextArea
11+
12+
class ErrorTextArea : JTextArea() {
13+
override fun setText(text: String?) {
14+
foreground = DarkThemeManager.getInstance().errorMessageColor
15+
background = if (StringUtils.isEmpty(text)) {
16+
null
17+
} else {
18+
DarkThemeManager.getInstance().errorTextBackgroundColor
19+
}
20+
21+
super.setText(text)
22+
}
23+
}

0 commit comments

Comments
 (0)