Merge remote-tracking branch 'origin/GP-0-dragonmacher-test-fixes-2-7-23'

This commit is contained in:
Ryan Kurtz
2023-02-07 12:02:28 -05:00
3 changed files with 28 additions and 8 deletions
@@ -15,6 +15,8 @@
*/
package ghidra.app.plugin.core.equate;
import java.util.Objects;
import ghidra.app.cmd.equate.SetEquateCmd;
import ghidra.app.context.ListingActionContext;
import ghidra.framework.cmd.BackgroundCommand;
@@ -57,7 +59,7 @@ public class CreateEquateCmd extends BackgroundCommand {
false /* is modal */);
this.targetScalarValue = scalar.getValue();
this.iterator = iter;
this.equateName = equateName;
this.equateName = Objects.requireNonNull(equateName);
this.overwriteExisting = overwriteExisting;
this.context = context;
}
@@ -78,7 +80,7 @@ public class CreateEquateCmd extends BackgroundCommand {
this.iterator = iter;
this.overwriteExisting = overwriteExisting;
this.context = context;
this.enoom = enoom;
this.enoom = Objects.requireNonNull(enoom);
}
@Override
@@ -90,6 +90,10 @@ public class SetEquateDialog extends DialogComponentProvider {
private EquateFilterListener filterListener = new EquateFilterListener();
private EquateEnterListener enterListener = new EquateEnterListener();
// these will be set in the okCallback()
private String equateName;
private Enum enumDt;
/**
* Constructor
*
@@ -148,12 +152,14 @@ public class SetEquateDialog extends DialogComponentProvider {
int refCount = eqRowObject.getRefCount();
if (refCount > 0) {
if (eqRowObject.getEntryName().contains(EquateManager.ERROR_TAG)) {
c.setForeground(isSelected ? this.SELECTED_CELL_COLOR : this.BAD_EQUATE_COLOR);
c.setForeground(
isSelected ? this.SELECTED_CELL_COLOR : this.BAD_EQUATE_COLOR);
}
else {
Equate e = eqRowObject.getEquate();
if (e != null && !e.isEnumBased()) {
c.setForeground(isSelected ? this.SELECTED_CELL_COLOR : this.EQUATE_COLOR);
c.setForeground(
isSelected ? this.SELECTED_CELL_COLOR : this.EQUATE_COLOR);
}
}
}
@@ -397,6 +403,10 @@ public class SetEquateDialog extends DialogComponentProvider {
* Get the Equate Name entered or chosen by the user.
*/
public String getEquateName() {
return equateName;
}
private String doGetEquateName() {
EquateRowObject equateEntry = getRowObject();
if (equateEntry != null) {
return equateEntry.getEntryName();
@@ -413,6 +423,10 @@ public class SetEquateDialog extends DialogComponentProvider {
* @return the enum data type for the selected entry, or null if there is no enum.
*/
public Enum getEnumDataType() {
return enumDt;
}
private Enum doGetEnumDataType() {
EquateRowObject equateEntry = getRowObject();
return (equateEntry != null) ? equateEntry.getEnumDataType() : null;
}
@@ -515,8 +529,11 @@ public class SetEquateDialog extends DialogComponentProvider {
@Override
protected void okCallback() {
if (isValid(this.getEquateName(), scalar)) {
String name = doGetEquateName();
if (isValid(name, scalar)) {
result = OK;
equateName = name;
enumDt = doGetEnumDataType();
close();
}
else {
@@ -532,7 +549,7 @@ public class SetEquateDialog extends DialogComponentProvider {
// look up the new equate string
Equate newEquate = equateTable.getEquate(equateStr);
if (newEquate != null && getEnumDataType() == null) {
if (newEquate != null && doGetEnumDataType() == null) {
// make sure any existing equate with that name has the same value.
if (newEquate.getValue() != testScalar.getValue()) {
setStatus("Equate " + equateStr + " exists with value 0x" +
@@ -37,7 +37,7 @@ import ghidra.util.HelpLocation;
import ghidra.util.exception.AssertException;
public class SettingsDialog extends DialogComponentProvider {
private final static int WIDTH = 300;
private final static int HEIGHT = 150;
@@ -70,11 +70,12 @@ public class SettingsDialog extends DialogComponentProvider {
DockingWindowManager.showDialog(parent, this);
}
@Override
public void dispose() {
settingsTable.editingStopped(null);
settingsTable.dispose();
close();
super.dispose();
settingsDefs = null;
settings = null;
}