mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-4891 - Fixed an exception in the Stack editor when editing and using
the down arrow
This commit is contained in:
parent
0258fc3209
commit
28ea0c99f0
4 changed files with 45 additions and 17 deletions
|
@ -486,8 +486,8 @@ public abstract class CompositeEditorPanel extends JPanel
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
row = index;
|
row = index;
|
||||||
table.setRowSelectionInterval(row, row);
|
table.setRowSelectionInterval(row, row);
|
||||||
if (model.isCellEditable(index, modelColumn)) {
|
if (model.isCellEditable(row, modelColumn)) {
|
||||||
return beginEditField(model.getRow(), model.getColumn());
|
return beginEditField(row, modelColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -500,6 +500,7 @@ public abstract class CompositeEditorPanel extends JPanel
|
||||||
protected boolean editBelowField() {
|
protected boolean editBelowField() {
|
||||||
int row = model.getRow();
|
int row = model.getRow();
|
||||||
int modelColumn = model.getColumn();
|
int modelColumn = model.getColumn();
|
||||||
|
|
||||||
// Get the current row (index) and column (fieldNum).
|
// Get the current row (index) and column (fieldNum).
|
||||||
int index = row;
|
int index = row;
|
||||||
index++;
|
index++;
|
||||||
|
@ -508,8 +509,8 @@ public abstract class CompositeEditorPanel extends JPanel
|
||||||
if (index < numComps) {
|
if (index < numComps) {
|
||||||
row = index;
|
row = index;
|
||||||
table.setRowSelectionInterval(row, row);
|
table.setRowSelectionInterval(row, row);
|
||||||
if (model.isCellEditable(index, modelColumn)) {
|
if (model.isCellEditable(row, modelColumn)) {
|
||||||
return beginEditField(model.getRow(), model.getColumn());
|
return beginEditField(row, modelColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -602,7 +603,7 @@ public abstract class CompositeEditorPanel extends JPanel
|
||||||
model.setColumn(modelIndex);
|
model.setColumn(modelIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
model.setColumn(-1);
|
model.setColumn(e.getFirstIndex());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -406,22 +406,16 @@ public class StackEditorModel extends CompositeEditorModel {
|
||||||
if (columnIndex == LENGTH) {
|
if (columnIndex == LENGTH) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((rowIndex < 0) || (rowIndex >= getRowCount())) {
|
if (rowIndex < 0 || rowIndex >= getRowCount()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (columnIndex < 0 || columnIndex >= getColumnCount()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DataTypeComponent dtc = stackDt.getComponent(rowIndex);
|
DataTypeComponent dtc = stackDt.getComponent(rowIndex);
|
||||||
if (dtc == null) {
|
if (dtc == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if (columnIndex != NAME) {
|
|
||||||
// int offset = dtc.getOffset();
|
|
||||||
// if (!hasCustomParameterStorage && originalStack.isParameterOffset(offset)) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (dtc.getDataType() instanceof StackPieceDataType) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
boolean notDefined = (stackDt.getDefinedComponentAtOrdinal(rowIndex) == null);
|
boolean notDefined = (stackDt.getDefinedComponentAtOrdinal(rowIndex) == null);
|
||||||
return !(notDefined && (columnIndex == OFFSET));
|
return !(notDefined && (columnIndex == OFFSET));
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,6 +474,16 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void downArrow() {
|
||||||
|
triggerActionKey(getTable(), 0, KeyEvent.VK_DOWN);
|
||||||
|
waitForSwing();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void downArrow(JComponent component) {
|
||||||
|
triggerActionKey(component, 0, KeyEvent.VK_DOWN);
|
||||||
|
waitForSwing();
|
||||||
|
}
|
||||||
|
|
||||||
protected void endKey() {
|
protected void endKey() {
|
||||||
triggerActionKey(getKeyEventDestination(), 0, KeyEvent.VK_END);
|
triggerActionKey(getKeyEventDestination(), 0, KeyEvent.VK_END);
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
|
|
|
@ -139,6 +139,29 @@ public class StackEditorProvider1Test extends AbstractStackEditorProviderTest {
|
||||||
assertStackEditorHidden(function);
|
assertStackEditorHidden(function);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEditUsingArrowKeys() throws Exception {
|
||||||
|
|
||||||
|
init(SIMPLE_STACK);
|
||||||
|
|
||||||
|
int row = 1;
|
||||||
|
int column = model.getNameColumn();
|
||||||
|
clickTableCell(getTable(), row, column, 1);
|
||||||
|
assertColumn(column);
|
||||||
|
performAction(editFieldAction, provider, true);
|
||||||
|
|
||||||
|
// change name
|
||||||
|
JTextField tf = getCellEditorTextField();
|
||||||
|
setText(tf, tf.getText() + "change");
|
||||||
|
|
||||||
|
downArrow(tf);
|
||||||
|
assertRow(row + 1);
|
||||||
|
assertColumn(column);
|
||||||
|
|
||||||
|
assertIsEditingField(row + 1, column);
|
||||||
|
escape();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteAssociatedFunction() throws Exception {
|
public void testDeleteAssociatedFunction() throws Exception {
|
||||||
Window dialog;
|
Window dialog;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue