GP-1981 - Theming - Version Tracking color conversion; Help css color

conversion
This commit is contained in:
dragonmacher 2022-08-22 19:24:05 -04:00 committed by ghidragon
parent 3f8096014f
commit 7c7d98090f
25 changed files with 367 additions and 142 deletions

View file

@ -15,6 +15,11 @@
*/
package ghidra.feature.vt.gui.duallisting;
import java.awt.Color;
import java.util.*;
import docking.widgets.fieldpanel.support.Highlight;
import generic.theme.GColor;
import ghidra.app.plugin.core.codebrowser.ListingHighlightProvider;
import ghidra.app.util.HighlightProvider;
import ghidra.app.util.viewer.field.*;
@ -32,24 +37,27 @@ import ghidra.program.model.listing.*;
import ghidra.util.Msg;
import ghidra.util.exception.AssertException;
import java.awt.Color;
import java.util.*;
import docking.widgets.fieldpanel.support.Highlight;
public class VTDualListingHighlightProvider implements HighlightProvider {
private static Color APPLIED_MARKUP_COLOR = new Color(150, 220, 150); // green
private static Color UNAPPLIED_MARKUP_COLOR = new Color(255, 170, 85); // orange
private static Color IGNORED_MARKUP_COLOR = new Color(220, 220, 220); // gray
private static Color REJECTED_MARKUP_COLOR = new Color(250, 200, 200); // pink
private static Color FAILED_MARKUP_COLOR = new Color(255, 80, 80); // red
private static Color NO_ADDRESS_MARKUP_COLOR = new Color(205, 185, 220); // purple
private static Color SAME_MARKUP_COLOR = new Color(175, 225, 255); // light blue
private static Color CONFLICT_MARKUP_COLOR = new Color(255, 225, 105); // gold
private static Color APPLIED_MARKUP_COLOR =
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.applied");
private static Color UNAPPLIED_MARKUP_COLOR =
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.unapplied");
private static Color IGNORED_MARKUP_COLOR =
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.ignored");
private static Color REJECTED_MARKUP_COLOR =
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.rejected");
private static Color FAILED_MARKUP_COLOR =
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.failed");
private static Color NO_ADDRESS_MARKUP_COLOR =
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.no.address");
private static Color SAME_MARKUP_COLOR =
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.same");
private static Color CONFLICT_MARKUP_COLOR =
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.conflict");
private HashMap<Address, HashMap<VTMarkupType, VTMarkupItem>> map =
new HashMap<Address, HashMap<VTMarkupType, VTMarkupItem>>();
new HashMap<>();
private final VTController controller;
private ListingPanel listingPanel;
private ListingHighlightProvider listingHighlighter;
@ -112,7 +120,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
HashMap<VTMarkupType, VTMarkupItem> typeMap = map.get(address);
if (typeMap == null) {
typeMap = new HashMap<VTMarkupType, VTMarkupItem>();
typeMap = new HashMap<>();
map.put(address, typeMap);
}
@ -203,7 +211,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
cursorTextOffset, highlights);
}
List<Highlight> highlightList = new ArrayList<Highlight>();
List<Highlight> highlightList = new ArrayList<>();
for (Highlight highlight : highlights) {
highlightList.add(highlight);
@ -274,7 +282,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
}
return highlightColor;
}
/**
* Creates a darker shade of the color passed-in, based on the given amount.
*
@ -285,22 +293,22 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
*
* @param color the color to shade
* @param amount number between 0..1 (the smaller the number, the darker the shade)
* @return
* @return the new color
*/
private static Color shade(Color color, double amount) {
if (color != null) {
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
double newR = (r * amount);
double newG = (g * amount);
double newB = (b * amount);
return new Color((int)newR, (int)newG, (int)newB);
return new Color((int) newR, (int) newG, (int) newB);
}
return null;
}
@ -315,7 +323,8 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
if (markupItem != null) {
VTMarkupItemStatus status = markupItem.getStatus();
StringStringable value =
(StringStringable) ((isSource || markupItem.canUnapply()) ? markupItem.getSourceValue()
(StringStringable) ((isSource || markupItem.canUnapply())
? markupItem.getSourceValue()
: markupItem.getOriginalDestinationValue());
String comment = value.getString();
if (comment != null) {
@ -418,7 +427,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
CodeUnit codeUnit = (CodeUnit) obj;
address = codeUnit.getMinAddress();
}
ArrayList<Highlight> highlightList = new ArrayList<Highlight>();
ArrayList<Highlight> highlightList = new ArrayList<>();
HashMap<VTMarkupType, VTMarkupItem> typeMap = map.get(address);
if (typeMap != null) {
VTMarkupItem markupItem = typeMap.get(RepeatableCommentMarkupType.INSTANCE);
@ -429,7 +438,8 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
return highlightList.toArray(new Highlight[highlightList.size()]);
}
private Highlight[] getFunctionSignatureHighlights(String text, Object obj, int cursorTextOffset) {
private Highlight[] getFunctionSignatureHighlights(String text, Object obj,
int cursorTextOffset) {
Function function = null;
if (obj instanceof Function) {
function = (Function) obj;
@ -445,7 +455,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
Address address = function.getEntryPoint();
HashMap<VTMarkupType, VTMarkupItem> typeMap = map.get(address);
if (typeMap != null) {
ArrayList<Highlight> highlightList = new ArrayList<Highlight>();
ArrayList<Highlight> highlightList = new ArrayList<>();
// // Check if the text is in the Return Type
// addFunctionHighlight(FunctionReturnTypeMarkupType.INSTANCE, text, cursorTextOffset,
@ -485,7 +495,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
Address address = function.getEntryPoint();
HashMap<VTMarkupType, VTMarkupItem> typeMap = map.get(address);
if (typeMap != null) {
ArrayList<Highlight> highlightList = new ArrayList<Highlight>();
ArrayList<Highlight> highlightList = new ArrayList<>();
VTMarkupItem markupItem = typeMap.get(FunctionSignatureMarkupType.INSTANCE);
if (markupItem == null) {
@ -544,7 +554,8 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
if (startIndex >= 0) {
int endIndex = startIndex + displayString.length() - 1;
Color highlightColor =
getMarkupBackgroundColor(cursorTextOffset, markupItem, startIndex, endIndex);
getMarkupBackgroundColor(cursorTextOffset, markupItem, startIndex,
endIndex);
Highlight highlight = new Highlight(startIndex, endIndex, highlightColor);
highlightList.add(highlight);
}
@ -557,7 +568,8 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
VTMarkupItem markupItem = typeMap.get(FunctionNameMarkupType.INSTANCE);
if (markupItem != null) {
FunctionNameStringable value =
(isSource || markupItem.canUnapply()) ? (FunctionNameStringable) markupItem.getSourceValue()
(isSource || markupItem.canUnapply())
? (FunctionNameStringable) markupItem.getSourceValue()
: (FunctionNameStringable) markupItem.getOriginalDestinationValue();
if (value != null) {
int parameterStart = text.indexOf("(");
@ -569,7 +581,8 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
if (startIndex >= 0) {
int endIndex = startIndex + name.length() - 1;
Color highlightColor =
getMarkupBackgroundColor(cursorTextOffset, markupItem, startIndex, endIndex);
getMarkupBackgroundColor(cursorTextOffset, markupItem, startIndex,
endIndex);
Highlight highlight = new Highlight(startIndex, endIndex, highlightColor);
highlightList.add(highlight);
}
@ -832,7 +845,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
if (storageAddress == null) {
return new Highlight[0];
}
ArrayList<Highlight> highlightList = new ArrayList<Highlight>();
ArrayList<Highlight> highlightList = new ArrayList<>();
HashMap<VTMarkupType, VTMarkupItem> typeMap = map.get(storageAddress);
if (typeMap != null) {
VTMarkupItem markupItem = typeMap.get(markupType);
@ -914,16 +927,18 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
if (typeMap != null) {
VTMarkupItem markupItem = typeMap.get(LabelMarkupType.INSTANCE);
if (markupItem != null) {
ArrayList<Highlight> highlightList = new ArrayList<Highlight>();
ArrayList<Highlight> highlightList = new ArrayList<>();
MultipleSymbolStringable value =
(MultipleSymbolStringable) ((isSource || markupItem.canUnapply()) ? markupItem.getSourceValue()
(MultipleSymbolStringable) ((isSource || markupItem.canUnapply())
? markupItem.getSourceValue()
: markupItem.getOriginalDestinationValue());
if (value != null) {
// Highlight the entire labels field.
int startIndex = 0;
int endIndex = text.length() - 1;
Color highlightColor =
getMarkupBackgroundColor(cursorTextOffset, markupItem, startIndex, endIndex);
getMarkupBackgroundColor(cursorTextOffset, markupItem, startIndex,
endIndex);
Highlight highlight = new Highlight(startIndex, endIndex, highlightColor);
highlightList.add(highlight);
return highlightList.toArray(new Highlight[highlightList.size()]);
@ -942,9 +957,10 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
if (typeMap != null) {
VTMarkupItem markupItem = typeMap.get(DataTypeMarkupType.INSTANCE);
if (markupItem != null) {
ArrayList<Highlight> highlightList = new ArrayList<Highlight>();
ArrayList<Highlight> highlightList = new ArrayList<>();
DataTypeStringable value =
(DataTypeStringable) ((isSource || markupItem.canUnapply()) ? markupItem.getSourceValue()
(DataTypeStringable) ((isSource || markupItem.canUnapply())
? markupItem.getSourceValue()
: markupItem.getOriginalDestinationValue());
if (value != null) {
Program sourceProgram =

View file

@ -30,11 +30,13 @@ import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.label.GDLabel;
import docking.widgets.label.GHtmlLabel;
import docking.widgets.textfield.HexIntegerFormatter;
import generic.theme.GColor;
import ghidra.feature.vt.api.main.VTAssociation;
import ghidra.feature.vt.gui.provider.matchtable.NumberRangeProducer;
import ghidra.feature.vt.gui.provider.matchtable.NumberRangeSubFilterChecker;
import ghidra.framework.options.SaveState;
import ghidra.program.model.address.Address;
import ghidra.util.WebColors;
public abstract class AbstractAddressRangeFilter<T> extends AncillaryFilter<T>
implements NumberRangeSubFilterChecker, NumberRangeProducer {
@ -46,6 +48,8 @@ public abstract class AbstractAddressRangeFilter<T> extends AncillaryFilter<T>
private static final String UPPER_RANGE_SELECTED_VALUE_KEY = "upper.range.selected.value.key";
private static final String IS_ENABLED_VALUE_KEY = "is.enabled.value.key";
private static final Color FG_TOOLTIP_DEFAULT = new GColor("color.fg.version.tracking.tooltip");
private static final Integer BASE_COMPONENT_LAYER = 1;
private static final Integer HOVER_COMPONENT_LAYER = 2;
private static final Integer DISABLED_COMPONENT_LAYER = 3;
@ -118,8 +122,10 @@ public abstract class AbstractAddressRangeFilter<T> extends AncillaryFilter<T>
//
// Lower Score Panel
//
String fgColor = WebColors.toString(FG_TOOLTIP_DEFAULT, false);
lowerRangePanel = new JPanel(new GridLayout(2, 1));
JLabel lowLabel = new GHtmlLabel("<html><font size=\"2\" color=\"808080\">low</font>");
JLabel lowLabel =
new GHtmlLabel("<html><font size=\"2\" color=\"" + fgColor + "\">low</font>");
lowLabel.setHorizontalAlignment(SwingConstants.CENTER);
lowLabel.setVerticalAlignment(SwingConstants.BOTTOM);
lowerRangePanel.add(lowLabel);
@ -138,7 +144,8 @@ public abstract class AbstractAddressRangeFilter<T> extends AncillaryFilter<T>
// Upper Score Panel
//
upperRangePanel = new JPanel(new GridLayout(2, 1));
JLabel upperLabel = new GHtmlLabel("<html><font size=\"2\" color=\"808080\">high</font>");
JLabel upperLabel =
new GHtmlLabel("<html><font size=\"2\" color=\"" + fgColor + "\">high</font>");
upperLabel.setHorizontalAlignment(SwingConstants.CENTER);
upperLabel.setVerticalAlignment(SwingConstants.BOTTOM);
upperRangePanel.add(upperLabel);

View file

@ -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.
@ -16,15 +15,10 @@
*/
package ghidra.feature.vt.gui.filters;
import static ghidra.feature.vt.gui.filters.Filter.FilterEditingStatus.APPLIED;
import static ghidra.feature.vt.gui.filters.Filter.FilterEditingStatus.NONE;
import ghidra.feature.vt.gui.filters.Filter.FilterEditingStatus;
import ghidra.util.SystemUtilities;
import static ghidra.feature.vt.gui.filters.Filter.FilterEditingStatus.*;
import java.awt.Color;
import java.awt.event.FocusEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.ParseException;
import java.util.HashSet;
import java.util.Set;
@ -33,12 +27,18 @@ import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class FilterFormattedTextField extends JFormattedTextField {
private static final Color ERROR_BACKGROUND_COLOR = new Color(218, 217, 206);
private static final String TEXT_FIELD_BACKGROUND_COLOR_KEY = "TextField.background";
protected static final Color EDITING_BACKGROUND_COLOR = new Color(243, 242, 131);
import generic.theme.GColor;
import ghidra.feature.vt.gui.filters.Filter.FilterEditingStatus;
import ghidra.util.SystemUtilities;
private Set<FilterStatusListener> listeners = new HashSet<FilterStatusListener>();
public class FilterFormattedTextField extends JFormattedTextField {
private static final Color ERROR_BACKGROUND_COLOR =
new GColor("color.bg.version.tracking.filter.formatted.field.error");
protected static final Color EDITING_BACKGROUND_COLOR =
new GColor("color.bg.version.tracking.filter.formatted.field.editing");
private static final String TEXT_FIELD_BACKGROUND_COLOR_KEY = "TextField.background";
private Set<FilterStatusListener> listeners = new HashSet<>();
private FilterEditingStatus currentStatus = NONE;
private final Object defaultValue;
@ -57,24 +57,23 @@ public class FilterFormattedTextField extends JFormattedTextField {
this.currentStatus = NONE;
getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
updateText();
}
@Override
public void insertUpdate(DocumentEvent e) {
updateText();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateText();
}
});
addPropertyChangeListener("value", new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
editingFinished();
}
});
addPropertyChangeListener("value", evt -> editingFinished());
}
public void disableFocusEventProcessing() {

View file

@ -37,6 +37,7 @@ import docking.widgets.EventTrigger;
import docking.widgets.fieldpanel.FieldPanel;
import docking.widgets.label.GDLabel;
import docking.widgets.table.threaded.ThreadedTableModel;
import generic.theme.GColor;
import ghidra.app.plugin.core.functioncompare.FunctionComparisonPanel;
import ghidra.app.services.GoToService;
import ghidra.app.util.viewer.listingpanel.ListingCodeComparisonPanel;
@ -79,6 +80,8 @@ public class VTFunctionAssociationProvider extends ComponentProviderAdapter
ResourceManager.loadImage("images/application_tile_horizontal.png");
private static final String SHOW_COMPARE_ACTION_GROUP = "A9_ShowCompare"; // "A9_" forces to right of other dual view actions in toolbar.
private static final Color FG_ERROR = new GColor("color.fg.error");
private GhidraTable sourceFunctionsTable;
private GhidraTable destinationFunctionsTable;
private VTFunctionAssociationTableModel sourceFunctionsModel;
@ -358,7 +361,7 @@ public class VTFunctionAssociationProvider extends ComponentProviderAdapter
JPanel statusPanel = new JPanel(new BorderLayout());
statusLabel = new GDLabel(NO_ERROR_MESSAGE);
statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
statusLabel.setForeground(Color.RED.darker());
statusLabel.setForeground(FG_ERROR);
statusLabel.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {

View file

@ -15,7 +15,6 @@
*/
package ghidra.feature.vt.gui.provider.markuptable;
import java.awt.Color;
import java.awt.Component;
import org.apache.commons.lang3.StringUtils;
@ -93,9 +92,11 @@ public class MarkupItemValueRenderer extends AbstractGhidraColumnRenderer<String
}
setBold();
if (!isSelected) {
setForeground(Color.BLACK);
}
// This should not be needed
// if (!isSelected) {
// setForeground(Colors.FOREGROUND);
// }
return;
}

View file

@ -23,6 +23,7 @@ import java.util.stream.Collectors;
import javax.swing.JLabel;
import docking.widgets.table.*;
import generic.theme.GColor;
import ghidra.app.util.SymbolInspector;
import ghidra.docking.settings.Settings;
import ghidra.feature.vt.api.impl.MarkupItemImpl;
@ -50,6 +51,13 @@ public class VTMarkupItemsTableModel extends AddressBasedTableModel<VTMarkupItem
private static final String TITLE = "VTMatchMarkupItem Table Model";
private static final Color FG_ERROR =
new GColor("color.fg.version.tracking.markup.items.table.error");
private static final Color FG_USER_DEFINED =
new GColor("color.fg.version.tracking.markup.items.table.user.defined.address");
private static final Color FG_USER_DEFINED_SELECTED =
new GColor("color.fg.version.tracking.markup.items.table.user.defined.address.selected");
private List<Filter<VTMarkupItem>> allFilters = new ArrayList<>();
private final VTController controller;
@ -336,7 +344,7 @@ public class VTMarkupItemsTableModel extends AddressBasedTableModel<VTMarkupItem
if (address != null && address != Address.NO_ADDRESS && symbolInspector != null) {
s = program.getSymbolTable().getPrimarySymbol(address);
}
Color c = Color.RED;
Color c = FG_ERROR;
if (symbolInspector != null) {
symbolInspector.setProgram(program);
c = symbolInspector.getColor(s);
@ -471,7 +479,7 @@ public class VTMarkupItemsTableModel extends AddressBasedTableModel<VTMarkupItem
if (address != null && address != Address.NO_ADDRESS && symbolInspector != null) {
s = program.getSymbolTable().getPrimarySymbol(address);
}
Color c = Color.RED;
Color c = FG_ERROR;
if (symbolInspector != null) {
symbolInspector.setProgram(program);
c = symbolInspector.getColor(s);
@ -510,10 +518,10 @@ public class VTMarkupItemsTableModel extends AddressBasedTableModel<VTMarkupItem
JLabel renderer = (JLabel) super.getTableCellRendererComponent(renderData);
if (NO_SOURCE_TEXT.equals(addressSource)) {
setForeground(Color.RED);
setForeground(FG_ERROR);
}
else if (VTMarkupItem.USER_DEFINED_ADDRESS_SOURCE.equals(addressSource)) {
setForeground(isSelected ? Color.CYAN : Color.CYAN.darker());
setForeground(isSelected ? FG_USER_DEFINED : FG_USER_DEFINED_SELECTED);
}
renderer.setOpaque(true);

View file

@ -15,14 +15,17 @@
*/
package ghidra.feature.vt.gui.provider.matchtable;
import java.awt.Color;
import java.awt.Component;
import javax.swing.*;
import docking.widgets.table.GTableCellRenderingData;
import generic.theme.GColor;
import ghidra.docking.settings.Settings;
import ghidra.feature.vt.api.main.*;
import ghidra.util.HTMLUtilities;
import ghidra.util.WebColors;
import ghidra.util.table.column.AbstractGhidraColumnRenderer;
import resources.MultiIcon;
import resources.ResourceManager;
@ -34,8 +37,15 @@ import resources.icons.TranslateIcon;
*/
public class MatchMarkupStatusRenderer extends AbstractGhidraColumnRenderer<VTMatch> {
private static final Color FG_TOOLTIP_DEFAULT = new GColor("color.fg.version.tracking.tooltip");
private static final Color FG_TOOLTIP_UNEXAMINED =
new GColor("color.bg.version.tracking.match.table.markup.status.tooltip.unexamined");
private static ImageIcon DISABLED_ICON =
ResourceManager.getDisabledIcon(ResourceManager.loadImage("images/ledgreen.png"), 50);
private static ImageIcon DISABLED_ICON_SMALL =
ResourceManager.getDisabledIcon(ResourceManager.loadImage("images/ledgreen.png", 8, 8), 50);
private static final ImageIcon APPLIED_BASE_ICON =
ResourceManager.loadImage("images/ledgreen.png", 8, 8);
private static final ImageIcon REJECTED_BASE_ICON =
@ -53,11 +63,11 @@ public class MatchMarkupStatusRenderer extends AbstractGhidraColumnRenderer<VTMa
private static Icon IGNORED_ICON = new TranslateIcon(IGNORED_BASE_ICON, 27, 4);
private static Icon ERROR_ICON = new TranslateIcon(ERROR_BASE_ICON, 36, 4);
private static Icon DISABLED_NOT_APPLIED_ICON = new TranslateIcon(DISABLED_ICON, 0, 4);
private static Icon DISABLED_APPLIED_ICON = new TranslateIcon(DISABLED_ICON, 9, 4);
private static Icon DISABLED_REJECTED_ICON = new TranslateIcon(DISABLED_ICON, 18, 4);
private static Icon DISABLED_IGNORED_ICON = new TranslateIcon(DISABLED_ICON, 27, 4);
private static Icon DISABLED_ERROR_ICON = new TranslateIcon(DISABLED_ICON, 36, 4);
private static Icon DISABLED_NOT_APPLIED_ICON = new TranslateIcon(DISABLED_ICON_SMALL, 0, 4);
private static Icon DISABLED_APPLIED_ICON = new TranslateIcon(DISABLED_ICON_SMALL, 9, 4);
private static Icon DISABLED_REJECTED_ICON = new TranslateIcon(DISABLED_ICON_SMALL, 18, 4);
private static Icon DISABLED_IGNORED_ICON = new TranslateIcon(DISABLED_ICON_SMALL, 27, 4);
private static Icon DISABLED_ERROR_ICON = new TranslateIcon(DISABLED_ICON_SMALL, 36, 4);
@Override
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
@ -105,16 +115,21 @@ public class MatchMarkupStatusRenderer extends AbstractGhidraColumnRenderer<VTMa
ImageIcon icon = DISABLED_ICON;
String message = "Has one or more \"Unexamined\" markup items";
String fontColor = "gray";
Color color = FG_TOOLTIP_DEFAULT;
if (status.hasUnexaminedMarkup()) {
icon = NOT_APPLIED_BASE_ICON;
fontColor = "black";
color = FG_TOOLTIP_UNEXAMINED;
}
String fontColor = WebColors.toString(color, false);
buf.append("<img src=\"").append(icon.getDescription()).append("\" />");
buf.append("<font color=\"").append(fontColor).append("\">");
buf.append(message).append("</font><br>");
icon = DISABLED_ICON;
icon = ERROR_BASE_ICON;
message = "Has one or more \"Applied\" markup items";
fontColor = "gray";
if (status.hasAppliedMarkup()) {
@ -126,6 +141,9 @@ public class MatchMarkupStatusRenderer extends AbstractGhidraColumnRenderer<VTMa
buf.append(message).append("</font><br>");
icon = DISABLED_ICON;
icon = DISABLED_ICON_SMALL;
message = "Has one or more \"Rejected\" markup items to apply";
fontColor = "gray";
if (status.hasRejectedMarkup()) {

View file

@ -21,11 +21,13 @@ import java.awt.Component;
import javax.swing.JTable;
import docking.widgets.table.GTableCellRenderingData;
import generic.theme.GColor;
import ghidra.feature.vt.api.main.*;
import ghidra.util.table.CompositeGhidraTableCellRenderer;
public class MatchTableRenderer extends CompositeGhidraTableCellRenderer {
private static final Color LOCKED_OUT_BACKGROUND_COLOR = new Color(239, 239, 239);
private static final Color LOCKED_OUT_BACKGROUND_COLOR =
new GColor("color.bg.version.tracking.match.table.locked.out");
@Override
public Component getTableCellRendererComponent(GTableCellRenderingData data) {

View file

@ -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.
@ -16,15 +15,27 @@
*/
package ghidra.feature.vt.gui.provider.matchtable;
import ghidra.feature.vt.api.main.VTAssociationMarkupStatus;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Icon;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Java;
import ghidra.feature.vt.api.main.VTAssociationMarkupStatus;
public class VTMarkupStatusIcon implements Icon {
private static final Color BG_APPLIED =
new GColor("color.bg.version.tracking.match.table.markup.status.applied");
private static final Color BG_REJECTED =
new GColor("color.bg.version.tracking.match.table.markup.status.rejected");
private static final Color BG_DONT_CARE =
new GColor("color.bg.version.tracking.match.table.markup.status.dont.care");
private static final Color BG_DONT_KNOW =
new GColor("color.bg.version.tracking.match.table.markup.status.dont.know");
private int BORDER = 2;
private int WIDTH = 44;
private int KNOB_WIDTH = 4;
@ -63,7 +74,7 @@ public class VTMarkupStatusIcon implements Icon {
drawBar(g, x + startX + BORDER + 1, y + BORDER + 1, width, colors.get(i));
}
g.setColor(Color.BLACK);
g.setColor(Java.BORDER);
g.drawRect(x, y, WIDTH, HEIGHT);
// g.drawRect(x, y, WIDTH / 2, HEIGHT);
g.drawRect(x + WIDTH, y + HEIGHT / 2 - 3, KNOB_WIDTH, 6);
@ -75,22 +86,20 @@ public class VTMarkupStatusIcon implements Icon {
g.fillRect(x, y, width, HEIGHT - 2 * BORDER - 1);
}
private List<Color> getColors(VTAssociationMarkupStatus status) {
Color ORANGE = new Color(255, 150, 0);
Color GREEN = new Color(0, 180, 0);
Color BLUE = new Color(80, 80, 240);
List<Color> list = new ArrayList<Color>(4);
if (status.hasRejectedMarkup()) {
list.add(Color.RED);
private List<Color> getColors(VTAssociationMarkupStatus markupStatus) {
List<Color> list = new ArrayList<>(4);
if (markupStatus.hasRejectedMarkup()) {
list.add(BG_REJECTED);
}
if (status.hasAppliedMarkup() || status.isFullyApplied()) {
list.add(GREEN);
if (markupStatus.hasAppliedMarkup() || markupStatus.isFullyApplied()) {
list.add(BG_APPLIED);
}
if (status.hasDontCareMarkup()) {
list.add(BLUE);
if (markupStatus.hasDontCareMarkup()) {
list.add(BG_DONT_CARE);
}
if (status.hasDontKnowMarkup()) {
list.add(ORANGE);
if (markupStatus.hasDontKnowMarkup()) {
list.add(BG_DONT_KNOW);
}
return list;
}

View file

@ -30,6 +30,7 @@ import docking.widgets.label.GDLabel;
import docking.widgets.table.GTable;
import docking.widgets.table.RowObjectTableModel;
import docking.widgets.table.threaded.ThreadedTableModel;
import generic.theme.GColor;
import ghidra.feature.vt.api.impl.VTChangeManager;
import ghidra.feature.vt.api.main.*;
import ghidra.feature.vt.gui.actions.*;
@ -66,7 +67,8 @@ public abstract class VTMatchOneToManyTableProvider extends ComponentProviderAda
private static final String TITLE_PREFIX = "Version Tracking Matches for ";
private static final Icon ICON = ResourceManager.loadImage("images/text_list_bullets.png");
protected static final Color LOCAL_INFO_FOREGROUND_COLOR = new Color(0, 128, 0);
protected static final Color LOCAL_INFO_FOREGROUND_COLOR =
new GColor("color.fg.version.tracking.function.match.local.info");
private JComponent component;
private MatchThreadedTablePanel tablePanel;

View file

@ -23,11 +23,20 @@ import javax.swing.*;
import docking.widgets.label.GIconLabel;
import docking.widgets.table.GTableCellRenderingData;
import generic.theme.GColor;
import ghidra.feature.vt.api.main.VTAssociationStatus;
import ghidra.util.table.GhidraTableCellRenderer;
import resources.ResourceManager;
public class RelatedMatchRenderer extends GhidraTableCellRenderer {
private static final Color GOOD =
new GColor("color.bg.version.tracking.related.matches.table.good");
private static final Color MEDIUM =
new GColor("color.bg.version.tracking.related.matches.table.medium");
private static final Color BAD =
new GColor("color.bg.version.tracking.related.matches.table.bad");
static Map<VTRelatedMatchCorrelationType, JLabel> sourceMap;
static Map<VTRelatedMatchCorrelationType, JLabel> destinationMap;
static Map<VTAssociationStatus, JLabel> statusMap;
@ -99,10 +108,6 @@ public class RelatedMatchRenderer extends GhidraTableCellRenderer {
return renderer;
}
private static final Color GOOD = Color.green;
private static final Color MEDIUM = Color.yellow;
private static final Color BAD = Color.red;
private Color findBackgroundColor(VTRelatedMatchType value) {
double goodness = value.getGoodness() / 100.0;
double badness = 1.0 - goodness;

View file

@ -27,6 +27,7 @@ import javax.swing.JLabel;
import docking.widgets.table.GTableCellRenderingData;
import docking.widgets.table.TableFilter;
import generic.theme.GColor;
import ghidra.app.util.SymbolInspector;
import ghidra.docking.settings.Settings;
import ghidra.feature.vt.api.impl.VTProgramCorrelatorInfo;
@ -56,6 +57,8 @@ public abstract class AbstractVTMatchTableModel extends AddressBasedTableModel<V
protected Comparator<VTMatch> markupStatusColumnComparator = new MarkupStatusColumnComparator();
protected VTSession session;
private static final Color FG_ERROR = new GColor("color.fg.version.tracking.match.table.error");
private Set<Filter<VTMatch>> allFilters = new HashSet<>();
protected final VTController controller;
@ -589,7 +592,7 @@ public abstract class AbstractVTMatchTableModel extends AddressBasedTableModel<V
}
}
else {
renderer.setForeground(Color.RED);
renderer.setForeground(FG_ERROR);
}
renderer.setOpaque(true);
@ -714,11 +717,11 @@ public abstract class AbstractVTMatchTableModel extends AddressBasedTableModel<V
if (!address.isMemoryAddress() && symbolInspector != null) {
Symbol s = program.getSymbolTable().getPrimarySymbol(address);
symbolInspector.setProgram(program);
Color c = (s != null) ? symbolInspector.getColor(s) : Color.RED;
Color c = (s != null) ? symbolInspector.getColor(s) : FG_ERROR;
setForeground(c);
}
else if (!program.getMemory().contains(address)) {
setForeground(Color.RED);
setForeground(FG_ERROR);
}
renderer.setOpaque(true);
@ -828,7 +831,7 @@ public abstract class AbstractVTMatchTableModel extends AddressBasedTableModel<V
}
}
else {
renderer.setForeground(Color.RED);
renderer.setForeground(FG_ERROR);
}
renderer.setOpaque(true);
@ -953,11 +956,11 @@ public abstract class AbstractVTMatchTableModel extends AddressBasedTableModel<V
if (!address.isMemoryAddress() && symbolInspector != null) {
Symbol s = program.getSymbolTable().getPrimarySymbol(address);
symbolInspector.setProgram(program);
Color c = (s != null) ? symbolInspector.getColor(s) : Color.RED;
Color c = (s != null) ? symbolInspector.getColor(s) : FG_ERROR;
setForeground(c);
}
else if (!program.getMemory().contains(address)) {
setForeground(Color.RED);
setForeground(FG_ERROR);
}
renderer.setOpaque(true);

View file

@ -21,6 +21,7 @@ import java.awt.Component;
import javax.swing.JComponent;
import docking.widgets.table.GTableCellRenderingData;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.util.SymbolInspector;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.model.symbol.Symbol;
@ -49,7 +50,7 @@ public class VTSymbolRenderer extends GhidraTableCellRenderer {
private void handleSymbol(Object value, boolean isSelected) {
setBold();
if (!isSelected) {
Color color = Color.BLACK;
Color color = Colors.FOREGROUND;
if (value instanceof Symbol) {
Symbol s = (Symbol) value;
inspector.setProgram(s.getProgram());