Merge remote-tracking branch

'origin/GP-4891-dragonmacher-stack-editor-exception' (Closes #6883)
This commit is contained in:
Ryan Kurtz 2024-09-06 06:15:54 -04:00
commit 3d7139e0a8
4 changed files with 45 additions and 17 deletions

View File

@ -486,8 +486,8 @@ public abstract class CompositeEditorPanel extends JPanel
if (index >= 0) {
row = index;
table.setRowSelectionInterval(row, row);
if (model.isCellEditable(index, modelColumn)) {
return beginEditField(model.getRow(), model.getColumn());
if (model.isCellEditable(row, modelColumn)) {
return beginEditField(row, modelColumn);
}
}
return false;
@ -500,6 +500,7 @@ public abstract class CompositeEditorPanel extends JPanel
protected boolean editBelowField() {
int row = model.getRow();
int modelColumn = model.getColumn();
// Get the current row (index) and column (fieldNum).
int index = row;
index++;
@ -508,8 +509,8 @@ public abstract class CompositeEditorPanel extends JPanel
if (index < numComps) {
row = index;
table.setRowSelectionInterval(row, row);
if (model.isCellEditable(index, modelColumn)) {
return beginEditField(model.getRow(), model.getColumn());
if (model.isCellEditable(row, modelColumn)) {
return beginEditField(row, modelColumn);
}
}
return false;
@ -602,7 +603,7 @@ public abstract class CompositeEditorPanel extends JPanel
model.setColumn(modelIndex);
}
else {
model.setColumn(-1);
model.setColumn(e.getFirstIndex());
}
});

View File

@ -406,22 +406,16 @@ public class StackEditorModel extends CompositeEditorModel {
if (columnIndex == LENGTH) {
return false;
}
if ((rowIndex < 0) || (rowIndex >= getRowCount())) {
if (rowIndex < 0 || rowIndex >= getRowCount()) {
return false;
}
if (columnIndex < 0 || columnIndex >= getColumnCount()) {
return false;
}
DataTypeComponent dtc = stackDt.getComponent(rowIndex);
if (dtc == null) {
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);
return !(notDefined && (columnIndex == OFFSET));
}

View File

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -474,6 +474,16 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
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() {
triggerActionKey(getKeyEventDestination(), 0, KeyEvent.VK_END);
waitForSwing();

View File

@ -139,6 +139,29 @@ public class StackEditorProvider1Test extends AbstractStackEditorProviderTest {
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
public void testDeleteAssociatedFunction() throws Exception {
Window dialog;