Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-6440: first pass

d-millarc03d53a4d61f
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/TimeOverviewColorService.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/TimeOverviewColorService.java
index f310bfd6e2..e547d18080 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/TimeOverviewColorService.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/TimeOverviewColorService.java
@@ -16,7 +16,8 @@
package ghidra.app.plugin.core.debug.gui.timeoverview;
import java.awt.Color;
-import java.util.*;
+import java.util.List;
+import java.util.TreeSet;
import docking.action.DockingActionIf;
import ghidra.framework.plugintool.PluginTool;
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/timetype/TimeTypeOverviewColorService.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/timetype/TimeTypeOverviewColorService.java
index 7639ff24a0..877a8be809 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/timetype/TimeTypeOverviewColorService.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/timetype/TimeTypeOverviewColorService.java
@@ -67,9 +67,16 @@ public class TimeTypeOverviewColorService implements TimeOverviewColorService {
@Override
public Color getColor(Long snap) {
Set<Pair<TimeType, String>> types = plugin.getTypes(snap);
- Color c = Colors.BACKGROUND;
+ Color c = colorMap.get(TimeType.UNDEFINED);
+ if (c == null) {
+ c = Colors.BACKGROUND;
+ }
for (Pair<TimeType, String> pair : types) {
- c = ColorUtils.addColors(c, pair.getLeft().getDefaultColor());
+ Color color = colorMap.get(pair.getLeft());
+ if (color == null) {
+ color = pair.getLeft().getDefaultColor();
+ }
+ c = ColorUtils.addColors(c, color);
}
return c;
}
@@ -103,11 +110,11 @@ public class TimeTypeOverviewColorService implements TimeOverviewColorService {
public List<DockingActionIf> getActions() {
List<DockingActionIf> actions = new ArrayList<>();
actions.add(new ActionBuilder("Show Legend", getName())
- .popupMenuPath("Show Legend")
+ .popupMenuPath("Show " + getName() + " Legend")
.description("Show types and associated colors")
.helpLocation(getHelpLocation())
.enabledWhen(c -> c.getContextObject() == overviewComponent)
- .onAction(c -> tool.showDialog(getLegendDialog()))
+ .onAction(c -> tool.showDialog(getLegendDialog(overviewComponent)))
.build());
return actions;
@@ -151,11 +158,12 @@ public class TimeTypeOverviewColorService implements TimeOverviewColorService {
public void setColor(TimeType type, Color newColor) {
ToolOptions options = tool.getOptions(OPTIONS_NAME);
options.setColor(type.getDescription(), newColor);
+ colorMap.put(type, newColor);
}
- private DialogComponentProvider getLegendDialog() {
+ private DialogComponentProvider getLegendDialog(TimeOverviewColorComponent component) {
if (legendDialog == null) {
- legendPanel = new TimeTypeOverviewLegendPanel(this);
+ legendPanel = new TimeTypeOverviewLegendPanel(this, component);
legendDialog =
new OverviewColorLegendDialog("Overview Legend", legendPanel, getHelpLocation());
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/timetype/TimeTypeOverviewLegendPanel.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/timetype/TimeTypeOverviewLegendPanel.java
index 27bbb50913..7451edc72c 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/timetype/TimeTypeOverviewLegendPanel.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/timeoverview/timetype/TimeTypeOverviewLegendPanel.java
@@ -22,6 +22,7 @@ import java.awt.event.MouseEvent;
import javax.swing.*;
import docking.widgets.label.GLabel;
+import ghidra.app.plugin.core.debug.gui.timeoverview.TimeOverviewColorComponent;
import ghidra.util.layout.PairLayout;
/**
@@ -30,9 +31,12 @@ import ghidra.util.layout.PairLayout;
public class TimeTypeOverviewLegendPanel extends JPanel {
private static Dimension COLOR_SIZE = new Dimension(15, 15);
private TimeTypeOverviewColorService colorService;
+ private TimeOverviewColorComponent overviewComponent;
- public TimeTypeOverviewLegendPanel(TimeTypeOverviewColorService colorService) {
+ public TimeTypeOverviewLegendPanel(TimeTypeOverviewColorService colorService,
+ TimeOverviewColorComponent component) {
this.colorService = colorService;
+ this.overviewComponent = component;
setLayout(new PairLayout(4, 10));
setBorder(BorderFactory.createEmptyBorder(4, 20, 4, 30));
buildLegend();
@@ -67,6 +71,8 @@ public class TimeTypeOverviewLegendPanel extends JPanel {
Color newColor =
JColorChooser.showDialog(ColorPanel.this, "Select Color", getBackground());
colorService.setColor(type, newColor);
+ ColorPanel.this.repaint();
+ overviewComponent.refreshAll();
}
});
}