mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-194353: honor focused state in cell editors. On behalf of Jens.
This commit is contained in:
@@ -174,7 +174,7 @@ public class DarculaUIUtil {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void paintCellEditorBorder(Graphics2D g2, Component c, Rectangle r) {
|
||||
public static void paintCellEditorBorder(Graphics2D g2, Component c, Rectangle r, boolean hasFocus) {
|
||||
g2 = (Graphics2D)g2.create();
|
||||
try {
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@@ -188,9 +188,11 @@ public class DarculaUIUtil {
|
||||
border.append(new Rectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2), false);
|
||||
|
||||
Object op = ((JComponent)c).getClientProperty("JComponent.outline");
|
||||
Outline outline = op == null ? Outline.focus : Outline.valueOf(op.toString());
|
||||
outline.setGraphicsColor(g2, true);
|
||||
g2.fill(border);
|
||||
if (op != null || hasFocus) {
|
||||
Outline outline = op == null ? Outline.focus : Outline.valueOf(op.toString());
|
||||
outline.setGraphicsColor(g2, true);
|
||||
g2.fill(border);
|
||||
}
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
@@ -211,9 +213,10 @@ public class DarculaUIUtil {
|
||||
|
||||
EditorTextField editorTextField = UIUtil.getParentOfType(EditorTextField.class, c);
|
||||
if (editorTextField == null) return;
|
||||
boolean hasFocus = editorTextField.getFocusTarget().hasFocus();
|
||||
|
||||
if (isTableCellEditor(c)) {
|
||||
paintCellEditorBorder((Graphics2D)g, c, new Rectangle(x, y, width, height));
|
||||
paintCellEditorBorder((Graphics2D)g, c, new Rectangle(x, y, width, height), hasFocus);
|
||||
} else {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
@@ -242,7 +245,6 @@ public class DarculaUIUtil {
|
||||
|
||||
g2.translate(x, y);
|
||||
|
||||
boolean hasFocus = editorTextField.getFocusTarget().hasFocus();
|
||||
Object op = editorTextField.getClientProperty("JComponent.outline");
|
||||
if (op != null) {
|
||||
paintOutlineBorder(g2, width, height, 0, true, hasFocus, Outline.valueOf(op.toString()));
|
||||
|
||||
+2
-2
@@ -335,11 +335,11 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB
|
||||
Rectangle r = new Rectangle(x, y, width, height);
|
||||
|
||||
try {
|
||||
checkFocus();
|
||||
if (!DarculaUIUtil.isTableCellEditor(c)) {
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
checkFocus();
|
||||
JBInsets.removeFrom(r, JBUI.insets(1));
|
||||
g2.translate(r.x, r.y);
|
||||
|
||||
@@ -362,7 +362,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB
|
||||
g2.fill(border);
|
||||
}
|
||||
} else {
|
||||
paintCellEditorBorder(g2, c, r);
|
||||
paintCellEditorBorder(g2, c, r, hasFocus);
|
||||
}
|
||||
} finally {
|
||||
g2.dispose();
|
||||
|
||||
+2
-3
@@ -68,11 +68,12 @@ public class DarculaEditorTextFieldBorder extends DarculaTextBorder implements V
|
||||
|
||||
EditorTextField editorTextField = UIUtil.getParentOfType(EditorTextField.class, c);
|
||||
if (editorTextField == null) return;
|
||||
boolean hasFocus = editorTextField.getFocusTarget().hasFocus();
|
||||
|
||||
Rectangle r = new Rectangle(x, y, width, height);
|
||||
|
||||
if (isTableCellEditor(c)) {
|
||||
paintCellEditorBorder((Graphics2D)g, c, r);
|
||||
paintCellEditorBorder((Graphics2D)g, c, r, hasFocus);
|
||||
} else {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
@@ -95,8 +96,6 @@ public class DarculaEditorTextFieldBorder extends DarculaTextBorder implements V
|
||||
g2.setColor(c.getBackground());
|
||||
g2.fill(outer);
|
||||
|
||||
boolean hasFocus = editorTextField.getFocusTarget().hasFocus();
|
||||
|
||||
Object op = editorTextField.getClientProperty("JComponent.outline");
|
||||
if (op != null) {
|
||||
paintOutlineBorder(g2, r.width, r.height, 0, true, hasFocus, Outline.valueOf(op.toString()));
|
||||
|
||||
+2
-2
@@ -38,11 +38,12 @@ public class DarculaTextBorder implements Border, UIResource, ErrorBorderCapable
|
||||
if (((JComponent)c).getClientProperty("JTextField.Search.noBorderRing") == Boolean.TRUE) return;
|
||||
|
||||
Rectangle r = new Rectangle(x, y, width, height);
|
||||
boolean focused = isFocused(c);
|
||||
|
||||
if (TextFieldWithPopupHandlerUI.isSearchField(c)) {
|
||||
paintSearchArea((Graphics2D)g, r, (JTextComponent)c, false);
|
||||
} else if (isTableCellEditor(c)) {
|
||||
paintCellEditorBorder((Graphics2D)g, c, r);
|
||||
paintCellEditorBorder((Graphics2D)g, c, r, focused);
|
||||
} else if (!(c.getParent() instanceof JComboBox)){
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
@@ -59,7 +60,6 @@ public class DarculaTextBorder implements Border, UIResource, ErrorBorderCapable
|
||||
clipForBorder(c, g2, r.width, r.height);
|
||||
|
||||
Object op = ((JComponent)c).getClientProperty("JComponent.outline");
|
||||
boolean focused = isFocused(c);
|
||||
if (op != null) {
|
||||
paintOutlineBorder(g2, r.width, r.height, 0, isSymmetric(), focused, Outline.valueOf(op.toString()));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user