ex
}
color =
- fieldOptions.getColor(GhidraOptions.OPTION_HIGHLIGHT_COLOR, new Color(255, 255, 180));
+ fieldOptions.getColor(GhidraOptions.OPTION_HIGHLIGHT_COLOR,
+ GhidraOptions.DEFAULT_HIGHLIGHT_COLOR);
MarkerSet highlightMarkers = getHighlightMarkers(currentProgram);
fieldPanel.setHighlightColor(color);
if (highlightMarkers != null) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/LayeredColorModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/LayeredColorModel.java
index 4f786ec39b..d191af9cdc 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/LayeredColorModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/LayeredColorModel.java
@@ -18,6 +18,7 @@ package ghidra.app.plugin.core.codebrowser;
import java.awt.Color;
import java.math.BigInteger;
+import generic.theme.TempColorUtils;
import ghidra.app.util.viewer.listingpanel.ListingBackgroundColorModel;
import ghidra.app.util.viewer.listingpanel.ListingPanel;
@@ -52,10 +53,7 @@ public class LayeredColorModel implements ListingBackgroundColorModel {
}
private Color blend(Color primary, Color secondary) {
- int red = (primary.getRed() * 2 + secondary.getRed()) / 3;
- int green = (primary.getGreen() * 2 + secondary.getGreen()) / 3;
- int blue = (primary.getBlue() * 2 + secondary.getBlue()) / 3;
- return new Color(red, green, blue);
+ return TempColorUtils.blend1(primary, secondary);
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java
index 1532741187..14c97610ea 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java
@@ -54,8 +54,8 @@ public class ListingHighlightProvider
implements ButtonPressedListener, OptionsChangeListener, HighlightProvider {
//@formatter:off
private static final Color DEFAULT_HIGHLIGHT_COLOR = new GColor("color.fg.listing.highlighter.default");
- private static final Color DEFAULT_SCOPED_READ_COLOR = new GColor("color.fg.listing.highlighter.scoped-read");
- private static final Color DEFAULT_SCOPED_WRITE_COLOR = new GColor("color.fg.listing.highlighter.scoped-write");
+ private static final Color DEFAULT_SCOPED_READ_COLOR = new GColor("color.fg.listing.highlighter.scoped.read");
+ private static final Color DEFAULT_SCOPED_WRITE_COLOR = new GColor("color.fg.listing.highlighter.scoped.write");
private static final String DISPLAY_HIGHLIGHT_NAME = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Enabled";
private static final String SCOPED_WRITE_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Write Highlight Color";
private static final String SCOPED_READ_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Read Highlight Color";
@@ -144,7 +144,7 @@ public class ListingHighlightProvider
Pattern highlightPattern = currentHighlightPattern;
Matcher matcher = highlightPattern.matcher(text);
- List
";
+ "
";
toolTipText = toolTipText.replace("", errorText);
}
return createTooltipComponent(toolTipText);
@@ -149,7 +151,9 @@ public class DataTypeListingHover extends AbstractConfigurableHover implements L
result += "
Missing NULL terminator.";
}
if (sdi.getStringLength() > dataInstance.getLength()) {
- result += "
String exceeds data field.";
+ result +=
+ "
String exceeds data field.";
}
}
return result;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/colorizer/ColorizingPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/colorizer/ColorizingPlugin.java
index 04de35dbbd..38ab64510e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/colorizer/ColorizingPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/colorizer/ColorizingPlugin.java
@@ -24,6 +24,8 @@ import org.jdom.Element;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.MenuData;
+import generic.theme.GColor;
+import generic.theme.TempColorUtils;
import ghidra.app.CorePluginPackage;
import ghidra.app.context.ListingActionContext;
import ghidra.app.plugin.PluginCategoryNames;
@@ -61,7 +63,7 @@ public class ColorizingPlugin extends ProgramPlugin implements DomainObjectListe
private static final String MARKER_DESCRIPTION = "Shows the location of user-applied colors";
private static final int PRIORITY = MarkerService.CHANGE_PRIORITY - 1; // lowest priority
- private static final Color MARKER_COLOR = Color.PINK;
+ private static final Color MARKER_COLOR = new GColor("color.bg.plugin.colorizer.marker");
private static final String COLOR_HISTORY_XML_NAME = "COLOR_HISTORY";
private static final String COLOR_HISTORY_LIST_XML_NAME = "COLOR_HISTORY";
@@ -80,12 +82,7 @@ public class ColorizingPlugin extends ProgramPlugin implements DomainObjectListe
private NextColorRangeAction nextAction;
private PreviousColorRangeAction previousAction;
- private SwingUpdateManager updateManager = new SwingUpdateManager(1000, new Runnable() {
- @Override
- public void run() {
- doUpdate();
- }
- });
+ private SwingUpdateManager updateManager = new SwingUpdateManager(1000, () -> doUpdate());
public ColorizingPlugin(PluginTool tool) {
super(tool);
@@ -108,12 +105,12 @@ public class ColorizingPlugin extends ProgramPlugin implements DomainObjectListe
public void readConfigState(SaveState saveState) {
Element xmlElement = saveState.getXmlElement(COLOR_HISTORY_XML_NAME);
if (xmlElement != null) {
- List
" +
"data type to be specified. The actual computed alignment
" +
- "may be any multiple of this value. (<F1> for help)";
+ "may be any multiple of this value. " +
+ "(<F1> for help)";
alignPanel.setToolTipText(alignmentToolTip);
addMinimumAlignmentComponents();
@@ -570,7 +573,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
infoPanel.add(actualAlignmentPanel, gridBagConstraints);
actualAlignmentValueTextField = new JTextField(8);
- actualAlignmentValueTextField.setText("" + ((CompEditorModel) model).getActualAlignment());
+ actualAlignmentValueTextField
+ .setText(Integer.toString(((CompEditorModel) model).getActualAlignment()));
actualAlignmentValueTextField.setToolTipText(actualAlignmentToolTip);
actualAlignmentValueTextField.setEditable(false);
if (helpManager != null) {
@@ -586,7 +590,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 3;
infoPanel.add(actualAlignmentValueTextField, gridBagConstraints);
- actualAlignmentValueTextField.setBackground(new Color(getBackground().getRGB()));
+ actualAlignmentValueTextField.setBackground(getBackground());
}
private void setupPacking() {
@@ -669,8 +673,11 @@ public class CompEditorPanel extends CompositeEditorPanel {
private void setupPackingEnablementButton() {
packingEnablementButton.setName("Packing Enablement");
String packingToolTipText =
- "Enable packing when details of all components are known (including sizing and alignment).
" +
- "Disable packing when Reverse Engineering composite. (<F1> for help)";
+ "Enable packing when details of all components are known (including sizing and" +
+ " alignment).
" +
+ "Disable packing when Reverse Engineering composite. " +
+ "(<F1> for help)";
packingEnablementButton.addActionListener(e -> {
((CompEditorModel) model).setPackingType(
packingEnablementButton.isSelected() ? PackingType.DEFAULT : PackingType.DISABLED,
@@ -708,8 +715,9 @@ public class CompEditorPanel extends CompositeEditorPanel {
explicitPackingButton.addActionListener(e -> chooseByValuePacking());
explicitPackingButton.setToolTipText(packingToolTipText);
if (helpManager != null) {
- helpManager.registerHelp(explicitPackingButton, new HelpLocation(provider.getHelpTopic(),
- provider.getHelpName() + "_" + "Pack"));
+ helpManager.registerHelp(explicitPackingButton,
+ new HelpLocation(provider.getHelpTopic(),
+ provider.getHelpName() + "_" + "Pack"));
}
explicitPackingTextField.setName("Packing Value");
@@ -831,7 +839,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
}
else {
// not editable - use same background as panel
- sizeTextField.setBackground(new Color(getBackground().getRGB()));
+ sizeTextField.setBackground(getBackground());
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java
index 4bd980b492..450ab47ec1 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java
@@ -43,6 +43,7 @@ import docking.widgets.label.GDLabel;
import docking.widgets.label.GLabel;
import docking.widgets.table.*;
import docking.widgets.textfield.GValidatedTextField;
+import generic.theme.GColor;
import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.datatype.DataTypeSelectionEditor;
import ghidra.app.util.datatype.NavigationDirection;
@@ -70,8 +71,6 @@ public abstract class CompositeEditorPanel extends JPanel
implements CompositeEditorModelListener, ComponentCellEditorListener, Draggable, Droppable {
// Normal color for selecting components in the table.
- // TODO: Why do we choose a different selection color?
- //private static final Color SELECTION_COLOR = Color.YELLOW.brighter().brighter();
//protected static final Insets TEXTFIELD_INSETS = new JTextField().getInsets();
protected static final Border BEVELED_BORDER = BorderFactory.createLoweredBevelBorder();
@@ -605,8 +604,6 @@ public abstract class CompositeEditorPanel extends JPanel
JScrollPane sp = new JScrollPane(table);
table.setPreferredScrollableViewportSize(new Dimension(model.getWidth(), 250));
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- //table.setSelectionBackground(SELECTION_COLOR);
- //table.setSelectionForeground(Color.black);
tablePanel.add(sp, BorderLayout.CENTER);
SearchControlPanel searchPanel = new SearchControlPanel(this);
@@ -636,7 +633,7 @@ public abstract class CompositeEditorPanel extends JPanel
// This can happen on the Mac and is usually white. This is a simple solution for
// that scenario. If this fails on other platforms, then do something more advanced
// at that point.
- table.setGridColor(Color.GRAY);
+ table.setGridColor(new GColor("color.bg.table.grid"));
}
}
@@ -668,7 +665,7 @@ public abstract class CompositeEditorPanel extends JPanel
JPanel panel = new JPanel(new BorderLayout());
statusLabel = new GDLabel(" ");
statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
- statusLabel.setForeground(Color.blue);
+ statusLabel.setForeground(new GColor("color.fg.dialog.status.normal"));
statusLabel.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DataTypeCellRenderer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DataTypeCellRenderer.java
index 59dfe9478b..358c42b509 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DataTypeCellRenderer.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DataTypeCellRenderer.java
@@ -15,13 +15,13 @@
*/
package ghidra.app.plugin.core.compositeeditor;
-import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import docking.widgets.table.GTableCellRenderer;
import docking.widgets.table.GTableCellRenderingData;
+import generic.theme.GThemeDefaults.Colors;
import ghidra.app.util.ToolTipUtils;
import ghidra.program.model.data.*;
import ghidra.util.HTMLUtilities;
@@ -43,7 +43,7 @@ public class DataTypeCellRenderer extends GTableCellRenderer {
String dtString = "";
String tooltipText = null;
- boolean useRed = false;
+ boolean showError = false;
DataType dt = null;
if (value instanceof DataTypeInstance) {
@@ -51,7 +51,7 @@ public class DataTypeCellRenderer extends GTableCellRenderer {
tooltipText = getDataTypeToolTip(dt);
dtString = dt.getDisplayName();
if (dt.isNotYetDefined()) {
- useRed = true;
+ showError = true;
}
}
@@ -61,8 +61,8 @@ public class DataTypeCellRenderer extends GTableCellRenderer {
c.setToolTipText(tooltipText);
- if (useRed) {
- c.setForeground(Color.RED);
+ if (showError) {
+ c.setForeground(Colors.ERROR);
}
return c;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/CreateStructureDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/CreateStructureDialog.java
index 83c88dcb5d..5d3d6c9eda 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/CreateStructureDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/CreateStructureDialog.java
@@ -15,10 +15,10 @@
*/
package ghidra.app.plugin.core.data;
-import java.awt.*;
+import java.awt.Component;
+import java.awt.Dimension;
import java.awt.event.*;
import java.util.*;
-import java.util.List;
import javax.swing.*;
import javax.swing.border.TitledBorder;
@@ -31,6 +31,7 @@ import javax.swing.text.Document;
import docking.DialogComponentProvider;
import docking.widgets.button.GRadioButton;
import docking.widgets.table.*;
+import generic.theme.GThemeDefaults.Colors;
import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.ToolTipUtils;
import ghidra.framework.plugintool.PluginTool;
@@ -272,18 +273,17 @@ public class CreateStructureDialog extends DialogComponentProvider {
return matchingStylePanel;
}
- // toggles whether the structure being created is new, based upon the
- // name field, or a current structure, based upon a structure in the
- // table. This method updates the GUI to reflect the current creation
- // state.
+ // toggles whether the structure being created is new, based upon the name field, or a current
+ // structure, based upon a structure in the table. This method updates the GUI to reflect the
+ // current creation state.
private void setCreateStructureByName(boolean createStructureByName) {
if (createStructureByName) {
- nameBorder.setTitleColor(Color.BLACK);
- structureBorder.setTitleColor(Color.GRAY);
+ nameBorder.setTitleColor(Colors.FOREGROUND);
+ structureBorder.setTitleColor(Colors.FOREGROUND_DISABLED);
}
else {
- nameBorder.setTitleColor(Color.GRAY);
- structureBorder.setTitleColor(Color.BLACK);
+ nameBorder.setTitleColor(Colors.FOREGROUND_DISABLED);
+ structureBorder.setTitleColor(Colors.FOREGROUND);
}
nameTextField.setEnabled(createStructureByName);
@@ -299,7 +299,7 @@ public class CreateStructureDialog extends DialogComponentProvider {
// this class in terms of data contained
private void searchForMatchingStructures(final Program program, final Structure structure) {
- SwingUtilities.invokeLater(() -> {
+ Swing.runLater(() -> {
// Get the structures from the DataTypeManagers of the
// DataTypeManagerService
DataTypeManagerService service = pluginTool.getService(DataTypeManagerService.class);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeComparePanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeComparePanel.java
index 670762ce09..368eeb90d7 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeComparePanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeComparePanel.java
@@ -18,10 +18,9 @@ package ghidra.app.plugin.core.datamgr;
import java.awt.*;
import javax.swing.*;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
import docking.widgets.label.GDHtmlLabel;
+import generic.theme.GThemeDefaults.Colors;
import ghidra.app.util.ToolTipUtils;
import ghidra.app.util.html.HTMLDataTypeRepresentation;
import ghidra.program.model.data.DataType;
@@ -41,13 +40,6 @@ class DataTypeComparePanel extends JPanel {
private String clientName;
private String sourceName;
- /**
- * Creates a panel for viewing two data types side by side.
- * @param dataType1 the first data type to display.
- * @param dataType2 the second data type to display.
- * @param one_to_two true if this panel should display an arrow from data type 1 to data type 2.
- * false if the should be from 2 to 1.
- */
DataTypeComparePanel(String clientName, String sourceName) {
super(new GridLayout(0, 2));
this.clientName = clientName;
@@ -72,12 +64,12 @@ class DataTypeComparePanel extends JPanel {
add(rightPanel);
dtLabel1 = new GDHtmlLabel();
dtLabel1.setOpaque(true);
- dtLabel1.setBackground(Color.WHITE);
+ dtLabel1.setBackground(Colors.BACKGROUND);
dtLabel1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0));
dtLabel1.setVerticalAlignment(SwingConstants.TOP);
dtLabel2 = new GDHtmlLabel();
dtLabel2.setOpaque(true);
- dtLabel2.setBackground(Color.WHITE);
+ dtLabel2.setBackground(Colors.BACKGROUND);
dtLabel2.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0));
dtLabel2.setVerticalAlignment(SwingConstants.TOP);
@@ -96,19 +88,13 @@ class DataTypeComparePanel extends JPanel {
private void syncScrollers(JScrollPane leftScrollPane, JScrollPane rightScrollPane) {
final JViewport viewport1 = leftScrollPane.getViewport();
final JViewport viewport2 = rightScrollPane.getViewport();
- viewport1.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- int y = viewport1.getViewPosition().y;
- viewport2.setViewPosition(new Point(0, y));
- }
+ viewport1.addChangeListener(e -> {
+ int y = viewport1.getViewPosition().y;
+ viewport2.setViewPosition(new Point(0, y));
});
- viewport2.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- int y = viewport2.getViewPosition().y;
- viewport1.setViewPosition(new Point(0, y));
- }
+ viewport2.addChangeListener(e -> {
+ int y = viewport2.getViewPosition().y;
+ viewport1.setViewPosition(new Point(0, y));
});
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/DeleteArchiveAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/DeleteArchiveAction.java
index ee790a84b3..7e2343a725 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/DeleteArchiveAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/DeleteArchiveAction.java
@@ -24,6 +24,7 @@ import docking.ActionContext;
import docking.action.*;
import docking.widgets.OptionDialog;
import docking.widgets.tree.GTree;
+import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.archive.FileArchive;
@@ -95,7 +96,8 @@ public class DeleteArchiveAction extends DockingAction {
"Confirm Delete Operation",
"Are you sure you want to delete archive: " +
HTMLUtilities.escapeHTML(node.getName()) + "?
" +
- "(WARNING: This action will permanently " +
+ "(WARNING: This action will permanently " +
"delete the file from disk.)",
"Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
return;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/RemoveInvalidArchiveFromProgramAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/RemoveInvalidArchiveFromProgramAction.java
index 2b8b847c18..43895edceb 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/RemoveInvalidArchiveFromProgramAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/RemoveInvalidArchiveFromProgramAction.java
@@ -23,6 +23,7 @@ import docking.action.MenuData;
import docking.widgets.OptionDialog;
import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode;
+import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.archive.*;
@@ -79,7 +80,8 @@ public class RemoveInvalidArchiveFromProgramAction extends DockingAction {
"Are you sure you want to delete archive: " +
HTMLUtilities.escapeHTML(invalidArchiveNode.getName()) +
" from the program?
" +
- "(WARNING: This action will disassociate " +
+ "(WARNING: This action will disassociate " +
"all datatypes in the program from this archive.)",
"Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
return;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/TypeGraphTask.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/TypeGraphTask.java
index 2f82ea310d..ee9ed3929b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/TypeGraphTask.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/TypeGraphTask.java
@@ -17,6 +17,7 @@ package ghidra.app.plugin.core.datamgr.actions;
import java.awt.Color;
+import generic.theme.GColor;
import ghidra.app.util.ToolTipUtils;
import ghidra.program.model.data.*;
import ghidra.service.graph.*;
@@ -33,6 +34,13 @@ import ghidra.util.task.TaskMonitor;
*/
public class TypeGraphTask extends Task {
+ private static final Color BG_COLOR_DEFAULT =
+ new GColor("color.bg.plugin.datamgr.edge.default");
+ private static final Color BG_COLOR_COMPOSITE =
+ new GColor("color.bg.plugin.datamgr.edge.composite");
+ private static final Color BG_COLOR_REFERERNCE =
+ new GColor("color.bg.plugin.datamgr.edge.reference");
+
private DataType type;
private String graphTitle;
private GraphDisplayProvider graphService;
@@ -64,9 +72,9 @@ public class TypeGraphTask extends Task {
.build();
GraphDisplayOptions options = new GraphDisplayOptionsBuilder(graphType)
- .defaultVertexColor(Color.BLUE)
- .edge(COMPOSITE, Color.MAGENTA)
- .edge(REFERENCE, Color.BLUE)
+ .defaultVertexColor(BG_COLOR_DEFAULT)
+ .edge(COMPOSITE, BG_COLOR_COMPOSITE)
+ .edge(REFERENCE, BG_COLOR_REFERERNCE)
.build();
AttributedGraph graph = new AttributedGraph(graphTitle, graphType);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorProvider.java
index e82d4a6388..0b94219acb 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorProvider.java
@@ -31,6 +31,7 @@ import docking.ActionContext;
import docking.ComponentProvider;
import docking.action.*;
import docking.widgets.OptionDialog;
+import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.compositeeditor.EditorListener;
import ghidra.app.plugin.core.compositeeditor.EditorProvider;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
@@ -400,8 +401,9 @@ public class EnumEditorProvider extends ComponentProviderAdapter
private int showOptionDialog(Enum editedEnoom, Set
it will invalidate equates created with the old value(s).
");
+ "If you save this Enum with the new value(s) listed below,
" +
+ " it will invalidate equates created with the old value(s).
");
msg.append("");
for (String field : oldNameFields) {
String newVal;
@@ -412,13 +414,16 @@ public class EnumEditorProvider extends ComponentProviderAdapter
// Happens if a field is deleted or there is a name AND value change.
newVal = "Missing";
}
- msg.append(String.format("
");
msg.append(
- "Invalidated equates can be automatically removed now or
managed later from the Equates Table
* Hint text will be shown in light grey, italicized, and in angle brackets. Normal text will * be plain black. */ public class HintTextAreaIS extends HintTextArea { - private String hint; - /** * Constructs the class with the hint text to be shown. * - * @param hint + * @param hint the hint */ public HintTextAreaIS(final String hint) { super(hint); @@ -53,16 +51,12 @@ public class HintTextAreaIS extends HintTextArea { setAttributes(); } - /********************************************************************************************* - * PRIVATE METHODS - ********************************************************************************************/ - /** * Sets the text attributes to be used when there is an error in the input. */ private void setErrorAttributes() { this.setFont(getFont().deriveFont(Font.PLAIN)); - setForeground(Color.RED); + setForeground(Colors.ERROR); } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InsertBytesWidget.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InsertBytesWidget.java index 0b1743217a..5814423a2c 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InsertBytesWidget.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InsertBytesWidget.java @@ -15,7 +15,8 @@ */ package ghidra.app.plugin.core.instructionsearch.ui; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.ArrayList; @@ -25,6 +26,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import docking.DialogComponentProvider; +import generic.theme.GThemeDefaults.Colors.Dialogs; import ghidra.app.plugin.core.instructionsearch.model.*; import ghidra.app.plugin.core.instructionsearch.ui.SelectionModeWidget.InputMode; import ghidra.app.plugin.core.instructionsearch.util.InstructionSearchUtils; @@ -290,7 +292,8 @@ public class InsertBytesWidget extends DialogComponentProvider implements KeyLis // there's a problem with the input. Just print a message to the user and // exit. if (allBytes.size() < instruction.getLength()) { - msgPanel.setMessageText("Input invalid: unknown disassembly error.", Color.RED); + msgPanel.setMessageText("Input invalid: unknown disassembly error.", + Dialogs.FG_MESSAGE_ERROR); return; } allBytes.subList(0, instruction.getLength()).clear(); @@ -300,7 +303,8 @@ public class InsertBytesWidget extends DialogComponentProvider implements KeyLis // If there's an exception, just stop and let the user figure out what went // wrong - no need to continue. - msgPanel.setMessageText("Input invalid: unknown disassembly error.", Color.RED); + msgPanel.setMessageText("Input invalid: unknown disassembly error.", + Dialogs.FG_MESSAGE_ERROR); Msg.debug(this, "Error disassembling instruction", e); return; diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionSearchDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionSearchDialog.java index ec79cebaad..b546e8889b 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionSearchDialog.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionSearchDialog.java @@ -23,6 +23,8 @@ import javax.swing.*; import docking.ComponentProvider; import docking.DialogComponentProvider; +import generic.theme.GColor; +import generic.theme.GThemeDefaults.Colors.Dialogs; import ghidra.app.events.ProgramSelectionPluginEvent; import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin; import ghidra.app.plugin.core.instructionsearch.model.InstructionMetadata; @@ -61,6 +63,9 @@ import ghidra.util.task.TaskMonitor; public class InstructionSearchDialog extends DialogComponentProvider implements Observer { + private static final Color BG_COLOR_MARKERS = + new GColor("color.bg.plugin.instructionsearch.search.markers"); + // Panel containing the {@link InstructionTable} and {@link PreviewTable}. private InstructionSearchMainPanel tablePanel; @@ -136,7 +141,7 @@ public class InstructionSearchDialog extends DialogComponentProvider implements if (selection == null && getMessagePanel() != null) { getMessagePanel().setMessageText( "Select instructions from the listing (and hit reload) to populate the table.", - Color.BLUE); + Dialogs.FG_MESSAGE_NORMAL); } if (selection != null && plugin.isSelectionValid(selection, this)) { @@ -498,7 +503,7 @@ public class InstructionSearchDialog extends DialogComponentProvider implements model.setSelectionSize(matchSize); TableComponentProvider
tableProvider = table.showTableWithMarkers(title + " " + model.getName(), "InstructionSearch", - model, Color.GREEN, null, "Instruction Search Results", null); + model, BG_COLOR_MARKERS, null, "Instruction Search Results", null); tableProvider.installRemoveItemsAction(); }; SystemUtilities.runSwingLater(runnable); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTable.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTable.java index 1723488baf..0e3b33cf66 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTable.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTable.java @@ -15,7 +15,6 @@ */ package ghidra.app.plugin.core.instructionsearch.ui; -import java.awt.Color; import java.awt.event.*; import java.util.List; @@ -23,6 +22,7 @@ import javax.swing.*; import docking.DockingWindowManager; import docking.widgets.EmptyBorderButton; +import generic.theme.GThemeDefaults.Colors.Dialogs; import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin; import ghidra.app.plugin.core.instructionsearch.model.*; import ghidra.app.services.GoToService; @@ -168,7 +168,9 @@ public class InstructionTable extends AbstractInstructionTable { } InstructionTableDataObject[][] dataObjects = - new InstructionTableDataObject[dialog.getSearchData().getInstructions().size()][numColumns]; + new InstructionTableDataObject[dialog.getSearchData() + .getInstructions() + .size()][numColumns]; // Loop over all instructions, adding pertinent info to each data object. This could be a long-running // operation so put in a task that can be cancelled. @@ -516,9 +518,10 @@ public class InstructionTable extends AbstractInstructionTable { } else { if (dialog.getMessagePanel() != null) { - dialog.getMessagePanel().setMessageText( - "Instruction was loaded manually, no address in the listing to navigate to.", - Color.BLUE); + dialog.getMessagePanel() + .setMessageText( + "Instruction was loaded manually, no address in the listing to navigate to.", + Dialogs.FG_MESSAGE_NORMAL); } } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTableCellRenderer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTableCellRenderer.java index 58fa759f76..07e9a79018 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTableCellRenderer.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTableCellRenderer.java @@ -21,6 +21,7 @@ import javax.swing.*; import javax.swing.table.TableModel; import docking.widgets.table.GTableCellRenderingData; +import generic.theme.Gui; import ghidra.app.plugin.core.instructionsearch.model.InstructionTableDataObject; import ghidra.util.table.GhidraTableCellRenderer; @@ -30,10 +31,6 @@ import ghidra.util.table.GhidraTableCellRenderer; */ public class InstructionTableCellRenderer extends GhidraTableCellRenderer { - /** - * - * @param font - */ public InstructionTableCellRenderer(Font font) { super(font); } @@ -76,24 +73,10 @@ public class InstructionTableCellRenderer extends GhidraTableCellRenderer { return this; } - /********************************************************************************************* - * PRIVATE METHODS - ********************************************************************************************/ - - /** - * - * @param dataObject - * @param theRenderer - */ private void setBorderAttributes(InstructionTableDataObject dataObject, JLabel theRenderer) { theRenderer.setBorder(dataObject.getBorder()); } - /** - * - * @param dataObject - * @param theRenderer - */ private void setForegroundAttributes(InstructionTableDataObject dataObject, JLabel theRenderer) { // Change the foreground to use a font of our choosing. The main reason is that we @@ -103,12 +86,6 @@ public class InstructionTableCellRenderer extends GhidraTableCellRenderer { theRenderer.setFont(newFont); } - /** - * - * @param isSelected - * @param hasFocus - * @param dataObject - */ private void setBackgroundAttributes(boolean isSelected, boolean hasFocus, InstructionTableDataObject dataObject) { // Set the background color based on what the cell says. If it's selected, make it a @@ -116,7 +93,7 @@ public class InstructionTableCellRenderer extends GhidraTableCellRenderer { Color backgroundColor = dataObject.getBackgroundColor(); if (backgroundColor != null) { if (isSelected || hasFocus) { - setBackground(backgroundColor.darker()); + setBackground(Gui.darker(backgroundColor)); } else { setBackground(backgroundColor); @@ -124,12 +101,6 @@ public class InstructionTableCellRenderer extends GhidraTableCellRenderer { } } - /** - * - * @param table - * @param value - * @param col - */ private void setTextAttributes(JTable table, Object value, int col) { setHorizontalAlignment(SwingConstants.LEFT); TableModel model = table.getModel(); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/SearchInstructionsTask.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/SearchInstructionsTask.java index 833fc6a7b9..69bd7f6ec5 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/SearchInstructionsTask.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/SearchInstructionsTask.java @@ -15,19 +15,18 @@ */ package ghidra.app.plugin.core.instructionsearch.ui; -import java.awt.Color; import java.util.*; -import javax.swing.SwingUtilities; - +import generic.theme.GThemeDefaults.Colors.Dialogs; import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin; import ghidra.app.plugin.core.instructionsearch.model.InstructionMetadata; import ghidra.app.plugin.core.instructionsearch.ui.SearchDirectionWidget.Direction; import ghidra.app.services.GoToService; import ghidra.program.model.address.Address; import ghidra.program.model.address.AddressRange; -import ghidra.program.model.listing.CodeUnit; +import ghidra.program.model.listing.*; import ghidra.program.util.BytesFieldLocation; +import ghidra.util.Swing; import ghidra.util.task.Task; import ghidra.util.task.TaskMonitor; @@ -73,8 +72,11 @@ class SearchInstructionsTask extends Task { // See if we're searching forward or backwards. boolean forward = - searchDialog.getControlPanel().getDirectionWidget().getSearchDirection().equals( - Direction.FORWARD); + searchDialog.getControlPanel() + .getDirectionWidget() + .getSearchDirection() + .equals( + Direction.FORWARD); // If we're searching backwards we need to process address ranges in reverse so reverse // the list. @@ -121,7 +123,7 @@ class SearchInstructionsTask extends Task { // // Note we put these on the swing thread or it will throw off the task monitor display. if (searchResults != null) { - SwingUtilities.invokeLater(() -> { + Swing.runLater(() -> { goToLocation(searchResults.getAddr()); searchDialog.getMessagePanel().clear(); }); @@ -134,7 +136,8 @@ class SearchInstructionsTask extends Task { // If we've gone through all the ranges and there are still no results, show an // error message. - searchDialog.getMessagePanel().setMessageText("No results found", Color.BLUE); + searchDialog.getMessagePanel() + .setMessageText("No results found", Dialogs.FG_MESSAGE_NORMAL); return; } @@ -157,13 +160,13 @@ class SearchInstructionsTask extends Task { // The reason for the getting the CodeUnit is that the instruction might be an off-cut, // and if that's the case, then we can't navigate directly to it. What we have to do // is find the CodeUnit containing the instruction and navigate to that. + Program currentProgram = searchPlugin.getCurrentProgram(); + Listing listing = currentProgram.getListing(); if (direction == Direction.FORWARD) { for (InstructionMetadata instr : searchResults) { - CodeUnit unit = searchPlugin.getCurrentProgram().getListing().getCodeUnitContaining( - instr.getAddr()); - - if (unit.getMinAddress().compareTo(currentAddress) > 0) { - return unit.getMinAddress(); + CodeUnit cu = listing.getCodeUnitContaining(instr.getAddr()); + if (cu.getMinAddress().compareTo(currentAddress) > 0) { + return cu.getMinAddress(); } } } @@ -173,14 +176,12 @@ class SearchInstructionsTask extends Task { // // See above for an explanation for why we need to get the CodeUnit in this block. if (direction == Direction.BACKWARD) { - ListIterator
- * Colors 0-15 are the {@link AnsiRenderer#BASIC_COLORS: standard + high-intensity. Colors
+ * Colors 0-15 are the {@link AnsiRenderer#AnsiRenderer}: standard + high-intensity. Colors
* 16-231 come from a 6x6x6 RGB cube; see {@link AnsiRenderer#CUBE_STEPS}. Finally, colors
- * 232-255 are 24 steps of grayscale.
+ * 232-255 are 24 steps of gray scale.
*
* @param v an 8-bit number
* @return the ANSI color
@@ -117,12 +103,12 @@ public class AnsiRenderer {
int b = v % 6;
int g = (v / 6) % 6;
int r = (v / 36) % 6;
- return new Color(CUBE_STEPS[r], CUBE_STEPS[g], CUBE_STEPS[b]);
+ return TempColorUtils.fromRgb(CUBE_STEPS[r], CUBE_STEPS[g], CUBE_STEPS[b]);
}
else if (v < 256) {
v -= 232;
int gray = v * 10 + 8;
- return new Color(gray, gray, gray);
+ return TempColorUtils.fromRgb(gray, gray, gray);
}
else {
/* invalid */
@@ -146,7 +132,7 @@ public class AnsiRenderer {
private int handleSGRAttribute(String[] bits, int pos) throws NumberFormatException {
int code = Integer.parseInt(bits[pos]);
if (code >= 30 && code < 50) {
- /* Colour codes */
+ /* Color codes */
Object attributeName =
(code < 40) ? StyleConstants.Foreground : StyleConstants.Background;
int colorCode = code % 10;
@@ -172,7 +158,7 @@ public class AnsiRenderer {
int r = Integer.parseInt(bits[pos + 2]);
int g = Integer.parseInt(bits[pos + 3]);
int b = Integer.parseInt(bits[pos + 4]);
- attributes.addAttribute(attributeName, new Color(r, g, b));
+ attributes.addAttribute(attributeName, TempColorUtils.fromRgb(r, g, b));
return 5;
}
return 1;
@@ -314,6 +300,7 @@ public class AnsiRenderer {
* @param document Document to render the string to
* @param text A text string which may contain 7-bit ANSI escape codes
* @param attributes Current text attributes; may be modified by this function
+ * @throws BadLocationException if there is an error parsing the text
*/
public void renderString(StyledDocument document, String text, MutableAttributeSet attributes)
throws BadLocationException {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/CodeCompletionWindow.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/CodeCompletionWindow.java
index ae2ff6e252..12c9e8501d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/CodeCompletionWindow.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/CodeCompletionWindow.java
@@ -25,6 +25,7 @@ import javax.swing.border.EmptyBorder;
import javax.swing.event.ListDataListener;
import docking.widgets.list.GListCellRenderer;
+import generic.theme.GThemeDefaults.Colors;
import generic.util.WindowUtilities;
import ghidra.app.plugin.core.console.CodeCompletion;
@@ -37,7 +38,7 @@ import ghidra.app.plugin.core.console.CodeCompletion;
public class CodeCompletionWindow extends JDialog {
private static final long serialVersionUID = 1L;
/* from ReferenceHoverPlugin */
- private static final Color BACKGROUND_COLOR = new Color(255, 255, 230);
+ private static final Color BACKGROUND_COLOR = Colors.TOOLTIP_BACKGROUND;
protected final InterpreterPanel console;
protected final JTextPane outputTextField;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/marker/MarkerSetImpl.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/marker/MarkerSetImpl.java
index 1df241ba0f..1c3f0af14a 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/marker/MarkerSetImpl.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/marker/MarkerSetImpl.java
@@ -27,6 +27,7 @@ import javax.swing.ImageIcon;
import docking.widgets.fieldpanel.support.FieldRange;
import docking.widgets.fieldpanel.support.FieldSelection;
import generic.json.Json;
+import generic.theme.TempColorUtils;
import ghidra.app.services.MarkerDescriptor;
import ghidra.app.services.MarkerSet;
import ghidra.app.util.viewer.listingpanel.VerticalPixelAddressMap;
@@ -259,10 +260,7 @@ abstract class MarkerSetImpl implements MarkerSet {
}
protected static Color getFillColor(Color c) {
- int red = (c.getRed() + 3 * COLOR_VALUE) / 4;
- int green = (c.getGreen() + 3 * COLOR_VALUE) / 4;
- int blue = (c.getBlue() + 3 * COLOR_VALUE) / 4;
- return new Color(red, green, blue);
+ return TempColorUtils.blend2(c, COLOR_VALUE);
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/misc/MyProgramChangesDisplayPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/misc/MyProgramChangesDisplayPlugin.java
index 24aaf0a191..f39ffa1f7b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/misc/MyProgramChangesDisplayPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/misc/MyProgramChangesDisplayPlugin.java
@@ -29,6 +29,7 @@ import javax.swing.ImageIcon;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.ToolBarData;
+import generic.theme.GColor;
import ghidra.app.CorePluginPackage;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.ProgramPlugin;
@@ -73,6 +74,15 @@ public class MyProgramChangesDisplayPlugin extends ProgramPlugin implements Doma
private final static int OTHER_CHANGES_PRIORITY = MarkerService.CHANGE_PRIORITY + 2;
private final static int CONFLICT_PRIORITY = MarkerService.CHANGE_PRIORITY + 3;
+ private static final Color BG_COLOR_MARKER_UNSAVED =
+ new GColor("color.bg.plugin.myprogramchangesdisplay.markers.changes.unsaved");
+ private static final Color BG_COLOR_MARKER_CONFLICTING =
+ new GColor("color.bg.plugin.myprogramchangesdisplay.markers.changes.conflicting");
+ private static final Color BG_COLOR_MARKER_LATEST =
+ new GColor("color.bg.plugin.myprogramchangesdisplay.markers.changes.latest.version");
+ private static final Color BG_COLOR_MARKER_NOT_CHECKED_IN =
+ new GColor("color.bg.plugin.myprogramchangesdisplay.markers.changes.not.checked.in");
+
private MarkerService markerService;
private MarkerSet currentMyChangeMarks; // my changes since last save
@@ -191,7 +201,7 @@ public class MyProgramChangesDisplayPlugin extends ProgramPlugin implements Doma
private void createMarkerSets(Program program) {
currentMyChangeMarks =
markerService.createAreaMarker("Changes: Unsaved", "My changes not yet saved", program,
- MY_CHANGE_PRIORITY, true, true, false, Color.darkGray);
+ MY_CHANGE_PRIORITY, true, true, false, BG_COLOR_MARKER_UNSAVED);
if (program.getDomainFile().isCheckedOut()) {
trackServerChanges(program);
@@ -201,15 +211,15 @@ public class MyProgramChangesDisplayPlugin extends ProgramPlugin implements Doma
private void trackServerChanges(Program program) {
currentChangesSinceCheckoutMarks = markerService.createAreaMarker("Changes: Not Checked-In",
"My saved changes made since I checked it out", program, CHANGES_SINCE_CO_PRIORITY,
- true, true, false, Color.GREEN);
+ true, true, false, BG_COLOR_MARKER_NOT_CHECKED_IN);
currentOtherChangeMarks = markerService.createAreaMarker("Changes: Latest Version",
"Changes made by others to this program since I checked it out", program,
- OTHER_CHANGES_PRIORITY, true, true, false, Color.BLUE);
+ OTHER_CHANGES_PRIORITY, true, true, false, BG_COLOR_MARKER_LATEST);
currentConflictChangeMarks = markerService.createAreaMarker("Changes: Conflicting",
"Changes made by others to this program that conflict with my changes", program,
- CONFLICT_PRIORITY, true, true, false, Color.RED);
+ CONFLICT_PRIORITY, true, true, false, BG_COLOR_MARKER_CONFLICTING);
}
private void disposeMarkerSets(Program program) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/misc/RegisterField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/misc/RegisterField.java
index fa4d3f27ab..6431da816b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/misc/RegisterField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/misc/RegisterField.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,61 +23,63 @@ import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.text.*;
-/**
- *
- */
+import generic.theme.GThemeDefaults.Colors;
+
public class RegisterField extends JTextField {
-// private static Color UNSET_COLOR = new Color(204,0,204);
+
private int bitSize;
private Long currentValue;
private long maxValue;
- private PlainDocument doc;
+ private PlainDocument doc;
private boolean inFocus;
private boolean skipFilter;
private ChangeListener listener;
- private Color noValueColor = Color.LIGHT_GRAY;
- private Color valueColor = Color.BLACK;
- private boolean useNoValue;
- /**
- * Constructor for RegisterField.
- */
- public RegisterField(int bitSize, Long initialValue) {
- this(bitSize, initialValue, true);
- }
-
- public RegisterField(int bitSize, Long initialValue, boolean useNoValue) {
- this.useNoValue = useNoValue;
- setBitSize( bitSize );
-
- doc = new PlainDocument();
- doc.setDocumentFilter(new MyDocFilter());
- this.setDocument(doc);
- doSetValue(initialValue);
+ private Color noValueColor = Colors.FOREGROUND_DISABLED;
+ private Color valueColor = Colors.FOREGROUND;
+ private boolean useNoValue;
- this.addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent ev) {
+ public RegisterField(int bitSize, Long initialValue) {
+ this(bitSize, initialValue, true);
+ }
+
+ public RegisterField(int bitSize, Long initialValue, boolean useNoValue) {
+ this.useNoValue = useNoValue;
+ setBitSize(bitSize);
+
+ doc = new PlainDocument();
+ doc.setDocumentFilter(new MyDocFilter());
+ this.setDocument(doc);
+ doSetValue(initialValue);
+
+ this.addFocusListener(new FocusListener() {
+ @Override
+ public void focusGained(FocusEvent ev) {
inFocus = true;
doSetValue(currentValue);
- }
+ }
- public void focusLost(FocusEvent ev) {
- inFocus = false;
+ @Override
+ public void focusLost(FocusEvent ev) {
+ inFocus = false;
doSetValue(currentValue);
- }
- });
- }
+ }
+ });
+ }
+
public Long getValue() {
return currentValue;
}
-
+
public void setNoValueColor(Color c) {
noValueColor = c;
updateColor();
}
+
public void setValueColor(Color c) {
valueColor = c;
updateColor();
}
+
private void updateColor() {
if (inFocus || currentValue != null) {
setForeground(valueColor);
@@ -89,104 +90,113 @@ public class RegisterField extends JTextField {
setHorizontalAlignment(CENTER);
}
}
- public void setBitSize( int bitSize ) {
- this.bitSize = bitSize;
- boolean isValid = bitSize >= 1 && bitSize < 64;
+ public void setBitSize(int bitSize) {
+ this.bitSize = bitSize;
- this.setEditable(isValid);
- this.setEnabled(isValid);
+ boolean isValid = bitSize >= 1 && bitSize < 64;
- this.useNoValue = true;
+ this.setEditable(isValid);
+ this.setEnabled(isValid);
- if (isValid) {
- this.maxValue = (1L << bitSize) - 1;
- }
- else {
- skipFilter = true;
- this.maxValue = 1;
- }
+ this.useNoValue = true;
- /// if the value is no longer valid, then clear the value
- if ( !isValidValue( getValue() ) ) {
- doSetValue( null );
- }
- }
- public void setValue(Long value) {
+ if (isValid) {
+ this.maxValue = (1L << bitSize) - 1;
+ }
+ else {
+ skipFilter = true;
+ this.maxValue = 1;
+ }
+
+ /// if the value is no longer valid, then clear the value
+ if (!isValidValue(getValue())) {
+ doSetValue(null);
+ }
+ }
+
+ public void setValue(Long value) {
if (isEqual(value, currentValue)) {
return;
}
doSetValue(value);
- }
- private void doSetValue(Long value) {
- if (value == null) {
- if (inFocus) {
+ }
+
+ private void doSetValue(Long value) {
+ if (value == null) {
+ if (inFocus) {
setTextField("");
- }
- else {
- if (useNoValue) {
+ }
+ else {
+ if (useNoValue) {
setTextField("-- No Value --");
- }
- else {
- setTextField("");
- }
- }
- }
- else {
- setTextField("0x"+Long.toHexString(value.longValue()));
- }
- currentValue = value;
+ }
+ else {
+ setTextField("");
+ }
+ }
+ }
+ else {
+ setTextField("0x" + Long.toHexString(value.longValue()));
+ }
+ currentValue = value;
updateColor();
- }
- private boolean isEqual(Long l1, Long l2) {
- if (l1 != null) {
- return l1.equals(l2);
- }
- else if (l2 != null) {
- return false;
- }
- return true;
- }
+ }
+
+ private boolean isEqual(Long l1, Long l2) {
+ if (l1 != null) {
+ return l1.equals(l2);
+ }
+ else if (l2 != null) {
+ return false;
+ }
+ return true;
+ }
+
private void setTextField(String text) {
- if ( doc == null ) {
- return;
- }
+ if (doc == null) {
+ return;
+ }
skipFilter = true;
- try {
- doc.replace(0, doc.getLength(), text, null);
- }
- catch (BadLocationException e) {}
+ try {
+ doc.replace(0, doc.getLength(), text, null);
+ }
+ catch (BadLocationException e) {
+ // ignore
+ }
skipFilter = false;
}
+
public void setChangeListener(ChangeListener listener) {
this.listener = listener;
}
+
private boolean processText() {
String text = getText();
-
- if (text.length() == 0){
+
+ if (text.length() == 0) {
if (currentValue != null) {
currentValue = null;
notifyListeners();
}
return true;
}
-
+
if (text.equals("0x") || text.equals("0X")) {
- if ((currentValue == null) || (currentValue.longValue() != 0)) {
- currentValue = new Long(0);
+ if ((currentValue == null) || (currentValue.longValue() != 0)) {
+ currentValue = 0L;
notifyListeners();
}
return true;
}
try {
if (!text.startsWith("0x") && !text.startsWith("0X")) {
- while(text.length() > 1 && text.charAt(0)== '0') {
+ while (text.length() > 1 && text.charAt(0) == '0') {
text = text.substring(1);
- }
+ }
}
- Long newValue = Long.decode(text);
- if ( isValidValue( newValue ) ) {
+ Long newValue = Long.decode(text);
+ if (isValidValue(newValue)) {
if (!newValue.equals(currentValue)) {
currentValue = newValue;
notifyListeners();
@@ -194,46 +204,42 @@ public class RegisterField extends JTextField {
return true;
}
}
- catch(Exception e) {
+ catch (Exception e) {
+ // handled by using beep below
}
+
Toolkit.getDefaultToolkit().beep();
return false;
}
- private boolean isValidValue(Long value) {
- if ( value == null ) {
- return false;
- }
- long l = value.longValue();
- return (l >= 0) && (l <= maxValue);
- }
+ private boolean isValidValue(Long value) {
+ if (value == null) {
+ return false;
+ }
+ long l = value.longValue();
+ return (l >= 0) && (l <= maxValue);
+ }
-
class MyDocFilter extends DocumentFilter {
- /**
- * @see javax.swing.text.DocumentFilter#insertString(FilterBypass, int, String, AttributeSet)
- */
- @Override
- public void insertString(FilterBypass fb, int offset, String string,
- AttributeSet attr) throws BadLocationException {
+
+ @Override
+ public void insertString(FilterBypass fb, int offset, String string,
+ AttributeSet attr) throws BadLocationException {
if (skipFilter) {
super.insertString(fb, offset, string, attr);
return;
}
String oldText = getText();
- fb.insertString(offset, string, attr);
+ fb.insertString(offset, string, attr);
if (!processText()) {
fb.replace(0, doc.getLength(), oldText, attr);
}
- }
+ }
- /**
- * @see javax.swing.text.DocumentFilter#remove(FilterBypass, int, int)
- */
- @Override
- public void remove(FilterBypass fb, int offset, int length)
- throws BadLocationException {
+ @Override
+ public void remove(FilterBypass fb, int offset, int length)
+ throws BadLocationException {
if (skipFilter) {
super.remove(fb, offset, length);
return;
@@ -244,48 +250,45 @@ public class RegisterField extends JTextField {
if (!processText()) {
fb.replace(0, doc.getLength(), oldText, null);
}
- }
+ }
- /**
- * @see javax.swing.text.DocumentFilter#replace(FilterBypass, int, int, String, AttributeSet)
- */
- @Override
- public void replace(FilterBypass fb, int offset, int length,
- String text, AttributeSet attrs) throws BadLocationException {
+ @Override
+ public void replace(FilterBypass fb, int offset, int length,
+ String text, AttributeSet attrs) throws BadLocationException {
if (skipFilter) {
super.replace(fb, offset, length, text, attrs);
return;
}
String oldText = getText();
- fb.replace(offset, length, text, attrs);
+ fb.replace(offset, length, text, attrs);
if (!processText()) {
fb.replace(0, doc.getLength(), oldText, attrs);
}
- }
- }
+ }
+ }
public static void main(String[] args) {
JFrame f = new JFrame("Test");
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JTextField("123"), BorderLayout.SOUTH);
- RegisterField rf = new RegisterField(1, new Long(1));
+ RegisterField rf = new RegisterField(1, 1L);
panel.add(rf, BorderLayout.CENTER);
f.getContentPane().add(panel);
f.pack();
f.setVisible(true);
- }
-
+ }
+
private void notifyListeners() {
if (listener != null) {
- listener.stateChanged( null );
+ listener.stateChanged(null);
}
- }
+ }
+
public int getBitSize() {
return bitSize;
}
+
public Color getValueColor() {
return valueColor;
}
}
-
-
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java
index 50e0090637..d482152893 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java
@@ -18,6 +18,7 @@ package ghidra.app.plugin.core.navigation.locationreferences;
import java.awt.Color;
import docking.widgets.fieldpanel.support.Highlight;
+import generic.theme.GColor;
import ghidra.GhidraOptions;
import ghidra.app.nav.Navigatable;
import ghidra.app.services.*;
@@ -42,7 +43,8 @@ class LocationReferencesHighlighter {
"Reference Search" + GhidraOptions.DELIMITER + "Highlight Match Color";
private static final String HIGHLIGHT_COLOR_DESCRIPTION =
"The highlight color of matches for the 'Show References' searcher";
- private static Color DEFAULT_HIGHLIGHT_COLOR = new Color(168, 202, 242);
+ private static Color DEFAULT_HIGHLIGHT_COLOR =
+ new GColor("color.bg.plugin.locationreferences.highlight");
private boolean isHighlighting = false;
private final Navigatable navigatable;
@@ -52,15 +54,11 @@ class LocationReferencesHighlighter {
private HighlightProvider highlightProvider;
private MarkerRemover markerRemover;
private Color highlightColor;
- private OptionsChangeListener optionsListener = new OptionsChangeListener() {
- @Override
- public void optionsChanged(ToolOptions options, String name, Object oldValue,
- Object newValue) {
- if (name.equals(HIGHLIGHT_COLOR_KEY)) {
- highlightColor = (Color) newValue;
- }
- }
- };
+ private OptionsChangeListener optionsListener = (options, name, oldValue, newValue) -> {
+if (name.equals(HIGHLIGHT_COLOR_KEY)) {
+ highlightColor = (Color) newValue;
+}
+};
// This is a bit unusual, but we do this here, since this highlighter will come and
// go with each search. If we do not register a priori, then the option will not appear in the
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesTableModel.java
index 3f77196d72..671955bdab 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesTableModel.java
@@ -15,13 +15,13 @@
*/
package ghidra.app.plugin.core.navigation.locationreferences;
-import java.awt.Color;
import java.awt.Component;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import docking.widgets.table.GTableCellRenderingData;
+import generic.theme.GThemeDefaults.Colors.Tables;
import ghidra.docking.settings.Settings;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.model.address.Address;
@@ -171,7 +171,7 @@ class LocationReferencesTableModel extends AddressBasedTableModel ");
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/spaceview/GhidraColorMap.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/spaceview/GhidraColorMap.java
deleted file mode 100644
index 3b3cf9c6d9..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/spaceview/GhidraColorMap.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ###
- * IP: GHIDRA
- * REVIEWED: YES
- *
- * 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.app.plugin.core.spaceview;
-
-import java.awt.Color;
-import java.awt.image.IndexColorModel;
-
-public class GhidraColorMap {
-
- /*
- tier 1
-
- undefined (GRAY)
- zero (BLACK)
- low (DARK ORANGE)
- whitespace (PALE BLUE)
- digit (LIGHT BLUE)
- upper (LIGHT BLUE)
- lower (MED BLUE)
- symbol (DARK BLUE)
- high (DARK RED)
- full (-1, 255) (WHITE)
-
- tier 2
-
- float? (GREEN)
- double? (GREEN)
- int? (ORANGE)
- long? (ORANGE)
- instruction? (PINK)
- address? (YELLOW)
-
- tier 3
-
- SEAFOAM
- defined data (simple types)
- defined data (structs)
- defined data (unions)
-
- MAGENTA
- code (memory)
- code (flow)
- code (special)
- code (normal)
-
- PURPLE
- fun code (memory)
- fun code (flow)
- fun code (special)
- fun code (normal)
-
- RED
- error bookmarks
-
- tier 4
-
- selected (BRIGHT GREEN)
- highlighted (BRIGHT YELLOW)
- selected and highlighted (BRIGHT YELLOW GREEN)
-
- immutables needed:
-
- segmenting
- hilbert ordering
- maximuming
- from array
- cache
- iterator
-
- also:
-
- bijection from address to index in array space
- bijection from pixelspace to indexspace
- */
-
- public IndexColorModel getColorModel() {
- Color[] colors =
- new Color[] { new Color(190, 255, 0), Color.red, new Color(128, 128, 128), Color.cyan,
- Color.magenta, };
-
- byte[] red = new byte[colors.length];
- byte[] grn = new byte[colors.length];
- byte[] blu = new byte[colors.length];
- for (int ii = 0; ii < colors.length; ++ii) {
- red[ii] = (byte) colors[ii].getRed();
- grn[ii] = (byte) colors[ii].getGreen();
- blu[ii] = (byte) colors[ii].getBlue();
- }
- IndexColorModel colorModel = new IndexColorModel(8, colors.length, red, grn, blu);
-
- return colorModel;
- }
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/spaceview/PixelType.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/spaceview/PixelType.java
deleted file mode 100644
index a37178780c..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/spaceview/PixelType.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ###
- * IP: GHIDRA
- * REVIEWED: YES
- *
- * 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.app.plugin.core.spaceview;
-
-public enum PixelType {
- UNUSED_TYPE,
- ERROR,
-
- UNINIT_UNUSED,
- UNINIT_DATA,
-
- EXTERNAL,
-
- UNDEF_DATA0,
- UNDEF_DATA1,
- UNDEF_DATA2,
- UNDEF_DATA3,
- UNDEF_DATA4,
- UNDEF_DATA5,
- UNDEF_DATA6,
- UNDEF_DATA7,
-
- DEF_DATA0,
- DEF_DATA1,
- DEF_DATA2,
- DEF_DATA3,
- DEF_DATA4,
- DEF_DATA5,
- DEF_DATA6,
- DEF_DATA7,
-
- CODE_MEMORY,
- CODE_FLOW,
- CODE_SPECIAL,
- CODE_NORMAL,
-
- FUN_CODE_MEMORY,
- FUN_CODE_FLOW,
- FUN_CODE_SPECIAL,
- FUN_CODE_NORMAL,
-
- SELECTED,
- HIGHLIGHTED,
- SEL_AND_HIGH;
-
- public byte type() {
- return (byte) ordinal();
- }
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/spaceview/SpacecurveRasterPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/spaceview/SpacecurveRasterPanel.java
deleted file mode 100644
index 566e82fae9..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/spaceview/SpacecurveRasterPanel.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ###
- * IP: GHIDRA
- * REVIEWED: YES
- *
- * 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.app.plugin.core.spaceview;
-
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.image.*;
-import java.util.Hashtable;
-
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-
-public class SpacecurveRasterPanel extends JPanel {
- protected static final Hashtable, ?> EMPTY_HASHTABLE = new Hashtable
Would " +
- "you like to keep your changes in the editor or " +
+ "you like to keep your changes in the editor or " +
"discard your changes?",
KEEP_CHANGES_TEXT, DISCARD_CHANGES_TEXT, OptionDialog.QUESTION_MESSAGE);
@@ -469,7 +472,9 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
//
choice = OptionDialog.showOptionDialog(scrollPane, CHANGE_DESTINATION_TITLE,
"You can save your current changes to another file or " +
- "overwrite the contents of the file on disk.",
+ "overwrite the contents of the file on disk.",
SAVE_CHANGES_AS_TEXT, OVERWRITE_CHANGES_TEXT, OptionDialog.QUESTION_MESSAGE);
//
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptTableModel.java
index 80357d52e5..884a93febd 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptTableModel.java
@@ -24,6 +24,8 @@ import javax.swing.event.TableModelEvent;
import docking.widgets.table.*;
import generic.jar.ResourceFile;
+import generic.theme.GThemeDefaults.Colors;
+import generic.theme.GThemeDefaults.Colors.Tables;
import ghidra.app.script.GhidraScriptInfoManager;
import ghidra.app.script.ScriptInfo;
import ghidra.docking.settings.Settings;
@@ -370,7 +372,7 @@ class GhidraScriptTableModel extends GDynamicColumnTableModel