Fixed the structure editor sometimes losing focus when editing data

types
This commit is contained in:
dragonmacher 2023-03-15 15:58:57 -04:00
parent 179f093aca
commit c7b4c69720
3 changed files with 25 additions and 13 deletions

View File

@ -186,6 +186,7 @@ public abstract class CompositeEditorPanel extends JPanel
if (editingRow < 0) {
return;
}
int modelColumn = table.convertColumnIndexToModel(table.getEditingColumn());
if (!launchBitFieldEditor(modelColumn, editingRow)) {
model.beginEditingField(editingRow, modelColumn);
@ -1332,7 +1333,7 @@ public abstract class CompositeEditorPanel extends JPanel
@Override
public void focusEditor() {
boolean didFocus = textField.requestFocusInWindow();
textField.requestFocusInWindow();
}
@Override

View File

@ -20,6 +20,7 @@ import java.awt.event.ActionListener;
import javax.swing.*;
import docking.action.*;
import docking.widgets.table.GTable;
import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HelpLocation;
@ -79,7 +80,13 @@ abstract public class CompositeEditorTableAction extends DockingAction implement
if (provider == null) {
return; // must have been disposed
}
JTable table = ((CompositeEditorPanel) provider.getComponent()).getTable();
if (table instanceof GTable gTable) {
gTable.requestTableFocus();
return;
}
if (table.isEditing()) {
table.getEditorComponent().requestFocus();
}

View File

@ -940,22 +940,26 @@ public class GTable extends JTable {
public boolean editCellAt(int row, int column, EventObject e) {
boolean editAtCell = super.editCellAt(row, column, e);
if (editAtCell) {
TableCellEditor currentEditor = getCellEditor();
Component editorComponent = getEditorComponent();
if (currentEditor instanceof FocusableEditor focusable) {
focusable.focusEditor();
}
else {
editorComponent.requestFocusInWindow();
}
if (editorComponent instanceof JTextComponent textComponent) {
textComponent.selectAll();
}
requestTableFocus();
}
return editAtCell;
}
public void requestTableFocus() {
TableCellEditor currentEditor = getCellEditor();
Component editorComponent = getEditorComponent();
if (currentEditor instanceof FocusableEditor focusable) {
focusable.focusEditor();
}
else {
editorComponent.requestFocusInWindow();
}
if (editorComponent instanceof JTextComponent textComponent) {
textComponent.selectAll();
}
}
public void scrollToSelectedRow() {
int[] selectedRows = getSelectedRows();
if (selectedRows == null || selectedRows.length == 0) {