1 /* |
1 /* |
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
5276 return false; |
5276 return false; |
5277 } |
5277 } |
5278 // Don't start when just a modifier is pressed |
5278 // Don't start when just a modifier is pressed |
5279 int code = e.getKeyCode(); |
5279 int code = e.getKeyCode(); |
5280 if (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL || |
5280 if (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL || |
5281 code == KeyEvent.VK_ALT) { |
5281 code == KeyEvent.VK_ALT || code == KeyEvent.VK_META || |
|
5282 code == KeyEvent.VK_ALT_GRAPH) { |
5282 return false; |
5283 return false; |
5283 } |
5284 } |
5284 // Try to install the editor |
5285 // Try to install the editor |
5285 int leadRow = getSelectionModel().getLeadSelectionIndex(); |
5286 int leadRow = getSelectionModel().getLeadSelectionIndex(); |
5286 int leadColumn = getColumnModel().getSelectionModel(). |
5287 int leadColumn = getColumnModel().getSelectionModel(). |
5300 retValue = ((JComponent)editorComponent).processKeyBinding |
5301 retValue = ((JComponent)editorComponent).processKeyBinding |
5301 (ks, e, WHEN_FOCUSED, pressed); |
5302 (ks, e, WHEN_FOCUSED, pressed); |
5302 // If we have started an editor as a result of the user |
5303 // If we have started an editor as a result of the user |
5303 // pressing a key and the surrendersFocusOnKeystroke property |
5304 // pressing a key and the surrendersFocusOnKeystroke property |
5304 // is true, give the focus to the new editor. |
5305 // is true, give the focus to the new editor. |
5305 if (getSurrendersFocusOnKeystroke()) { |
5306 Object prop = getClientProperty("JTable.forceAutoStartsEdit"); |
|
5307 if (getSurrendersFocusOnKeystroke() |
|
5308 || Boolean.TRUE.equals(prop)) { |
5306 editorComponent.requestFocus(); |
5309 editorComponent.requestFocus(); |
5307 } |
5310 } |
5308 } |
5311 } |
5309 } |
5312 } |
5310 return retValue; |
5313 return retValue; |
6666 * |
6669 * |
6667 * @since 1.5 |
6670 * @since 1.5 |
6668 */ |
6671 */ |
6669 protected AccessibleJTable() { |
6672 protected AccessibleJTable() { |
6670 super(); |
6673 super(); |
|
6674 JTable.this.putClientProperty("JTable.forceAutoStartsEdit", true); |
6671 JTable.this.addPropertyChangeListener(this); |
6675 JTable.this.addPropertyChangeListener(this); |
6672 JTable.this.getSelectionModel().addListSelectionListener(this); |
6676 JTable.this.getSelectionModel().addListSelectionListener(this); |
6673 TableColumnModel tcm = JTable.this.getColumnModel(); |
6677 TableColumnModel tcm = JTable.this.getColumnModel(); |
6674 tcm.addColumnModelListener(this); |
6678 tcm.addColumnModelListener(this); |
6675 tcm.getSelectionModel().addListSelectionListener(this); |
6679 tcm.getSelectionModel().addListSelectionListener(this); |
7102 public Accessible getAccessibleAt(Point p) { |
7106 public Accessible getAccessibleAt(Point p) { |
7103 int column = columnAtPoint(p); |
7107 int column = columnAtPoint(p); |
7104 int row = rowAtPoint(p); |
7108 int row = rowAtPoint(p); |
7105 |
7109 |
7106 if ((column != -1) && (row != -1)) { |
7110 if ((column != -1) && (row != -1)) { |
7107 TableColumn aColumn = getColumnModel().getColumn(column); |
7111 if (row == getEditingRow() && column == getEditingColumn()) { |
7108 TableCellRenderer renderer = aColumn.getCellRenderer(); |
7112 Component editor = getEditorComponent(); |
7109 if (renderer == null) { |
7113 if (editor instanceof Accessible) { |
7110 Class<?> columnClass = getColumnClass(column); |
7114 return (Accessible) editor; |
7111 renderer = getDefaultRenderer(columnClass); |
7115 } |
7112 } |
7116 } |
7113 Component component = renderer.getTableCellRendererComponent( |
|
7114 JTable.this, null, false, false, |
|
7115 row, column); |
|
7116 return new AccessibleJTableCell(JTable.this, row, column, |
7117 return new AccessibleJTableCell(JTable.this, row, column, |
7117 getAccessibleIndexAt(row, column)); |
7118 getAccessibleIndexAt(row, column)); |
7118 } |
7119 } |
7119 return null; |
7120 return null; |
7120 } |
7121 } |
7143 // children increase across, and then down, for tables |
7144 // children increase across, and then down, for tables |
7144 // (arbitrary decision) |
7145 // (arbitrary decision) |
7145 int column = getAccessibleColumnAtIndex(i); |
7146 int column = getAccessibleColumnAtIndex(i); |
7146 int row = getAccessibleRowAtIndex(i); |
7147 int row = getAccessibleRowAtIndex(i); |
7147 |
7148 |
7148 TableColumn aColumn = getColumnModel().getColumn(column); |
7149 if (row == getEditingRow() && column == getEditingColumn()) { |
7149 TableCellRenderer renderer = aColumn.getCellRenderer(); |
7150 Component editor = getEditorComponent(); |
7150 if (renderer == null) { |
7151 if (editor instanceof Accessible) { |
7151 Class<?> columnClass = getColumnClass(column); |
7152 return (Accessible) editor; |
7152 renderer = getDefaultRenderer(columnClass); |
7153 } |
7153 } |
7154 } |
7154 Component component = renderer.getTableCellRendererComponent( |
|
7155 JTable.this, null, false, false, |
|
7156 row, column); |
|
7157 return new AccessibleJTableCell(JTable.this, row, column, |
7155 return new AccessibleJTableCell(JTable.this, row, column, |
7158 getAccessibleIndexAt(row, column)); |
7156 getAccessibleIndexAt(row, column)); |
7159 } |
7157 } |
7160 } |
7158 } |
7161 |
7159 |