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

@ -24,7 +24,7 @@ color.cursor.unfocused.listing = color.cursor.unfocused
color.fg.listing.address = color.fg
color.fg.listing.ref.bad = red
color.fg.listing.bytes = blue
color.fg.listing.constant = turquoise
color.fg.listing.constant = green
color.fg.listing.label.unreferenced = black
color.fg.listing.entrypoint = magenta
color.fg.listing.comment.auto = lightGray
@ -43,7 +43,7 @@ color.fg.listing.function.tag = mediumVioletRed
color.fg.listing.function.param.auto = gray
color.fg.listing.function.return-type = black
color.fg.listing.function.param.custom = indigo
color.fg.listing.function.param.dynamic = teal
color.fg.listing.function.param.dynamic = #006666
color.fg.listing.label.local = green
color.fg.listing.label.non-primary = olive
color.fg.listing.label.primary = darkBlue

View File

@ -6,10 +6,9 @@ color.flowtype.fall-through = red
color.flowtype.jump.conditional = #007C00 // dark green
color.flowtype.jump.unconditional = blue
color.bg.table.selection.bundle = lightSkyBlue
color.fg.table.selection.bundle = black
color.bg.table.selection.bundle = [color]textHighlight
color.fg.table.selection.bundle = [color]textHighlightText
color.fg.table.bundle.disabled = darkGray
color.fg.table.bundle.error = red
color.fg.table.bundle.busy = gray
color.fg.table.bundle.inactive = black
color.fg.table.bundle.active = green
@ -55,10 +54,9 @@ color.flowtype.jump.conditional = rgb(95, 129, 157)
color.flowtype.jump.unconditional = rgb(140, 148, 64)
color.bg.table.selection.bundle = darkBlue
color.fg.table.selection.bundle = gray
color.bg.table.selection.bundle = [color]textHighlight
color.fg.table.selection.bundle = [color]textHighlightText
color.fg.table.bundle.disabled = lightGray
color.fg.table.bundle.error = indianRed
color.fg.table.bundle.busy = gray
color.fg.table.bundle.inactive = lightGray
color.fg.table.bundle.active = limeGreen

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -23,7 +23,7 @@
<H2><A name="DataTypes"></A>Data Types</H2>
<BLOCKQUOTE>
<P><FONT color="#000000">Data is created by applying <I>Data Types</I> to bytes in
<P>Data is created by applying <I>Data Types</I> to bytes in
memory.&nbsp; Data Types interpret bytes as values and provide a visual interpretation of
those bytes based on the Data Type used, e.g., a four byte IEEE floating point number or a
two byte <A href="../Glossary/glossary.htm#LittleEndian">little endian</A>
@ -583,7 +583,7 @@
<P><IMG src="../../shared/note.yellow.png">&nbsp;Regardless of how a data type is applied, data is
only created if the data type will fit within the available undefined bytes.&nbsp;&nbsp;</P>
<H3><FONT color="#0000ff">Drag from Data Type Manager</FONT></H3>
<H3>Drag from Data Type Manager</H3>
<BLOCKQUOTE>
<P>Use the <A href=
@ -610,8 +610,7 @@
</BLOCKQUOTE>
<H3><A name="DataCycleGroups"></A><A name="Cycle__byte_word_dword_qword"></A><A name=
"Cycle__float_double"></A> <A name="Cycle__char_string_unicode"></A><FONT color=
"#0000ff">Cycle Groups</FONT></H3>
"Cycle__float_double"></A> <A name="Cycle__char_string_unicode"></A>Cycle Groups</H3>
<BLOCKQUOTE>
<P>Cycle Groups are an easy way to apply <I>basic</I> data types (byte, word, float,
@ -679,7 +678,7 @@
</OL>
</BLOCKQUOTE>
<H3><A name="Favorites"></A><FONT color="#0000ff">Favorites</FONT></H3>
<H3><A name="Favorites"></A>Favorites</FONT></H3>
<BLOCKQUOTE>
<P>A <I>Favorite</I> data type is a data type that you use frequently and want to apply
@ -703,7 +702,7 @@
Shortcut</A>.&nbsp; Key Bindings allow you to assign "hot keys" to any menu item.</P>
</BLOCKQUOTE>
<H3><A name="Recently_Used"></A><FONT color="#0000ff">Recently Used Data Type</FONT></H3>
<H3><A name="Recently_Used"></A>Recently Used Data Type</H3>
<BLOCKQUOTE>
<P>The last applied data type is always available at the bottom of the data menu.&nbsp; By

View File

@ -15,9 +15,9 @@
*/
package ghidra.app.plugin.core.osgi;
import java.awt.*;
import java.awt.Color;
import java.awt.Component;
import java.util.*;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@ -45,7 +45,7 @@ public class BundleStatusTableModel
extends GDynamicColumnTableModel<BundleStatus, List<BundleStatus>> {
//@formatter:off
private static final Color COLOR_BUNDLE_ERROR = new GColor("color.fg.table.bundle.error");
private static final Color COLOR_BUNDLE_ERROR = new GColor("color.fg.error");
private static final Color COLOR_BUNDLE_DISABLED = new GColor("color.fg.table.bundle.disabled");
private static final Color COLOR_BUNDLE_BUSY = new GColor("color.fg.table.bundle.busy");
private static final Color COLOR_BUNDLE_INACTIVE = new GColor("color.fg.table.bundle.inactive");
@ -150,8 +150,6 @@ public class BundleStatusTableModel
});
}
/***************************************************/
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
BundleStatus status = statuses.get(rowIndex);
@ -557,7 +555,6 @@ public class BundleStatusTableModel
BundleStatus status = (BundleStatus) data.getRowObject();
ResourceFile file = (ResourceFile) data.getValue();
JLabel label = (JLabel) super.getTableCellRendererComponent(data);
label.setFont(defaultFont.deriveFont(defaultFont.getStyle() | Font.BOLD));
label.setText(Path.toPathString(file));
GhidraBundle bundle = bundleHost.getGhidraBundle(file);
if (bundle == null || bundle instanceof GhidraPlaceholderBundle || !file.exists()) {
@ -577,6 +574,7 @@ public class BundleStatusTableModel
label.setForeground(COLOR_BUNDLE_INACTIVE);
}
}
return label;
}

View File

@ -13,8 +13,8 @@
<tr><th colspan="3" align="center">Function ID</th></tr>
<tr>
<td width="20%" align="left"></td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="FunctionIDPlugin.html">Next</a>
<th width="60%" align="center"><EFBFBD></th>
<td width="20%" align="right"><EFBFBD><a accesskey="n" href="FunctionIDPlugin.html">Next</a>
</td>
</tr>
</table>
@ -290,14 +290,14 @@ parameter information is stripped.
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"></td>
<td width="20%" align="center"> </td>
<td width="40%" align="right"> <a accesskey="n" href="FunctionIDPlugin.html">Next</a>
<td width="20%" align="center"><EFBFBD></td>
<td width="40%" align="right"><EFBFBD><a accesskey="n" href="FunctionIDPlugin.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Function ID </td>
<td width="40%" align="left" valign="top">Function ID<EFBFBD></td>
<td width="20%" align="center"></td>
<td width="40%" align="right" valign="top"> Function ID Plug-in</td>
<td width="40%" align="right" valign="top"><EFBFBD>Function ID Plug-in</td>
</tr>
</table>
</div>

View File

@ -5,6 +5,7 @@
##MODULE IP: Tango Icons - Public Domain
Module.manifest||GHIDRA||||END|
data/ExtensionPoint.manifest||GHIDRA||reviewed||END|
data/version.tracking.theme.properties||GHIDRA||||END|
src/main/docs/VTClasses.png||GHIDRA||reviewed||END|
src/main/docs/VTGuiImpl.png||GHIDRA||reviewed||END|
src/main/help/help/TOC_Source.xml||GHIDRA||reviewed||END|

View File

@ -0,0 +1,65 @@
[Defaults]
color.fg.version.tracking.tooltip = gray
color.bg.version.tracking.dual.listing.highlight.markup.applied = rgb(150, 220, 150) // green
color.bg.version.tracking.dual.listing.highlight.markup.unapplied = rgb(255, 170, 85) // orange
color.bg.version.tracking.dual.listing.highlight.markup.ignored = gainsboro // gray
color.bg.version.tracking.dual.listing.highlight.markup.rejected = rgb(250, 200, 200) // pink
color.bg.version.tracking.dual.listing.highlight.markup.failed = rgb(255, 80, 80) // red
color.bg.version.tracking.dual.listing.highlight.markup.no.address = rgb(205, 185, 220) // purple
color.bg.version.tracking.dual.listing.highlight.markup.same = rgb(175, 225, 255) // light blue
color.bg.version.tracking.dual.listing.highlight.markup.conflict = rgb(255, 225, 105) // gold
color.bg.version.tracking.filter.formatted.field.error = rgb(218, 217, 206) // grayish
color.bg.version.tracking.filter.formatted.field.editing = rgb(243, 242, 131) // yellowish
color.bg.version.tracking.match.table.locked.out = whitesmoke
color.bg.version.tracking.match.table.markup.status.applied = rgb(0, 180, 0) // green
color.bg.version.tracking.match.table.markup.status.rejected = red
color.bg.version.tracking.match.table.markup.status.dont.care = royalblue
color.bg.version.tracking.match.table.markup.status.dont.know = orange
color.bg.version.tracking.match.table.markup.status.tooltip.unexamined = black
color.fg.version.tracking.match.table.error = color.fg.error
color.fg.version.tracking.markup.items.table.error = color.fg.error
color.fg.version.tracking.markup.items.table.user.defined.address = cyan
color.fg.version.tracking.markup.items.table.user.defined.address.selected = lightseagreen
color.bg.version.tracking.related.matches.table.good = green
color.bg.version.tracking.related.matches.table.medium = yellow
color.bg.version.tracking.related.matches.table.bad = red
color.fg.version.tracking.function.match.local.info = green
[Dark Defaults]
color.bg.version.tracking.dual.listing.highlight.markup.applied = rgb(150, 220, 150) // green
color.bg.version.tracking.dual.listing.highlight.markup.unapplied = rgb(255, 170, 85) // orange
color.bg.version.tracking.dual.listing.highlight.markup.ignored = rgb(220, 220, 220) // gray
color.bg.version.tracking.dual.listing.highlight.markup.rejected = rgb(250, 200, 200) // pink
color.bg.version.tracking.dual.listing.highlight.markup.failed = rgb(255, 80, 80) // red
color.bg.version.tracking.dual.listing.highlight.markup.no.address = rgb(205, 185, 220) // purple
color.bg.version.tracking.dual.listing.highlight.markup.same = rgb(175, 225, 255) // light blue
color.bg.version.tracking.dual.listing.highlight.markup.conflict = rgb(255, 225, 105) // gold
color.bg.version.tracking.filter.formatted.field.error = rgb(218, 217, 206) // grayish
color.bg.version.tracking.filter.formatted.field.editing = rgb(243, 242, 131) // yellowish
color.bg.version.tracking.match.table.locked.out = whitesmoke
color.bg.version.tracking.match.table.markup.status.applied = rgb(0, 180, 0) // green
color.bg.version.tracking.match.table.markup.status.rejected = red
color.bg.version.tracking.match.table.markup.status.dont.care = royalblue
color.bg.version.tracking.match.table.markup.status.dont.know = orange
color.fg.version.tracking.match.table.error = color.fg.error
color.fg.version.tracking.markup.items.table.error = color.fg.error
color.fg.version.tracking.markup.items.table.user.defined.address = cyan
color.fg.version.tracking.markup.items.table.user.defined.address.selected = lightseagreen
color.bg.version.tracking.related.matches.table.good = green
color.bg.version.tracking.related.matches.table.medium = yellow
color.bg.version.tracking.related.matches.table.bad = red
color.fg.version.tracking.function.match.local.info = green

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());

View File

@ -5,9 +5,18 @@ color.fg = black
color.fg.error = red
color.fg.disabled = lightGray
color.fg.help.selector.h1 = #000080
color.fg.help.selector.h2 = #984C4C
color.fg.help.selector.h3 = #0000FF
color.fg.help.selector.p.provided.by.plugin = #7F7F7F
color.fg.help.selector.p.related.topic = #800080
color.fg.help.selector.th = #EDF3FE
color.fg.help.selector.code = black
color.fg.help.selector.code.path = #4682B4
color.bg.header.active = steelblue
color.bg.header.inactive = rgb(150, 150, 150)
color.fg.header.active = ivory
color.fg.header.active = black
color.fg.header.inactive = black
color.header.drag.cursor = black
@ -89,10 +98,23 @@ icon.checkmark.green = images/checkmark_green.gif
icon.theme.import = images/mail-receive.png
icon.theme.export = images/mail-folder-outbox.png
// Fonts
[Dark Defaults]
color.bg = #46494B // color used by flatlaf dark theme
color.fg = lightgray
color.fg.error = indianRed
color.fg.help.selector.h1 = #66AAF4
color.fg.help.selector.h2 = #9999F9
color.fg.help.selector.h3 = #FF99CC
color.fg.help.selector.p.provided.by.plugin = #CCCCCC
color.fg.help.selector.p.related.topic = #800080
color.fg.help.selector.th = #EDF3FE
color.fg.help.selector.code = gray
color.fg.help.selector.code.path = #5BA5E3
color.bg.header.active = #788CBD
color.bg.header.inactive = dimGray
@ -124,5 +146,5 @@ color.bg.tableheader.gradient.start = color.bg
color.bg.tableheader.gradient.end = darkGray
color.bg.tableheader.gradient.start.primary = color.bg
color.bg.tableheader.gradient.end.primary = darkBlue
color.bg.table.row.alt = rgb(45,47,65) //TODO
color.bg.table.row.alt = rgb(45,47,65)

View File

@ -21,8 +21,8 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.*;
import java.net.*;
import java.util.Collection;
import java.util.List;
import java.util.*;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -34,6 +34,7 @@ import javax.swing.text.html.*;
import javax.swing.text.html.HTML.Tag;
import generic.jar.ResourceFile;
import generic.theme.GColor;
import ghidra.framework.Application;
import ghidra.framework.preferences.Preferences;
import ghidra.util.Msg;
@ -41,9 +42,9 @@ import resources.*;
import utilities.util.FileUtilities;
/**
* A class that allows Ghidra to intercept JavaHelp navigation events in order to resolve them
* to Ghidra's help system. Without this class, contribution plugins have no way of
* referencing help documents within Ghidra's default help location.
* A class that allows Ghidra to intercept JavaHelp navigation events in order to resolve them to
* Ghidra's help system. Without this class, contribution plugins have no way of referencing help
* documents within Ghidra's default help location.
* <p>
* This class is currently installed by the {@link GHelpSet}.
*
@ -60,6 +61,25 @@ public class GHelpHTMLEditorKit extends HTMLEditorKit {
private static final String HELP_WINDOW_ZOOM_FACTOR = "HELP.WINDOW.FONT.SIZE.MODIFIER";
private static int fontSizeModifier;
/**
* A mapping of known style sheet colors to convert from the values in the style sheet to colors
* defined in the system theme.
*/
private static final Map<String, GColor> colorsById = new HashMap<>();
static {
colorsById.put("h1", new GColor("color.fg.help.selector.h1"));
colorsById.put("h2", new GColor("color.fg.help.selector.h2"));
colorsById.put("h3", new GColor("color.fg.help.selector.h3"));
colorsById.put("p.providedbyplugin",
new GColor("color.fg.help.selector.p.provided.by.plugin"));
colorsById.put("p.relatedtopic",
new GColor("color.fg.help.selector.p.related.topic"));
colorsById.put("th", new GColor("color.fg.help.selector.th"));
colorsById.put("code", new GColor("color.fg.help.selector.code"));
colorsById.put("code.path", new GColor("color.fg.help.selector.code.path"));
}
private static final Pattern COLOR_PATTERN = Pattern.compile("(color:\\s*#{0,1}\\w+;)");
private HyperlinkListener[] delegateListeners = null;
private HyperlinkListener resolverHyperlinkListener;
@ -276,11 +296,19 @@ public class GHelpHTMLEditorKit extends HTMLEditorKit {
return null;
}
StringBuffer buffy = new StringBuffer();
StringBuilder buffy = new StringBuilder();
try {
List<String> lines = FileUtilities.getLines(url);
for (String line : lines) {
changePixels(line, fontSizeModifier, buffy);
StringBuilder lineBuilder = new StringBuilder();
changePixels(line, fontSizeModifier, lineBuilder);
String updatedLine = lineBuilder.toString();
lineBuilder.delete(0, lineBuilder.length());
changeColor(updatedLine, lineBuilder);
buffy.append(lineBuilder.toString());
buffy.append('\n');
}
}
@ -293,7 +321,31 @@ public class GHelpHTMLEditorKit extends HTMLEditorKit {
return reader;
}
private void changePixels(String line, int amount, StringBuffer buffy) {
private void changeColor(String line, StringBuilder buffy) {
int blockStart = line.indexOf("{");
if (blockStart == -1) {
buffy.append(line);
return;
}
String cssSelector = line.substring(0, blockStart).trim();
cssSelector = cssSelector.toLowerCase(); // normalize
GColor gColor = colorsById.get(cssSelector);
if (gColor == null) {
buffy.append(line);
return;
}
Matcher matcher = COLOR_PATTERN.matcher(line);
if (matcher.find()) {
matcher.appendReplacement(buffy, "color: " + gColor.toHexString() + ";");
}
matcher.appendTail(buffy);
}
private void changePixels(String line, int amount, StringBuilder buffy) {
Matcher matcher = FONT_SIZE_PATTERN.matcher(line);
while (matcher.find()) {

View File

@ -6,6 +6,9 @@ color.bg.visualgraph.satellite = lightgray
color.bg.highlight.visualgraph = rgba(255,255,0,155) // somewhat transparent yellow
color.bg.visualgraph.message = rgb(138, 185, 241) // jordy blue
color.bg.visualgraph.drop.shadow.dark = black
color.bg.visualgraph.drop.shadow.light = gray
color.bg.visualgraph.satellite.vertex = color.palette.material.secondary.variant
color.fg.visualgraph.message = color.palette.black
@ -39,6 +42,9 @@ color.bg.highlight.visualgraph = rgba(120,120,120,155) // light gray with dark b
color.bg.visualgraph.message = rgb(65, 146, 242) // dark blue close to jordy blue
color.fg.visualgraph.message = color.palette.lightgray
color.bg.visualgraph.drop.shadow.dark = black
color.bg.visualgraph.drop.shadow.light = gray
color.bg.visualgraph.satellite.vertex = color.palette.material.secondary.variant
color.bg.visualgraph.dockingvertex = color.palette.material.secondary.variant

View File

@ -30,7 +30,6 @@ import edu.uci.ics.jung.visualization.transform.MutableTransformer;
import edu.uci.ics.jung.visualization.transform.MutableTransformerDecorator;
import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.graph.viewer.VisualEdge;
import ghidra.graph.viewer.VisualVertex;
@ -44,6 +43,10 @@ public class AbstractVisualVertexRenderer<V extends VisualVertex, E extends Visu
extends BasicVertexRenderer<V, E> {
private static final Color HIGHLIGHT_COLOR = new GColor("color.bg.highlight.visualgraph");
private static final Color DROP_SHADOW_DARK =
new GColor("color.bg.visualgraph.drop.shadow.dark");
private static final Color DROP_SHADOW_LIGHT =
new GColor("color.bg.visualgraph.drop.shadow.light");
private Function<? super V, Paint> vertexFillPaintTransformer;
@ -146,14 +149,21 @@ public class AbstractVisualVertexRenderer<V extends VisualVertex, E extends Visu
return;
}
g.setColor(Palette.GRAY);
int upperOffset = -3;
int grayOffset = 15;
int blackOffset = 5;
// the upper-offset ensures the upper and left side of the vertex are discernable when tiny
g.setColor(DROP_SHADOW_LIGHT);
AffineTransform xform3 = AffineTransform.getTranslateInstance(upperOffset, upperOffset);
Shape xShape3 = xform3.createTransformedShape(shape);
g.fill(xShape3);
AffineTransform xform = AffineTransform.getTranslateInstance(grayOffset, grayOffset);
Shape xShape = xform.createTransformedShape(shape);
g.fill(xShape);
g.setColor(Palette.BLACK);
g.setColor(DROP_SHADOW_DARK);
AffineTransform xform2 = AffineTransform.getTranslateInstance(blackOffset, blackOffset);
Shape xShape2 = xform2.createTransformedShape(shape);
g.fill(xShape2);