Skip to content

Commit 40b68f4

Browse files
feature: 优化文本框的border
1 parent 28821f6 commit 40b68f4

4 files changed

Lines changed: 71 additions & 5 deletions

File tree

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ platformType = IU
1010
platformVersion = 2020.3
1111

1212
# ko,ja,eb,zh
13-
# ,-Dide.browser.jcef.log.level=verbose,-Duser.language=en-US
14-
runIdeJvmArgs = -Dfile.encoding=utf-8
13+
# ,-Dide.browser.jcef.log.level=verbose,-Duser.language=en
14+
runIdeJvmArgs = -Dfile.encoding=utf-8,-Duser.language=ko

src/main/java/com/fulinlin/localization/PluginBundle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected ResourceBundle findBundle( @NotNull @NonNls String pathToBundle, @NotN
3737
var ideLocale = DynamicBundle.getLocale();
3838
if (!ideLocale.equals(Locale.ENGLISH)) {
3939
// load your bundle from baseName_<language>.properties, e.g. "baseName_zh.properties"
40-
var localizedPath = pathToBundle + "_" + ideLocale.getLanguage();
40+
//var localizedPath = pathToBundle + "_" + ideLocale.getLanguage();
4141
var localeBundle = ResourceBundle.getBundle(pathToBundle, ideLocale, loader, control);
4242
if (localeBundle != null && !base.equals(localeBundle)) {
4343
setParent(localeBundle, base);
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.fulinlin.ui.commit;
2+
3+
import com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder;
4+
import com.intellij.ide.ui.laf.darcula.ui.TextFieldWithPopupHandlerUI;
5+
import com.intellij.util.ui.JBInsets;
6+
import com.intellij.util.ui.MacUIUtil;
7+
8+
import javax.swing.*;
9+
import javax.swing.text.JTextComponent;
10+
import java.awt.*;
11+
import java.awt.geom.Path2D;
12+
import java.awt.geom.Rectangle2D;
13+
14+
import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.*;
15+
16+
public class CommitDarculaTextBorder extends DarculaTextBorder {
17+
18+
@Override
19+
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
20+
if (((JComponent) c).getClientProperty("JTextField.Search.noBorderRing") == Boolean.TRUE) return;
21+
22+
Rectangle r = new Rectangle(x, y, width, height);
23+
boolean focused = isFocused(c);
24+
25+
if (TextFieldWithPopupHandlerUI.isSearchField(c)) {
26+
paintSearchArea((Graphics2D) g, r, (JTextComponent) c, false);
27+
} else if (isTableCellEditor(c)) {
28+
paintCellEditorBorder((Graphics2D) g, c, r, focused);
29+
} else if (!(c.getParent() instanceof JComboBox)) {
30+
Graphics2D g2 = (Graphics2D) g.create();
31+
try {
32+
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
33+
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
34+
MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
35+
36+
JBInsets.removeFrom(r, paddings());
37+
g2.translate(r.x, r.y);
38+
39+
float lw = lw(g2);
40+
float bw = bw();
41+
42+
clipForBorder(c, g2, r.width, r.height);
43+
/*
44+
Object op = ((JComponent) c).getClientProperty("JComponent.outline");
45+
if (c.isEnabled() && op != null) {
46+
paintOutlineBorder(g2, r.width, r.height, 0, isSymmetric(), focused, Outline.valueOf(op.toString()));
47+
} else {
48+
Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
49+
border.append(new Rectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2), false);
50+
border.append(new Rectangle2D.Float(bw + lw, bw + lw, r.width - (bw + lw) * 2, r.height - (bw + lw) * 2), false);
51+
boolean editable = !(c instanceof JTextComponent) || ((JTextComponent) c).isEditable();
52+
g2.setColor(getOutlineColor(c.isEnabled() && editable, focused));
53+
g2.fill(border);
54+
}
55+
*/
56+
Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
57+
border.append(new Rectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2), false);
58+
border.append(new Rectangle2D.Float(bw + lw, bw + lw, r.width - (bw + lw) * 2, r.height - (bw + lw) * 2), false);
59+
g2.setColor(getOutlineColor(false, focused));
60+
g2.fill(border);
61+
} finally {
62+
g2.dispose();
63+
}
64+
}
65+
}
66+
}

src/main/java/com/fulinlin/ui/commit/CommitPanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ JPanel getMainPanel() {
6868
changeDescriptionLabel.setText(PluginBundle.get("commit.changes.field"));
6969
longDescriptionScrollPane.setBorder(BorderFactory.createEmptyBorder());
7070
breakingChangesScrollPane.setBorder(BorderFactory.createEmptyBorder());
71-
longDescription.setBorder(new DarculaTextBorder());
72-
breakingChanges.setBorder(new DarculaTextBorder());
71+
longDescription.setBorder(new CommitDarculaTextBorder());
72+
breakingChanges.setBorder(new CommitDarculaTextBorder());
7373
return mainPanel;
7474
}
7575

0 commit comments

Comments
 (0)