GP-1981 - Theming - GColor migration fixes

This commit is contained in:
dragonmacher 2022-08-19 16:52:15 -04:00 committed by ghidragon
parent 3d9c5f0242
commit b837bd3aa3
33 changed files with 866 additions and 233 deletions

View file

@ -76,8 +76,17 @@ class ProjectDataPanel extends JSplitPane {
projectTab.addTab("Tree View", activePanel);
projectTab.addTab("Table View", tablePanel);
// setup the active data tree panel
this.add(projectTab, JSplitPane.LEFT);
//
// Setup the active data tree panel
//
// Use a panel for the left side of the split pane so the split pane background does not
// shine through. This allows users to change the split pane background to change the
// divider color without affecting the background of the front end.
//
JPanel leftPanel = new JPanel(new BorderLayout());
leftPanel.add(projectTab);
this.add(leftPanel, JSplitPane.LEFT);
projectTab.setBorder(BorderFactory.createTitledBorder(BORDER_PREFIX));
// initialize the read-only project view tabbed pane

View file

@ -16,8 +16,8 @@
package ghidra.framework.main;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.InvocationTargetException;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
@ -28,11 +28,11 @@ import docking.DialogComponentProvider;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.list.ListPanel;
import generic.theme.GThemeDefaults.Colors;
import ghidra.framework.model.DomainFile;
import ghidra.framework.model.ProjectLocator;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.*;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.*;
@ -80,20 +80,12 @@ public class SaveDataDialog extends DialogComponentProvider {
yesButton = new JButton("Save");
yesButton.setMnemonic('S');
addButton(yesButton);
yesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
okCallback();
}
});
yesButton.addActionListener(evt -> okCallback());
noButton = new JButton("Don't Save");
noButton.setMnemonic('n');
noButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
operationCompleted = true;
close();
}
noButton.addActionListener(evt -> {
operationCompleted = true;
close();
});
addButton(noButton);
addCancelButton();
@ -178,7 +170,7 @@ public class SaveDataDialog extends DialogComponentProvider {
deselectAllButton = new JButton(DESELECT_ALL);
deselectAllButton.setMnemonic('N');
JPanel buttonPanel = ButtonPanelFactory.createButtonPanel(
JPanel myButtonPanel = ButtonPanelFactory.createButtonPanel(
new JButton[] { selectAllButton, deselectAllButton });
//
@ -189,7 +181,7 @@ public class SaveDataDialog extends DialogComponentProvider {
listPanel.setMouseListener(new ListMouseListener());
// Layout Main Panel
parentPanel.add(buttonPanel, BorderLayout.EAST);
parentPanel.add(myButtonPanel, BorderLayout.EAST);
parentPanel.add(listPanel, BorderLayout.CENTER);
parentPanel.setBorder(new TitledBorder("Data"));
@ -201,19 +193,9 @@ public class SaveDataDialog extends DialogComponentProvider {
* Add listeners to the buttons.
*/
private void addListeners() {
selectAllButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectAll();
}
});
selectAllButton.addActionListener(e -> selectAll());
deselectAllButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deselectAll();
}
});
deselectAllButton.addActionListener(e -> deselectAll());
}
@ -265,7 +247,7 @@ public class SaveDataDialog extends DialogComponentProvider {
yesButton.setEnabled(false);
for (int i = 0; i < files.size(); i++) {
checkboxes[i] = new GCheckBox(files.get(i).getName());
checkboxes[i].setBackground(Color.white);
checkboxes[i].setBackground(Colors.BACKGROUND);
saveable[i] = files.get(i).canSave();
if (!saveable[i]) {
String text = files.get(i).getName() + readOnlyString;
@ -285,10 +267,9 @@ public class SaveDataDialog extends DialogComponentProvider {
}
listPanel.refreshList(checkboxes);
setFocusComponent(yesButton);//.requestFocusInWindow();
setFocusComponent(yesButton);
}
/////////////////////////////////////////////////////////////////////////
/**
* Cell renderer to show the checkboxes for the changed data files.
*/
@ -307,7 +288,7 @@ public class SaveDataDialog extends DialogComponentProvider {
// set color to red if file cannot be saved 'as is'
if (!saveable[index]) {
checkboxes[index].setForeground(Color.red);
checkboxes[index].setForeground(Colors.ERROR);
checkboxes[index].setFont(boldFont);
}
return checkboxes[index];
@ -340,10 +321,6 @@ public class SaveDataDialog extends DialogComponentProvider {
}
}
/////////////////////////////////////////////////////////////////////////
/**
* Task to save files.
*/
private class SaveTask extends Task {
private DomainFile[] domainFiles;
@ -352,9 +329,6 @@ public class SaveDataDialog extends DialogComponentProvider {
this.domainFiles = files;
}
/**
* @see ghidra.util.task.Task#run(TaskMonitor)
*/
@Override
public void run(TaskMonitor monitor) {
try {
@ -377,42 +351,12 @@ public class SaveDataDialog extends DialogComponentProvider {
t);
}
if (operationCompleted) {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
close();
}
});
}
catch (InterruptedException e) {
// don't care?
}
catch (InvocationTargetException e) {
// don't care?
}
Swing.runNow(() -> close());
}
else if (monitor.isCancelled()) {
updateList();
Swing.runNow(() -> initList());
}
}
/**
* Refresh the list of files that need saving.
*/
private void updateList() {
Runnable r = new Runnable() {
@Override
public void run() {
initList();
}
};
try {
SwingUtilities.invokeAndWait(r);
}
catch (Exception e) {
// don't care?
}
}
}
}

View file

@ -25,6 +25,7 @@ import javax.swing.*;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.list.ListPanel;
import generic.theme.GThemeDefaults.Colors;
import ghidra.framework.model.DomainFile;
/**
@ -52,7 +53,7 @@ class DomainFilesPanel extends JPanel {
for (int i = 0; i < fileList.size(); i++) {
DomainFile df = fileList.get(i);
checkboxes[i] = new GCheckBox(df.getPathname(), true);
checkboxes[i].setBackground(Color.white);
checkboxes[i].setBackground(Colors.BACKGROUND);
}
//

View file

@ -23,6 +23,7 @@ import javax.swing.table.TableColumn;
import docking.DialogComponentProvider;
import docking.widgets.table.*;
import generic.theme.GColor;
import ghidra.app.util.GenericHelpTopics;
import ghidra.framework.plugintool.PluginConfigurationModel;
import ghidra.framework.plugintool.PluginTool;
@ -38,6 +39,11 @@ import help.HelpService;
*/
public class PluginInstallerDialog extends DialogComponentProvider {
private static final Color FG_COLOR_HAS_DEPENDENTS =
new GColor("color.fg.plugin.installer.table.has.dependents");
private static final Color FG_COLOR_HAS_DEPENDENTS_SELECTED =
new GColor("color.fg.plugin.installer.table.has.dependents.selected");
private PluginTool tool;
private PluginConfigurationModel model;
private List<PluginDescription> pluginDescriptions;
@ -253,7 +259,7 @@ public class PluginInstallerDialog extends DialogComponentProvider {
if (isSelected) {
if (hasDependents) {
renderer.setForeground(Color.pink);
renderer.setForeground(FG_COLOR_HAS_DEPENDENTS_SELECTED);
renderer.setFont(boldFont);
}
else {
@ -264,7 +270,7 @@ public class PluginInstallerDialog extends DialogComponentProvider {
else {
// set color to red if other plugins depend on this plugin
if (hasDependents) {
renderer.setForeground(Color.red);
renderer.setForeground(FG_COLOR_HAS_DEPENDENTS);
renderer.setFont(boldFont);
}
else {

View file

@ -144,6 +144,7 @@ public class GProgressBar extends JPanel {
* By default, this property is <code>false</code>.
* Some look and feels might not support indeterminate progress bars;
* they will ignore this property.
* @param indeterminate true if indeterminate
*
* @see JProgressBar
*/
@ -157,6 +158,7 @@ public class GProgressBar extends JPanel {
/**
* Show or not show the progress icon (spinning globe) according to
* the showIcon param.
* @param showIcon true to show the icon
*/
public void showProgressIcon(final boolean showIcon) {
if (showIcon == showingIcon) {

View file

@ -20,6 +20,7 @@ import java.awt.*;
import javax.swing.*;
import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults.Colors;
import ghidra.framework.task.gui.GProgressBar;
public class ScheduledTaskPanel extends JPanel {
@ -38,13 +39,13 @@ public class ScheduledTaskPanel extends JPanel {
layout = new ScheduledElementLayout();
setLayout(layout);
label = new GDLabel(labelText);
setBackground(Color.WHITE);
setBackground(Colors.BACKGROUND);
add(label);
}
void addProgressBar() {
progressBar = new GProgressBar(null, true, true, false, 12);
progressBar.setBackgroundColor(Color.WHITE);
progressBar.setBackgroundColor(Colors.BACKGROUND);
add(progressBar);
layout.clearPreferredSize();
invalidate();