Merge remote-tracking branch 'origin/GP-2795-dragonmacher-button-disabled-icons'

This commit is contained in:
Ryan Kurtz 2023-01-03 11:05:22 -05:00
commit e100c84085
16 changed files with 123 additions and 114 deletions

View file

@ -23,6 +23,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import docking.DialogComponentProvider;
import docking.widgets.button.GButton;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
import ghidra.framework.plugintool.PluginTool;
import ghidra.trace.model.Trace;
@ -72,11 +73,11 @@ public class DebuggerTimeSelectionDialog extends DialogComponentProvider {
scheduleText = new JTextField();
hbox.add(scheduleText);
hbox.add(new JLabel("Ticks: "));
hbox.add(tickBack = new JButton(DebuggerResources.ICON_STEP_BACK));
hbox.add(tickStep = new JButton(DebuggerResources.ICON_STEP_INTO));
hbox.add(tickBack = new GButton(DebuggerResources.ICON_STEP_BACK));
hbox.add(tickStep = new GButton(DebuggerResources.ICON_STEP_INTO));
hbox.add(new JLabel("Ops: "));
hbox.add(opBack = new JButton(DebuggerResources.ICON_STEP_BACK));
hbox.add(opStep = new JButton(DebuggerResources.ICON_STEP_INTO));
hbox.add(opBack = new GButton(DebuggerResources.ICON_STEP_BACK));
hbox.add(opStep = new GButton(DebuggerResources.ICON_STEP_INTO));
workPanel.add(hbox, BorderLayout.NORTH);
}

View file

@ -27,6 +27,7 @@ import com.google.common.base.Predicate;
import docking.ActionContext;
import docking.widgets.DropDownSelectionTextField;
import docking.widgets.OptionDialog;
import docking.widgets.button.GButton;
import docking.widgets.label.GDLabel;
import generic.theme.GIcon;
import generic.theme.GThemeDefaults.Colors;
@ -126,13 +127,13 @@ public class BitFieldEditorPanel extends JPanel {
JPanel panel = new JPanel(new HorizontalLayout(5));
decrementButton = new JButton(DECREMENT_ICON);
decrementButton = new GButton(DECREMENT_ICON);
decrementButton.setFocusable(false);
decrementButton.setToolTipText("Decrement allocation unit offset");
decrementButton.addActionListener(e -> adjustAllocationOffset(-1));
panel.add(decrementButton);
incrementButton = new JButton(INCREMENT_ICON);
incrementButton = new GButton(INCREMENT_ICON);
incrementButton.setFocusable(false);
incrementButton.setToolTipText("Increment allocation unit offset");
incrementButton.addActionListener(e -> adjustAllocationOffset(1));

View file

@ -31,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
import docking.*;
import docking.widgets.OptionDialog;
import docking.widgets.button.GButton;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.combobox.GComboBox;
import docking.widgets.label.GLabel;
@ -440,10 +441,10 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
private Component buildButtonPanel() {
JPanel panel = new JPanel(new VerticalLayout(5));
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
addButton = new JButton(Icons.ADD_ICON);
removeButton = new JButton(Icons.DELETE_ICON);
upButton = new JButton(new GIcon("icon.up"));
downButton = new JButton(new GIcon("icon.down"));
addButton = new GButton(Icons.ADD_ICON);
removeButton = new GButton(Icons.DELETE_ICON);
upButton = new GButton(new GIcon("icon.up"));
downButton = new GButton(new GIcon("icon.down"));
addButton.setToolTipText("Add parameter");
removeButton.setToolTipText("Delete selected parameters");
upButton.setToolTipText("Move selected parameter up");

View file

@ -20,6 +20,7 @@ import java.awt.event.ActionListener;
import javax.swing.*;
import docking.widgets.button.GButton;
import generic.theme.GIcon;
import resources.Icons;
@ -128,6 +129,10 @@ public class FunctionTagButtonPanel extends JPanel {
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setMaximumSize(new Dimension(30, 300));
addBtn.setEnabled(false);
removeBtn.setEnabled(false);
deleteBtn.setEnabled(false);
}
/**
@ -140,7 +145,7 @@ public class FunctionTagButtonPanel extends JPanel {
* @return the new button
*/
private JButton createButton(String name, Icon icon, String tooltip, ActionListener action) {
JButton button = new JButton(name);
JButton button = new GButton(name);
button.setName(name);
button.setToolTipText(tooltip);
button.setIcon(icon);

View file

@ -29,6 +29,7 @@ import javax.swing.table.AbstractTableModel;
import org.jdom.Element;
import docking.DropDownMenuIcon;
import docking.widgets.button.GButton;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.label.GDLabel;
@ -104,7 +105,7 @@ class EditMemoryReferencePanel extends EditReferencePanel {
toAddressField = new AddressInput();
addrHistoryButton = new JButton(MENU_ICON);
addrHistoryButton = new GButton(MENU_ICON);
addrHistoryButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {

View file

@ -20,8 +20,10 @@ import java.util.HashSet;
import java.util.List;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import docking.widgets.button.GButton;
import docking.widgets.label.GDLabel;
import generic.theme.GIcon;
import ghidra.program.model.address.*;
@ -81,10 +83,10 @@ public class AddressSetEditorPanel extends JPanel {
maxAddressField.addChangeListener(listener);
maxAddressPanel.add(maxAddressField, BorderLayout.CENTER);
maxAddressPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
addRangeButton = new JButton(ADD_ICON);
addRangeButton = new GButton(ADD_ICON);
addRangeButton.addActionListener(e -> addRange());
addRangeButton.setToolTipText("Add the range to the set of included addresses");
subtractRangeButton = new JButton(SUBTRACT_ICON);
subtractRangeButton = new GButton(SUBTRACT_ICON);
subtractRangeButton.addActionListener(e -> subtractRange());
subtractRangeButton.setToolTipText("Remove the range from the set of included addresses");
@ -116,7 +118,7 @@ public class AddressSetEditorPanel extends JPanel {
bottomButtons = new JPanel();
bottomButtons.setLayout(new MiddleLayout());
removeRangeButton = new JButton("Remove Selected Range(s)");
removeRangeButton = new GButton("Remove Selected Range(s)");
removeRangeButton.addActionListener(e -> removeRange());
bottomButtons.add(removeRangeButton);

View file

@ -30,6 +30,7 @@ import javax.swing.table.TableColumn;
import docking.DockingWindowManager;
import docking.widgets.OptionDialog;
import docking.widgets.button.BrowseButton;
import docking.widgets.button.GButton;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GHtmlLabel;
@ -566,7 +567,7 @@ class SymbolServerPanel extends JPanel {
private static JButton createImageButton(Icon buttonIcon, String alternateText) {
JButton button = new JButton(buttonIcon);
JButton button = new GButton(buttonIcon);
button.setToolTipText(alternateText);
button.setPreferredSize(BUTTON_SIZE);

View file

@ -17,13 +17,13 @@ package ghidra.feature.vt.gui.wizard;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import docking.widgets.button.GButton;
import docking.widgets.button.GRadioButton;
import docking.widgets.label.GLabel;
import docking.widgets.list.GList;
@ -46,11 +46,7 @@ public class ChooseAddressSetEditorPanel extends JPanel {
private PluginTool tool;
private final String name;
private final Program program;
private final AddressFactory addressFactory;
private final AddressSet selectionAddressSet;
private boolean hasSelection = false;
private final AddressSet myInitialAddressSet;
private final AddressSetChoice initialAddressSetChoice;
private AddressSet myCurrentAddressSet;
private AddressSetChoice currentAddressSetChoice;
private JRadioButton entireProgramButton;
@ -70,18 +66,14 @@ public class ChooseAddressSetEditorPanel extends JPanel {
final AddressSetChoice initialAddressSetChoice) {
super(new BorderLayout());
// Establish the initial state from the parameters.
this.tool = tool;
this.name = name;
this.program = program;
this.addressFactory = program.getAddressFactory();
this.selectionAddressSet = new AddressSet(selectionAddressSet);
if (selectionAddressSet != null && !selectionAddressSet.isEmpty()) {
hasSelection = true;
}
this.myInitialAddressSet = new AddressSet(myInitialAddressSet);
this.initialAddressSetChoice = (initialAddressSetChoice != null) ? initialAddressSetChoice
: (hasSelection ? AddressSetChoice.SELECTION : AddressSetChoice.ENTIRE_PROGRAM);
if (myInitialAddressSet != null && !myInitialAddressSet.isEmpty()) {
myCurrentAddressSet = new AddressSet(myInitialAddressSet);
@ -134,26 +126,9 @@ public class ChooseAddressSetEditorPanel extends JPanel {
myRangesButton.setToolTipText("Limit the address ranges from the " + name +
" program to those that I am specifying here.");
entireProgramButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev) {
choseEntireProgram();
}
});
toolSelectionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev) {
choseToolSelection();
}
});
myRangesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev) {
choseMyRanges();
}
});
entireProgramButton.addActionListener(ev -> choseEntireProgram());
toolSelectionButton.addActionListener(ev -> choseToolSelection());
myRangesButton.addActionListener(ev -> choseMyRanges());
chooseSourcePanel.add(entireProgramButton);
chooseSourcePanel.add(toolSelectionButton);
@ -195,13 +170,8 @@ public class ChooseAddressSetEditorPanel extends JPanel {
bottomButtons = new JPanel();
bottomButtons.setLayout(new MiddleLayout());
removeRangeButton = new JButton("Remove Selected Range(s)");
removeRangeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeRange();
}
});
removeRangeButton = new GButton("Remove Selected Range(s)");
removeRangeButton.addActionListener(e -> removeRange());
bottomButtons.add(removeRangeButton);
return bottomButtons;
@ -209,22 +179,12 @@ public class ChooseAddressSetEditorPanel extends JPanel {
private Component createRangeListPanel() {
addRangeButton = new JButton(ADD_ICON);
addRangeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showAddRangeDialog();
}
});
addRangeButton = new GButton(ADD_ICON);
addRangeButton.addActionListener(e -> showAddRangeDialog());
addRangeButton.setToolTipText("Add the range to the set of included addresses");
subtractRangeButton = new JButton(SUBTRACT_ICON);
subtractRangeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showSubtractRangeDialog();
}
});
subtractRangeButton = new GButton(SUBTRACT_ICON);
subtractRangeButton.addActionListener(e -> showSubtractRangeDialog());
subtractRangeButton.setToolTipText("Remove the range from the set of included addresses");
JPanel buttonPanel = new JPanel();
@ -237,12 +197,7 @@ public class ChooseAddressSetEditorPanel extends JPanel {
listModel = new AddressSetListModel(myCurrentAddressSet.toList());
list = new GList<>(listModel);
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
validateRemoveButton();
}
});
list.getSelectionModel().addListSelectionListener(e -> validateRemoveButton());
JScrollPane scrollPane = new JScrollPane(list);
JPanel panel = new JPanel(new BorderLayout());
@ -255,24 +210,16 @@ public class ChooseAddressSetEditorPanel extends JPanel {
}
protected void showAddRangeDialog() {
AddressRangeListener addListener = new AddressRangeListener() {
@Override
public void processAddressRange(Address minAddress, Address maxAddress) {
addRange(minAddress, maxAddress);
}
};
AddressRangeListener addListener =
(minAddress, maxAddress) -> addRange(minAddress, maxAddress);
AddRemoveAddressRangeDialog addRangeDialog =
new AddRemoveAddressRangeDialog("Add", name, program, addListener);
tool.showDialog(addRangeDialog, this.getRootPane());
}
protected void showSubtractRangeDialog() {
AddressRangeListener subtractListener = new AddressRangeListener() {
@Override
public void processAddressRange(Address minAddress, Address maxAddress) {
subtractRange(minAddress, maxAddress);
}
};
AddressRangeListener subtractListener =
(minAddress, maxAddress) -> subtractRange(minAddress, maxAddress);
AddRemoveAddressRangeDialog removeRangeDialog =
new AddRemoveAddressRangeDialog("Remove", name, program, subtractListener);
tool.showDialog(removeRangeDialog, this.getRootPane());
@ -289,8 +236,8 @@ public class ChooseAddressSetEditorPanel extends JPanel {
private synchronized void removeRange() {
int[] selectedIndices = list.getSelectedIndices();
AddressSet removeRanges = new AddressSet();
for (int i = 0; i < selectedIndices.length; i++) {
AddressRange addressRange = listModel.getElementAt(selectedIndices[i]);
for (int selectedIndex : selectedIndices) {
AddressRange addressRange = listModel.getElementAt(selectedIndex);
removeRanges.add(addressRange);
}
myCurrentAddressSet.delete(removeRanges);

View file

@ -0,0 +1,46 @@
/* ###
* 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 javax.swing.Icon;
import javax.swing.JButton;
import resources.ResourceManager;
/**
* A drop-in replacement for {@link JButton} that correctly installs a disable icon.
*/
public class GButton extends JButton {
public GButton() {
super();
}
public GButton(Icon icon) {
super(icon);
}
public GButton(String text) {
super(text);
}
@Override
public void setIcon(Icon newIcon) {
Icon disabledIcon = ResourceManager.getDisabledIcon(newIcon);
setDisabledIcon(disabledIcon);
super.setIcon(newIcon);
}
}

View file

@ -140,7 +140,7 @@ public class GLabel extends JLabel implements GComponent {
* <p>
* If the user has a type of "GLabel", they will see the deprecated warning on calls to setText().
* <p>
* If there are calls to setText() after the initial value has been set by the ctor, a
* If there are calls to setText() after the initial value has been set by the constructor, a
* warning will be printed in the log.
* <p>
* @param text string this label will display

View file

@ -25,6 +25,7 @@ import javax.swing.*;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableColumn;
import docking.widgets.button.GButton;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.table.*;
@ -162,26 +163,26 @@ public class PathManager {
panel = new JPanel(new BorderLayout(5, 5));
if (allowOrdering) {
upButton = new JButton(Icons.UP_ICON);
upButton = new GButton(Icons.UP_ICON);
upButton.setName("UpArrow");
upButton.setToolTipText("Move the selected path up in list");
upButton.addActionListener(e -> up());
upButton.setFocusable(false);
downButton = new JButton(Icons.DOWN_ICON);
downButton = new GButton(Icons.DOWN_ICON);
downButton.setName("DownArrow");
downButton.setToolTipText("Move the selected path down in list");
downButton.addActionListener(e -> down());
downButton.setFocusable(false);
}
addButton = new JButton(Icons.ADD_ICON);
addButton = new GButton(Icons.ADD_ICON);
addButton.setName("AddPath");
addButton.setToolTipText("Display file chooser to select files to add");
addButton.addActionListener(e -> add());
addButton.setFocusable(false);
removeButton = new JButton(Icons.DELETE_ICON);
removeButton = new GButton(Icons.DELETE_ICON);
removeButton.setName("RemovePath");
removeButton.setToolTipText("Remove selected path(s) from list");
removeButton.addActionListener(e -> remove());

View file

@ -24,6 +24,7 @@ import java.util.Objects;
import javax.swing.*;
import docking.widgets.OptionDialog;
import docking.widgets.button.GButton;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.table.*;
@ -157,24 +158,24 @@ public class PathnameTablePanel extends JPanel {
private void create() {
upButton = new JButton(Icons.UP_ICON);
upButton = new GButton(Icons.UP_ICON);
upButton.setName("UpArrow");
upButton.setToolTipText("Move the selected path up in list");
upButton.addActionListener(e -> up());
downButton = new JButton(Icons.DOWN_ICON);
downButton = new GButton(Icons.DOWN_ICON);
downButton.setName("DownArrow");
downButton.setToolTipText("Move the selected path down in list");
downButton.addActionListener(e -> down());
addButton = new JButton(Icons.ADD_ICON);
addButton = new GButton(Icons.ADD_ICON);
addButton.setName("AddPath");
addButton.setToolTipText("Display file chooser to select files to add");
addButton.addActionListener(e -> add());
removeButton = new JButton(Icons.DELETE_ICON);
removeButton = new GButton(Icons.DELETE_ICON);
removeButton.setName("RemovePath");
removeButton.setToolTipText("Remove selected path(s) from list");
removeButton.addActionListener(e -> remove());
resetButton = new JButton(RESET_ICON);
resetButton = new GButton(RESET_ICON);
resetButton.setName("RefreshPaths");
resetButton.setToolTipText("Resets path list to the default values");
resetButton.addActionListener(e -> reset());

View file

@ -31,6 +31,7 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import docking.DialogComponentProvider;
import docking.widgets.button.GButton;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
import docking.widgets.label.GDLabel;
@ -44,7 +45,6 @@ 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.
@ -268,13 +268,11 @@ class EditPluginPathDialog extends DialogComponentProvider {
private JPanel buildPluginPathsPanel() {
// create the UP and DOWN arrows panel
upButton = new JButton(Icons.UP_ICON);
upButton.setDisabledIcon(ResourceManager.getDisabledIcon(Icons.UP_ICON));
upButton = new GButton(Icons.UP_ICON);
upButton.setName("UpArrow");
upButton.addActionListener(e -> handleSelection(UP));
downButton = new JButton(Icons.DOWN_ICON);
downButton.setDisabledIcon(ResourceManager.getDisabledIcon(Icons.DOWN_ICON));
downButton = new GButton(Icons.DOWN_ICON);
downButton.setName("DownArrow");
downButton.addActionListener(e -> handleSelection(DOWN));
JPanel arrowButtonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));
@ -282,11 +280,11 @@ class EditPluginPathDialog extends DialogComponentProvider {
arrowButtonsPanel.add(downButton);
// create the Add and Remove panel
JButton addJarButton = new JButton(ADD_JAR_BUTTON_TEXT);
JButton addJarButton = new GButton(ADD_JAR_BUTTON_TEXT);
addJarButton.addActionListener(e -> addJarCallback());
JButton addDirButton = new JButton(ADD_DIR_BUTTON_TEXT);
JButton addDirButton = new GButton(ADD_DIR_BUTTON_TEXT);
addDirButton.addActionListener(e -> addDirCallback());
removeButton = new JButton("Remove");
removeButton = new GButton("Remove");
removeButton.addActionListener(e -> handleSelection(REMOVE));
Dimension d = addJarButton.getPreferredSize();
addDirButton.setPreferredSize(d);

View file

@ -32,6 +32,7 @@ import docking.action.MenuData;
import docking.tool.ToolConstants;
import docking.widgets.OkDialog;
import docking.widgets.OptionDialog;
import docking.widgets.button.GButton;
import docking.widgets.dialogs.InputDialog;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.filechooser.GhidraFileChooserMode;
@ -697,7 +698,7 @@ public class FrontEndPlugin extends Plugin
RepositoryAdapter repository = project.getRepository();
User user = null;
boolean isConnected = repository.isConnected();
connectionButton = new JButton(isConnected ? CONNECTED_ICON : DISCONNECTED_ICON);
connectionButton = new GButton(isConnected ? CONNECTED_ICON : DISCONNECTED_ICON);
connectionButton.addActionListener(e -> connect());
connectionButton.setContentAreaFilled(false);

View file

@ -27,6 +27,7 @@ import javax.swing.border.BevelBorder;
import docking.DialogComponentProvider;
import docking.widgets.OptionDialog;
import docking.widgets.button.GButton;
import docking.widgets.label.GDLabel;
import docking.widgets.label.GLabel;
import docking.wizard.WizardManager;
@ -253,7 +254,7 @@ public class ProjectInfoDialog extends DialogComponentProvider {
JLabel connectLabel = new GDLabel("Connection Status:", SwingConstants.RIGHT);
panel.add(connectLabel);
connectionButton = new JButton(
connectionButton = new GButton(
isConnected ? FrontEndPlugin.CONNECTED_ICON : FrontEndPlugin.DISCONNECTED_ICON);
connectionButton.addActionListener(e -> connect());
connectionButton.setName("Connect Button");

View file

@ -17,15 +17,17 @@ package ghidra.framework.main;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.*;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.ChangeListener;
import javax.swing.event.MouseInputAdapter;
import docking.DialogComponentProvider;
import docking.widgets.button.GButton;
import docking.widgets.button.GRadioButton;
import docking.widgets.label.GDLabel;
import docking.widgets.label.GLabel;
@ -78,7 +80,7 @@ class RepositoryChooser extends DialogComponentProvider {
serverInfoComponent.setChangeListener(e -> serverInfoChanged());
topPanel.add(serverInfoComponent, BorderLayout.CENTER);
queryButton = new JButton(REFRESH_ICON);
queryButton = new GButton(REFRESH_ICON);
queryButton.setToolTipText("Refresh Repository Names List");
setDefaultButton(queryButton);
queryButton.addActionListener(e -> queryServer());