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 javax.swing.*;
import javax.swing.border.Border;
import docking.ActionContext;
import docking.WindowPosition;
import docking.options.editor.ButtonPanelFactory;
import docking.util.image.ToolIconURL;
import docking.widgets.OptionDialog;
import docking.widgets.label.*;
@ -238,8 +238,19 @@ class MergeManagerProvider extends ComponentProviderAdapter {
cancelButton = new JButton("Cancel");
cancelButton.addActionListener(e -> cancelCallback(false));
JPanel panel = ButtonPanelFactory.createButtonPanel(
new JButton[] { applyButton, cancelButton }, ButtonPanelFactory.X_AXIS);
JPanel panel = new JPanel();
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;
}

View file

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

View file

@ -25,7 +25,7 @@ import javax.swing.*;
import javax.swing.border.TitledBorder;
import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.button.BrowseButton;
import docking.widgets.button.GRadioButton;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.filechooser.GhidraFileChooser;
@ -194,8 +194,8 @@ public class SearchStringDialog extends DialogComponentProvider {
JLabel alignLabel = new GLabel("Alignment: ");
alignLabel.setName("alignment");
alignLabel.setToolTipText(
"<html>Searches for strings that start on the given alignment<br>" +
alignLabel
.setToolTipText("<html>Searches for strings that start on the given alignment<br>" +
"value. The default alignment is processor dependent.");
panel.add(alignLabel);
@ -230,7 +230,7 @@ public class SearchStringDialog extends DialogComponentProvider {
modelFieldPanel.add(wordModelField);
// 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() {
@Override
public void actionPerformed(ActionEvent e) {
@ -273,8 +273,8 @@ public class SearchStringDialog extends DialogComponentProvider {
memoryBlockGroup.add(loadedBlocksRB);
memoryBlockGroup.add(allBlocksRB);
loadedBlocksRB.setToolTipText(HTMLUtilities.toHTML(
"Only searches memory blocks that are loaded in a running executable.\n " +
loadedBlocksRB.setToolTipText(HTMLUtilities
.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" +
"This option exludes these other (non-loaded) blocks."));
allBlocksRB.setToolTipText(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -24,7 +24,7 @@ import javax.swing.event.DocumentListener;
import org.apache.commons.lang3.StringUtils;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.button.BrowseButton;
import docking.widgets.label.GDLabel;
import docking.wizard.*;
import generic.theme.*;
@ -77,8 +77,7 @@ public class NewSessionPanel extends AbstractMageJPanel<VTWizardStateKey> {
Gui.registerFont(folderNameField, GThemeDefaults.Ids.Fonts.MONOSPACED);
folderNameField.setEditable(false); // force user to browse to choose
JButton browseFolderButton =
ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
JButton browseFolderButton = new BrowseButton();
browseFolderButton.addActionListener(e -> browseDataTreeFolders());
JLabel newSessionLabel = new GDLabel("New Session Name: ");
@ -466,7 +465,7 @@ public class NewSessionPanel extends AbstractMageJPanel<VTWizardStateKey> {
}
private JButton createSourceBrowseButton() {
JButton button = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
JButton button = new BrowseButton();
button.setName("SOURCE_BUTTON");
button.addActionListener(e -> {
DomainFile programFile = VTWizardUtils.chooseDomainFile(NewSessionPanel.this,
@ -479,7 +478,7 @@ public class NewSessionPanel extends AbstractMageJPanel<VTWizardStateKey> {
}
private JButton createDestinationBrowseButton() {
JButton button = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
JButton button = new BrowseButton();
button.setName("DESTINATION_BUTTON");
button.addActionListener(e -> {
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 docking.widgets.button.BrowseButton;
import docking.widgets.filechooser.GhidraFileChooser;
/**
@ -105,7 +106,7 @@ public class FileChooserEditor extends PropertyEditorSupport {
setLayout(bl);
textField.setText(currentFileValue != null ? currentFileValue.getAbsolutePath() : "");
browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
browseButton = new BrowseButton();
add(textField);
add(Box.createHorizontalStrut(5));

View file

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

View file

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

View file

@ -24,7 +24,7 @@ import javax.swing.*;
import docking.DialogComponentProvider;
import docking.DockingWindowManager;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.button.BrowseButton;
import docking.widgets.label.GLabel;
import docking.widgets.table.AbstractGTableModel;
import docking.widgets.table.RowObjectTableModel;
@ -134,7 +134,7 @@ public class ListSelectionDialog<T> extends DialogComponentProvider {
panel.add(jLabel, BorderLayout.WEST);
panel.add(field, BorderLayout.CENTER);
JButton browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
JButton browseButton = new BrowseButton();
browseButton.addActionListener(e -> browse());
panel.add(browseButton, BorderLayout.EAST);
return panel;
@ -221,8 +221,8 @@ public class ListSelectionDialog<T> extends DialogComponentProvider {
list.add("bOb");
list.add("bobby");
list.add("zzz");
ListSelectionDialog<String> dialog = ListSelectionDialog.getStringListSelectionDialog(
"String Picker", "Choose String:", list);
ListSelectionDialog<String> dialog = ListSelectionDialog
.getStringListSelectionDialog("String Picker", "Choose String:", list);
String selectedValue = dialog.show(jFrame);
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 javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GDLabel;
@ -43,6 +43,8 @@ import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.filechooser.ExtensionFileFilter;
import ghidra.util.filechooser.GhidraFileFilter;
import resources.Icons;
import resources.ResourceManager;
/**
* 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_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_SELECTED_PATH_COLOR = Tables.FG_ERROR_SELECTED;
private final static Color STATUS_MESSAGE_COLOR = Messages.NORMAL;
@ -267,10 +268,13 @@ class EditPluginPathDialog extends DialogComponentProvider {
private JPanel buildPluginPathsPanel() {
// 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.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.addActionListener(e -> handleSelection(DOWN));
JPanel arrowButtonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));
@ -278,17 +282,33 @@ class EditPluginPathDialog extends DialogComponentProvider {
arrowButtonsPanel.add(downButton);
// 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());
JButton addDirButton = ButtonPanelFactory.createButton(ADD_DIR_BUTTON_TEXT);
JButton addDirButton = new JButton(ADD_DIR_BUTTON_TEXT);
addDirButton.addActionListener(e -> addDirCallback());
removeButton = ButtonPanelFactory.createButton("Remove");
removeButton = new JButton("Remove");
removeButton.addActionListener(e -> handleSelection(REMOVE));
Dimension d = addJarButton.getPreferredSize();
addDirButton.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
JPanel listButtonPanel = new JPanel(new BorderLayout(0, 0));

View file

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

View file

@ -22,8 +22,8 @@ import java.util.Arrays;
import java.util.List;
import javax.swing.*;
import javax.swing.border.Border;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.list.GListCellRenderer;
import docking.widgets.table.GTable;
@ -237,8 +237,24 @@ public class ProjectAccessPanel extends AbstractWizardJPanel {
});
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());
// 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 docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.list.ListPanel;
import generic.theme.GThemeDefaults.Colors;
@ -47,16 +46,11 @@ import ghidra.util.task.*;
*/
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 JPanel mainPanel;
private GCheckBox[] checkboxes;
private List<DomainFile> files;
private boolean[] saveable;
private JButton selectAllButton;
private JButton deselectAllButton;
private JButton yesButton;
private JButton noButton;
private PluginTool tool;
@ -89,8 +83,6 @@ public class SaveDataDialog extends DialogComponentProvider {
});
addButton(noButton);
addCancelButton();
addListeners();
}
/**
@ -162,25 +154,12 @@ public class SaveDataDialog extends DialogComponentProvider {
panel.setLayout(new BorderLayout());
JPanel parentPanel = new JPanel(new BorderLayout());
//
// Create Button Panel
//
selectAllButton = new JButton(SELECT_ALL);
selectAllButton.setMnemonic('A');
deselectAllButton = new JButton(DESELECT_ALL);
deselectAllButton.setMnemonic('N');
SelectPanel myButtonPanel = new SelectPanel(e -> selectAll(), e -> deselectAll());
JPanel myButtonPanel = ButtonPanelFactory.createButtonPanel(
new JButton[] { selectAllButton, deselectAllButton });
//
// List Panel
//
listPanel = new ListPanel();
listPanel.setCellRenderer(new DataCellRenderer());
listPanel.setMouseListener(new ListMouseListener());
// Layout Main Panel
parentPanel.add(myButtonPanel, BorderLayout.EAST);
parentPanel.add(listPanel, BorderLayout.CENTER);
parentPanel.setBorder(new TitledBorder("Data"));
@ -189,16 +168,6 @@ public class SaveDataDialog extends DialogComponentProvider {
return panel;
}
/**
* Add listeners to the buttons.
*/
private void addListeners() {
selectAllButton.addActionListener(e -> selectAll());
deselectAllButton.addActionListener(e -> deselectAll());
}
/**
* Select all files to be saved.
*/
@ -304,7 +273,7 @@ public class SaveDataDialog extends DialogComponentProvider {
public void mouseClicked(MouseEvent e) {
clearStatusText();
JList list = (JList) e.getSource();
JList<?> list = (JList<?>) e.getSource();
int index = list.locationToIndex(e.getPoint());
if (index < 0) {
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.text.Document;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.button.BrowseButton;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GDLabel;
@ -178,7 +178,7 @@ class SelectProjectPanel extends AbstractWizardJPanel {
projectNameField.getDocument().addDocumentListener(docListener);
directoryField.getDocument().addDocumentListener(docListener);
browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
browseButton = new BrowseButton();
browseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {

View file

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

View file

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

View file

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