-
Notifications
You must be signed in to change notification settings - Fork 5.2k
/
InstallButton.java
68 lines (55 loc) · 2.18 KB
/
InstallButton.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2000-2018 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.ide.plugins.newui;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.plugins.PluginManagerConfigurable;
import com.intellij.ui.JBColor;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
/**
* @author Alexander Lobas
*/
public class InstallButton extends ColorButton {
private static final Color GreenColor = new JBColor(0x5D9B47, 0x2B7B50);
private static final Color FillForegroundColor = JBColor.namedColor("Plugins.Button.installFillForeground", WhiteForeground);
private static final Color FillBackgroundColor = JBColor.namedColor("Plugins.Button.installFillBackground", GreenColor);
private static final Color ForegroundColor = JBColor.namedColor("Plugins.Button.installForeground", GreenColor);
private static final Color BackgroundColor =
JBColor.namedColor("Plugins.Button.installBackground", PluginManagerConfigurable.MAIN_BG_COLOR);
@SuppressWarnings("UseJBColor")
private static final Color FocusedBackground = JBColor.namedColor("Plugins.Button.installFocusedBackground", new Color(0xE1F6DA));
private static final Color BorderColor = JBColor.namedColor("Plugins.Button.installBorderColor", GreenColor);
public InstallButton(boolean fill) {
if (fill) {
setTextColor(FillForegroundColor);
setBgColor(FillBackgroundColor);
}
else {
setTextColor(ForegroundColor);
setFocusedTextColor(ForegroundColor);
setBgColor(BackgroundColor);
}
setFocusedBgColor(FocusedBackground);
setBorderColor(BorderColor);
setFocusedBorderColor(BorderColor);
setTextAndSize();
}
protected void setTextAndSize() {
setText(IdeBundle.message("action.AnActionButton.text.install"));
setWidth72(this);
}
@Override
public void setEnabled(boolean b) {
super.setEnabled(b);
}
public void setEnabled(boolean enabled, @Nullable @Nls String statusText) {
super.setEnabled(enabled);
if (enabled) {
setTextAndSize();
}
else {
setText(statusText);
setWidth(this, 80);
}
}
}