mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-02 03:57:13 +08:00
Test fixes
This commit is contained in:
+4
-2
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.equate;
|
package ghidra.app.plugin.core.equate;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import ghidra.app.cmd.equate.SetEquateCmd;
|
import ghidra.app.cmd.equate.SetEquateCmd;
|
||||||
import ghidra.app.context.ListingActionContext;
|
import ghidra.app.context.ListingActionContext;
|
||||||
import ghidra.framework.cmd.BackgroundCommand;
|
import ghidra.framework.cmd.BackgroundCommand;
|
||||||
@@ -57,7 +59,7 @@ public class CreateEquateCmd extends BackgroundCommand {
|
|||||||
false /* is modal */);
|
false /* is modal */);
|
||||||
this.targetScalarValue = scalar.getValue();
|
this.targetScalarValue = scalar.getValue();
|
||||||
this.iterator = iter;
|
this.iterator = iter;
|
||||||
this.equateName = equateName;
|
this.equateName = Objects.requireNonNull(equateName);
|
||||||
this.overwriteExisting = overwriteExisting;
|
this.overwriteExisting = overwriteExisting;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
@@ -78,7 +80,7 @@ public class CreateEquateCmd extends BackgroundCommand {
|
|||||||
this.iterator = iter;
|
this.iterator = iter;
|
||||||
this.overwriteExisting = overwriteExisting;
|
this.overwriteExisting = overwriteExisting;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.enoom = enoom;
|
this.enoom = Objects.requireNonNull(enoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ public class SetEquateDialog extends DialogComponentProvider {
|
|||||||
private EquateFilterListener filterListener = new EquateFilterListener();
|
private EquateFilterListener filterListener = new EquateFilterListener();
|
||||||
private EquateEnterListener enterListener = new EquateEnterListener();
|
private EquateEnterListener enterListener = new EquateEnterListener();
|
||||||
|
|
||||||
|
// these will be set in the okCallback()
|
||||||
|
private String equateName;
|
||||||
|
private Enum enumDt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@@ -148,12 +152,14 @@ public class SetEquateDialog extends DialogComponentProvider {
|
|||||||
int refCount = eqRowObject.getRefCount();
|
int refCount = eqRowObject.getRefCount();
|
||||||
if (refCount > 0) {
|
if (refCount > 0) {
|
||||||
if (eqRowObject.getEntryName().contains(EquateManager.ERROR_TAG)) {
|
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 {
|
else {
|
||||||
Equate e = eqRowObject.getEquate();
|
Equate e = eqRowObject.getEquate();
|
||||||
if (e != null && !e.isEnumBased()) {
|
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.
|
* Get the Equate Name entered or chosen by the user.
|
||||||
*/
|
*/
|
||||||
public String getEquateName() {
|
public String getEquateName() {
|
||||||
|
return equateName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String doGetEquateName() {
|
||||||
EquateRowObject equateEntry = getRowObject();
|
EquateRowObject equateEntry = getRowObject();
|
||||||
if (equateEntry != null) {
|
if (equateEntry != null) {
|
||||||
return equateEntry.getEntryName();
|
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.
|
* @return the enum data type for the selected entry, or null if there is no enum.
|
||||||
*/
|
*/
|
||||||
public Enum getEnumDataType() {
|
public Enum getEnumDataType() {
|
||||||
|
return enumDt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Enum doGetEnumDataType() {
|
||||||
EquateRowObject equateEntry = getRowObject();
|
EquateRowObject equateEntry = getRowObject();
|
||||||
return (equateEntry != null) ? equateEntry.getEnumDataType() : null;
|
return (equateEntry != null) ? equateEntry.getEnumDataType() : null;
|
||||||
}
|
}
|
||||||
@@ -515,8 +529,11 @@ public class SetEquateDialog extends DialogComponentProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void okCallback() {
|
protected void okCallback() {
|
||||||
if (isValid(this.getEquateName(), scalar)) {
|
String name = doGetEquateName();
|
||||||
|
if (isValid(name, scalar)) {
|
||||||
result = OK;
|
result = OK;
|
||||||
|
equateName = name;
|
||||||
|
enumDt = doGetEnumDataType();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -532,7 +549,7 @@ public class SetEquateDialog extends DialogComponentProvider {
|
|||||||
|
|
||||||
// look up the new equate string
|
// look up the new equate string
|
||||||
Equate newEquate = equateTable.getEquate(equateStr);
|
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.
|
// make sure any existing equate with that name has the same value.
|
||||||
if (newEquate.getValue() != testScalar.getValue()) {
|
if (newEquate.getValue() != testScalar.getValue()) {
|
||||||
setStatus("Equate " + equateStr + " exists with value 0x" +
|
setStatus("Equate " + equateStr + " exists with value 0x" +
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import ghidra.util.HelpLocation;
|
|||||||
import ghidra.util.exception.AssertException;
|
import ghidra.util.exception.AssertException;
|
||||||
|
|
||||||
public class SettingsDialog extends DialogComponentProvider {
|
public class SettingsDialog extends DialogComponentProvider {
|
||||||
|
|
||||||
private final static int WIDTH = 300;
|
private final static int WIDTH = 300;
|
||||||
private final static int HEIGHT = 150;
|
private final static int HEIGHT = 150;
|
||||||
|
|
||||||
@@ -70,11 +70,12 @@ public class SettingsDialog extends DialogComponentProvider {
|
|||||||
DockingWindowManager.showDialog(parent, this);
|
DockingWindowManager.showDialog(parent, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
settingsTable.editingStopped(null);
|
settingsTable.editingStopped(null);
|
||||||
settingsTable.dispose();
|
settingsTable.dispose();
|
||||||
|
|
||||||
close();
|
super.dispose();
|
||||||
settingsDefs = null;
|
settingsDefs = null;
|
||||||
settings = null;
|
settings = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user