GP-4154 - Theming - Fixed font issues; updated font usage with attributes

This commit is contained in:
dragonmacher 2024-02-23 13:13:06 -05:00
parent c5bad0a88f
commit b586d65a3b
91 changed files with 1309 additions and 1191 deletions

View file

@ -84,8 +84,12 @@ icon.plugin.manager.default = plasma.png
font.help.about = font.monospaced
font.keybindings.status = sansserif-plain-11
font.task.viewer = sansserif-bold-36
font.user.agreement = sansserif-plain-16
font.task.progress.label.message = sansserif-plain-12
font.user.agreement = sansserif-italic-22
font.panel.details = font.standard
font.panel.details.monospaced = font.monospaced[bold]
font.pluginpanel.name = sansserif-plain-18

View file

@ -15,7 +15,8 @@
*/
package ghidra.framework.main;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Insets;
import java.io.InputStream;
import javax.swing.*;
@ -57,11 +58,10 @@ public class UserAgreementDialog extends DialogComponentProvider {
}
private JComponent buildWorkPanel() {
Font font = Gui.getFont(FONT_ID);
JPanel panel = new JPanel(new BorderLayout());
JLabel label = new GDLabel("Ghidra User Agreement", SwingConstants.CENTER);
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
label.setFont(font.deriveFont(Font.ITALIC, 22f));
Gui.registerFont(label, FONT_ID);
panel.add(label, BorderLayout.NORTH);
panel.setBorder(BorderFactory.createEmptyBorder(10, 40, 40, 40));
JEditorPane editorPane = new JEditorPane();

View file

@ -23,6 +23,7 @@ import java.util.List;
import javax.swing.*;
import docking.widgets.label.GDLabel;
import generic.theme.Gui;
import ghidra.framework.client.RepositoryAdapter;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.remote.User;
@ -33,9 +34,9 @@ import ghidra.framework.remote.User;
*/
public class ViewProjectAccessPanel extends ProjectAccessPanel {
/**
/**
* Construct a new panel.
*
*
* @param repository handle to the repository adapter
* @param tool the plugin tool
* @throws IOException if there's an error processing repository information
@ -47,13 +48,13 @@ public class ViewProjectAccessPanel extends ProjectAccessPanel {
/**
* Constructs a new panel.
*
*
* @param knownUsers names of the users that are known to the remote server
* @param currentUser the current user
* @param allUsers all users known to the repository
* @param repositoryName the name of the repository
* @param anonymousServerAccessAllowed true if the server allows anonymous access
* @param anonymousAccessEnabled true if the repository allows anonymous access
* @param anonymousAccessEnabled true if the repository allows anonymous access
* (ignored if anonymousServerAccessAllowed is false)
* @param tool the current tool
*/
@ -66,7 +67,7 @@ public class ViewProjectAccessPanel extends ProjectAccessPanel {
}
/**
* Creates the main gui panel, containing the known users, button, and user access
* Creates the main gui panel, containing the known users, button, and user access
* panels.
*/
@Override
@ -82,9 +83,7 @@ public class ViewProjectAccessPanel extends ProjectAccessPanel {
if (anonymousServerAccessAllowed && origAnonymousAccessEnabled) {
JLabel anonymousAccessLabel = new GDLabel("Anonymous Read-Only Access Enabled");
anonymousAccessLabel.setBorder(BorderFactory.createEmptyBorder(5, 2, 0, 0));
Font f = anonymousAccessLabel.getFont().deriveFont(Font.ITALIC);
anonymousAccessLabel.setFont(f);
Gui.registerFont(anonymousAccessLabel, Font.ITALIC);
mainPanel.add(anonymousAccessLabel, BorderLayout.SOUTH);
}

View file

@ -17,79 +17,57 @@ package ghidra.framework.plugintool.dialog;
import static ghidra.util.HTMLUtilities.*;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.*;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import docking.widgets.label.GDHtmlLabel;
import generic.theme.GColor;
import ghidra.util.HTMLUtilities;
import generic.theme.*;
/**
* Abstract class that defines a panel for displaying name/value pairs with html-formatting.
*/
public abstract class AbstractDetailsPanel extends JPanel {
protected static final String FONT_DEFAULT = "font.panel.details";
protected static final String FONT_MONOSPACED = "font.panel.details.monospaced";
private static final int MIN_WIDTH = 700;
protected static final int LEFT_COLUMN_WIDTH = 150;
protected static final int RIGHT_MARGIN = 30;
// Font attributes for the title of each row.
protected static SimpleAttributeSet titleAttrSet;
protected static GAttributes titleAttrs;
protected JLabel textLabel;
protected JScrollPane sp;
private ThemeListener themeListener = e -> {
if (e.isFontChanged(FONT_DEFAULT) || e.isFontChanged(FONT_MONOSPACED)) {
updateFieldAttributes();
}
};
protected AbstractDetailsPanel() {
createFieldAttributes();
Gui.addThemeListener(themeListener);
}
private void updateFieldAttributes() {
createFieldAttributes();
refresh();
repaint();
}
/**
* Sets attributes for the different pieces of information being displayed in this
* Sets attributes for the different pieces of information being displayed in this
* panel.
*/
protected abstract void createFieldAttributes();
/**
* Returns a new {@link SimpleAttributeSet} with all attributes set by the caller.
*
* @param fontFamily the font to use
* @param fontSize the font size
* @param bold if true, render text bold
* @param color the foreground text color
* @return a new attribute set
*/
protected SimpleAttributeSet createAttributeSet(String fontFamily, int fontSize, boolean bold,
Color color) {
SimpleAttributeSet attrSet = new SimpleAttributeSet();
attrSet.addAttribute(StyleConstants.FontFamily, fontFamily);
attrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(fontSize));
attrSet.addAttribute(StyleConstants.Bold, bold);
attrSet.addAttribute(StyleConstants.Foreground, color);
return attrSet;
}
/**
* Returns a new {@link SimpleAttributeSet} with the following default attributes set:
* <ul>
* <li>FontFamily: "Tahoma"</li>
* <li>FontSize: 11</li>
* <li>Bold: True</li>
* </ul>
*
* @param color the foreground text color
* @return a new attribute set
*/
protected SimpleAttributeSet createAttributeSet(Color color) {
SimpleAttributeSet attrSet = new SimpleAttributeSet();
attrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
attrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
attrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
attrSet.addAttribute(StyleConstants.Foreground, color);
return attrSet;
}
protected abstract void refresh();
/**
* Clears the text in the details pane.
@ -127,27 +105,26 @@ public abstract class AbstractDetailsPanel extends JPanel {
/**
* Inserts an html-formatted string into the given buffer. This is meant to be used
* for inserting the name of each row in the description text.
*
*
* @param buffer the string buffer to add to
* @param rowName the name of the row to add
*/
protected void insertRowTitle(StringBuilder buffer, String rowName) {
buffer.append("<TR>");
buffer.append("<TD VALIGN=\"TOP\">");
insertHTMLLine(buffer, rowName + ":", titleAttrSet);
insertHTMLLine(buffer, rowName + ":", titleAttrs);
buffer.append("</TD>");
}
/**
* Inserts an html-formatted string into the given buffer. This is meant to be used
* for inserting the value of each row in the description text.
*
*
* @param buffer the string buffer to add to
* @param value the text to add
* @param attributes the structure containing formatting information
* @param attributes the structure containing formatting information
*/
protected void insertRowValue(StringBuilder buffer, String value,
SimpleAttributeSet attributes) {
protected void insertRowValue(StringBuilder buffer, String value, GAttributes attributes) {
buffer.append("<TD VALIGN=\"TOP\" WIDTH=\"80%\">");
insertHTMLLine(buffer, value, attributes);
buffer.append("</TD>");
@ -161,33 +138,13 @@ public abstract class AbstractDetailsPanel extends JPanel {
* @param string the string to add
* @param attributes the formatting instructions
*/
protected void insertHTMLString(StringBuilder buffer, String string,
SimpleAttributeSet attributes) {
protected void insertHTMLString(StringBuilder buffer, String string, GAttributes attributes) {
if (string == null) {
return;
}
buffer.append("<FONT COLOR=\"");
Color foregroundColor = (Color) attributes.getAttribute(StyleConstants.Foreground);
buffer.append(HTMLUtilities.toHexString(foregroundColor));
buffer.append("\" FACE=\"");
buffer.append(attributes.getAttribute(StyleConstants.FontFamily).toString());
buffer.append("\">");
Boolean isBold = (Boolean) attributes.getAttribute(StyleConstants.Bold);
isBold = (isBold == null) ? Boolean.FALSE : isBold;
String text = HTMLUtilities.escapeHTML(string);
if (isBold) {
text = HTMLUtilities.bold(text);
}
buffer.append(text);
buffer.append("</FONT>");
buffer.append(attributes.toStyledHtml(string));
}
/**
@ -196,8 +153,7 @@ public abstract class AbstractDetailsPanel extends JPanel {
* @param string the string to insert
* @param attributes the attributes to apply
*/
protected void insertHTMLLine(StringBuilder buffer, String string,
SimpleAttributeSet attributes) {
protected void insertHTMLLine(StringBuilder buffer, String string, GAttributes attributes) {
if (string == null) {
return;
}

View file

@ -15,17 +15,16 @@
*/
package ghidra.framework.plugintool.dialog;
import java.awt.Font;
import java.awt.Point;
import java.util.*;
import javax.swing.KeyStroke;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import docking.action.DockingActionIf;
import docking.action.MenuData;
import docking.actions.KeyBindingUtils;
import generic.theme.GColor;
import generic.theme.*;
import ghidra.framework.plugintool.PluginConfigurationModel;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.PluginDescription;
@ -37,29 +36,52 @@ import ghidra.util.HTMLUtilities;
*/
class PluginDetailsPanel extends AbstractDetailsPanel {
private SimpleAttributeSet nameAttrSet;
private SimpleAttributeSet depNameAttrSet;
private SimpleAttributeSet descrAttrSet;
private SimpleAttributeSet categoriesAttrSet;
private SimpleAttributeSet classAttrSet;
private SimpleAttributeSet locAttrSet;
private SimpleAttributeSet developerAttrSet;
private SimpleAttributeSet dependencyAttrSet;
private SimpleAttributeSet noValueAttrSet;
private static final GColor NO_VALUE_COLOR = new GColor("color.fg.pluginpanel.details.novalue");
private static final GColor DEPENDENCY_COLOR =
new GColor("color.fg.pluginpanel.details.dependency");
private static final GColor LOCATION_COLOR = new GColor("color.fg.pluginpanel.details.loc");
private static final GColor DEVELOPER_COLOR =
new GColor("color.fg.pluginpanel.details.developer");
private static final GColor CLASS_COLOR = new GColor("color.fg.pluginpanel.details.class");
private static final GColor CATEGORIES_COLOR =
new GColor("color.fg.pluginpanel.details.category");
private static final GColor TITLE_COLOR = new GColor("color.fg.pluginpanel.details.title");
private static final GColor DESCRIPTION_COLOR =
new GColor("color.fg.pluginpanel.details.description");
private static final GColor NAME_NO_DEPENDENTS_COLOR =
new GColor("color.fg.pluginpanel.details.name.no.dependents");
private static final GColor NAME_DEPENDENTS_COLOR =
new GColor("color.fg.pluginpanel.details.name.has.dependents");
private GAttributes nameAttrs;
private GAttributes dependenciesNameAttrs;
private GAttributes descriptionAttrs;
private GAttributes categoriesAttrs;
private GAttributes classAttrs;
private GAttributes locationAttrs;
private GAttributes developerAttrs;
private GAttributes dependencyAttrs;
private GAttributes noValueAttrs;
private final PluginConfigurationModel model;
private PluginTool tool;
private PluginDescription currentDescriptor;
PluginDetailsPanel(PluginTool tool, PluginConfigurationModel model) {
super();
this.tool = tool;
this.model = model;
createFieldAttributes();
createMainPanel();
}
@Override
protected void refresh() {
setPluginDescription(currentDescriptor);
}
void setPluginDescription(PluginDescription descriptor) {
this.currentDescriptor = descriptor;
textLabel.setText("");
if (descriptor == null) {
return;
@ -74,43 +96,43 @@ class PluginDetailsPanel extends AbstractDetailsPanel {
insertRowTitle(buffer, "Name");
insertRowValue(buffer, descriptor.getName(),
!dependencies.isEmpty() ? depNameAttrSet : nameAttrSet);
!dependencies.isEmpty() ? dependenciesNameAttrs : nameAttrs);
insertRowTitle(buffer, "Description");
insertRowValue(buffer, descriptor.getDescription(), descrAttrSet);
insertRowValue(buffer, descriptor.getDescription(), descriptionAttrs);
insertRowTitle(buffer, "Status");
insertRowValue(buffer, descriptor.getStatus().getDescription(),
(descriptor.getStatus() == PluginStatus.RELEASED) ? titleAttrSet : developerAttrSet);
(descriptor.getStatus() == PluginStatus.RELEASED) ? titleAttrs : developerAttrs);
insertRowTitle(buffer, "Package");
insertRowValue(buffer, descriptor.getPluginPackage().getName(), categoriesAttrSet);
insertRowValue(buffer, descriptor.getPluginPackage().getName(), categoriesAttrs);
insertRowTitle(buffer, "Category");
insertRowValue(buffer, descriptor.getCategory(), categoriesAttrSet);
insertRowValue(buffer, descriptor.getCategory(), categoriesAttrs);
insertRowTitle(buffer, "Plugin Class");
insertRowValue(buffer, descriptor.getPluginClass().getName(), classAttrSet);
insertRowValue(buffer, descriptor.getPluginClass().getName(), classAttrs);
insertRowTitle(buffer, "Class Location");
insertRowValue(buffer, descriptor.getSourceLocation(), locAttrSet);
insertRowValue(buffer, descriptor.getSourceLocation(), locationAttrs);
insertRowTitle(buffer, "Used By");
buffer.append("<TD VALIGN=\"TOP\">");
if (dependencies.isEmpty()) {
insertHTMLLine(buffer, "None", noValueAttrSet);
insertHTMLLine(buffer, "None", noValueAttrs);
}
else {
for (int i = 0; i < dependencies.size(); i++) {
insertHTMLString(buffer, dependencies.get(i).getPluginClass().getName(),
dependencyAttrSet);
dependencyAttrs);
if (i < dependencies.size() - 1) {
buffer.append(HTMLUtilities.BR);
}
}
insertHTMLLine(buffer, "", titleAttrSet); // add a newline
insertHTMLLine(buffer, "", titleAttrs); // add a newline
}
buffer.append("</TD>");
buffer.append("</TR>");
@ -121,16 +143,16 @@ class PluginDetailsPanel extends AbstractDetailsPanel {
List<Class<?>> servicesRequired = descriptor.getServicesRequired();
if (servicesRequired.isEmpty()) {
insertHTMLLine(buffer, "None", noValueAttrSet);
insertHTMLLine(buffer, "None", noValueAttrs);
}
else {
for (int i = 0; i < servicesRequired.size(); i++) {
insertHTMLString(buffer, servicesRequired.get(i).getName(), dependencyAttrSet);
insertHTMLString(buffer, servicesRequired.get(i).getName(), dependencyAttrs);
if (i < servicesRequired.size() - 1) {
buffer.append(HTMLUtilities.BR);
}
}
insertHTMLLine(buffer, "", titleAttrSet); // add a newline
insertHTMLLine(buffer, "", titleAttrs); // add a newline
}
buffer.append("</TD>");
buffer.append("</TR>");
@ -158,7 +180,7 @@ class PluginDetailsPanel extends AbstractDetailsPanel {
buffer.append("<TR>");
buffer.append("<TD VALIGN=\"TOP\">");
insertHTMLLine(buffer, "Loaded Actions:", titleAttrSet);
insertHTMLLine(buffer, "Loaded Actions:", titleAttrs);
buffer.append("</TD>");
Set<DockingActionIf> actions = Collections.emptySet();
@ -169,7 +191,7 @@ class PluginDetailsPanel extends AbstractDetailsPanel {
if (actions.isEmpty()) {
buffer.append("<TD VALIGN=\"TOP\">");
insertHTMLLine(buffer, "No actions for plugin", noValueAttrSet);
insertHTMLLine(buffer, "No actions for plugin", noValueAttrs);
buffer.append("</TD>");
buffer.append("</TR>");
return;
@ -182,7 +204,7 @@ class PluginDetailsPanel extends AbstractDetailsPanel {
for (DockingActionIf dockableAction : actions) {
buffer.append("<TR><TD WIDTH=\"200\">");
insertHTMLString(buffer, dockableAction.getName(), locAttrSet);
insertHTMLString(buffer, dockableAction.getName(), locationAttrs);
buffer.append("</TD>");
buffer.append("<TD WIDTH=\"300\">");
@ -190,17 +212,17 @@ class PluginDetailsPanel extends AbstractDetailsPanel {
String[] menuPath = menuBarData == null ? null : menuBarData.getMenuPath();
String menuPathString = createStringForMenuPath(menuPath);
if (menuPathString != null) {
insertHTMLString(buffer, menuPathString, locAttrSet);
insertHTMLString(buffer, menuPathString, locationAttrs);
}
else {
MenuData popupMenuData = dockableAction.getPopupMenuData();
String[] popupPath = popupMenuData == null ? null : popupMenuData.getMenuPath();
if (popupPath != null) {
insertHTMLString(buffer, "(in a context popup menu)", noValueAttrSet);
insertHTMLString(buffer, "(in a context popup menu)", noValueAttrs);
}
else {
insertHTMLString(buffer, "Not in a menu", noValueAttrSet);
insertHTMLString(buffer, "Not in a menu", noValueAttrs);
}
}
@ -210,10 +232,10 @@ class PluginDetailsPanel extends AbstractDetailsPanel {
KeyStroke keyBinding = dockableAction.getKeyBinding();
if (keyBinding != null) {
String keyStrokeString = KeyBindingUtils.parseKeyStroke(keyBinding);
insertHTMLString(buffer, keyStrokeString, locAttrSet);
insertHTMLString(buffer, keyStrokeString, locationAttrs);
}
else {
insertHTMLString(buffer, "No keybinding", noValueAttrSet);
insertHTMLString(buffer, "No keybinding", noValueAttrs);
}
buffer.append("</TD></TR>");
@ -242,74 +264,19 @@ class PluginDetailsPanel extends AbstractDetailsPanel {
@Override
protected void createFieldAttributes() {
titleAttrSet = new SimpleAttributeSet();
titleAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
titleAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
titleAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
titleAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.title"));
Font font = Gui.getFont(FONT_DEFAULT);
titleAttrs = new GAttributes(font, TITLE_COLOR);
nameAttrs = new GAttributes(font, NAME_NO_DEPENDENTS_COLOR);
dependenciesNameAttrs = new GAttributes(font, NAME_DEPENDENTS_COLOR);
descriptionAttrs = new GAttributes(font, DESCRIPTION_COLOR);
categoriesAttrs = new GAttributes(font, CATEGORIES_COLOR);
locationAttrs = new GAttributes(font, LOCATION_COLOR);
developerAttrs = new GAttributes(font, DEVELOPER_COLOR);
nameAttrSet = new SimpleAttributeSet();
nameAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
nameAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
nameAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
nameAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.name.no.dependents"));
Font fontMonospaced = Gui.getFont(FONT_MONOSPACED);
classAttrs = new GAttributes(fontMonospaced, CLASS_COLOR);
dependencyAttrs = new GAttributes(fontMonospaced, DEPENDENCY_COLOR);
depNameAttrSet = new SimpleAttributeSet();
depNameAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
depNameAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
depNameAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
depNameAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.name.has.dependents"));
descrAttrSet = new SimpleAttributeSet();
descrAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
descrAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
descrAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
descrAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.description"));
categoriesAttrSet = new SimpleAttributeSet();
categoriesAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
categoriesAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
categoriesAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
categoriesAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.category"));
classAttrSet = new SimpleAttributeSet();
classAttrSet.addAttribute(StyleConstants.FontFamily, "monospaced");
classAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
classAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
classAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.class"));
locAttrSet = new SimpleAttributeSet();
locAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
locAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
locAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
locAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.loc"));
developerAttrSet = new SimpleAttributeSet();
developerAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
developerAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
developerAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
developerAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.developer"));
dependencyAttrSet = new SimpleAttributeSet();
dependencyAttrSet.addAttribute(StyleConstants.FontFamily, "monospaced");
dependencyAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
dependencyAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
dependencyAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.dependency"));
noValueAttrSet = new SimpleAttributeSet();
noValueAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
noValueAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
noValueAttrSet.addAttribute(StyleConstants.Italic, Boolean.TRUE);
noValueAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.novalue"));
noValueAttrs = new GAttributes(font, NO_VALUE_COLOR);
}
}

View file

@ -15,11 +15,14 @@
*/
package ghidra.framework.plugintool.dialog;
import static ghidra.framework.plugintool.dialog.PluginInstallerTableModel.*;
import java.awt.*;
import java.util.List;
import javax.swing.*;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import docking.DialogComponentProvider;
import docking.widgets.table.*;
@ -149,30 +152,23 @@ public class PluginInstallerDialog extends DialogComponentProvider {
tableFilterPanel = new GTableFilterPanel<>(table, tableModel);
JScrollPane sp = new JScrollPane(table);
pluginTablePanel.add(sp, BorderLayout.CENTER);
pluginTablePanel.add(tableFilterPanel, BorderLayout.SOUTH);
// Restrict the size of the first couple columns - the default size is
// way too large. This is annoying but our table column classes don't have a nice
// way to restrict column width.
TableColumn inst_col =
table.getColumnModel().getColumn(PluginInstallerTableModel.INSTALLED_COL);
inst_col.setMaxWidth(30);
TableColumn status_col =
table.getColumnModel().getColumn(PluginInstallerTableModel.STATUS_COL);
status_col.setMaxWidth(24);
TableColumnModel columnModel = table.getColumnModel();
TableColumn installedColumn = columnModel.getColumn(INSTALLED_COL);
installedColumn.setMaxWidth(30);
TableColumn statusColumn = columnModel.getColumn(STATUS_COL);
statusColumn.setMaxWidth(24);
tableModel.setTableSortState(
TableSortState.createDefaultSortState(PluginInstallerTableModel.NAME_COL));
tableModel.setTableSortState(TableSortState.createDefaultSortState(NAME_COL));
tableModel.refresh();
table.getColumnModel()
.getColumn(PluginInstallerTableModel.NAME_COL)
.setCellRenderer(new NameCellRenderer());
table.getColumnModel()
.getColumn(PluginInstallerTableModel.STATUS_COL)
.setCellRenderer(new StatusCellRenderer());
columnModel.getColumn(NAME_COL).setCellRenderer(new NameCellRenderer());
columnModel.getColumn(STATUS_COL).setCellRenderer(new StatusCellRenderer());
HelpService help = Help.getHelpService();
help.registerHelp(table, new HelpLocation(GenericHelpTopics.TOOL, "PluginDialog"));
@ -214,10 +210,10 @@ public class PluginInstallerDialog extends DialogComponentProvider {
renderer.setIcon((value instanceof Icon) ? (Icon) value : null);
String toolTipText = "";
if (value == PluginInstallerTableModel.EXPERIMENTAL_ICON) {
if (value == EXPERIMENTAL_ICON) {
toolTipText = "This plugin is usable, but not fully tested or documented";
}
else if (value == PluginInstallerTableModel.DEV_ICON) {
else if (value == DEV_ICON) {
toolTipText =
"This plugin is under development and not intended for general use.\n" +
"It could cause Ghidra to become unstable!";

View file

@ -176,7 +176,7 @@ public class PluginManagerComponent extends JPanel implements Scrollable {
labelPanel.setBackground(BG);
GLabel nameLabel = new GLabel(pluginPackage.getName());
nameLabel.setFont(nameLabel.getFont().deriveFont(18f));
Gui.registerFont(nameLabel, "font.pluginpanel.name");
nameLabel.setForeground(new GColor("color.fg.pluginpanel.name"));
labelPanel.add(nameLabel);

View file

@ -15,13 +15,11 @@
*/
package ghidra.framework.project.extensions;
import java.awt.Color;
import java.awt.Font;
import java.awt.Point;
import javax.swing.text.SimpleAttributeSet;
import docking.widgets.table.threaded.ThreadedTableModelListener;
import generic.theme.GColor;
import generic.theme.*;
import ghidra.framework.plugintool.dialog.AbstractDetailsPanel;
import ghidra.util.extensions.ExtensionDetails;
@ -33,27 +31,28 @@ import ghidra.util.extensions.ExtensionDetails;
*/
class ExtensionDetailsPanel extends AbstractDetailsPanel {
private static final Color FG_COLOR_AUTHOR =
private static final GColor FG_COLOR_AUTHOR =
new GColor("color.fg.extensionpanel.details.author");
private static final Color FG_COLOR_DATE = new GColor("color.fg.extensionpanel.details.date");
private static final Color FG_COLOR_DESCRIPTION =
private static final GColor FG_COLOR_DATE = new GColor("color.fg.extensionpanel.details.date");
private static final GColor FG_COLOR_DESCRIPTION =
new GColor("color.fg.extensionpanel.details.description");
private static final Color FG_COLOR_NAME = new GColor("color.fg.extensionpanel.details.name");
private static final Color FG_COLOR_PATH = new GColor("color.fg.extensionpanel.path");
private static final Color FG_COLOR_TITLE = new GColor("color.fg.extensionpanel.details.title");
private static final Color FG_COLOR_VERSION =
private static final GColor FG_COLOR_NAME = new GColor("color.fg.extensionpanel.details.name");
private static final GColor FG_COLOR_PATH = new GColor("color.fg.extensionpanel.path");
private static final GColor FG_COLOR_TITLE =
new GColor("color.fg.extensionpanel.details.title");
private static final GColor FG_COLOR_VERSION =
new GColor("color.fg.extensionpanel.details.version");
/** Attribute sets define the visual characteristics for each field */
private SimpleAttributeSet nameAttrSet;
private SimpleAttributeSet descrAttrSet;
private SimpleAttributeSet authorAttrSet;
private SimpleAttributeSet createdOnAttrSet;
private SimpleAttributeSet versionAttrSet;
private SimpleAttributeSet pathAttrSet;
private GAttributes nameAttrSet;
private GAttributes descrAttrSet;
private GAttributes authorAttrSet;
private GAttributes createdOnAttrSet;
private GAttributes versionAttrSet;
private GAttributes pathAttrSet;
private ExtensionDetails currentDetails;
ExtensionDetailsPanel(ExtensionTablePanel tablePanel) {
super();
createFieldAttributes();
createMainPanel();
@ -82,13 +81,19 @@ class ExtensionDetailsPanel extends AbstractDetailsPanel {
});
}
@Override
protected void refresh() {
setDescription(currentDetails);
}
/**
* Updates this panel with the given extension.
*
*
* @param details the extension to display
*/
public void setDescription(ExtensionDetails details) {
this.currentDetails = details;
clear();
if (details == null) {
return;
@ -134,12 +139,14 @@ class ExtensionDetailsPanel extends AbstractDetailsPanel {
@Override
protected void createFieldAttributes() {
titleAttrSet = createAttributeSet(FG_COLOR_TITLE);
nameAttrSet = createAttributeSet(FG_COLOR_NAME);
descrAttrSet = createAttributeSet(FG_COLOR_DESCRIPTION);
authorAttrSet = createAttributeSet(FG_COLOR_AUTHOR);
createdOnAttrSet = createAttributeSet(FG_COLOR_DATE);
versionAttrSet = createAttributeSet(FG_COLOR_VERSION);
pathAttrSet = createAttributeSet(FG_COLOR_PATH);
Font font = Gui.getFont(FONT_DEFAULT);
titleAttrs = new GAttributes(font, FG_COLOR_TITLE);
nameAttrSet = new GAttributes(font, FG_COLOR_NAME);
descrAttrSet = new GAttributes(font, FG_COLOR_DESCRIPTION);
authorAttrSet = new GAttributes(font, FG_COLOR_AUTHOR);
createdOnAttrSet = new GAttributes(font, FG_COLOR_DATE);
versionAttrSet = new GAttributes(font, FG_COLOR_VERSION);
pathAttrSet = new GAttributes(font, FG_COLOR_PATH);
}
}

View file

@ -25,6 +25,7 @@ import docking.util.AnimatedIcon;
import docking.widgets.EmptyBorderButton;
import docking.widgets.label.GDHtmlLabel;
import docking.widgets.label.GIconLabel;
import generic.theme.Gui;
import ghidra.util.Msg;
import ghidra.util.SystemUtilities;
import ghidra.util.layout.VerticalLayout;
@ -36,6 +37,8 @@ import resources.ResourceManager;
public class GProgressBar extends JPanel {
private static final NumberFormat PERCENT_FORMAT = NumberFormat.getPercentInstance();
private static final String MESSAGE_FONT_ID = "font.task.progress.label.message";
private volatile long lastProgress = -1;
private volatile long progress;
private volatile long scaleFactor = 1;
@ -47,7 +50,6 @@ public class GProgressBar extends JPanel {
private volatile boolean paintProgressValue = true;
private boolean showingIcon = true;
private final float fontSize;
private JProgressBar progressBar;
private JLabel messageLabel;
private JLabel imageLabel;
@ -61,10 +63,9 @@ public class GProgressBar extends JPanel {
private CancelledListener cancelledListener;
public GProgressBar(CancelledListener cancelledListener, boolean includeTextField,
boolean includeCancelButton, boolean includeAnimatedIcon, float fontSize) {
boolean includeCancelButton, boolean includeAnimatedIcon) {
super(new BorderLayout(5, 1));
this.cancelledListener = cancelledListener;
this.fontSize = fontSize;
buildProgressPanel(includeTextField, includeCancelButton, includeAnimatedIcon);
@ -217,7 +218,7 @@ public class GProgressBar extends JPanel {
// don't care
}
};
messageLabel.setFont(messageLabel.getFont().deriveFont(fontSize));
Gui.registerFont(messageLabel, MESSAGE_FONT_ID);
Dimension d = messageLabel.getPreferredSize();
d.width = 180;
messageLabel.setPreferredSize(d);

View file

@ -31,7 +31,6 @@ public class ScheduledTaskPanel extends JPanel {
private ScheduledElementLayout layout;
public ScheduledTaskPanel(String labelText, int indention) {
super();
this.indention = indention;
setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
@ -44,7 +43,7 @@ public class ScheduledTaskPanel extends JPanel {
}
void addProgressBar() {
progressBar = new GProgressBar(null, true, true, false, 12);
progressBar = new GProgressBar(null, true, true, false);
progressBar.setBackgroundColor(Colors.BACKGROUND);
add(progressBar);
layout.clearPreferredSize();
@ -71,7 +70,7 @@ public class ScheduledTaskPanel extends JPanel {
//==================================================================================================
// Inner Classes
//==================================================================================================
//==================================================================================================
// This layout handles the scrolling based on the scrollOffset as set by the setHiddenViewAmount()
// It also optionally shows the scrollbar for the task or group.

View file

@ -15,8 +15,7 @@
*/
package ghidra.framework.task;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@ -46,11 +45,11 @@ public class GProgressBarTest extends AbstractDockingTest {
cancelled = true;
}
};
progressBar = new GProgressBar(cancelledListener, true, true, true, 10.0f);
progressBar = new GProgressBar(cancelledListener, true, true, true);
}
@Test
public void testBasicProgress() {
public void testBasicProgress() {
progressBar.initialize(100);
assertEquals(0, progressBar.getProgress());
assertEquals(100, progressBar.getMax());
@ -62,7 +61,7 @@ public class GProgressBarTest extends AbstractDockingTest {
}
@Test
public void testLongValues() {
public void testLongValues() {
progressBar.initialize(0x400000000L);
progressBar.setProgress(10);
assertEquals(10, progressBar.getProgress());
@ -73,7 +72,7 @@ public class GProgressBarTest extends AbstractDockingTest {
}
@Test
public void testMessage() {
public void testMessage() {
progressBar.initialize(100);
progressBar.setMessage("Hey");
assertEquals("Hey", progressBar.getMessage());
@ -91,7 +90,7 @@ public class GProgressBarTest extends AbstractDockingTest {
}
@Test
public void testCancel() {
public void testCancel() {
progressBar.initialize(100);
progressBar.setProgress(50);
assertTrue(!cancelled);