mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-25 05:32:14 +00:00
Merge remote-tracking branch
'origin/GP-4414_ghidragon_export_options_not_screen_reader_friendly--SQUASHED' (Closes #6279)
This commit is contained in:
commit
1fa19633d3
@ -64,12 +64,12 @@ import ghidra.util.task.*;
|
||||
public class ExporterDialog extends DialogComponentProvider implements AddressFactoryService {
|
||||
|
||||
private static final String XML_WARNING =
|
||||
" Warning: XML is lossy and intended only for transfering data to external tools. " +
|
||||
"GZF is the recommended format for saving and sharing program data.";
|
||||
" Warning: XML is lossy and intended only for transfering data to external tools. " +
|
||||
"GZF is the recommended format for saving and sharing program data.";
|
||||
|
||||
private static final String SARIF_WARNING =
|
||||
" Warning: SARIF is lossy and intended only for transfering data to external tools. " +
|
||||
"GZF is the recommended format for saving and sharing program data.";
|
||||
" Warning: SARIF is lossy and intended only for transfering data to external tools. " +
|
||||
"GZF is the recommended format for saving and sharing program data.";
|
||||
|
||||
private static String lastUsedExporterName = GzfExporter.NAME; // default to GZF first time
|
||||
|
||||
@ -216,6 +216,8 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
||||
selectionOnlyLabel = new GLabel("Selection Only:");
|
||||
if (!isFrontEndPlugin()) {
|
||||
selectionCheckBox = new GCheckBox("");
|
||||
selectionCheckBox.setToolTipText("Select to only export from selected program areas");
|
||||
selectionCheckBox.getAccessibleContext().setAccessibleName("Selection Only");
|
||||
updateSelectionCheckbox();
|
||||
panel.add(selectionOnlyLabel);
|
||||
panel.add(selectionCheckBox);
|
||||
@ -226,6 +228,7 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
||||
private Component buildFilePanel() {
|
||||
filePathTextField = new JTextField();
|
||||
filePathTextField.setName("OUTPUT_FILE_TEXTFIELD");
|
||||
filePathTextField.getAccessibleContext().setAccessibleName("Output File");
|
||||
filePathTextField.setText(getFileName());
|
||||
filePathTextField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
@ -246,6 +249,8 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
||||
});
|
||||
|
||||
fileChooserButton = new BrowseButton();
|
||||
fileChooserButton.getAccessibleContext()
|
||||
.setAccessibleDescription("Invoke file chooser dialog to pick output file");
|
||||
fileChooserButton.addActionListener(e -> chooseDestinationFile());
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
@ -308,6 +313,7 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
||||
comboBox.setSelectedItem(defaultExporter);
|
||||
}
|
||||
comboBox.addItemListener(e -> selectedFormatChanged());
|
||||
comboBox.getAccessibleContext().setAccessibleName("Format");
|
||||
return comboBox;
|
||||
}
|
||||
|
||||
@ -490,10 +496,8 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
||||
String msg = "Could not open file: " + domainFile.getName() +
|
||||
"\n\nAvailable export options will be limited.";
|
||||
if (e.isUpgradable()) {
|
||||
msg +=
|
||||
"\n\nA data upgrade is required. You may open file" +
|
||||
"\nin a tool first then Export if a different exporter" +
|
||||
"\nis required.";
|
||||
msg += "\n\nA data upgrade is required. You may open file" +
|
||||
"\nin a tool first then Export if a different exporter" + "\nis required.";
|
||||
}
|
||||
else {
|
||||
msg += "\nFile was created with a newer version of Ghidra";
|
||||
@ -621,9 +625,8 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
||||
try {
|
||||
Map<String, String> metadata =
|
||||
domainObject != null ? domainObject.getMetadata() : domainFile.getMetadata();
|
||||
AboutDomainObjectUtils.displayInformation(tool, domainFile,
|
||||
metadata, "Export Results Summary", resultsBuffer.toString(),
|
||||
helpLocation);
|
||||
AboutDomainObjectUtils.displayInformation(tool, domainFile, metadata,
|
||||
"Export Results Summary", resultsBuffer.toString(), helpLocation);
|
||||
}
|
||||
finally {
|
||||
if (domainObject != null) {
|
||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
@ -72,36 +71,42 @@ public class OptionsEditorPanel extends JPanel {
|
||||
}
|
||||
|
||||
private Component buildOptionGroupPanel(List<Option> optionGroup) {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
JPanel innerPanel = buildInnerOptionsPanel(optionGroup);
|
||||
panel.add(innerPanel, BorderLayout.CENTER);
|
||||
|
||||
if (needsSelectAllDeselectAllButton(optionGroup)) {
|
||||
panel.add(buildSelectAllDeselectAllButtonPanel(innerPanel), BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
panel.setBorder(createBorder(optionGroup.get(0).getGroup()));
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component buildSelectAllDeselectAllButtonPanel(JPanel innerPanel) {
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
||||
List<JCheckBox> list = findAllCheckBoxes(innerPanel);
|
||||
buttonPanel.add(buildSelectAll(list));
|
||||
buttonPanel.add(buildDeselectAll(list));
|
||||
buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
|
||||
return buttonPanel;
|
||||
}
|
||||
|
||||
private JPanel buildInnerOptionsPanel(List<Option> optionGroup) {
|
||||
JPanel panel = new JPanel(getBestLayout());
|
||||
String group = optionGroup.get(0).getGroup();
|
||||
|
||||
panel.setBorder(createBorder(group));
|
||||
for (Option option : optionGroup) {
|
||||
Component editorComponent = getEditorComponent(option);
|
||||
if (editorComponent != null) {
|
||||
// Editor not available - omit option from panel
|
||||
panel.add(new GLabel(option.getName(), SwingConstants.RIGHT));
|
||||
GLabel label = new GLabel(option.getName(), SwingConstants.RIGHT);
|
||||
panel.add(label);
|
||||
editorComponent.setName(option.getName()); // set the component name to the option name
|
||||
editorComponent.getAccessibleContext().setAccessibleName(option.getName());
|
||||
panel.add(editorComponent);
|
||||
}
|
||||
}
|
||||
|
||||
if (needsSelectAllDeselectAllButton(optionGroup)) {
|
||||
JPanel wrapperPanel = new JPanel(new BorderLayout());
|
||||
wrapperPanel.add(panel, BorderLayout.CENTER);
|
||||
List<JCheckBox> list = findAllCheckBoxes(panel);
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
||||
buttonPanel.add(buildSelectAll(list));
|
||||
buttonPanel.add(buildDeselectAll(list));
|
||||
wrapperPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||
Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
|
||||
Border marginBorder = BorderFactory.createEmptyBorder(10, 0, 10, 10);
|
||||
panel.setBorder(BorderFactory.createCompoundBorder(etchedBorder, marginBorder));
|
||||
buttonPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
|
||||
return wrapperPanel;
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
@ -154,7 +159,8 @@ public class OptionsEditorPanel extends JPanel {
|
||||
}
|
||||
|
||||
private Map<String, List<Option>> organizeByGroup(List<Option> options) {
|
||||
Map<String, List<Option>> map = LazyMap.lazyMap(new HashMap<>(), () -> new ArrayList<>());
|
||||
Map<String, List<Option>> map =
|
||||
LazyMap.lazyMap(new LinkedHashMap<>(), () -> new ArrayList<>());
|
||||
|
||||
for (Option option : options) {
|
||||
String group = option.getGroup();
|
||||
|
@ -23,7 +23,7 @@ import ghidra.framework.options.SaveState;
|
||||
|
||||
class ProgramTextOptions {
|
||||
|
||||
final static String OPTION_WIDTH = "Width";
|
||||
final static String OPTION_FIELD_WIDTHS = "Field Widths";
|
||||
final static String OPTION_WIDTH_ADDR = " Address ";
|
||||
final static String OPTION_WIDTH_BYTES = " Bytes ";
|
||||
final static String OPTION_WIDTH_PREMNEMONIC = " PreMnemonic ";
|
||||
@ -34,7 +34,7 @@ class ProgramTextOptions {
|
||||
final static String OPTION_WIDTH_REF = " References ";
|
||||
final static String OPTION_WIDTH_DATA_FIELD = " Data Field Name ";
|
||||
|
||||
final static String OPTION_SHOW = "Show";
|
||||
final static String OPTION_INCLUDED_TYPES = "Included Types";
|
||||
final static String OPTION_SHOW_COMMENTS = " Comments ";
|
||||
final static String OPTION_SHOW_PROPERTIES = " Properties ";
|
||||
final static String OPTION_SHOW_STRUCTURES = " Structures ";
|
||||
@ -45,7 +45,7 @@ class ProgramTextOptions {
|
||||
final static String OPTION_SHOW_FUNCTIONS = " Functions ";
|
||||
final static String OPTION_SHOW_BLOCK_NAMES = " Block Names ";
|
||||
|
||||
final static String OPTION_ADV = "Advanced";
|
||||
final static String OPTION_PREFIXES = "Special Prefixes";
|
||||
final static String OPTION_ADV_LABEL_SUFFIX = " Label Suffix ";
|
||||
final static String OPTION_ADV_COMMENT_SUFFIX = " Comment Prefix ";
|
||||
|
||||
@ -106,28 +106,38 @@ class ProgramTextOptions {
|
||||
|
||||
List<Option> getOptions() {//TODO add right into list
|
||||
Option[] options = new Option[] {
|
||||
new Option(OPTION_WIDTH, OPTION_WIDTH_LABEL, Integer.valueOf(labelWidth)),
|
||||
new Option(OPTION_WIDTH, OPTION_WIDTH_ADDR, Integer.valueOf(addrWidth)),
|
||||
new Option(OPTION_WIDTH, OPTION_WIDTH_BYTES, Integer.valueOf(bytesWidth)),
|
||||
new Option(OPTION_WIDTH, OPTION_WIDTH_PREMNEMONIC, Integer.valueOf(preMnemonicWidth)),
|
||||
new Option(OPTION_WIDTH, OPTION_WIDTH_MNEMONIC, Integer.valueOf(mnemonicWidth)),
|
||||
new Option(OPTION_WIDTH, OPTION_WIDTH_OPERAND, Integer.valueOf(operandWidth)),
|
||||
new Option(OPTION_WIDTH, OPTION_WIDTH_EOL, Integer.valueOf(eolWidth)),
|
||||
new Option(OPTION_WIDTH, OPTION_WIDTH_REF, Integer.valueOf(refWidth)),
|
||||
new Option(OPTION_WIDTH, OPTION_WIDTH_DATA_FIELD, Integer.valueOf(dataFieldNameWidth)),
|
||||
new Option(OPTION_INCLUDED_TYPES, OPTION_SHOW_COMMENTS, Boolean.valueOf(showComments)),
|
||||
new Option(OPTION_INCLUDED_TYPES, OPTION_SHOW_PROPERTIES,
|
||||
Boolean.valueOf(showProperties)),
|
||||
new Option(OPTION_INCLUDED_TYPES, OPTION_SHOW_STRUCTURES,
|
||||
Boolean.valueOf(showStructures)),
|
||||
new Option(OPTION_INCLUDED_TYPES, OPTION_SHOW_UNDEFINED,
|
||||
Boolean.valueOf(showUndefinedData)),
|
||||
new Option(OPTION_INCLUDED_TYPES, OPTION_SHOW_REF_HEADER,
|
||||
Boolean.valueOf(showReferenceHeaders)),
|
||||
new Option(OPTION_INCLUDED_TYPES, OPTION_SHOW_BACK_REFS,
|
||||
Boolean.valueOf(showBackReferences)),
|
||||
new Option(OPTION_INCLUDED_TYPES, OPTION_SHOW_FORWARD_REFS,
|
||||
Boolean.valueOf(showForwardReferences)),
|
||||
new Option(OPTION_INCLUDED_TYPES, OPTION_SHOW_FUNCTIONS,
|
||||
Boolean.valueOf(showFunctions)),
|
||||
new Option(OPTION_INCLUDED_TYPES, OPTION_SHOW_BLOCK_NAMES,
|
||||
Boolean.valueOf(showBlockNameInOperands)),
|
||||
|
||||
new Option(OPTION_SHOW, OPTION_SHOW_COMMENTS, Boolean.valueOf(showComments)),
|
||||
new Option(OPTION_SHOW, OPTION_SHOW_PROPERTIES, Boolean.valueOf(showProperties)),
|
||||
new Option(OPTION_SHOW, OPTION_SHOW_STRUCTURES, Boolean.valueOf(showStructures)),
|
||||
new Option(OPTION_SHOW, OPTION_SHOW_UNDEFINED, Boolean.valueOf(showUndefinedData)),
|
||||
new Option(OPTION_SHOW, OPTION_SHOW_REF_HEADER, Boolean.valueOf(showReferenceHeaders)),
|
||||
new Option(OPTION_SHOW, OPTION_SHOW_BACK_REFS, Boolean.valueOf(showBackReferences)),
|
||||
new Option(OPTION_SHOW, OPTION_SHOW_FORWARD_REFS, Boolean.valueOf(showForwardReferences)),
|
||||
new Option(OPTION_SHOW, OPTION_SHOW_FUNCTIONS, Boolean.valueOf(showFunctions)),
|
||||
new Option(OPTION_SHOW, OPTION_SHOW_BLOCK_NAMES, Boolean.valueOf(showBlockNameInOperands)),
|
||||
new Option(OPTION_FIELD_WIDTHS, OPTION_WIDTH_LABEL, Integer.valueOf(labelWidth)),
|
||||
new Option(OPTION_FIELD_WIDTHS, OPTION_WIDTH_ADDR, Integer.valueOf(addrWidth)),
|
||||
new Option(OPTION_FIELD_WIDTHS, OPTION_WIDTH_BYTES, Integer.valueOf(bytesWidth)),
|
||||
new Option(OPTION_FIELD_WIDTHS, OPTION_WIDTH_PREMNEMONIC,
|
||||
Integer.valueOf(preMnemonicWidth)),
|
||||
new Option(OPTION_FIELD_WIDTHS, OPTION_WIDTH_MNEMONIC, Integer.valueOf(mnemonicWidth)),
|
||||
new Option(OPTION_FIELD_WIDTHS, OPTION_WIDTH_OPERAND, Integer.valueOf(operandWidth)),
|
||||
new Option(OPTION_FIELD_WIDTHS, OPTION_WIDTH_EOL, Integer.valueOf(eolWidth)),
|
||||
new Option(OPTION_FIELD_WIDTHS, OPTION_WIDTH_REF, Integer.valueOf(refWidth)),
|
||||
new Option(OPTION_FIELD_WIDTHS, OPTION_WIDTH_DATA_FIELD,
|
||||
Integer.valueOf(dataFieldNameWidth)),
|
||||
|
||||
new Option(OPTION_ADV, OPTION_ADV_LABEL_SUFFIX, labelSuffix),
|
||||
new Option(OPTION_ADV, OPTION_ADV_COMMENT_SUFFIX, commentPrefix), };
|
||||
new Option(OPTION_PREFIXES, OPTION_ADV_LABEL_SUFFIX, labelSuffix),
|
||||
new Option(OPTION_PREFIXES, OPTION_ADV_COMMENT_SUFFIX, commentPrefix), };
|
||||
List<Option> optionsList = new ArrayList<Option>();
|
||||
Collections.addAll(optionsList, options);
|
||||
return optionsList;
|
||||
@ -139,7 +149,7 @@ class ProgramTextOptions {
|
||||
String groupName = option.getGroup();
|
||||
String optionName = option.getName();
|
||||
try {
|
||||
if (groupName.equals(OPTION_WIDTH)) {
|
||||
if (groupName.equals(OPTION_FIELD_WIDTHS)) {
|
||||
int value = ((Integer) option.getValue()).intValue();
|
||||
|
||||
if (optionName.equals(OPTION_WIDTH_LABEL)) {
|
||||
@ -173,7 +183,7 @@ class ProgramTextOptions {
|
||||
wasOptionHandled = false;
|
||||
}
|
||||
}
|
||||
else if (groupName.equals(OPTION_SHOW)) {
|
||||
else if (groupName.equals(OPTION_INCLUDED_TYPES)) {
|
||||
boolean value = ((Boolean) option.getValue()).booleanValue();
|
||||
|
||||
if (optionName.equals(OPTION_SHOW_COMMENTS)) {
|
||||
@ -207,7 +217,7 @@ class ProgramTextOptions {
|
||||
wasOptionHandled = false;
|
||||
}
|
||||
}
|
||||
else if (groupName.equals(OPTION_ADV)) {
|
||||
else if (groupName.equals(OPTION_PREFIXES)) {
|
||||
String value = (String) option.getValue();
|
||||
|
||||
if (optionName.equals(OPTION_ADV_COMMENT_SUFFIX)) {
|
||||
@ -392,7 +402,7 @@ class ProgramTextOptions {
|
||||
}
|
||||
|
||||
boolean isShowFunctionLabel() {
|
||||
return false;//TODO:
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isShowBlockName() {
|
||||
|
@ -61,6 +61,7 @@ public class DefaultOptionComponent extends GenericOptionsComponent {
|
||||
}
|
||||
add(label);
|
||||
add(component);
|
||||
component.getAccessibleContext().setAccessibleName(label.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user