Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-7393: use charset picker in more spots

dev747368c09723348ffe
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/strings/EncodedStringsDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/strings/EncodedStringsDialog.java
index 63d7589076..ff175b1d76 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/strings/EncodedStringsDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/strings/EncodedStringsDialog.java
@@ -58,7 +58,9 @@ import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.program.util.ProgramLocation;
import ghidra.util.Msg;
import ghidra.util.Swing;
+import ghidra.util.charset.CharsetInfo;
import ghidra.util.charset.CharsetInfoManager;
+import ghidra.util.charset.picker.CharsetPickerField;
import ghidra.util.exception.CancelledException;
import ghidra.util.layout.PairLayout;
import ghidra.util.table.GhidraTable;
@@ -87,7 +89,7 @@ public class EncodedStringsDialog extends DialogComponentProvider {
private GhidraTable table;
private JPanel optionsPanel;
- private GhidraComboBox<String> charsetComboBox;
+ private CharsetPickerField charsetPicker;
private JToggleButton showAdvancedOptionsButton;
private JToggleButton showScriptOptionsButton;
private JToggleButton showTranslateOptionsButton;
@@ -154,10 +156,10 @@ public class EncodedStringsDialog extends DialogComponentProvider {
/**
* For test/screen shot use
*
- * @param charsetName set the charset
+ * @param newCS set the charset
*/
- public void setSelectedCharset(String charsetName) {
- charsetComboBox.setSelectedItem(charsetName);
+ public void setSelectedCharset(Charset newCS) {
+ charsetPicker.setCharset(newCS);
}
/**
@@ -320,7 +322,7 @@ public class EncodedStringsDialog extends DialogComponentProvider {
boolean ssm = selectedAddresses.getNumAddresses() == 1;
- addRow(new GLabel("Charset:", SwingConstants.RIGHT), charsetComboBox,
+ addRow(new GLabel("Charset:", SwingConstants.RIGHT), charsetPicker,
showScriptOptionsButton, showTranslateOptionsButton, showAdvancedOptionsButton,
advancedFailedCountLabel);
@@ -442,15 +444,12 @@ public class EncodedStringsDialog extends DialogComponentProvider {
}
private void buildCharsetPickerComponents() {
- charsetComboBox = new GhidraComboBox<>();
- charsetComboBox.getAccessibleContext().setAccessibleName("Charset Checkboxes");
- for (String charsetName : CharsetInfoManager.getInstance().getCharsetNames()) {
- charsetComboBox.addToModel(charsetName);
- }
- charsetComboBox.setSelectedItem(getDefault(EncodedStringsPlugin.CHARSET_OPTIONNAME,
- EncodedStringsPlugin.CHARSET_DEFAULT_VALUE));
- charsetComboBox.addItemListener(itemListener);
- charsetComboBox.setToolTipText("Which character set to use to decode the raw bytes.");
+ String csName = getDefault(EncodedStringsPlugin.CHARSET_OPTIONNAME,
+ EncodedStringsPlugin.CHARSET_DEFAULT_VALUE);
+ charsetPicker = new CharsetPickerField(csName);
+ charsetPicker.setClearButtonVisible(false);
+ charsetPicker.addItemListener(itemListener);
+ charsetPicker.setToolTipText("Which character set to use to decode the raw bytes.");
}
private void buildOptionsButtonComponents() {
@@ -657,7 +656,7 @@ public class EncodedStringsDialog extends DialogComponentProvider {
private void fixupComboBoxSizes() {
// Make the charset and script comboboxes the same width
- requiredUnicodeScript.setPreferredSize(charsetComboBox.getPreferredSize());
+ requiredUnicodeScript.setPreferredSize(charsetPicker.getPreferredSize());
}
private void buildTranslateComponents() {
@@ -907,10 +906,7 @@ public class EncodedStringsDialog extends DialogComponentProvider {
}
private void updateOptions() {
- String charsetName = charsetComboBox.getSelectedItem().toString();
- if (!charsetExists(charsetName)) {
- charsetName = CharsetInfoManager.USASCII;
- }
+ CharsetInfo csi = charsetPicker.getCharsetInfo();
boolean scriptOptions = showScriptOptionsButton.isSelected();
boolean excludeStringsWithErrors = excludeStringsWithCodecErrorCB.isSelected();
@@ -924,20 +920,20 @@ public class EncodedStringsDialog extends DialogComponentProvider {
selectedAddresses.getNumAddresses())
: -1; // single string mode - no min len
- AbstractStringDataType stringDT = CHARSET_TO_DT_MAP.get(charsetName);
+ AbstractStringDataType stringDT = CHARSET_TO_DT_MAP.get(csi.getName());
Settings settings = SettingsImpl.NO_SETTINGS;
if (stringDT == null) {
stringDT = StringDataType.dataType;
settings = new SettingsImpl();
- CharsetSettingsDefinition.CHARSET.setCharset(settings, charsetName);
+ CharsetSettingsDefinition.CHARSET.setCharset(settings, csi.getName());
}
- int charSize = CharsetInfoManager.getInstance().getCharsetCharSize(charsetName);
+ int charSize = csi.getMinBytesPerChar();
updateTrigramStringValidator(stringModelFilenameComboBox.getText());
boolean requireValidStrings = requireValidStringCB.isSelected();
boolean breakOnRef = breakOnRefCB.isSelected();
- currentOptions = new EncodedStringsOptions(stringDT, settings, charsetName,
+ currentOptions = new EncodedStringsOptions(stringDT, settings, csi.getName(),
scriptOptions ? getRequiredScripts() : null, scriptOptions ? getAllowedScripts() : null,
excludeStringsWithErrors, excludeStringsWithNonStdCtrlChars, alignStartofString,
charSize, minStrLen, breakOnRef, stringValidator, requireValidStrings);
@@ -972,8 +968,7 @@ public class EncodedStringsDialog extends DialogComponentProvider {
private Set<UnicodeScript> getRequiredScripts() {
Set<UnicodeScript> scripts = EnumSet.noneOf(UnicodeScript.class);
- UnicodeScript selectedUnicodeScript =
- (UnicodeScript) requiredUnicodeScript.getSelectedItem();
+ UnicodeScript selectedUnicodeScript = requiredUnicodeScript.getSelectedItem();
if (selectedUnicodeScript != null &&
selectedUnicodeScript != CharacterScriptUtils.ANY_SCRIPT_ALIAS) {
scripts.add(selectedUnicodeScript);
@@ -1054,7 +1049,7 @@ public class EncodedStringsDialog extends DialogComponentProvider {
requiredUnicodeScript.removeItemListener(itemListener);
UnicodeScript currentSelectedScript =
- (UnicodeScript) requiredUnicodeScript.getSelectedItem();
+ requiredUnicodeScript.getSelectedItem();
requiredUnicodeScript.setModel(getScriptListModel(stats));
if (stats.foundScriptCounts.containsKey(currentSelectedScript)) {
@@ -1114,16 +1109,6 @@ public class EncodedStringsDialog extends DialogComponentProvider {
.formatted(formatLength(addrs.getNumAddresses(), "addresses"), addrRangeStr);
}
- private static boolean charsetExists(String charsetName) {
- try {
- Charset charset = Charset.forName(charsetName);
- return charset != null;
- }
- catch (RuntimeException e) {
- return false;
- }
- }
-
private static String formatLength(long length, String unitSuffix) {
int divisor = 1;
String unitPrefix = "";
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFImportOptions.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFImportOptions.java
index f2a8b99be6..1861126b17 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFImportOptions.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFImportOptions.java
@@ -20,7 +20,9 @@ import java.nio.charset.Charset;
import ghidra.app.plugin.core.analysis.AnalysisOptionsUpdater;
import ghidra.app.plugin.core.analysis.DWARFAnalyzer;
import ghidra.app.services.Analyzer;
+import ghidra.framework.options.OptionType;
import ghidra.framework.options.Options;
+import ghidra.util.charset.picker.CharsetOptionsEditor;
/**
* Import options exposed by the {@link DWARFAnalyzer}
@@ -575,8 +577,8 @@ public class DWARFImportOptions {
options.registerOption(OPTION_COPY_EXTERNAL_DEBUG_FILE_SYMBOLS,
isCopyExternalDebugFileSymbols(), null, OPTION_COPY_EXTERNAL_DEBUG_FILE_SYMBOLS_DESC);
- options.registerOption(OPTION_CHARSET_NAME, getCharsetName(), null,
- OPTION_CHARSET_NAME_DESC);
+ options.registerOption(OPTION_CHARSET_NAME, OptionType.STRING_TYPE, getCharsetName(), null,
+ OPTION_CHARSET_NAME_DESC, () -> new CharsetOptionsEditor());
options.registerOption(OPTION_SHOW_VARIABLE_STORAGE_INFO, isShowVariableStorageInfo(),
null, OPTION_SHOW_VARIABLE_STORAGE_DESC);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetOptionsEditor.java b/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetOptionsEditor.java
new file mode 100644
index 0000000000..1ef2ea4189
--- /dev/null
+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetOptionsEditor.java
@@ -0,0 +1,82 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.util.charset.picker;
+
+import java.awt.Component;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.beans.PropertyEditorSupport;
+import java.nio.charset.Charset;
+import java.util.Objects;
+
+/**
+ * PropertyEditor for charset options. This shows a text field and a browse button to bring
+ * up a Charset Picker dialog. The option value is plain text, not a Charset instance.
+ */
+public class CharsetOptionsEditor extends PropertyEditorSupport {
+
+ private String currentValue;
+ private ItemListener itemListener = this::selectedItemChanged;
+
+ @Override
+ public String getAsText() {
+ return Objects.requireNonNullElse(currentValue, "");
+ }
+
+ @Override
+ public Object getValue() {
+ return getAsText();
+ }
+
+ @Override
+ public void setAsText(String text) throws IllegalArgumentException {
+ currentValue = text;
+ }
+
+ @Override
+ public void setValue(Object value) {
+ if (value == null) {
+ currentValue = null;
+ }
+ else if (value instanceof Charset cs) {
+ currentValue = cs.name();
+ }
+ else if (value instanceof String csName) {
+ currentValue = csName;
+ }
+ }
+
+ @Override
+ public boolean supportsCustomEditor() {
+ return true;
+ }
+
+ @Override
+ public Component getCustomEditor() {
+ CharsetPickerField editorComp = new CharsetPickerField();
+ editorComp.setCharsetName(currentValue);
+ editorComp.addItemListener(itemListener);
+
+ return editorComp;
+ }
+
+ private void selectedItemChanged(ItemEvent e) {
+ if (e.getSource() instanceof CharsetPickerField cspf) {
+ currentValue = cspf.getCharsetName();
+ firePropertyChange();
+ }
+ }
+}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetPickerDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetPickerDialog.java
index 24d6a139c9..02fc6dc4e1 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetPickerDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetPickerDialog.java
@@ -35,7 +35,9 @@ public class CharsetPickerDialog extends DialogComponentProvider {
*/
public static CharsetInfo pickCharset(CharsetInfo defaultCSI) {
CharsetPickerDialog dlg = new CharsetPickerDialog();
- dlg.setSelectedCharset(defaultCSI);
+ if (defaultCSI != null) {
+ dlg.setSelectedCharset(defaultCSI);
+ }
DockingWindowManager.showDialog(dlg);
return dlg.getSelectedCharset();
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetPickerField.java b/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetPickerField.java
new file mode 100644
index 0000000000..10b461eeaa
--- /dev/null
+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/charset/picker/CharsetPickerField.java
@@ -0,0 +1,217 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.util.charset.picker;
+
+import java.awt.BorderLayout;
+import java.awt.ItemSelectable;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+
+import javax.swing.*;
+
+import docking.widgets.button.BrowseButton;
+import generic.theme.GIcon;
+import ghidra.util.HTMLUtilities;
+import ghidra.util.charset.CharsetInfo;
+import ghidra.util.charset.CharsetInfoManager;
+import ghidra.util.datastruct.ListenerSet;
+
+/**
+ * A swing component that displays the name of a charset in a text field and allows the user to
+ * pick a new one using a popup dialog.
+ */
+public class CharsetPickerField extends JPanel implements ItemSelectable {
+ private JTextField charsetTF;
+ private BrowseButton browseButton;
+ private JButton clearButton;
+ private Icon clearIcon = new GIcon("icon.text.field.clear");
+
+ private CharsetInfo csi;
+ private ListenerSet<ItemListener> listeners = new ListenerSet<>(ItemListener.class, false);
+
+ public CharsetPickerField() {
+ this((CharsetInfo) null);
+ }
+
+ public CharsetPickerField(String charsetName) {
+ this(CharsetInfoManager.getInstance().get(charsetName, StandardCharsets.US_ASCII));
+ }
+
+ public CharsetPickerField(CharsetInfo csi) {
+ super(new BorderLayout());
+
+ this.charsetTF = new JTextField(15);
+ this.charsetTF.setEditable(false);
+ this.charsetTF.setFocusable(false);
+ this.charsetTF.getAccessibleContext().setAccessibleName("Charset Name");
+
+ JPanel buttonPanel = new JPanel(new BorderLayout(1, 0));
+
+ this.clearButton = new JButton(clearIcon);
+ this.clearButton.addActionListener(_ -> clearCharset());
+ this.clearButton.getAccessibleContext().setAccessibleName("Clear Selected Charset");
+ this.clearButton.setToolTipText("Clear Charset");
+
+ this.browseButton = new BrowseButton();
+ this.browseButton.addActionListener(_ -> chooseCharset());
+ this.browseButton.getAccessibleContext().setAccessibleName("Browse Charsets");
+ this.browseButton.setToolTipText("Browse Charsets");
+
+
+ buttonPanel.add(clearButton, BorderLayout.WEST);
+ buttonPanel.add(browseButton, BorderLayout.EAST);
+
+ add(charsetTF, BorderLayout.CENTER);
+ add(buttonPanel, BorderLayout.EAST);
+
+ updateCSI(csi);
+ }
+
+ /**
+ * Toggles the "clear" button's visibility
+ *
+ * @param b boolean flag, true mean visible, false not visible
+ */
+ public void setClearButtonVisible(boolean b) {
+ clearButton.setVisible(b);
+ }
+
+ /**
+ * Sets the current charset for this component, and updates any listeners with that change.
+ *
+ * @param newCS a {@link Charset}, or null to deselect
+ */
+ public void setCharset(Charset newCS) {
+ updateCSI(newCS != null ? CharsetInfoManager.getInstance().get(newCS) : null);
+
+ ItemEvent e = newCS != null
+ ? new ItemEvent(this, ItemEvent.ITEM_FIRST, newCS, ItemEvent.SELECTED)
+ : new ItemEvent(this, ItemEvent.ITEM_FIRST, null, ItemEvent.DESELECTED);
+ listeners.invoke().itemStateChanged(e);
+ }
+
+ /**
+ * Sets the current charset for this component, and updates any listeners with that change.
+ *
+ * @param name string name of a {@link Charset}, or null to deselect
+ */
+ public void setCharsetName(String name) {
+ CharsetInfo newCSI = name != null && !name.isBlank()
+ ? CharsetInfoManager.getInstance().get(name, StandardCharsets.US_ASCII)
+ : null;
+
+ updateCSI(newCSI);
+
+ ItemEvent e = newCSI != null
+ ? new ItemEvent(this, ItemEvent.ITEM_FIRST, newCSI.getCharset(), ItemEvent.SELECTED)
+ : new ItemEvent(this, ItemEvent.ITEM_FIRST, null, ItemEvent.DESELECTED);
+ listeners.invoke().itemStateChanged(e);
+ }
+
+ /**
+ * {@return the name of the current charset, or null if no charset is selected}
+ */
+ public String getCharsetName() {
+ return csi != null ? csi.getName() : null;
+ }
+
+ /**
+ * {@return the current charset, or null if none selected}
+ */
+ public Charset getCharset() {
+ return csi != null ? csi.getCharset() : null;
+ }
+
+ /**
+ * {@return the current charset's CharsetInfo}
+ */
+ public CharsetInfo getCharsetInfo() {
+ return csi;
+ }
+
+ @Override
+ public void setToolTipText(String text) {
+ super.setToolTipText(text);
+ updateCSI(csi);
+ }
+
+ private void clearCharset() {
+ updateCSI(null);
+
+ ItemEvent e = new ItemEvent(this, ItemEvent.ITEM_FIRST, null, ItemEvent.SELECTED);
+ listeners.invoke().itemStateChanged(e);
+ }
+
+ private void chooseCharset() {
+ CharsetInfo newCSI = CharsetPickerDialog.pickCharset(csi);
+ if (newCSI != null) {
+ updateCSI(newCSI);
+
+ ItemEvent e =
+ new ItemEvent(this, ItemEvent.ITEM_FIRST, newCSI.getCharset(), ItemEvent.SELECTED);
+
+ listeners.invoke().itemStateChanged(e);
+ }
+ }
+
+ private void updateCSI(CharsetInfo newCSI) {
+ this.csi = newCSI;
+
+ String baseTT = Objects.requireNonNullElse(getToolTipText(), "");
+ if (csi != null) {
+ if (!baseTT.isEmpty()) {
+ baseTT += "<br><br>";
+ }
+ String desc = Objects.requireNonNullElse(newCSI.getComment(), "N/A");
+
+ boolean needsHTML = !HTMLUtilities.isHTML(baseTT);
+
+ charsetTF.setText(newCSI.getName());
+ charsetTF.setToolTipText("""
+ %s%s
+ Charset: <b>%s</b><br>
+ <br>
+ Description: <b>%s</b>""".formatted(
+ needsHTML ? "<html>" : "",
+ baseTT,
+ newCSI.getName(),
+ HTMLUtilities.lineWrapWithHTMLLineBreaks(desc, 50)));
+ }
+ else {
+ charsetTF.setText("");
+ charsetTF.setToolTipText(baseTT);
+ }
+ }
+
+ @Override
+ public Object[] getSelectedObjects() {
+ return csi != null ? new Object[] { csi.getCharset() } : new Object[0];
+ }
+
+ @Override
+ public void addItemListener(ItemListener l) {
+ listeners.add(l);
+ }
+
+ @Override
+ public void removeItemListener(ItemListener l) {
+ listeners.remove(l);
+ }
+
+}
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerOptionsDialog.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerOptionsDialog.java
index d5d8a1a6e1..0ed4b27c7a 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerOptionsDialog.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerOptionsDialog.java
@@ -15,7 +15,8 @@
*/
package ghidra.app.plugin.core.byteviewer;
-import java.awt.*;
+import java.awt.Component;
+import java.awt.GridLayout;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.math.BigInteger;
@@ -35,14 +36,13 @@ import generic.theme.GThemeDefaults.Colors;
import generic.theme.GThemeDefaults.Colors.Messages;
import ghidra.app.plugin.core.format.DataFormatModel;
import ghidra.util.HelpLocation;
-import ghidra.util.charset.CharsetInfo;
-import ghidra.util.charset.picker.CharsetPickerDialog;
+import ghidra.util.charset.picker.CharsetPickerField;
import ghidra.util.layout.PairLayout;
import ghidra.util.layout.VerticalLayout;
public class ByteViewerOptionsDialog extends DialogComponentProvider {
- private JTextField charsetField;
+ private CharsetPickerField charsetField;
private BrowseButton charsetPickerButton;
private ByteViewerComponentProvider provider;
private ByteViewerConfigOptions configOptions;
@@ -214,18 +214,10 @@ public class ByteViewerOptionsDialog extends DialogComponentProvider {
panel.add(hexGroupSizeSpinner.getSpinner());
panel.add(new GLabel("Charset:"));
- charsetField = new JTextField();
- charsetField.setEditable(false);
- charsetField.setText(configOptions.getCharsetInfo().getName());
- charsetField.getAccessibleContext().setAccessibleName("Character Set Name");
-
- charsetPickerButton = new BrowseButton();
- charsetPickerButton.addActionListener(e -> pickCharset());
- charsetPickerButton.getAccessibleContext().setAccessibleName("Character Set Picker");
- JPanel charsetPanel = new JPanel(new BorderLayout());
- charsetPanel.add(charsetField, BorderLayout.CENTER);
- charsetPanel.add(charsetPickerButton, BorderLayout.EAST);
- panel.add(charsetPanel);
+ charsetField = new CharsetPickerField(configOptions.getCharsetInfo());
+ charsetField.setClearButtonVisible(false);
+ charsetField.addItemListener(_ -> updateCharset());
+ panel.add(charsetField);
panel.add(new GLabel("Compact Char Width:"));
GCheckBox compactChars = new GCheckBox();
@@ -279,16 +271,8 @@ public class ByteViewerOptionsDialog extends DialogComponentProvider {
updateButtonEnablement();
}
- private void pickCharset() {
- CharsetInfo newCSI = CharsetPickerDialog.pickCharset(configOptions.getCharsetInfo());
- if (newCSI != null) {
- setCharsetInfo(newCSI);
- }
- }
-
- private void setCharsetInfo(CharsetInfo newCSI) {
- configOptions.setCharsetInfo(newCSI);
- charsetField.setText(newCSI.getName());
+ private void updateCharset() {
+ configOptions.setCharsetInfo(charsetField.getCharsetInfo());
}
private JPanel buildModelPickerPanel() {
diff --git a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/EncodedStringsDialogScreenShots.java b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/EncodedStringsDialogScreenShots.java
index d7553f7c20..95d73d47ee 100644
--- a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/EncodedStringsDialogScreenShots.java
+++ b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/EncodedStringsDialogScreenShots.java
@@ -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.
@@ -20,6 +20,7 @@ import java.nio.charset.StandardCharsets;
import org.junit.Before;
import org.junit.Test;
+import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
import ghidra.app.plugin.core.strings.EncodedStringsDialog;
import ghidra.app.plugin.core.strings.EncodedStringsPlugin;
import ghidra.app.services.ProgramManager;
@@ -84,7 +85,8 @@ public class EncodedStringsDialogScreenShots extends GhidraScreenShotGenerator {
public void testEncodedStringsDialog_initial() {
positionListingTop(0x50);
makeSelection(0x50, 0x500);
- performAction(plugin.getSearchForEncodedStringsAction());
+ performAction(plugin.getSearchForEncodedStringsAction(),
+ getComponentProvider(CodeViewerProvider.class), false);
EncodedStringsDialog dialog = waitForDialogComponent(EncodedStringsDialog.class);
waitForTableModel(dialog.getStringModel());
@@ -96,7 +98,8 @@ public class EncodedStringsDialogScreenShots extends GhidraScreenShotGenerator {
public void testEncodedStringsDialog_advancedoptions() {
positionListingTop(0x50);
makeSelection(0x50, 0x500);
- performAction(plugin.getSearchForEncodedStringsAction());
+ performAction(plugin.getSearchForEncodedStringsAction(),
+ getComponentProvider(CodeViewerProvider.class), false);
EncodedStringsDialog dialog = waitForDialogComponent(EncodedStringsDialog.class);
Swing.runNow(() -> {
@@ -104,7 +107,7 @@ public class EncodedStringsDialogScreenShots extends GhidraScreenShotGenerator {
dialog.setShowScriptOptions(true);
dialog.setAllowAnyScriptOption(true);
dialog.setRequireValidStringOption(false);
- dialog.setSelectedCharset("UTF-8");
+ dialog.setSelectedCharset(StandardCharsets.UTF_8);
});
waitForTableModel(dialog.getStringModel());
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/strings/EncodedStringsDialogTest.java b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/strings/EncodedStringsDialogTest.java
index 99b72cb40f..dd8d604c32 100644
--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/strings/EncodedStringsDialogTest.java
+++ b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/strings/EncodedStringsDialogTest.java
@@ -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.
@@ -124,7 +124,7 @@ public class EncodedStringsDialogTest extends AbstractProgramBasedTest {
public void testUTF8() {
showDialog(ram.getAddressRange());
Swing.runNow(() -> {
- dialog.setSelectedCharset("UTF-8");
+ dialog.setSelectedCharset(StandardCharsets.UTF_8);
});
waitForTableModel(tableModel);
assertEquals(4, tableModel.getRowCount());
@@ -136,7 +136,7 @@ public class EncodedStringsDialogTest extends AbstractProgramBasedTest {
Swing.runNow(() -> {
dialog.setShowAdvancedOptions(true);
dialog.setExcludeNonStdCtrlChars(false);
- dialog.setSelectedCharset("UTF-8");
+ dialog.setSelectedCharset(StandardCharsets.UTF_8);
});
waitForTableModel(tableModel);
assertEquals(5, tableModel.getRowCount());
@@ -148,7 +148,7 @@ public class EncodedStringsDialogTest extends AbstractProgramBasedTest {
Swing.runNow(() -> {
dialog.setShowAdvancedOptions(true);
dialog.setRequireValidStringOption(false);
- dialog.setSelectedCharset("UTF-8");
+ dialog.setSelectedCharset(StandardCharsets.UTF_8);
});
waitForTableModel(tableModel);
assertEquals(4, tableModel.getRowCount());