Merge remote-tracking branch 'origin/GP-2795-dragonmacher-theme-cleanup-buttons--SQUASHED'

This commit is contained in:
Ryan Kurtz 2022-12-13 06:30:39 -05:00
commit 5e2bbde8dd
29 changed files with 364 additions and 555 deletions

View file

@ -19,10 +19,10 @@ import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import docking.ActionContext; import docking.ActionContext;
import docking.WindowPosition; import docking.WindowPosition;
import docking.options.editor.ButtonPanelFactory;
import docking.util.image.ToolIconURL; import docking.util.image.ToolIconURL;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.label.*; import docking.widgets.label.*;
@ -238,8 +238,19 @@ class MergeManagerProvider extends ComponentProviderAdapter {
cancelButton = new JButton("Cancel"); cancelButton = new JButton("Cancel");
cancelButton.addActionListener(e -> cancelCallback(false)); cancelButton.addActionListener(e -> cancelCallback(false));
JPanel panel = ButtonPanelFactory.createButtonPanel( JPanel panel = new JPanel();
new JButton[] { applyButton, cancelButton }, ButtonPanelFactory.X_AXIS); JPanel subPanel = new JPanel();
panel.add(subPanel);
subPanel.setLayout(new GridLayout(1, 0, 10, 0));
int top = 8;
int side = 20;
Border inside = BorderFactory.createEmptyBorder(top, side, top, side);
subPanel.setBorder(inside);
subPanel.add(applyButton);
subPanel.add(cancelButton);
return panel; return panel;
} }

View file

@ -26,8 +26,8 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.button.BrowseButton;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
@ -169,8 +169,8 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
} }
}; };
OptionsDialog optionsDialog = new OptionsDialog(options, validator, this); OptionsDialog optionsDialog = new OptionsDialog(options, validator, this);
optionsDialog.setHelpLocation( optionsDialog
new HelpLocation("ExporterPlugin", getAnchorForSelectedFormat())); .setHelpLocation(new HelpLocation("ExporterPlugin", getAnchorForSelectedFormat()));
tool.showDialog(optionsDialog); tool.showDialog(optionsDialog);
if (!optionsDialog.wasCancelled()) { if (!optionsDialog.wasCancelled()) {
options = optionsDialog.getOptions(); options = optionsDialog.getOptions();
@ -230,7 +230,7 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
}); });
fileChooserButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); fileChooserButton = new BrowseButton();
fileChooserButton.addActionListener(e -> chooseDestinationFile()); fileChooserButton.addActionListener(e -> chooseDestinationFile());
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());

View file

@ -25,7 +25,7 @@ import javax.swing.*;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory; import docking.widgets.button.BrowseButton;
import docking.widgets.button.GRadioButton; import docking.widgets.button.GRadioButton;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
@ -194,8 +194,8 @@ public class SearchStringDialog extends DialogComponentProvider {
JLabel alignLabel = new GLabel("Alignment: "); JLabel alignLabel = new GLabel("Alignment: ");
alignLabel.setName("alignment"); alignLabel.setName("alignment");
alignLabel.setToolTipText( alignLabel
"<html>Searches for strings that start on the given alignment<br>" + .setToolTipText("<html>Searches for strings that start on the given alignment<br>" +
"value. The default alignment is processor dependent."); "value. The default alignment is processor dependent.");
panel.add(alignLabel); panel.add(alignLabel);
@ -230,7 +230,7 @@ public class SearchStringDialog extends DialogComponentProvider {
modelFieldPanel.add(wordModelField); modelFieldPanel.add(wordModelField);
// Set up a file chooser that allows the user to select a new *.sng file. // Set up a file chooser that allows the user to select a new *.sng file.
JButton browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton browseButton = new BrowseButton();
browseButton.addActionListener(new ActionListener() { browseButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -273,8 +273,8 @@ public class SearchStringDialog extends DialogComponentProvider {
memoryBlockGroup.add(loadedBlocksRB); memoryBlockGroup.add(loadedBlocksRB);
memoryBlockGroup.add(allBlocksRB); memoryBlockGroup.add(allBlocksRB);
loadedBlocksRB.setToolTipText(HTMLUtilities.toHTML( loadedBlocksRB.setToolTipText(HTMLUtilities
"Only searches memory blocks that are loaded in a running executable.\n " + .toHTML("Only searches memory blocks that are loaded in a running executable.\n " +
"Ghidra now includes memory blocks for other data such as section headers.\n" + "Ghidra now includes memory blocks for other data such as section headers.\n" +
"This option exludes these other (non-loaded) blocks.")); "This option exludes these other (non-loaded) blocks."));
allBlocksRB.setToolTipText( allBlocksRB.setToolTipText(

View file

@ -28,7 +28,7 @@ import javax.swing.event.DocumentListener;
import org.apache.commons.collections4.map.LazyMap; import org.apache.commons.collections4.map.LazyMap;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import docking.options.editor.ButtonPanelFactory; import docking.widgets.button.BrowseButton;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.combobox.GComboBox; import docking.widgets.combobox.GComboBox;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
@ -244,10 +244,10 @@ public class OptionsEditorPanel extends JPanel {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
JTextField textField = new JTextField(); JTextField textField = new JTextField();
textField.setEditable(false); textField.setEditable(false);
JButton button = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton button = new BrowseButton();
button.addActionListener(e -> { button.addActionListener(e -> {
DataTreeDialog dataTreeDialog = new DataTreeDialog(this, DataTreeDialog dataTreeDialog =
"Choose a project folder", DataTreeDialog.CHOOSE_FOLDER); new DataTreeDialog(this, "Choose a project folder", DataTreeDialog.CHOOSE_FOLDER);
dataTreeDialog.setSelectedFolder(null); dataTreeDialog.setSelectedFolder(null);
dataTreeDialog.showComponent(); dataTreeDialog.showComponent();
DomainFolder folder = dataTreeDialog.getDomainFolder(); DomainFolder folder = dataTreeDialog.getDomainFolder();

View file

@ -21,8 +21,8 @@ import javax.swing.*;
import javax.swing.event.*; import javax.swing.event.*;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.DropDownSelectionTextField; import docking.widgets.DropDownSelectionTextField;
import docking.widgets.button.BrowseButton;
import ghidra.app.plugin.core.datamgr.util.DataTypeChooserDialog; import ghidra.app.plugin.core.datamgr.util.DataTypeChooserDialog;
import ghidra.app.plugin.core.datamgr.util.DataTypeUtils; import ghidra.app.plugin.core.datamgr.util.DataTypeUtils;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
@ -133,7 +133,7 @@ public class DataTypeSelectionEditor extends AbstractCellEditor {
selectionField.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); selectionField.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); browseButton = new BrowseButton();
browseButton.setToolTipText("Browse the Data Manager"); browseButton.setToolTipText("Browse the Data Manager");
browseButton.addActionListener(e -> showDataTypeBrowser()); browseButton.addActionListener(e -> showDataTypeBrowser());

View file

@ -31,8 +31,8 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.EmptyBorderButton; import docking.widgets.EmptyBorderButton;
import docking.widgets.button.BrowseButton;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.dialogs.MultiLineMessageDialog; import docking.widgets.dialogs.MultiLineMessageDialog;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
@ -212,7 +212,7 @@ public class ImporterDialog extends DialogComponentProvider {
folderNameTextField = new JTextField(); folderNameTextField = new JTextField();
folderNameTextField.setEditable(false); folderNameTextField.setEditable(false);
folderNameTextField.setFocusable(false); folderNameTextField.setFocusable(false);
folderButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); folderButton = new BrowseButton();
folderButton.addActionListener(e -> chooseProjectFolder()); folderButton.addActionListener(e -> chooseProjectFolder());
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
@ -226,7 +226,7 @@ public class ImporterDialog extends DialogComponentProvider {
languageTextField.setEditable(false); languageTextField.setEditable(false);
languageTextField.setFocusable(false); languageTextField.setFocusable(false);
languageButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); languageButton = new BrowseButton();
languageButton.addActionListener(e -> { languageButton.addActionListener(e -> {
Object selectedItem = loaderComboBox.getSelectedItem(); Object selectedItem = loaderComboBox.getSelectedItem();
if (selectedItem instanceof Loader) { if (selectedItem instanceof Loader) {
@ -277,8 +277,7 @@ public class ImporterDialog extends DialogComponentProvider {
private Component buildLoaderInfoButton() { private Component buildLoaderInfoButton() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
EmptyBorderButton helpButton = EmptyBorderButton helpButton = new EmptyBorderButton(new GIcon("icon.information"));
new EmptyBorderButton(new GIcon("icon.information"));
helpButton.setToolTipText("Show list of supported format/loaders"); helpButton.setToolTipText("Show list of supported format/loaders");
helpButton.addActionListener(e -> showSupportedImportFormats()); helpButton.addActionListener(e -> showSupportedImportFormats());

View file

@ -19,7 +19,7 @@ import java.awt.*;
import javax.swing.*; import javax.swing.*;
import docking.options.editor.ButtonPanelFactory; import docking.widgets.button.BrowseButton;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import ghidra.framework.main.AppInfo; import ghidra.framework.main.AppInfo;
import ghidra.framework.main.DataTreeDialog; import ghidra.framework.main.DataTreeDialog;
@ -53,7 +53,7 @@ class BatchProjectDestinationPanel extends JPanel {
JLabel folderLabel = new GDLabel("Destination Folder"); JLabel folderLabel = new GDLabel("Destination Folder");
folderLabel.setLabelFor(folderNameTextField); folderLabel.setLabelFor(folderNameTextField);
JButton browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton browseButton = new BrowseButton();
browseButton.addActionListener(e -> browseFolders()); browseButton.addActionListener(e -> browseFolders());
//ImporterUtils.changeFontToBold(browseButton); //ImporterUtils.changeFontToBold(browseButton);

View file

@ -37,9 +37,9 @@ import org.junit.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingDialog; import docking.DockingDialog;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.DropDownSelectionTextField; import docking.widgets.DropDownSelectionTextField;
import docking.widgets.DropDownTextFieldDataModel; import docking.widgets.DropDownTextFieldDataModel;
import docking.widgets.button.BrowseButton;
import docking.widgets.tree.GTree; import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode; import docking.widgets.tree.GTreeNode;
import generic.test.AbstractGTest; import generic.test.AbstractGTest;
@ -194,8 +194,9 @@ public class DataTypeSelectionDialogTest extends AbstractGhidraHeadedIntegration
assertTrue("The dialog was not made visible when tool.showDialog() was called.", assertTrue("The dialog was not made visible when tool.showDialog() was called.",
dialog.isVisible()); dialog.isVisible());
final JButton browseButton = findButtonByIcon(dialog, ButtonPanelFactory.BROWSE_ICON); AbstractButton browseButton =
pressButton(browseButton); findAbstractButtonByName(dialog.getComponent(), BrowseButton.NAME);
pressButton(browseButton, false);
Window window = waitForWindow("Data Type Chooser"); Window window = waitForWindow("Data Type Chooser");
@ -241,7 +242,7 @@ public class DataTypeSelectionDialogTest extends AbstractGhidraHeadedIntegration
doubleNode.getDataType().getName(), dataType.getName()); doubleNode.getDataType().getName(), dataType.getName());
// show the dialog again and cancel and make sure that the user selection is null // show the dialog again and cancel and make sure that the user selection is null
pressButton(browseButton); pressButton(browseButton, false);
window = waitForWindow("Data Type Chooser"); window = waitForWindow("Data Type Chooser");
assertTrue("The data type selection tree was not shown after pressing the browse button", assertTrue("The data type selection tree was not shown after pressing the browse button",
(window instanceof DockingDialog)); (window instanceof DockingDialog));
@ -263,11 +264,7 @@ public class DataTypeSelectionDialogTest extends AbstractGhidraHeadedIntegration
} }
private void waitForDialogToClose(DockingDialog dockingDialog) { private void waitForDialogToClose(DockingDialog dockingDialog) {
int count = 0; waitForCondition(() -> !dialog.isShowing(), "Dialog did not close!");
while (dockingDialog.isShowing() && count < 500) {
sleep(50);
}
assertTrue("Dialog did not close!", !dockingDialog.isShowing());
waitForSwing(); waitForSwing();
} }

View file

@ -25,9 +25,10 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory; import docking.widgets.button.BrowseButton;
import docking.widgets.combobox.GComboBox; import docking.widgets.combobox.GComboBox;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import ghidra.app.script.SelectLanguageDialog; import ghidra.app.script.SelectLanguageDialog;
@ -148,11 +149,11 @@ public class PopulateFidDialog extends DialogComponentProvider {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
symbolsFileTextField = new JTextField(); symbolsFileTextField = new JTextField();
panel.add(symbolsFileTextField, BorderLayout.CENTER); panel.add(symbolsFileTextField, BorderLayout.CENTER);
JButton browseButton = createBrowseButton(); JButton browseButton = new BrowseButton();
browseButton.addActionListener(e -> { browseButton.addActionListener(e -> {
GhidraFileChooser chooser = new GhidraFileChooser(tool.getToolFrame()); GhidraFileChooser chooser = new GhidraFileChooser(tool.getToolFrame());
chooser.setTitle("Choose Common Symbols File"); chooser.setTitle("Choose Common Symbols File");
chooser.setFileSelectionMode(GhidraFileChooser.FILES_ONLY); chooser.setFileSelectionMode(GhidraFileChooserMode.FILES_ONLY);
// chooser.setFileFilter(null); // chooser.setFileFilter(null);
File selectedFile = chooser.getSelectedFile(); File selectedFile = chooser.getSelectedFile();
if (selectedFile != null) { if (selectedFile != null) {
@ -168,7 +169,7 @@ public class PopulateFidDialog extends DialogComponentProvider {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
languageIdField = new JTextField(); languageIdField = new JTextField();
panel.add(languageIdField, BorderLayout.CENTER); panel.add(languageIdField, BorderLayout.CENTER);
JButton browseButton = createBrowseButton(); JButton browseButton = new BrowseButton();
browseButton.addActionListener(e -> { browseButton.addActionListener(e -> {
SelectLanguageDialog selectLanguageDialog = SelectLanguageDialog selectLanguageDialog =
new SelectLanguageDialog("Select Language", "Ok"); new SelectLanguageDialog("Select Language", "Ok");
@ -220,7 +221,7 @@ public class PopulateFidDialog extends DialogComponentProvider {
domainFolderField = new JTextField(); domainFolderField = new JTextField();
domainFolderField.setEditable(false); domainFolderField.setEditable(false);
panel.add(domainFolderField, BorderLayout.CENTER); panel.add(domainFolderField, BorderLayout.CENTER);
JButton browseButton = createBrowseButton(); JButton browseButton = new BrowseButton();
browseButton.addActionListener(e -> { browseButton.addActionListener(e -> {
final DataTreeDialog dialog = new DataTreeDialog(tool.getToolFrame(), final DataTreeDialog dialog = new DataTreeDialog(tool.getToolFrame(),
"Choose Root Folder", DataTreeDialog.CHOOSE_FOLDER); "Choose Root Folder", DataTreeDialog.CHOOSE_FOLDER);
@ -279,10 +280,6 @@ public class PopulateFidDialog extends DialogComponentProvider {
return true; return true;
} }
private JButton createBrowseButton() {
return ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
}
private static class LibraryChoice { private static class LibraryChoice {
private final String name; private final String name;
private final LibraryRecord libraryRecord; private final LibraryRecord libraryRecord;

View file

@ -26,8 +26,8 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.button.BrowseButton;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode; import docking.widgets.filechooser.GhidraFileChooserMode;
@ -128,7 +128,7 @@ public class GraphExporterDialog extends DialogComponentProvider {
}); });
fileChooserButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); fileChooserButton = new BrowseButton();
fileChooserButton.addActionListener(e -> chooseDestinationFile()); fileChooserButton.addActionListener(e -> chooseDestinationFile());
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
@ -262,8 +262,7 @@ public class GraphExporterDialog extends DialogComponentProvider {
private boolean doExport() { private boolean doExport() {
AtomicBoolean success = new AtomicBoolean(); AtomicBoolean success = new AtomicBoolean();
TaskLauncher.launchModal("Exporting Graph", TaskLauncher.launchModal("Exporting Graph", monitor -> success.set(tryExport(monitor)));
monitor -> success.set(tryExport(monitor)));
return success.get(); return success.get();
} }

View file

@ -25,8 +25,8 @@ import javax.swing.event.DocumentListener;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.button.BrowseButton;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode; import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GHtmlLabel; import docking.widgets.label.GHtmlLabel;
@ -123,7 +123,7 @@ class FilePromptDialog extends DialogComponentProvider {
updateButtonEnablement(); updateButtonEnablement();
} }
}); });
JButton browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton browseButton = new BrowseButton();
browseButton.addActionListener(e -> browse()); browseButton.addActionListener(e -> browse());
JPanel textFieldWithButtonPanel = new JPanel(new BorderLayout()); JPanel textFieldWithButtonPanel = new JPanel(new BorderLayout());

View file

@ -31,8 +31,8 @@ import javax.swing.event.DocumentListener;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import docking.event.mouse.GMouseListenerAdapter; import docking.event.mouse.GMouseListenerAdapter;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.button.BrowseButton;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.combobox.GComboBox; import docking.widgets.combobox.GComboBox;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
@ -164,8 +164,7 @@ public class LoadPdbDialog extends DialogComponentProvider {
private void updateSymbolServerServiceInstanceFromPreferences() { private void updateSymbolServerServiceInstanceFromPreferences() {
symbolServerInstanceCreatorContext = symbolServerInstanceCreatorContext =
SymbolServerInstanceCreatorRegistry.getInstance().getContext(program); SymbolServerInstanceCreatorRegistry.getInstance().getContext(program);
symbolServerService = symbolServerService = PdbPlugin.getSymbolServerService(symbolServerInstanceCreatorContext);
PdbPlugin.getSymbolServerService(symbolServerInstanceCreatorContext);
} }
@Override @Override
@ -242,21 +241,17 @@ public class LoadPdbDialog extends DialogComponentProvider {
} }
private String getSymbolFileToolText(SymbolFileLocation symbolFileLocation) { private String getSymbolFileToolText(SymbolFileLocation symbolFileLocation) {
return symbolFileLocation != null return symbolFileLocation != null ? String.format(
? String.format( "<html><table>" + "<tr><td>PDB Name:</td><td><b>%s</b></td></tr>" +
"<html><table>" +
"<tr><td>PDB Name:</td><td><b>%s</b></td></tr>" +
"<tr><td>Path:</td><td><b>%s</b></td></tr>" + "<tr><td>Path:</td><td><b>%s</b></td></tr>" +
"<tr><td>GUID/ID:</td><td><b>%s</b></td></tr>" + "<tr><td>GUID/ID:</td><td><b>%s</b></td></tr>" +
"<tr><td>Age:</td><td><b>%x</b></td></tr>" + "<tr><td>Age:</td><td><b>%x</b></td></tr>" +
"<tr><td>Is Exact Match:</td><td><b>%b</b></td</tr>" + "<tr><td>Is Exact Match:</td><td><b>%b</b></td</tr>" + "</table>",
"</table>",
HTMLUtilities.escapeHTML(symbolFileLocation.getFileInfo().getName()), HTMLUtilities.escapeHTML(symbolFileLocation.getFileInfo().getName()),
HTMLUtilities.escapeHTML(symbolFileLocation.getLocationStr()), HTMLUtilities.escapeHTML(symbolFileLocation.getLocationStr()),
symbolFileLocation.getFileInfo().getUniqueName(), symbolFileLocation.getFileInfo().getUniqueName(),
symbolFileLocation.getFileInfo().getIdentifiers().getAge(), symbolFileLocation.getFileInfo().getIdentifiers().getAge(),
symbolFileLocation.getFileInfo().isExactMatch(programSymbolFileInfo)) symbolFileLocation.getFileInfo().isExactMatch(programSymbolFileInfo)) : null;
: null;
} }
private void updateButtonEnablement() { private void updateButtonEnablement() {
@ -395,18 +390,15 @@ public class LoadPdbDialog extends DialogComponentProvider {
} }
}); });
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(overridePdbPathCheckBox, .registerHelp(overridePdbPathCheckBox, new HelpLocation(
new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, PdbPlugin.PDB_PLUGIN_HELP_TOPIC, SymbolFilePanel.SEARCH_OPTIONS_HELP_ANCHOR));
SymbolFilePanel.SEARCH_OPTIONS_HELP_ANCHOR));
pdbUniqueIdTextField = new BetterNonEditableTextField(36, "Missing", Colors.ERROR); pdbUniqueIdTextField = new BetterNonEditableTextField(36, "Missing", Colors.ERROR);
pdbUniqueIdTextField.setEditable(false); pdbUniqueIdTextField.setEditable(false);
pdbUniqueIdTextField.setText(programSymbolFileInfo.getUniqifierString()); pdbUniqueIdTextField.setText(programSymbolFileInfo.getUniqifierString());
pdbUniqueIdTextField.setToolTipText( pdbUniqueIdTextField.setToolTipText("<html>PDB GUID - 32 hexadecimal characters:<br>" +
"<html>PDB GUID - 32 hexadecimal characters:<br>" +
"&nbsp;&nbsp;<b>'012345678-0123-0123-0123-0123456789ABC'</b> (with or without dashes) or<br>" + "&nbsp;&nbsp;<b>'012345678-0123-0123-0123-0123456789ABC'</b> (with or without dashes) or<br>" +
"PDB Signature ID - 8 hexadecimal characters:<br>" + "PDB Signature ID - 8 hexadecimal characters:<br>" + "&nbsp;&nbsp;<b>'11223344'</b>");
"&nbsp;&nbsp;<b>'11223344'</b>");
pdbUniqueIdTextField.getDocument().addDocumentListener(docListener); pdbUniqueIdTextField.getDocument().addDocumentListener(docListener);
overridePdbUniqueIdCheckBox = new GCheckBox(); overridePdbUniqueIdCheckBox = new GCheckBox();
@ -422,9 +414,8 @@ public class LoadPdbDialog extends DialogComponentProvider {
} }
}); });
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(overridePdbUniqueIdCheckBox, .registerHelp(overridePdbUniqueIdCheckBox, new HelpLocation(
new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, PdbPlugin.PDB_PLUGIN_HELP_TOPIC, SymbolFilePanel.SEARCH_OPTIONS_HELP_ANCHOR));
SymbolFilePanel.SEARCH_OPTIONS_HELP_ANCHOR));
pdbAgeTextField = new BetterNonEditableHexTextField(8); pdbAgeTextField = new BetterNonEditableHexTextField(8);
pdbAgeTextField.setAllowNegative(false); pdbAgeTextField.setAllowNegative(false);
@ -446,9 +437,8 @@ public class LoadPdbDialog extends DialogComponentProvider {
} }
}); });
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(overridePdbAgeCheckBox, .registerHelp(overridePdbAgeCheckBox, new HelpLocation(
new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, PdbPlugin.PDB_PLUGIN_HELP_TOPIC, SymbolFilePanel.SEARCH_OPTIONS_HELP_ANCHOR));
SymbolFilePanel.SEARCH_OPTIONS_HELP_ANCHOR));
programPdbPanel = new JPanel(new PairLayout(5, 5)); programPdbPanel = new JPanel(new PairLayout(5, 5));
programPdbPanel.setBorder(BorderFactory.createTitledBorder("Program PDB Information")); programPdbPanel.setBorder(BorderFactory.createTitledBorder("Program PDB Information"));
@ -474,7 +464,7 @@ public class LoadPdbDialog extends DialogComponentProvider {
pdbLocationTextField = new HintTextField("Browse [...] for PDB file or use 'Advanced'"); pdbLocationTextField = new HintTextField("Browse [...] for PDB file or use 'Advanced'");
pdbLocationTextField.setEditable(false); pdbLocationTextField.setEditable(false);
choosePdbLocationButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); choosePdbLocationButton = new BrowseButton();
choosePdbLocationButton.addActionListener(e -> choosePdbFile()); choosePdbLocationButton.addActionListener(e -> choosePdbFile());
exactMatchIconLabel = new GIconLabel(Icons.EMPTY_ICON); exactMatchIconLabel = new GIconLabel(Icons.EMPTY_ICON);
@ -523,8 +513,7 @@ public class LoadPdbDialog extends DialogComponentProvider {
universalParserButton universalParserButton
.setToolTipText("Platform-independent PDB analyzer (No PDB.XML support)."); .setToolTipText("Platform-independent PDB analyzer (No PDB.XML support).");
msdiaParserButton = new JRadioButton("MSDIA"); msdiaParserButton = new JRadioButton("MSDIA");
msdiaParserButton.setToolTipText( msdiaParserButton.setToolTipText("<html>Legacy PDB Analyzer.<br>" +
"<html>Legacy PDB Analyzer.<br>" +
"Requires MS DIA-SDK for raw PDB processing (Windows only), or preprocessed PDB.XML file."); "Requires MS DIA-SDK for raw PDB processing (Windows only), or preprocessed PDB.XML file.");
universalParserButton.setSelected(true); universalParserButton.setSelected(true);
universalParserButton.addActionListener(l); universalParserButton.addActionListener(l);
@ -546,8 +535,7 @@ public class LoadPdbDialog extends DialogComponentProvider {
parserOptionsPanel.setBorder(BorderFactory.createTitledBorder("PDB Parser")); parserOptionsPanel.setBorder(BorderFactory.createTitledBorder("PDB Parser"));
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(parserOptionsPanel, .registerHelp(parserOptionsPanel,
new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "PDB Parser Panel"));
"PDB Parser Panel"));
parserOptionsPanel.add(new GLabel("Parser:")); parserOptionsPanel.add(new GLabel("Parser:"));
parserOptionsPanel.add(radioButtons); parserOptionsPanel.add(radioButtons);
@ -564,16 +552,16 @@ public class LoadPdbDialog extends DialogComponentProvider {
loadPdbButton.setName("Load"); loadPdbButton.setName("Load");
loadPdbButton.addActionListener(e -> { loadPdbButton.addActionListener(e -> {
if (selectedSymbolFile == null || if (selectedSymbolFile == null || (!selectedSymbolFile
(!selectedSymbolFile.isExactMatch(programSymbolFileInfo) && .isExactMatch(programSymbolFileInfo) &&
OptionDialog.showYesNoDialog(loadPdbButton, "Mismatched Pdb File Warning", OptionDialog.showYesNoDialog(loadPdbButton, "Mismatched Pdb File Warning",
"<html>The selected file is not an exact match for the current program.<br>" + "<html>The selected file is not an exact match for the current program.<br>" +
"Note: <b>Invalid disassembly may be produced!</b><br>" + "Note: <b>Invalid disassembly may be produced!</b><br>" +
"Continue anyway?") != OptionDialog.YES_OPTION)) { "Continue anyway?") != OptionDialog.YES_OPTION)) {
return; return;
} }
executeMonitoredRunnable("Prepare Selected Symbol File", executeMonitoredRunnable("Prepare Selected Symbol File", true, true, 0,
true, true, 0, this::prepareSelectedSymbolFileAndClose); this::prepareSelectedSymbolFileAndClose);
}); });
addButton(loadPdbButton); addButton(loadPdbButton);
@ -701,9 +689,8 @@ public class LoadPdbDialog extends DialogComponentProvider {
if (pdbSymbolFileInfo == null) { if (pdbSymbolFileInfo == null) {
pdbSymbolFileInfo = makeUnknownSymbolFileInstance(file.getName()); pdbSymbolFileInfo = makeUnknownSymbolFileInstance(file.getName());
} }
SymbolFileLocation symbolFileLocation = SymbolFileLocation symbolFileLocation = SameDirSymbolStore
SameDirSymbolStore.createManuallySelectedSymbolFileLocation(file, .createManuallySelectedSymbolFileLocation(file, pdbSymbolFileInfo);
pdbSymbolFileInfo);
Swing.runLater(() -> { Swing.runLater(() -> {
setSearchResults(List.of(symbolFileLocation), null); setSearchResults(List.of(symbolFileLocation), null);
setSelectedPdbFile(symbolFileLocation); setSelectedPdbFile(symbolFileLocation);
@ -719,8 +706,8 @@ public class LoadPdbDialog extends DialogComponentProvider {
} }
private void setPdbLocationValue(SymbolFileLocation symbolFileLocation, File file) { private void setPdbLocationValue(SymbolFileLocation symbolFileLocation, File file) {
boolean isExactMatch = symbolFileLocation != null boolean isExactMatch =
? symbolFileLocation.isExactMatch(programSymbolFileInfo) symbolFileLocation != null ? symbolFileLocation.isExactMatch(programSymbolFileInfo)
: false; : false;
pdbLocationTextField.setText(file != null ? file.getPath() : ""); pdbLocationTextField.setText(file != null ? file.getPath() : "");
pdbLocationTextField.setToolTipText(getSymbolFileToolText(symbolFileLocation)); pdbLocationTextField.setToolTipText(getSymbolFileToolText(symbolFileLocation));
@ -823,8 +810,8 @@ public class LoadPdbDialog extends DialogComponentProvider {
* progress * progress
* @param runnable {@link MonitoredRunnable} to run * @param runnable {@link MonitoredRunnable} to run
*/ */
private void executeMonitoredRunnable(String taskTitle, boolean canCancel, private void executeMonitoredRunnable(String taskTitle, boolean canCancel, boolean hasProgress,
boolean hasProgress, int delay, MonitoredRunnable runnable) { int delay, MonitoredRunnable runnable) {
Task task = new Task(taskTitle, canCancel, hasProgress, false) { Task task = new Task(taskTitle, canCancel, hasProgress, false) {
@Override @Override
public void run(TaskMonitor monitor) throws CancelledException { public void run(TaskMonitor monitor) throws CancelledException {

View file

@ -28,8 +28,8 @@ import javax.swing.*;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.button.BrowseButton;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode; import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GHtmlLabel; import docking.widgets.label.GHtmlLabel;
@ -53,6 +53,8 @@ import utilities.util.FileUtilities;
class SymbolServerPanel extends JPanel { class SymbolServerPanel extends JPanel {
private static final String MS_SYMBOLSERVER_ENVVAR = "_NT_SYMBOL_PATH"; private static final String MS_SYMBOLSERVER_ENVVAR = "_NT_SYMBOL_PATH";
private static final Dimension BUTTON_SIZE = new Dimension(32, 32);
private static List<WellKnownSymbolServerLocation> knownSymbolServers = private static List<WellKnownSymbolServerLocation> knownSymbolServers =
WellKnownSymbolServerLocation.loadAll(); WellKnownSymbolServerLocation.loadAll();
@ -108,9 +110,10 @@ class SymbolServerPanel extends JPanel {
JPanel buttonPanel = buildButtonPanel(); JPanel buttonPanel = buildButtonPanel();
JScrollPane tableScrollPane = buildTable(); JScrollPane tableScrollPane = buildTable();
defaultConfigNotice = new JPanel(); defaultConfigNotice = new JPanel();
defaultConfigNotice.add(new GHtmlLabel( defaultConfigNotice
"<html><center><font color=\"" + Colors.ERROR.toHexString() + .add(new GHtmlLabel(
"\"><br>" + "Missing / invalid configuration.<br><br>" + "<html><center><font color=\"" + Colors.ERROR.toHexString() + "\"><br>" +
"Missing / invalid configuration.<br><br>" +
"Using default search location:<br>" + "Program's Import Location<br>", "Using default search location:<br>" + "Program's Import Location<br>",
SwingConstants.CENTER)); SwingConstants.CENTER));
defaultConfigNotice.setPreferredSize(tableScrollPane.getPreferredSize()); defaultConfigNotice.setPreferredSize(tableScrollPane.getPreferredSize());
@ -198,43 +201,41 @@ class SymbolServerPanel extends JPanel {
} }
private JPanel buildButtonPanel() { private JPanel buildButtonPanel() {
refreshSearchLocationsStatusButton = refreshSearchLocationsStatusButton =
createImageButton(Icons.REFRESH_ICON, "Refresh Status", ButtonPanelFactory.ARROW_SIZE); createImageButton(Icons.REFRESH_ICON, "Refresh Status");
refreshSearchLocationsStatusButton.addActionListener(e -> refreshSearchLocationStatus()); refreshSearchLocationsStatusButton.addActionListener(e -> refreshSearchLocationStatus());
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(refreshSearchLocationsStatusButton, new HelpLocation( .registerHelp(refreshSearchLocationsStatusButton, new HelpLocation(
PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig Refresh Status")); PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig Refresh Status"));
moveLocationUpButton = ButtonPanelFactory.createButton(ButtonPanelFactory.ARROW_UP_TYPE); moveLocationUpButton = createImageButton(Icons.UP_ICON, "Up");
moveLocationUpButton.addActionListener(e -> moveLocation(-1)); moveLocationUpButton.addActionListener(e -> moveLocation(-1));
moveLocationUpButton.setToolTipText("Move location up"); moveLocationUpButton.setToolTipText("Move location up");
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(moveLocationUpButton, new HelpLocation( .registerHelp(moveLocationUpButton, new HelpLocation(
PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig MoveUpDown")); PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig MoveUpDown"));
moveLocationDownButton = moveLocationDownButton = createImageButton(Icons.DOWN_ICON, "Down");
ButtonPanelFactory.createButton(ButtonPanelFactory.ARROW_DOWN_TYPE);
moveLocationDownButton.addActionListener(e -> moveLocation(1)); moveLocationDownButton.addActionListener(e -> moveLocation(1));
moveLocationDownButton.setToolTipText("Move location down"); moveLocationDownButton.setToolTipText("Move location down");
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(moveLocationDownButton, new HelpLocation( .registerHelp(moveLocationDownButton, new HelpLocation(
PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig MoveUpDown")); PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig MoveUpDown"));
deleteLocationButton = deleteLocationButton = createImageButton(Icons.DELETE_ICON, "Delete");
createImageButton(Icons.DELETE_ICON, "Delete", ButtonPanelFactory.ARROW_SIZE);
deleteLocationButton.addActionListener(e -> deleteLocation()); deleteLocationButton.addActionListener(e -> deleteLocation());
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(deleteLocationButton, .registerHelp(deleteLocationButton,
new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig Delete")); new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig Delete"));
addLocationButton = createImageButton(Icons.ADD_ICON, "Add", ButtonPanelFactory.ARROW_SIZE); addLocationButton = createImageButton(Icons.ADD_ICON, "Add");
addLocationButton.addActionListener(e -> addLocation()); addLocationButton.addActionListener(e -> addLocation());
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(addLocationButton, .registerHelp(addLocationButton,
new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig Add")); new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "SymbolServerConfig Add"));
saveSearchLocationsButton = ButtonPanelFactory.createImageButton( saveSearchLocationsButton = createImageButton(Icons.SAVE_ICON, "Save Configuration");
Icons.get("images/disk.png"), "Save Configuration", ButtonPanelFactory.ARROW_SIZE);
saveSearchLocationsButton.addActionListener(e -> saveConfig()); saveSearchLocationsButton.addActionListener(e -> saveConfig());
DockingWindowManager.getHelpService() DockingWindowManager.getHelpService()
.registerHelp(saveSearchLocationsButton, .registerHelp(saveSearchLocationsButton,
@ -260,8 +261,7 @@ class SymbolServerPanel extends JPanel {
symbolStorageLocationTextField symbolStorageLocationTextField
.setToolTipText("User-specified directory where PDB files are stored. Required."); .setToolTipText("User-specified directory where PDB files are stored. Required.");
chooseSymbolStorageLocationButton = chooseSymbolStorageLocationButton = new BrowseButton();
ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
chooseSymbolStorageLocationButton.addActionListener(e -> chooseSymbolStorageLocation()); chooseSymbolStorageLocationButton.addActionListener(e -> chooseSymbolStorageLocation());
symbolStorageLocationPanel = new JPanel(new PairLayout(5, 5)); symbolStorageLocationPanel = new JPanel(new PairLayout(5, 5));
@ -494,8 +494,8 @@ class SymbolServerPanel extends JPanel {
Msg.showError(this, this, "Bad path", "Invalid path: " + dir); Msg.showError(this, this, "Bad path", "Invalid path: " + dir);
return; return;
} }
LocalSymbolStore localSymbolStore = new LocalSymbolStore(dir); LocalSymbolStore symbolStore = new LocalSymbolStore(dir);
tableModel.addSymbolServer(localSymbolStore); tableModel.addSymbolServer(symbolStore);
} }
private void deleteLocation() { private void deleteLocation() {
@ -564,13 +564,11 @@ class SymbolServerPanel extends JPanel {
return false; return false;
} }
private static JButton createImageButton(Icon buttonIcon, String alternateText, private static JButton createImageButton(Icon buttonIcon, String alternateText) {
Dimension preferredSize) {
JButton button = ButtonPanelFactory.createButton(""); JButton button = new JButton(buttonIcon);
button.setIcon(buttonIcon);
button.setToolTipText(alternateText); button.setToolTipText(alternateText);
button.setPreferredSize(preferredSize); button.setPreferredSize(BUTTON_SIZE);
return button; return button;
} }

View file

@ -24,7 +24,7 @@ import javax.swing.event.DocumentListener;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import docking.options.editor.ButtonPanelFactory; import docking.widgets.button.BrowseButton;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import docking.wizard.*; import docking.wizard.*;
import generic.theme.*; import generic.theme.*;
@ -77,8 +77,7 @@ public class NewSessionPanel extends AbstractMageJPanel<VTWizardStateKey> {
Gui.registerFont(folderNameField, GThemeDefaults.Ids.Fonts.MONOSPACED); Gui.registerFont(folderNameField, GThemeDefaults.Ids.Fonts.MONOSPACED);
folderNameField.setEditable(false); // force user to browse to choose folderNameField.setEditable(false); // force user to browse to choose
JButton browseFolderButton = JButton browseFolderButton = new BrowseButton();
ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
browseFolderButton.addActionListener(e -> browseDataTreeFolders()); browseFolderButton.addActionListener(e -> browseDataTreeFolders());
JLabel newSessionLabel = new GDLabel("New Session Name: "); JLabel newSessionLabel = new GDLabel("New Session Name: ");
@ -466,7 +465,7 @@ public class NewSessionPanel extends AbstractMageJPanel<VTWizardStateKey> {
} }
private JButton createSourceBrowseButton() { private JButton createSourceBrowseButton() {
JButton button = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton button = new BrowseButton();
button.setName("SOURCE_BUTTON"); button.setName("SOURCE_BUTTON");
button.addActionListener(e -> { button.addActionListener(e -> {
DomainFile programFile = VTWizardUtils.chooseDomainFile(NewSessionPanel.this, DomainFile programFile = VTWizardUtils.chooseDomainFile(NewSessionPanel.this,
@ -479,7 +478,7 @@ public class NewSessionPanel extends AbstractMageJPanel<VTWizardStateKey> {
} }
private JButton createDestinationBrowseButton() { private JButton createDestinationBrowseButton() {
JButton button = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton button = new BrowseButton();
button.setName("DESTINATION_BUTTON"); button.setName("DESTINATION_BUTTON");
button.addActionListener(e -> { button.addActionListener(e -> {
DomainFile programFile = VTWizardUtils.chooseDomainFile(NewSessionPanel.this, DomainFile programFile = VTWizardUtils.chooseDomainFile(NewSessionPanel.this,

View file

@ -1,267 +0,0 @@
/* ###
* 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 docking.options.editor;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import generic.theme.GThemeDefaults.Colors;
import resources.ResourceManager;
/**
* Class with static methods to create a JButton with a raised bevel border,
* and to create a JPanel with buttons created by calling the
* createButton() method.
*/
public class ButtonPanelFactory {
private ButtonPanelFactory() {
}
/**
* layout the buttons on the panel created with createButtonPanel()
* horizontally along the X-axis
*/
public final static char X_AXIS = '0';
/**
* layout the buttons on the panel created with createButtonPanel()
* vertically along the Y-axis
*/
public final static char Y_AXIS = '1';
/*
* types of buttons you can request from the factory that have
* been pre-configured using our convention
*/
/**
* Button that has an up arrow.
*/
public final static int ARROW_UP_TYPE = 0;
/**
* Button that has a down arrow.
*/
public final static int ARROW_DOWN_TYPE = 1;
/**
* Button that indicates a file chooser to browse.
*/
public final static int BROWSE_TYPE = 2;
/**
* Button for cancel.
*/
public final static int CANCEL_TYPE = 3;
/**
* Button that indicates an edit operation.
*/
public final static int EDIT_TYPE = 4;
/**
* Button for OK.
*/
public final static int OK_TYPE = 5;
/**
* Button that has a left arrow.
*/
public final static int ARROW_LEFT_TYPE = 6;
/**
* Button that has a right arrow.
*/
public final static int ARROW_RIGHT_TYPE = 7;
/*
* values used to construct various button types, as defined
* above. These constants may be useful outside the factory when
* the factory can't be used (e.g., when using StringInputPanel).
*/
/**
* Dimension for the arrow button.
*/
public final static Dimension ARROW_SIZE = new Dimension(32, 32);
/**
* Dimension for the browse button.
*/
public final static Dimension BROWSE_SIZE = new Dimension(30, 25);
/**
* Text for the browse button.
*/
public final static Icon BROWSE_ICON = new Icon() {
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(Colors.FOREGROUND);
g.fillRect(x, y + 5, 2, 2);
g.fillRect(x + 4, y + 5, 2, 2);
g.fillRect(x + 8, y + 5, 2, 2);
}
@Override
public int getIconWidth() {
return 10;
}
@Override
public int getIconHeight() {
return 10;
}
};
/**
* internal values used when creating the panels and buttons
*/
private final static int TOP_MARGIN = 8;
private final static int BOTTOM_MARGIN = 8;
private final static int SIDE_MARGIN = 20;
// private final static int BUTTON_MARGIN = 4;
private final static int BUTTON_GAP = 10;
private final static String CANCEL_LABEL = "Cancel";
private final static String OK_LABEL = "Ok";
private final static String UNTITLED = "Untitled Button";
private static final String BROWSE_TOOLTIP_TEXT = "Browse";
/**
* Create a button with specified type.
* @param buttonType the type of button to create.
*/
public static JButton createButton(int buttonType) {
switch (buttonType) {
case ARROW_DOWN_TYPE:
return createImageButton("images/down.png", "DOWN", ARROW_SIZE);
case ARROW_UP_TYPE:
return createImageButton("images/up.png", "UP", ARROW_SIZE);
case ARROW_LEFT_TYPE:
return createImageButton("images/left.png", "LEFT", ARROW_SIZE);
case ARROW_RIGHT_TYPE:
return createImageButton("images/right.png", "RIGHT", ARROW_SIZE);
case BROWSE_TYPE:
return createBrowseButton();
case CANCEL_TYPE:
return createButton(CANCEL_LABEL);
case EDIT_TYPE:
return createImageButton("images/accessories-text-editor.png", "Edit", BROWSE_SIZE);
case OK_TYPE:
return createButton(OK_LABEL);
default:
return createButton(UNTITLED);
}
}
/**
* Create a button with the given text.
* @param text the text to use in the button.
*/
public static JButton createButton(String text) {
return new JButton(text);
}
/**
* Create the panel for the buttons; the button are aligned vertically;
* the side margins on the panel has a default value of 20.
* @param buttons the array of buttons to put in the panel.
*/
public static JPanel createButtonPanel(JButton[] buttons) {
return createButtonPanel(buttons, SIDE_MARGIN, Y_AXIS);
}
/**
* Create the panel for the buttons; the button are aligned as specified;
* the side margins on the panel has a default value of 20.
* @param buttons the array buttons to put in the panel.
* @param alignment either X_AXIS or Y_AXIS
*/
public static JPanel createButtonPanel(JButton[] buttons, char alignment) {
return createButtonPanel(buttons, SIDE_MARGIN, alignment);
}
/**
* Create the panel for the buttons; the button are aligned vertically;
* use sideMargin value for side margins on the panel.
* @param buttons the array buttons to put in the panel.
* @param sideMargin the amount of margin space to use on the sides.
*/
public static JPanel createButtonPanel(JButton[] buttons, int sideMargin) {
return createButtonPanel(buttons, sideMargin, Y_AXIS);
}
/**
* Create the panel for the buttons; the button are aligned as specified;
* use sideMargin value for side margins on the panel, and use either
* X_AXIS or Y_AXIS as the alignment specification.
* @param buttons the array buttons to put in the panel.
* @param alignment either X_AXIS or Y_AXIS
*/
public static JPanel createButtonPanel(JButton[] buttons, int sideMargin, char alignment) {
JPanel panel = new JPanel();
JPanel subPanel = new JPanel();
panel.add(subPanel);
subPanel.setLayout((alignment == Y_AXIS ? new GridLayout(0, 1, 0, BUTTON_GAP)
: new GridLayout(1, 0, BUTTON_GAP, 0)));
Border inside =
BorderFactory.createEmptyBorder(TOP_MARGIN, sideMargin, BOTTOM_MARGIN, sideMargin);
subPanel.setBorder(inside);
for (JButton button : buttons) {
subPanel.add(button);
}
return panel;
}
/**
* Create an button that has an icon created from the given imageFile.
* @param imageFile icon filename
* @param alternateText text to use if the icon could not be loaded
* @param preferredSize size that the button would like to be
* @return JButton new button
*/
public static JButton createImageButton(String imageFile, String alternateText,
Dimension preferredSize) {
ImageIcon buttonIcon = ResourceManager.loadImage(imageFile);
return createImageButton(buttonIcon, alternateText, preferredSize);
}
/**
* Create a button with the given icon.
* @param buttonIcon icon for the button
* @param alternateText text to use if the icon could not be loaded
* @param preferredSize size that the button would like to be
* @return JButton new button
*/
public static JButton createImageButton(ImageIcon buttonIcon, String alternateText,
Dimension preferredSize) {
JButton button = ButtonPanelFactory.createButton("");
if (buttonIcon != null) {
button.setIcon(buttonIcon);
}
else {
button.setText(alternateText);
}
button.setPreferredSize(preferredSize);
return button;
}
private static JButton createBrowseButton() {
JButton button = new JButton(BROWSE_ICON);
button.setName("BrowseButton");
button.setToolTipText(BROWSE_TOOLTIP_TEXT);
return button;
}
}

View file

@ -26,6 +26,7 @@ import javax.swing.event.DocumentListener;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import docking.widgets.button.BrowseButton;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
/** /**
@ -105,7 +106,7 @@ public class FileChooserEditor extends PropertyEditorSupport {
setLayout(bl); setLayout(bl);
textField.setText(currentFileValue != null ? currentFileValue.getAbsolutePath() : ""); textField.setText(currentFileValue != null ? currentFileValue.getAbsolutePath() : "");
browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); browseButton = new BrowseButton();
add(textField); add(textField);
add(Box.createHorizontalStrut(5)); add(Box.createHorizontalStrut(5));

View file

@ -28,6 +28,7 @@ import org.apache.commons.io.FileUtils;
import docking.theme.gui.ProtectedIcon; import docking.theme.gui.ProtectedIcon;
import docking.widgets.*; import docking.widgets.*;
import docking.widgets.button.BrowseButton;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode; import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
@ -126,7 +127,7 @@ public class IconPropertyEditor extends PropertyEditorSupport {
}; };
dropDown.addDropDownSelectionChoiceListener(choiceListener); dropDown.addDropDownSelectionChoiceListener(choiceListener);
panel.add(dropDown, BorderLayout.CENTER); panel.add(dropDown, BorderLayout.CENTER);
JButton browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton browseButton = new BrowseButton();
panel.add(browseButton, BorderLayout.EAST); panel.add(browseButton, BorderLayout.EAST);
browseButton.addActionListener(e -> browse()); browseButton.addActionListener(e -> browse());

View file

@ -23,7 +23,7 @@ import java.io.IOException;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory; import docking.widgets.button.BrowseButton;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode; import docking.widgets.filechooser.GhidraFileChooserMode;
@ -138,7 +138,7 @@ public class ExportThemeDialog extends DialogComponentProvider {
fileTextField.setText(file.getAbsolutePath()); fileTextField.setText(file.getAbsolutePath());
fileTextField.setEditable(false); fileTextField.setEditable(false);
fileTextField.setFocusable(false); fileTextField.setFocusable(false);
JButton folderButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton folderButton = new BrowseButton();
folderButton.addActionListener(e -> chooseFile()); folderButton.addActionListener(e -> chooseFile());
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());

View file

@ -24,7 +24,7 @@ import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import docking.options.editor.ButtonPanelFactory; import docking.widgets.button.BrowseButton;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import docking.widgets.table.AbstractGTableModel; import docking.widgets.table.AbstractGTableModel;
import docking.widgets.table.RowObjectTableModel; import docking.widgets.table.RowObjectTableModel;
@ -134,7 +134,7 @@ public class ListSelectionDialog<T> extends DialogComponentProvider {
panel.add(jLabel, BorderLayout.WEST); panel.add(jLabel, BorderLayout.WEST);
panel.add(field, BorderLayout.CENTER); panel.add(field, BorderLayout.CENTER);
JButton browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton browseButton = new BrowseButton();
browseButton.addActionListener(e -> browse()); browseButton.addActionListener(e -> browse());
panel.add(browseButton, BorderLayout.EAST); panel.add(browseButton, BorderLayout.EAST);
return panel; return panel;
@ -221,8 +221,8 @@ public class ListSelectionDialog<T> extends DialogComponentProvider {
list.add("bOb"); list.add("bOb");
list.add("bobby"); list.add("bobby");
list.add("zzz"); list.add("zzz");
ListSelectionDialog<String> dialog = ListSelectionDialog.getStringListSelectionDialog( ListSelectionDialog<String> dialog = ListSelectionDialog
"String Picker", "Choose String:", list); .getStringListSelectionDialog("String Picker", "Choose String:", list);
String selectedValue = dialog.show(jFrame); String selectedValue = dialog.show(jFrame);
System.out.println("Selected: " + selectedValue); System.out.println("Selected: " + selectedValue);

View file

@ -0,0 +1,59 @@
/* ###
* 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 docking.widgets.button;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.Icon;
import javax.swing.JButton;
import generic.theme.GThemeDefaults.Colors;
/**
* A button meant to be used to show a chooser dialog.
*/
public class BrowseButton extends JButton {
public static final String NAME = "BrowseButton";
public static final String TOOLTIP_TEXT = "Browse";
private static final Icon ICON = new Icon() {
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(Colors.FOREGROUND);
g.fillRect(x, y + 5, 2, 2);
g.fillRect(x + 4, y + 5, 2, 2);
g.fillRect(x + 8, y + 5, 2, 2);
}
@Override
public int getIconWidth() {
return 10;
}
@Override
public int getIconHeight() {
return 10;
}
};
public BrowseButton() {
setIcon(ICON);
setName(NAME);
setToolTipText(TOOLTIP_TEXT);
}
}

View file

@ -25,12 +25,12 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode; import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
@ -43,6 +43,8 @@ import ghidra.util.HelpLocation;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.filechooser.ExtensionFileFilter; import ghidra.util.filechooser.ExtensionFileFilter;
import ghidra.util.filechooser.GhidraFileFilter; import ghidra.util.filechooser.GhidraFileFilter;
import resources.Icons;
import resources.ResourceManager;
/** /**
* Dialog for editing the Plugin path and Jar directory path preferences. * Dialog for editing the Plugin path and Jar directory path preferences.
@ -58,7 +60,6 @@ class EditPluginPathDialog extends DialogComponentProvider {
static final String ADD_DIR_BUTTON_TEXT = "Add Dir ..."; static final String ADD_DIR_BUTTON_TEXT = "Add Dir ...";
static final String ADD_JAR_BUTTON_TEXT = "Add Jar ..."; static final String ADD_JAR_BUTTON_TEXT = "Add Jar ...";
private final static int SIDE_MARGIN = 5;
private final static Color INVALID_PATH_COLOR = Tables.FG_ERROR_UNSELECTED; private final static Color INVALID_PATH_COLOR = Tables.FG_ERROR_UNSELECTED;
private final static Color INVALID_SELECTED_PATH_COLOR = Tables.FG_ERROR_SELECTED; private final static Color INVALID_SELECTED_PATH_COLOR = Tables.FG_ERROR_SELECTED;
private final static Color STATUS_MESSAGE_COLOR = Messages.NORMAL; private final static Color STATUS_MESSAGE_COLOR = Messages.NORMAL;
@ -267,10 +268,13 @@ class EditPluginPathDialog extends DialogComponentProvider {
private JPanel buildPluginPathsPanel() { private JPanel buildPluginPathsPanel() {
// create the UP and DOWN arrows panel // create the UP and DOWN arrows panel
upButton = ButtonPanelFactory.createButton(ButtonPanelFactory.ARROW_UP_TYPE); upButton = new JButton(Icons.UP_ICON);
upButton.setDisabledIcon(ResourceManager.getDisabledIcon(Icons.UP_ICON));
upButton.setName("UpArrow"); upButton.setName("UpArrow");
upButton.addActionListener(e -> handleSelection(UP)); upButton.addActionListener(e -> handleSelection(UP));
downButton = ButtonPanelFactory.createButton(ButtonPanelFactory.ARROW_DOWN_TYPE);
downButton = new JButton(Icons.DOWN_ICON);
downButton.setDisabledIcon(ResourceManager.getDisabledIcon(Icons.DOWN_ICON));
downButton.setName("DownArrow"); downButton.setName("DownArrow");
downButton.addActionListener(e -> handleSelection(DOWN)); downButton.addActionListener(e -> handleSelection(DOWN));
JPanel arrowButtonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10)); JPanel arrowButtonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));
@ -278,17 +282,33 @@ class EditPluginPathDialog extends DialogComponentProvider {
arrowButtonsPanel.add(downButton); arrowButtonsPanel.add(downButton);
// create the Add and Remove panel // create the Add and Remove panel
JButton addJarButton = ButtonPanelFactory.createButton(ADD_JAR_BUTTON_TEXT); JButton addJarButton = new JButton(ADD_JAR_BUTTON_TEXT);
addJarButton.addActionListener(e -> addJarCallback()); addJarButton.addActionListener(e -> addJarCallback());
JButton addDirButton = ButtonPanelFactory.createButton(ADD_DIR_BUTTON_TEXT); JButton addDirButton = new JButton(ADD_DIR_BUTTON_TEXT);
addDirButton.addActionListener(e -> addDirCallback()); addDirButton.addActionListener(e -> addDirCallback());
removeButton = ButtonPanelFactory.createButton("Remove"); removeButton = new JButton("Remove");
removeButton.addActionListener(e -> handleSelection(REMOVE)); removeButton.addActionListener(e -> handleSelection(REMOVE));
Dimension d = addJarButton.getPreferredSize(); Dimension d = addJarButton.getPreferredSize();
addDirButton.setPreferredSize(d); addDirButton.setPreferredSize(d);
removeButton.setPreferredSize(d); removeButton.setPreferredSize(d);
JPanel otherButtonsPanel = ButtonPanelFactory.createButtonPanel(
new JButton[] { addJarButton, addDirButton, removeButton }, SIDE_MARGIN); //
// Button panel for adding and removing jar files
//
JPanel otherButtonsPanel = new JPanel();
JPanel subPanel = new JPanel();
otherButtonsPanel.add(subPanel);
int buttonGap = 10;
subPanel.setLayout(new GridLayout(0, 1, 0, buttonGap));
int top = 8;
int side = 5;
Border inside = BorderFactory.createEmptyBorder(top, side, top, side);
subPanel.setBorder(inside);
subPanel.add(addJarButton);
subPanel.add(addDirButton);
subPanel.add(removeButton);
// put the right-side buttons panel together // put the right-side buttons panel together
JPanel listButtonPanel = new JPanel(new BorderLayout(0, 0)); JPanel listButtonPanel = new JPanel(new BorderLayout(0, 0));

View file

@ -26,7 +26,6 @@ import javax.swing.*;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.tool.ToolConstants; import docking.tool.ToolConstants;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.list.ListPanel; import docking.widgets.list.ListPanel;
@ -38,15 +37,10 @@ import ghidra.util.HelpLocation;
class ImportGhidraToolsDialog extends DialogComponentProvider { class ImportGhidraToolsDialog extends DialogComponentProvider {
private final static String SELECT_ALL = "Select All";
private final static String DESELECT_ALL = "Select None";
private ListPanel listPanel; private ListPanel listPanel;
private JPanel mainPanel; private JPanel mainPanel;
private GCheckBox[] checkboxes; private GCheckBox[] checkboxes;
private String[] tools; private String[] tools;
private JButton selectAllButton;
private JButton deselectAllButton;
private FrontEndTool tool; private FrontEndTool tool;
private boolean cancelled = false; private boolean cancelled = false;
@ -66,8 +60,6 @@ class ImportGhidraToolsDialog extends DialogComponentProvider {
addOKButton(); addOKButton();
addCancelButton(); addCancelButton();
addListeners();
} }
void showDialog() { void showDialog() {
@ -103,26 +95,13 @@ class ImportGhidraToolsDialog extends DialogComponentProvider {
panel.setLayout(new BorderLayout()); panel.setLayout(new BorderLayout());
JPanel availableToolsPanel = new JPanel(new BorderLayout()); JPanel availableToolsPanel = new JPanel(new BorderLayout());
// SelectPanel myButtonPanel = new SelectPanel(e -> selectAll(), e -> deselectAll());
// Create Button Panel
//
selectAllButton = new JButton(SELECT_ALL);
selectAllButton.setMnemonic('A');
deselectAllButton = new JButton(DESELECT_ALL);
deselectAllButton.setMnemonic('N');
JPanel buttonPanel = ButtonPanelFactory.createButtonPanel(
new JButton[] { selectAllButton, deselectAllButton });
//
// List Panel
//
listPanel = new ListPanel(); listPanel = new ListPanel();
listPanel.setCellRenderer(new DataCellRenderer()); listPanel.setCellRenderer(new DataCellRenderer());
listPanel.setMouseListener(new ListMouseListener()); listPanel.setMouseListener(new ListMouseListener());
// Layout Main Panel availableToolsPanel.add(myButtonPanel, BorderLayout.EAST);
availableToolsPanel.add(buttonPanel, BorderLayout.EAST);
availableToolsPanel.add(listPanel, BorderLayout.CENTER); availableToolsPanel.add(listPanel, BorderLayout.CENTER);
availableToolsPanel.setBorder(new TitledBorder("Available Tools")); availableToolsPanel.setBorder(new TitledBorder("Available Tools"));
@ -130,15 +109,6 @@ class ImportGhidraToolsDialog extends DialogComponentProvider {
return panel; return panel;
} }
/**
* Add listeners to the buttons.
*/
private void addListeners() {
selectAllButton.addActionListener(e -> selectAll());
deselectAllButton.addActionListener(e -> deselectAll());
}
/** /**
* Select all files to be saved. * Select all files to be saved.
*/ */

View file

@ -22,8 +22,8 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.list.GListCellRenderer; import docking.widgets.list.GListCellRenderer;
import docking.widgets.table.GTable; import docking.widgets.table.GTable;
@ -237,8 +237,24 @@ public class ProjectAccessPanel extends AbstractWizardJPanel {
}); });
removeAllButton.setEnabled(true); removeAllButton.setEnabled(true);
JPanel panel = ButtonPanelFactory.createButtonPanel( //
new JButton[] { addButton, addAllButton, removeButton, removeAllButton }, 5); // Button panel for moving users back and forth; a vertical panel of buttons
//
JPanel panel = new JPanel();
JPanel subPanel = new JPanel();
panel.add(subPanel);
subPanel.setLayout(new GridLayout(0, 1, 0, 10));
int top = 8;
int side = 5;
Border inside = BorderFactory.createEmptyBorder(top, side, top, side);
subPanel.setBorder(inside);
subPanel.add(addButton);
subPanel.add(addAllButton);
subPanel.add(removeButton);
subPanel.add(removeAllButton);
panel.setMinimumSize(panel.getPreferredSize()); panel.setMinimumSize(panel.getPreferredSize());
// Set up a listener so this panel can update its state when something in the user // Set up a listener so this panel can update its state when something in the user

View file

@ -25,7 +25,6 @@ import javax.swing.*;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.list.ListPanel; import docking.widgets.list.ListPanel;
import generic.theme.GThemeDefaults.Colors; import generic.theme.GThemeDefaults.Colors;
@ -47,16 +46,11 @@ import ghidra.util.task.*;
*/ */
public class SaveDataDialog extends DialogComponentProvider { public class SaveDataDialog extends DialogComponentProvider {
private final static String SELECT_ALL = "Select All";
private final static String DESELECT_ALL = "Select None";
private ListPanel listPanel; private ListPanel listPanel;
private JPanel mainPanel; private JPanel mainPanel;
private GCheckBox[] checkboxes; private GCheckBox[] checkboxes;
private List<DomainFile> files; private List<DomainFile> files;
private boolean[] saveable; private boolean[] saveable;
private JButton selectAllButton;
private JButton deselectAllButton;
private JButton yesButton; private JButton yesButton;
private JButton noButton; private JButton noButton;
private PluginTool tool; private PluginTool tool;
@ -89,8 +83,6 @@ public class SaveDataDialog extends DialogComponentProvider {
}); });
addButton(noButton); addButton(noButton);
addCancelButton(); addCancelButton();
addListeners();
} }
/** /**
@ -162,25 +154,12 @@ public class SaveDataDialog extends DialogComponentProvider {
panel.setLayout(new BorderLayout()); panel.setLayout(new BorderLayout());
JPanel parentPanel = new JPanel(new BorderLayout()); JPanel parentPanel = new JPanel(new BorderLayout());
// SelectPanel myButtonPanel = new SelectPanel(e -> selectAll(), e -> deselectAll());
// Create Button Panel
//
selectAllButton = new JButton(SELECT_ALL);
selectAllButton.setMnemonic('A');
deselectAllButton = new JButton(DESELECT_ALL);
deselectAllButton.setMnemonic('N');
JPanel myButtonPanel = ButtonPanelFactory.createButtonPanel(
new JButton[] { selectAllButton, deselectAllButton });
//
// List Panel
//
listPanel = new ListPanel(); listPanel = new ListPanel();
listPanel.setCellRenderer(new DataCellRenderer()); listPanel.setCellRenderer(new DataCellRenderer());
listPanel.setMouseListener(new ListMouseListener()); listPanel.setMouseListener(new ListMouseListener());
// Layout Main Panel
parentPanel.add(myButtonPanel, BorderLayout.EAST); parentPanel.add(myButtonPanel, BorderLayout.EAST);
parentPanel.add(listPanel, BorderLayout.CENTER); parentPanel.add(listPanel, BorderLayout.CENTER);
parentPanel.setBorder(new TitledBorder("Data")); parentPanel.setBorder(new TitledBorder("Data"));
@ -189,16 +168,6 @@ public class SaveDataDialog extends DialogComponentProvider {
return panel; return panel;
} }
/**
* Add listeners to the buttons.
*/
private void addListeners() {
selectAllButton.addActionListener(e -> selectAll());
deselectAllButton.addActionListener(e -> deselectAll());
}
/** /**
* Select all files to be saved. * Select all files to be saved.
*/ */
@ -304,7 +273,7 @@ public class SaveDataDialog extends DialogComponentProvider {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
clearStatusText(); clearStatusText();
JList list = (JList) e.getSource(); JList<?> list = (JList<?>) e.getSource();
int index = list.locationToIndex(e.getPoint()); int index = list.locationToIndex(e.getPoint());
if (index < 0) { if (index < 0) {
return; return;

View file

@ -0,0 +1,55 @@
/* ###
* 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.framework.main;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.Border;
/**
* A simple panel with buttons for selecting and de-selecting items
*/
public class SelectPanel extends JPanel {
private final static String SELECT_ALL = "Select All";
private final static String DESELECT_ALL = "Select None";
public SelectPanel(ActionListener selectAllCallback, ActionListener deselectAllCallback) {
JButton selectAllButton = new JButton(SELECT_ALL);
selectAllButton.setMnemonic('A');
selectAllButton.addActionListener(selectAllCallback);
JButton deselectAllButton = new JButton(DESELECT_ALL);
deselectAllButton.setMnemonic('N');
deselectAllButton.addActionListener(deselectAllCallback);
JPanel subPanel = new JPanel();
int buttonGap = 10;
subPanel.setLayout(new GridLayout(0, 1, 0, buttonGap));
int top = 8;
int side = 20;
Border inside = BorderFactory.createEmptyBorder(top, side, top, side);
subPanel.setBorder(inside);
subPanel.add(selectAllButton);
subPanel.add(deselectAllButton);
add(subPanel);
}
}

View file

@ -25,7 +25,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.text.Document; import javax.swing.text.Document;
import docking.options.editor.ButtonPanelFactory; import docking.widgets.button.BrowseButton;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode; import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
@ -178,7 +178,7 @@ class SelectProjectPanel extends AbstractWizardJPanel {
projectNameField.getDocument().addDocumentListener(docListener); projectNameField.getDocument().addDocumentListener(docListener);
directoryField.getDocument().addDocumentListener(docListener); directoryField.getDocument().addDocumentListener(docListener);
browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); browseButton = new BrowseButton();
browseButton.addActionListener(new ActionListener() { browseButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {

View file

@ -26,9 +26,9 @@ import javax.swing.border.TitledBorder;
import javax.swing.event.*; import javax.swing.event.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.util.image.ToolIconURL; import docking.util.image.ToolIconURL;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.button.BrowseButton;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import ghidra.framework.model.*; import ghidra.framework.model.*;
@ -312,7 +312,7 @@ public class SaveToolConfigDialog extends DialogComponentProvider implements Lis
iconField = new JTextField(12); iconField = new JTextField(12);
iconField.setName("IconName"); iconField.setName("IconName");
browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); browseButton = new BrowseButton();
JPanel panel = new JPanel(new BorderLayout(5, 0)); JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

View file

@ -23,7 +23,7 @@ import java.io.IOException;
import javax.swing.*; import javax.swing.*;
import docking.options.editor.ButtonPanelFactory; import docking.widgets.button.BrowseButton;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.label.GHtmlLabel; import docking.widgets.label.GHtmlLabel;
@ -47,7 +47,6 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
private JCheckBox useOldFileIDCheckBox; private JCheckBox useOldFileIDCheckBox;
public DataTypeArchiveTransformerPanel() { public DataTypeArchiveTransformerPanel() {
super();
initialize(); initialize();
} }
@ -87,7 +86,7 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
gbc.gridx = 2; gbc.gridx = 2;
gbc.gridwidth = 1; gbc.gridwidth = 1;
JButton oldBrowseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton oldBrowseButton = new BrowseButton();
oldBrowseButton.addActionListener(new ActionListener() { oldBrowseButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -124,7 +123,7 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
gbc.gridx = 2; gbc.gridx = 2;
gbc.gridwidth = 1; gbc.gridwidth = 1;
JButton newBrowseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE); JButton newBrowseButton = new BrowseButton();
newBrowseButton.addActionListener(new ActionListener() { newBrowseButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -155,8 +154,7 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
gbc.gridx = 2; gbc.gridx = 2;
gbc.gridwidth = 1; gbc.gridwidth = 1;
JButton destinationBrowseButton = JButton destinationBrowseButton = new BrowseButton();
ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
destinationBrowseButton.addActionListener(new ActionListener() { destinationBrowseButton.addActionListener(new ActionListener() {
@Override @Override

View file

@ -25,8 +25,8 @@ import org.junit.Test;
import docking.ComponentProvider; import docking.ComponentProvider;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.DropDownSelectionTextField; import docking.widgets.DropDownSelectionTextField;
import docking.widgets.button.BrowseButton;
import docking.widgets.tree.GTree; import docking.widgets.tree.GTree;
import ghidra.app.cmd.data.CreateDataCmd; import ghidra.app.cmd.data.CreateDataCmd;
import ghidra.app.plugin.core.compositeeditor.*; import ghidra.app.plugin.core.compositeeditor.*;
@ -38,7 +38,6 @@ import ghidra.program.model.data.*;
public class DataTypeEditorsScreenShots extends GhidraScreenShotGenerator { public class DataTypeEditorsScreenShots extends GhidraScreenShotGenerator {
public DataTypeEditorsScreenShots() { public DataTypeEditorsScreenShots() {
super();
} }
@Test @Test
@ -120,7 +119,8 @@ public class DataTypeEditorsScreenShots extends GhidraScreenShotGenerator {
performAction("Choose Data Type", "DataPlugin", false); performAction("Choose Data Type", "DataPlugin", false);
DialogComponentProvider dialog = getDialog(); DialogComponentProvider dialog = getDialog();
final JButton browseButton = findButtonByIcon(dialog, ButtonPanelFactory.BROWSE_ICON); AbstractButton browseButton =
findAbstractButtonByName(dialog.getComponent(), BrowseButton.NAME);
pressButton(browseButton, false); pressButton(browseButton, false);
waitForSwing(); waitForSwing();