mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Fixed the structure editor sometimes losing focus when editing data
types
This commit is contained in:
parent
179f093aca
commit
c7b4c69720
3 changed files with 25 additions and 13 deletions
|
@ -186,6 +186,7 @@ public abstract class CompositeEditorPanel extends JPanel
|
||||||
if (editingRow < 0) {
|
if (editingRow < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int modelColumn = table.convertColumnIndexToModel(table.getEditingColumn());
|
int modelColumn = table.convertColumnIndexToModel(table.getEditingColumn());
|
||||||
if (!launchBitFieldEditor(modelColumn, editingRow)) {
|
if (!launchBitFieldEditor(modelColumn, editingRow)) {
|
||||||
model.beginEditingField(editingRow, modelColumn);
|
model.beginEditingField(editingRow, modelColumn);
|
||||||
|
@ -1332,7 +1333,7 @@ public abstract class CompositeEditorPanel extends JPanel
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void focusEditor() {
|
public void focusEditor() {
|
||||||
boolean didFocus = textField.requestFocusInWindow();
|
textField.requestFocusInWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.awt.event.ActionListener;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
import docking.action.*;
|
import docking.action.*;
|
||||||
|
import docking.widgets.table.GTable;
|
||||||
import ghidra.framework.plugintool.Plugin;
|
import ghidra.framework.plugintool.Plugin;
|
||||||
import ghidra.framework.plugintool.PluginTool;
|
import ghidra.framework.plugintool.PluginTool;
|
||||||
import ghidra.util.HelpLocation;
|
import ghidra.util.HelpLocation;
|
||||||
|
@ -79,7 +80,13 @@ abstract public class CompositeEditorTableAction extends DockingAction implement
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
return; // must have been disposed
|
return; // must have been disposed
|
||||||
}
|
}
|
||||||
|
|
||||||
JTable table = ((CompositeEditorPanel) provider.getComponent()).getTable();
|
JTable table = ((CompositeEditorPanel) provider.getComponent()).getTable();
|
||||||
|
if (table instanceof GTable gTable) {
|
||||||
|
gTable.requestTableFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (table.isEditing()) {
|
if (table.isEditing()) {
|
||||||
table.getEditorComponent().requestFocus();
|
table.getEditorComponent().requestFocus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -940,22 +940,26 @@ public class GTable extends JTable {
|
||||||
public boolean editCellAt(int row, int column, EventObject e) {
|
public boolean editCellAt(int row, int column, EventObject e) {
|
||||||
boolean editAtCell = super.editCellAt(row, column, e);
|
boolean editAtCell = super.editCellAt(row, column, e);
|
||||||
if (editAtCell) {
|
if (editAtCell) {
|
||||||
TableCellEditor currentEditor = getCellEditor();
|
requestTableFocus();
|
||||||
Component editorComponent = getEditorComponent();
|
|
||||||
if (currentEditor instanceof FocusableEditor focusable) {
|
|
||||||
focusable.focusEditor();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
editorComponent.requestFocusInWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editorComponent instanceof JTextComponent textComponent) {
|
|
||||||
textComponent.selectAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return editAtCell;
|
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() {
|
public void scrollToSelectedRow() {
|
||||||
int[] selectedRows = getSelectedRows();
|
int[] selectedRows = getSelectedRows();
|
||||||
if (selectedRows == null || selectedRows.length == 0) {
|
if (selectedRows == null || selectedRows.length == 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue