mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Test fixes
This commit is contained in:
@@ -69,6 +69,7 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
|||||||
super(title, true, false, true, false);
|
super(title, true, false, true, false);
|
||||||
this.settingsDefinitions = settingDefinitions;
|
this.settingsDefinitions = settingDefinitions;
|
||||||
settings = new SettingsImpl(originalSettings) {
|
settings = new SettingsImpl(originalSettings) {
|
||||||
|
@Override
|
||||||
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
|
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
|
||||||
return originalSettings == null ||
|
return originalSettings == null ||
|
||||||
originalSettings.isChangeAllowed(settingsDefinition);
|
originalSettings.isChangeAllowed(settingsDefinition);
|
||||||
@@ -118,7 +119,7 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
close();
|
super.dispose();
|
||||||
settingsDefinitions = null;
|
settingsDefinitions = null;
|
||||||
defaultSettings = null;
|
defaultSettings = null;
|
||||||
settings = null;
|
settings = null;
|
||||||
@@ -150,23 +151,23 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
|||||||
|
|
||||||
private void readHexModePreferences() {
|
private void readHexModePreferences() {
|
||||||
intHexModeMap = new HashMap<>();
|
intHexModeMap = new HashMap<>();
|
||||||
for (int i = 0; i < settingsDefinitions.length; i++) {
|
for (SettingsDefinition settingsDefinition : settingsDefinitions) {
|
||||||
if (settingsDefinitions[i] instanceof NumberSettingsDefinition) {
|
if (settingsDefinition instanceof NumberSettingsDefinition) {
|
||||||
String propertyName = getHexModePropertyName(settingsDefinitions[i]);
|
String propertyName = getHexModePropertyName(settingsDefinition);
|
||||||
boolean hexMode = Boolean
|
boolean hexMode = Boolean
|
||||||
.valueOf(
|
.valueOf(
|
||||||
Preferences.getProperty(propertyName, Boolean.FALSE.toString()));
|
Preferences.getProperty(propertyName, Boolean.FALSE.toString()));
|
||||||
intHexModeMap.put(settingsDefinitions[i].getName(), hexMode);
|
intHexModeMap.put(settingsDefinition.getName(), hexMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeHexModePreferences() {
|
private void writeHexModePreferences() {
|
||||||
boolean save = false;
|
boolean save = false;
|
||||||
for (int i = 0; i < settingsDefinitions.length; i++) {
|
for (SettingsDefinition settingsDefinition : settingsDefinitions) {
|
||||||
if (settingsDefinitions[i] instanceof NumberSettingsDefinition) {
|
if (settingsDefinition instanceof NumberSettingsDefinition) {
|
||||||
boolean hexMode = intHexModeMap.get(settingsDefinitions[i].getName());
|
boolean hexMode = intHexModeMap.get(settingsDefinition.getName());
|
||||||
String propertyName = getHexModePropertyName(settingsDefinitions[i]);
|
String propertyName = getHexModePropertyName(settingsDefinition);
|
||||||
if (hexMode != Boolean
|
if (hexMode != Boolean
|
||||||
.valueOf(Preferences.getProperty(propertyName, Boolean.FALSE.toString()))) {
|
.valueOf(Preferences.getProperty(propertyName, Boolean.FALSE.toString()))) {
|
||||||
Preferences.setProperty(propertyName, Boolean.toString(hexMode));
|
Preferences.setProperty(propertyName, Boolean.toString(hexMode));
|
||||||
@@ -596,7 +597,6 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
|||||||
return sign + "0x" + signedValue.toString(16);
|
return sign + "0x" + signedValue.toString(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class SettingsRenderer extends GTableCellRenderer {
|
private class SettingsRenderer extends GTableCellRenderer {
|
||||||
|
|
||||||
private Font originalFont;
|
private Font originalFont;
|
||||||
@@ -634,7 +634,7 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
|||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NumberWrapper {
|
private class NumberWrapper {
|
||||||
|
|
||||||
final Number value; // may be null
|
final Number value; // may be null
|
||||||
@@ -703,7 +703,7 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
|||||||
GhidraComboBox<String> getComboBox() {
|
GhidraComboBox<String> getComboBox() {
|
||||||
return comboBox; // used for testing
|
return comboBox; // used for testing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getCellEditorValue() {
|
public Object getCellEditorValue() {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin
|
|||||||
|
|
||||||
private static final String EXTENSIONS_PATH_PREFIX = Path.GHIDRA_HOME + "/Extensions";
|
private static final String EXTENSIONS_PATH_PREFIX = Path.GHIDRA_HOME + "/Extensions";
|
||||||
|
|
||||||
private static final String SEACH_PROVIDER_NAME = "Search DataTypes Provider";
|
private static final String SEARCH_PROVIDER_NAME = "Search DataTypes Provider";
|
||||||
private static final int RECENTLY_USED_CACHE_SIZE = 10;
|
private static final int RECENTLY_USED_CACHE_SIZE = 10;
|
||||||
|
|
||||||
private static final String STANDARD_ARCHIVE_MENU = "Standard Archive";
|
private static final String STANDARD_ARCHIVE_MENU = "Standard Archive";
|
||||||
@@ -360,11 +360,10 @@ public class DataTypeManagerPlugin extends ProgramPlugin
|
|||||||
|
|
||||||
public DataTypesProvider createProvider() {
|
public DataTypesProvider createProvider() {
|
||||||
|
|
||||||
DataTypesProvider newProvider = new DataTypesProvider(this, SEACH_PROVIDER_NAME);
|
DataTypesProvider newProvider = new DataTypesProvider(this, SEARCH_PROVIDER_NAME, true);
|
||||||
newProvider.setIncludeDataTypeMembersInFilter(provider.includeDataMembersInSearch());
|
newProvider.setIncludeDataTypeMembersInFilter(provider.includeDataMembersInSearch());
|
||||||
newProvider.setFilteringArrays(provider.isFilteringArrays());
|
newProvider.setFilteringArrays(provider.isFilteringArrays());
|
||||||
newProvider.setFilteringPointers(provider.isFilteringPointers());
|
newProvider.setFilteringPointers(provider.isFilteringPointers());
|
||||||
newProvider.setTransient();
|
|
||||||
return newProvider;
|
return newProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,9 +99,18 @@ public class DataTypesProvider extends ComponentProviderAdapter {
|
|||||||
private boolean includeDataMembersInFilter;
|
private boolean includeDataMembersInFilter;
|
||||||
|
|
||||||
public DataTypesProvider(DataTypeManagerPlugin plugin, String providerName) {
|
public DataTypesProvider(DataTypeManagerPlugin plugin, String providerName) {
|
||||||
|
this(plugin, providerName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTypesProvider(DataTypeManagerPlugin plugin, String providerName,
|
||||||
|
boolean isTransient) {
|
||||||
super(plugin.getTool(), providerName, plugin.getName(), DataTypesActionContext.class);
|
super(plugin.getTool(), providerName, plugin.getName(), DataTypesActionContext.class);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
if (isTransient) {
|
||||||
|
setTransient();
|
||||||
|
}
|
||||||
|
|
||||||
setTitle(TITLE);
|
setTitle(TITLE);
|
||||||
setIcon(new GIcon("icon.plugin.datatypes.provider"));
|
setIcon(new GIcon("icon.plugin.datatypes.provider"));
|
||||||
addToToolbar();
|
addToToolbar();
|
||||||
@@ -114,11 +123,6 @@ public class DataTypesProvider extends ComponentProviderAdapter {
|
|||||||
createLocalActions();
|
createLocalActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // overridden to open access
|
|
||||||
protected void setTransient() {
|
|
||||||
super.setTransient();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This creates all the actions for opening/creating data type archives.
|
* This creates all the actions for opening/creating data type archives.
|
||||||
* It also creates the action for refreshing the built-in data types
|
* It also creates the action for refreshing the built-in data types
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
|||||||
private AddressInput baseAddrField; // used for Bit and Byte mapped blocks
|
private AddressInput baseAddrField; // used for Bit and Byte mapped blocks
|
||||||
private IntegerTextField schemeDestByteCountField; // used for Byte mapped blocks
|
private IntegerTextField schemeDestByteCountField; // used for Byte mapped blocks
|
||||||
private IntegerTextField schemeSrcByteCountField; // used for Byte mapped blocks
|
private IntegerTextField schemeSrcByteCountField; // used for Byte mapped blocks
|
||||||
|
|
||||||
private AddBlockModel model;
|
private AddBlockModel model;
|
||||||
private GhidraComboBox<MemoryBlockType> comboBox;
|
private GhidraComboBox<MemoryBlockType> comboBox;
|
||||||
private boolean updatingInitializedRB;
|
private boolean updatingInitializedRB;
|
||||||
@@ -325,8 +325,9 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
|||||||
tool.showDialog(this, tool.getComponentProvider(PluginConstants.MEMORY_MAP));
|
tool.showDialog(this, tool.getComponentProvider(PluginConstants.MEMORY_MAP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
close();
|
super.dispose();
|
||||||
model.dispose();
|
model.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,7 +428,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
|||||||
}
|
}
|
||||||
model.setBaseAddress(addr);
|
model.setBaseAddress(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void schemeSrcByteCountChanged() {
|
private void schemeSrcByteCountChanged() {
|
||||||
int value = schemeSrcByteCountField.getIntValue();
|
int value = schemeSrcByteCountField.getIntValue();
|
||||||
model.setSchemeSrcByteCount(value);
|
model.setSchemeSrcByteCount(value);
|
||||||
@@ -466,21 +467,21 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
|||||||
baseAddrField.setAddressFactory(addrFactory);
|
baseAddrField.setAddressFactory(addrFactory);
|
||||||
baseAddrField.setName("Source Addr");
|
baseAddrField.setName("Source Addr");
|
||||||
baseAddrField.addChangeListener(ev -> baseAddressChanged());
|
baseAddrField.addChangeListener(ev -> baseAddressChanged());
|
||||||
|
|
||||||
JPanel schemePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel schemePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
|
|
||||||
schemeDestByteCountField = new IntegerTextField(4, 1);
|
schemeDestByteCountField = new IntegerTextField(4, 1);
|
||||||
schemeDestByteCountField.setAllowNegativeValues(false);
|
schemeDestByteCountField.setAllowNegativeValues(false);
|
||||||
schemeDestByteCountField.setAllowsHexPrefix(false);
|
schemeDestByteCountField.setAllowsHexPrefix(false);
|
||||||
schemeDestByteCountField.setDecimalMode();
|
schemeDestByteCountField.setDecimalMode();
|
||||||
schemeDestByteCountField.addChangeListener(ev -> schemeDestByteCountChanged());
|
schemeDestByteCountField.addChangeListener(ev -> schemeDestByteCountChanged());
|
||||||
|
|
||||||
schemeSrcByteCountField = new IntegerTextField(4, 1);
|
schemeSrcByteCountField = new IntegerTextField(4, 1);
|
||||||
schemeSrcByteCountField.setAllowNegativeValues(false);
|
schemeSrcByteCountField.setAllowNegativeValues(false);
|
||||||
schemeSrcByteCountField.setAllowsHexPrefix(false);
|
schemeSrcByteCountField.setAllowsHexPrefix(false);
|
||||||
schemeSrcByteCountField.setDecimalMode();
|
schemeSrcByteCountField.setDecimalMode();
|
||||||
schemeSrcByteCountField.addChangeListener(ev -> schemeSrcByteCountChanged());
|
schemeSrcByteCountField.addChangeListener(ev -> schemeSrcByteCountChanged());
|
||||||
|
|
||||||
schemePanel.add(schemeDestByteCountField.getComponent());
|
schemePanel.add(schemeDestByteCountField.getComponent());
|
||||||
schemePanel.add(new GLabel(" : "));
|
schemePanel.add(new GLabel(" : "));
|
||||||
schemePanel.add(schemeSrcByteCountField.getComponent());
|
schemePanel.add(schemeSrcByteCountField.getComponent());
|
||||||
@@ -494,10 +495,10 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
|||||||
model.setBaseAddress(minAddr);
|
model.setBaseAddress(minAddr);
|
||||||
panel.add(new GLabel("Source Address:"));
|
panel.add(new GLabel("Source Address:"));
|
||||||
panel.add(baseAddrField);
|
panel.add(baseAddrField);
|
||||||
|
|
||||||
panel.add(new GLabel("Mapping Ratio:"));
|
panel.add(new GLabel("Mapping Ratio:"));
|
||||||
panel.add(schemePanel);
|
panel.add(schemePanel);
|
||||||
|
|
||||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,8 +94,9 @@ public class EditExternalLocationDialog extends DialogComponentProvider {
|
|||||||
/**
|
/**
|
||||||
* Dispose of this dialog.
|
* Dispose of this dialog.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
close();
|
super.dispose();
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
package docking.widgets;
|
package docking.widgets;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.*;
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -63,12 +64,7 @@ public class PasswordChangeDialog extends DialogComponentProvider {
|
|||||||
wp.add(new GLabel("Repeat Password:"));
|
wp.add(new GLabel("Repeat Password:"));
|
||||||
passwordField2 = new JPasswordField(16);
|
passwordField2 = new JPasswordField(16);
|
||||||
passwordField2.setName("PASSWORD-ENTRY2-COMPONENT");
|
passwordField2.setName("PASSWORD-ENTRY2-COMPONENT");
|
||||||
passwordField2.addActionListener(new ActionListener() {
|
passwordField2.addActionListener(e -> okCallback());
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
okCallback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
wp.add(passwordField2);
|
wp.add(passwordField2);
|
||||||
|
|
||||||
wp.add(new GLabel());
|
wp.add(new GLabel());
|
||||||
@@ -146,8 +142,15 @@ public class PasswordChangeDialog extends DialogComponentProvider {
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
// overridden to not call dispose, since this class does special cleanup on close
|
||||||
|
closeDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
close();
|
super.dispose();
|
||||||
if (newPassword != null) {
|
if (newPassword != null) {
|
||||||
Arrays.fill(newPassword, ' ');
|
Arrays.fill(newPassword, ' ');
|
||||||
newPassword = null;
|
newPassword = null;
|
||||||
|
|||||||
@@ -91,11 +91,11 @@ public class DefaultClientAuthenticator extends PopupKeyStorePasswordProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getNewPassword(final Component parent, String serverInfo, String username) {
|
public char[] getNewPassword(final Component parent, String serverInfo, String username) {
|
||||||
final PasswordChangeDialog dlg =
|
|
||||||
|
PasswordChangeDialog dlg =
|
||||||
new PasswordChangeDialog("Change Password", "Repository Server", serverInfo, username);
|
new PasswordChangeDialog("Change Password", "Repository Server", serverInfo, username);
|
||||||
Runnable r = () -> DockingWindowManager.showDialog(parent, dlg);
|
|
||||||
try {
|
try {
|
||||||
SystemUtilities.runSwingNow(r);
|
DockingWindowManager.showDialog(parent, dlg);
|
||||||
return dlg.getPassword();
|
return dlg.getPassword();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user