mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-25 20:26:24 +08:00
GP-6440: first pass
This commit is contained in:
+2
-1
@@ -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;
|
||||
|
||||
+14
-6
@@ -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());
|
||||
|
||||
+7
-1
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user