GT-2698 refactor UI elements to lock down HTML rendering

This commit is contained in:
dev747368 2019-04-11 15:55:56 -04:00
parent a03c96d37b
commit e0c25b0590
360 changed files with 3895 additions and 4563 deletions

View file

@ -162,7 +162,7 @@ public class SampleTableProvider extends ComponentProviderAdapter implements Opt
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
buffer.append("Writing the following objects to file: "); buffer.append("Writing the following objects to file: ");
buffer.append(fileChooserPanel.getFileName()); buffer.append(HTMLUtilities.friendlyEncodeHTML(fileChooserPanel.getFileName()));
List<FunctionStatsRowObject> selectedObjects = filterTable.getSelectedRowObjects(); List<FunctionStatsRowObject> selectedObjects = filterTable.getSelectedRowObjects();
for (FunctionStatsRowObject stats : selectedObjects) { for (FunctionStatsRowObject stats : selectedObjects) {

View file

@ -28,8 +28,7 @@ import javax.swing.event.DocumentListener;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import docking.ActionContext; import docking.*;
import docking.ComponentProvider;
import docking.action.ToggleDockingAction; import docking.action.ToggleDockingAction;
import docking.action.ToolBarData; import docking.action.ToolBarData;
import docking.menu.ActionState; import docking.menu.ActionState;
@ -146,7 +145,7 @@ public class SampleGraphProvider extends ComponentProviderAdapter {
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS)); panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
JLabel label = new JLabel("Vertex Filter: "); JLabel label = DockingUtils.createNonHtmlLabel("Vertex Filter: ");
label.setToolTipText( label.setToolTipText(
"Vertices with names matching the filter will remain, along with connected vertices"); "Vertices with names matching the filter will remain, along with connected vertices");
panel.add(label); panel.add(label);
@ -198,7 +197,7 @@ public class SampleGraphProvider extends ComponentProviderAdapter {
fadedButton.setSelected(true); fadedButton.setSelected(true);
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(new JLabel("Filtered Display: ")); panel.add(DockingUtils.createNonHtmlLabel("Filtered Display: "));
panel.add(fadedButton); panel.add(fadedButton);
panel.add(removedButton); panel.add(removedButton);
return panel; return panel;
@ -207,7 +206,7 @@ public class SampleGraphProvider extends ComponentProviderAdapter {
private void installTooltipProvider() { private void installTooltipProvider() {
VertexTooltipProvider<SampleVertex, SampleEdge> tooltipProvider = VertexTooltipProvider<SampleVertex, SampleEdge> tooltipProvider =
new VertexTooltipProvider<SampleVertex, SampleEdge>() { new VertexTooltipProvider<>() {
@Override @Override
public JComponent getTooltip(SampleVertex v) { public JComponent getTooltip(SampleVertex v) {
@ -342,8 +341,7 @@ public class SampleGraphProvider extends ComponentProviderAdapter {
private void addLayoutAction() { private void addLayoutAction() {
MultiStateDockingAction<LayoutProvider<SampleVertex, SampleEdge, SampleGraph>> layoutAction = MultiStateDockingAction<LayoutProvider<SampleVertex, SampleEdge, SampleGraph>> layoutAction =
new MultiStateDockingAction<LayoutProvider<SampleVertex, SampleEdge, SampleGraph>>( new MultiStateDockingAction<>(RELAYOUT_GRAPH_ACTION_NAME, plugin.getName()) {
RELAYOUT_GRAPH_ACTION_NAME, plugin.getName()) {
@Override @Override
protected void doActionPerformed(ActionContext context) { protected void doActionPerformed(ActionContext context) {

View file

@ -23,6 +23,8 @@ import java.awt.event.ActionListener;
import javax.swing.*; import javax.swing.*;
import docking.DockingUtils;
public class SearchGuiSingle extends SearchBaseExtended { public class SearchGuiSingle extends SearchBaseExtended {
private JButton searchButton; private JButton searchButton;
@ -48,7 +50,7 @@ public class SearchGuiSingle extends SearchBaseExtended {
opTwoCheckBox = new JCheckBox("Operand 2", false); opTwoCheckBox = new JCheckBox("Operand 2", false);
constCheckBox = new JCheckBox("Constants", false); constCheckBox = new JCheckBox("Constants", false);
searchButton = new JButton(); searchButton = new JButton();
jLabel1 = new JLabel(); jLabel1 = DockingUtils.createNonHtmlLabel();
GroupLayout jPanel1Layout = new GroupLayout(jPanel1); GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout); jPanel1.setLayout(jPanel1Layout);

View file

@ -20,8 +20,7 @@ import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import docking.ActionContext; import docking.*;
import docking.WindowPosition;
import docking.options.editor.ButtonPanelFactory; import docking.options.editor.ButtonPanelFactory;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
@ -106,9 +105,9 @@ class MergeManagerProvider extends ComponentProviderAdapter {
ListingMergePanel listingMergePanel = (ListingMergePanel) currentComponent; ListingMergePanel listingMergePanel = (ListingMergePanel) currentComponent;
Object actionContext = listingMergePanel.getActionContext(event); Object actionContext = listingMergePanel.getActionContext(event);
if (actionContext instanceof ProgramLocation) { if (actionContext instanceof ProgramLocation) {
ListingActionContext listingActionContext = ListingActionContext listingActionContext = new ListingActionContext(this,
new ListingActionContext(this, navigatable, (ProgramLocation) actionContext); navigatable, (ProgramLocation) actionContext);
return listingActionContext; return listingActionContext;
} }
} }
ProgramLocation programLocation = navigatable.getLocation(); ProgramLocation programLocation = navigatable.getLocation();
@ -206,11 +205,11 @@ class MergeManagerProvider extends ComponentProviderAdapter {
mainPanel.setLayout(new BorderLayout(0, 10)); mainPanel.setLayout(new BorderLayout(0, 10));
mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
nameLabel = new JLabel("Merge Programs", SwingConstants.LEFT); nameLabel = DockingUtils.createNonHtmlLabel("Merge Programs", SwingConstants.LEFT);
JPanel iconPanel = new JPanel(); JPanel iconPanel = new JPanel();
new BoxLayout(iconPanel, BoxLayout.X_AXIS); new BoxLayout(iconPanel, BoxLayout.X_AXIS);
JLabel iconLabel = new JLabel(MERGE_ICON); JLabel iconLabel = DockingUtils.createNonHtmlLabel(MERGE_ICON);
iconPanel.add(Box.createHorizontalStrut(5)); iconPanel.add(Box.createHorizontalStrut(5));
iconPanel.add(iconLabel); iconPanel.add(iconLabel);
iconPanel.add(Box.createHorizontalStrut(5)); iconPanel.add(Box.createHorizontalStrut(5));
@ -248,9 +247,8 @@ class MergeManagerProvider extends ComponentProviderAdapter {
} }
}); });
JPanel panel = JPanel panel = ButtonPanelFactory.createButtonPanel(
ButtonPanelFactory.createButtonPanel(new JButton[] { applyButton, cancelButton }, new JButton[] { applyButton, cancelButton }, ButtonPanelFactory.X_AXIS);
ButtonPanelFactory.X_AXIS);
return panel; return panel;
} }
@ -264,7 +262,7 @@ class MergeManagerProvider extends ComponentProviderAdapter {
phasePanel = new PhaseProgressPanel("Progress In Current Phase"); phasePanel = new PhaseProgressPanel("Progress In Current Phase");
defaultPanel.add(progressPanel); // panel with each phase and their status indicators. defaultPanel.add(progressPanel); // panel with each phase and their status indicators.
defaultPanel.add(new JLabel(" ")); // Blank separator label. defaultPanel.add(DockingUtils.createNonHtmlLabel(" ")); // Blank separator label.
defaultPanel.add(phasePanel); // panel for the current phase's progress and message. defaultPanel.add(phasePanel); // panel for the current phase's progress and message.
conflictPanel.add(defaultPanel, DEFAULT_ID); conflictPanel.add(defaultPanel, DEFAULT_ID);
conflictPanel.setPreferredSize(new Dimension(610, 500)); conflictPanel.setPreferredSize(new Dimension(610, 500));

View file

@ -22,6 +22,7 @@ import java.util.HashMap;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import docking.DockingUtils;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.layout.VerticalLayout; import ghidra.util.layout.VerticalLayout;
import resources.ResourceManager; import resources.ResourceManager;
@ -36,7 +37,7 @@ public class MergeProgressPanel extends JPanel {
public static ImageIcon IN_PROGRESS_ICON = ResourceManager.loadImage("images/right.png"); public static ImageIcon IN_PROGRESS_ICON = ResourceManager.loadImage("images/right.png");
public static ImageIcon COMPLETED_ICON = public static ImageIcon COMPLETED_ICON =
ResourceManager.loadImage("images/checkmark_green.gif"); ResourceManager.loadImage("images/checkmark_green.gif");
private HashMap<String, JLabel> imageMap = new HashMap<String, JLabel>(); private HashMap<String, JLabel> imageMap = new HashMap<>();
private static int INDENT_IN_PIXELS = 20; private static int INDENT_IN_PIXELS = 20;
/** /**
@ -56,18 +57,18 @@ public class MergeProgressPanel extends JPanel {
BoxLayout bl = new BoxLayout(phasesTitlePanel, BoxLayout.X_AXIS); BoxLayout bl = new BoxLayout(phasesTitlePanel, BoxLayout.X_AXIS);
phasesTitlePanel.setLayout(bl); phasesTitlePanel.setLayout(bl);
phasesTitlePanel.add(Box.createHorizontalStrut(5)); phasesTitlePanel.add(Box.createHorizontalStrut(5));
phasesTitlePanel.add(new JLabel("Merge Status")); phasesTitlePanel.add(DockingUtils.createNonHtmlLabel("Merge Status"));
phasesTitlePanel.add(Box.createHorizontalStrut(15)); phasesTitlePanel.add(Box.createHorizontalStrut(15));
phasesTitlePanel.add(new JLabel("( ")); phasesTitlePanel.add(DockingUtils.createNonHtmlLabel("( "));
phasesTitlePanel.add(new JLabel(DEFINED_ICON)); phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(DEFINED_ICON));
phasesTitlePanel.add(new JLabel(" = Pending")); phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(" = Pending"));
phasesTitlePanel.add(Box.createHorizontalStrut(10)); phasesTitlePanel.add(Box.createHorizontalStrut(10));
phasesTitlePanel.add(new JLabel(IN_PROGRESS_ICON)); phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(IN_PROGRESS_ICON));
phasesTitlePanel.add(new JLabel(" = In Progress")); phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(" = In Progress"));
phasesTitlePanel.add(Box.createHorizontalStrut(10)); phasesTitlePanel.add(Box.createHorizontalStrut(10));
phasesTitlePanel.add(new JLabel(COMPLETED_ICON)); phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(COMPLETED_ICON));
phasesTitlePanel.add(new JLabel(" = Completed")); phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(" = Completed"));
phasesTitlePanel.add(new JLabel(" )")); phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(" )"));
phasesTitlePanel.add(Box.createHorizontalStrut(5)); phasesTitlePanel.add(Box.createHorizontalStrut(5));
return phasesTitlePanel; return phasesTitlePanel;
} }
@ -83,8 +84,8 @@ public class MergeProgressPanel extends JPanel {
*/ */
public JPanel addInfo(String[] phase) { public JPanel addInfo(String[] phase) {
int phaseDepth = phase.length - 1; int phaseDepth = phase.length - 1;
JLabel imageLabel = new JLabel(DEFINED_ICON); JLabel imageLabel = DockingUtils.createNonHtmlLabel(DEFINED_ICON);
JLabel infoLabel = new JLabel(phase[phaseDepth]); JLabel infoLabel = DockingUtils.createNonHtmlLabel(phase[phaseDepth]);
JPanel labelPanel = new JPanel(); JPanel labelPanel = new JPanel();
labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
BoxLayout bl = new BoxLayout(labelPanel, BoxLayout.X_AXIS); BoxLayout bl = new BoxLayout(labelPanel, BoxLayout.X_AXIS);

View file

@ -22,9 +22,9 @@ import java.awt.event.ActionListener;
import javax.swing.*; import javax.swing.*;
import docking.DockingUtils;
import resources.ResourceManager; import resources.ResourceManager;
/** /**
* The PhaseProgressPanel provides a title, progress bar and message for the current phase that is * The PhaseProgressPanel provides a title, progress bar and message for the current phase that is
* in progress * in progress
@ -48,7 +48,7 @@ public class PhaseProgressPanel extends JPanel {
private boolean isTimerRunning; private boolean isTimerRunning;
private String message; private String message;
private int progress; private int progress;
private int lastProgress =-1; private int lastProgress = -1;
public PhaseProgressPanel(String title) { public PhaseProgressPanel(String title) {
this.title = title; this.title = title;
@ -62,8 +62,8 @@ public class PhaseProgressPanel extends JPanel {
* Determines and sets the preferred size of this panel. * Determines and sets the preferred size of this panel.
*/ */
private void adjustPreferredSize() { private void adjustPreferredSize() {
int width = titleLabel.getPreferredSize().width+5; int width = titleLabel.getPreferredSize().width + 5;
int height = titleLabel.getPreferredSize().height+5; int height = titleLabel.getPreferredSize().height + 5;
if (isShowingProgress) { if (isShowingProgress) {
height += 5; height += 5;
height += progressBar.getPreferredSize().height; height += progressBar.getPreferredSize().height;
@ -80,23 +80,25 @@ public class PhaseProgressPanel extends JPanel {
private void createProgressPanel() { private void createProgressPanel() {
titleLabel = new JLabel(title); titleLabel = DockingUtils.createNonHtmlLabel(title);
add(titleLabel); add(titleLabel);
progressLayout.putConstraint(SpringLayout.WEST, titleLabel, 5, SpringLayout.WEST, this); progressLayout.putConstraint(SpringLayout.WEST, titleLabel, 5, SpringLayout.WEST, this);
progressLayout.putConstraint(SpringLayout.NORTH, titleLabel, 5, SpringLayout.NORTH, this); progressLayout.putConstraint(SpringLayout.NORTH, titleLabel, 5, SpringLayout.NORTH, this);
progressBar = new JProgressBar(SwingConstants.HORIZONTAL); progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
Dimension dim = progressBar.getPreferredSize(); Dimension dim = progressBar.getPreferredSize();
progressBar.setPreferredSize(new Dimension(500, (int)dim.getHeight())); progressBar.setPreferredSize(new Dimension(500, (int) dim.getHeight()));
progressBar.setMaximum(100); progressBar.setMaximum(100);
progressLayout.putConstraint(SpringLayout.NORTH, progressBar, 5, SpringLayout.SOUTH, titleLabel); progressLayout.putConstraint(SpringLayout.NORTH, progressBar, 5, SpringLayout.SOUTH,
progressLayout.putConstraint(SpringLayout.WEST, progressBar, 0, SpringLayout.WEST, titleLabel); titleLabel);
progressLayout.putConstraint(SpringLayout.WEST, progressBar, 0, SpringLayout.WEST,
titleLabel);
doSetProgress(0); doSetProgress(0);
progressMessagePanel = new JPanel(new BorderLayout()); progressMessagePanel = new JPanel(new BorderLayout());
messageIcon = new JLabel(INFORM_ICON); messageIcon = DockingUtils.createNonHtmlLabel(INFORM_ICON);
messageIcon.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); messageIcon.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
messageLabel = new JLabel(DEFAULT_INFO); messageLabel = DockingUtils.createNonHtmlLabel(DEFAULT_INFO);
progressMessagePanel.add(messageIcon, BorderLayout.WEST); progressMessagePanel.add(messageIcon, BorderLayout.WEST);
progressMessagePanel.add(messageLabel, BorderLayout.CENTER); progressMessagePanel.add(messageLabel, BorderLayout.CENTER);
doSetMessage(DEFAULT_INFO); doSetMessage(DEFAULT_INFO);
@ -156,11 +158,11 @@ public class PhaseProgressPanel extends JPanel {
if (!isShowingMessage) { if (!isShowingMessage) {
add(progressMessagePanel); add(progressMessagePanel);
progressLayout.putConstraint(SpringLayout.WEST, progressMessagePanel, 0, progressLayout.putConstraint(SpringLayout.WEST, progressMessagePanel, 0,
SpringLayout.WEST, titleLabel); SpringLayout.WEST, titleLabel);
progressLayout.putConstraint(SpringLayout.NORTH, progressMessagePanel, 5, progressLayout.putConstraint(SpringLayout.NORTH, progressMessagePanel, 5,
SpringLayout.SOUTH, (isShowingProgress ? progressBar : titleLabel)); SpringLayout.SOUTH, (isShowingProgress ? progressBar : titleLabel));
isShowingMessage = true; isShowingMessage = true;
} }
doValidate(); doValidate();
} }
@ -182,12 +184,13 @@ public class PhaseProgressPanel extends JPanel {
*/ */
private void doSetProgress(final int progressPercentage) { private void doSetProgress(final int progressPercentage) {
if (progressPercentage < 0 || progressPercentage > 100) { if (progressPercentage < 0 || progressPercentage > 100) {
throw new RuntimeException("Invalid progress value ("+progressPercentage+"). Must be from 0 to 100."); throw new RuntimeException(
"Invalid progress value (" + progressPercentage + "). Must be from 0 to 100.");
} }
if (!isShowingProgress) { if (!isShowingProgress) {
add(progressBar); add(progressBar);
isShowingProgress = true; isShowingProgress = true;
} }
progressBar.setValue(progressPercentage); progressBar.setValue(progressPercentage);
doValidate(); doValidate();
} }
@ -221,7 +224,8 @@ public class PhaseProgressPanel extends JPanel {
public void removeProgress() { public void removeProgress() {
remove(progressBar); remove(progressBar);
if (isShowingMessage) { if (isShowingMessage) {
progressLayout.putConstraint(SpringLayout.NORTH, messageIcon, 5, SpringLayout.SOUTH, titleLabel); progressLayout.putConstraint(SpringLayout.NORTH, messageIcon, 5, SpringLayout.SOUTH,
titleLabel);
} }
isShowingProgress = false; isShowingProgress = false;
doValidate(); doValidate();

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,6 +22,7 @@ import java.awt.event.ItemListener;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.app.merge.MergeConstants; import ghidra.app.merge.MergeConstants;
/** /**
@ -32,9 +32,9 @@ import ghidra.app.merge.MergeConstants;
*/ */
class CategoryConflictPanel extends JPanel { class CategoryConflictPanel extends JPanel {
public static final String LATEST_BUTTON_NAME = "LatestVersionRB"; public static final String LATEST_BUTTON_NAME = "LatestVersionRB";
public static final String CHECKED_OUT_BUTTON_NAME = "CheckedOutVersionRB"; public static final String CHECKED_OUT_BUTTON_NAME = "CheckedOutVersionRB";
public static final String ORIGINAL_BUTTON_NAME = "OriginalVersionRB"; public static final String ORIGINAL_BUTTON_NAME = "OriginalVersionRB";
private ChangeListener listener; private ChangeListener listener;
private JRadioButton latestRB; private JRadioButton latestRB;
private JRadioButton myRB; private JRadioButton myRB;
@ -43,15 +43,14 @@ class CategoryConflictPanel extends JPanel {
private JPanel rbPanel; private JPanel rbPanel;
private JLabel categoryLabel; private JLabel categoryLabel;
CategoryConflictPanel(String title, ChangeListener listener) { CategoryConflictPanel(String title, ChangeListener listener) {
super(new BorderLayout()); super(new BorderLayout());
setBorder(BorderFactory.createTitledBorder(title)); setBorder(BorderFactory.createTitledBorder(title));
create(); create();
this.listener = listener; this.listener = listener;
} }
void setConflictInfo(String categoryName,
String latestStr, String myStr, String origStr) { void setConflictInfo(String categoryName, String latestStr, String myStr, String origStr) {
categoryLabel.setText(categoryName); categoryLabel.setText(categoryName);
group.remove(latestRB); group.remove(latestRB);
group.remove(myRB); group.remove(myRB);
@ -86,8 +85,8 @@ class CategoryConflictPanel extends JPanel {
panel.setLayout(new BorderLayout()); panel.setLayout(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JLabel clabel = new JLabel("Category: "); JLabel clabel = DockingUtils.createNonHtmlLabel("Category: ");
categoryLabel = new JLabel("CategoryName"); categoryLabel = DockingUtils.createNonHtmlLabel("CategoryName");
categoryLabel.setForeground(MergeConstants.CONFLICT_COLOR); categoryLabel.setForeground(MergeConstants.CONFLICT_COLOR);
JPanel labelPanel = new JPanel(); JPanel labelPanel = new JPanel();
@ -118,6 +117,7 @@ class CategoryConflictPanel extends JPanel {
add(panel); add(panel);
ItemListener itemListener = new ItemListener() { ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (listener != null) { if (listener != null) {
listener.stateChanged(null); listener.stateChanged(null);
@ -129,6 +129,7 @@ class CategoryConflictPanel extends JPanel {
originalRB.addItemListener(itemListener); originalRB.addItemListener(itemListener);
} }
private void addToButtonGroup() { private void addToButtonGroup() {
group.add(latestRB); group.add(latestRB);
group.add(myRB); group.add(myRB);

View file

@ -22,6 +22,7 @@ import java.awt.event.ItemListener;
import javax.swing.*; import javax.swing.*;
import docking.DockingUtils;
import docking.widgets.MultiLineLabel; import docking.widgets.MultiLineLabel;
import ghidra.app.merge.MergeConstants; import ghidra.app.merge.MergeConstants;
import ghidra.app.merge.util.ConflictCountPanel; import ghidra.app.merge.util.ConflictCountPanel;
@ -178,13 +179,13 @@ class DataTypeMergePanel extends JPanel {
private JPanel createInfoPanel() { private JPanel createInfoPanel() {
Icon icon = ResourceManager.loadImage("images/information.png"); Icon icon = ResourceManager.loadImage("images/information.png");
JLabel imageLabel = new JLabel(icon); JLabel imageLabel = DockingUtils.createNonHtmlLabel(icon);
MultiLineLabel label = MultiLineLabel label =
new MultiLineLabel("A data type change in your checked out version conflicts with a " new MultiLineLabel("A data type change in your checked out version conflicts with a " +
+ "data type change in the latest version.\n" "data type change in the latest version.\n" +
+ "Select the data type change you want included in the version " "Select the data type change you want included in the version " +
+ "that will result from this check-in."); "that will result from this check-in.");
JPanel labelPanel = new JPanel(); JPanel labelPanel = new JPanel();
labelPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); labelPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));

View file

@ -22,6 +22,7 @@ import java.awt.event.ItemListener;
import javax.swing.*; import javax.swing.*;
import docking.DockingUtils;
import docking.widgets.MultiLineLabel; import docking.widgets.MultiLineLabel;
import ghidra.app.merge.MergeConstants; import ghidra.app.merge.MergeConstants;
import ghidra.app.merge.util.ConflictCountPanel; import ghidra.app.merge.util.ConflictCountPanel;
@ -173,14 +174,13 @@ class SourceArchiveMergePanel extends JPanel {
private JPanel createInfoPanel() { private JPanel createInfoPanel() {
Icon icon = ResourceManager.loadImage("images/information.png"); Icon icon = ResourceManager.loadImage("images/information.png");
JLabel imageLabel = new JLabel(icon); JLabel imageLabel = DockingUtils.createNonHtmlLabel(icon);
MultiLineLabel label = MultiLineLabel label = new MultiLineLabel(
new MultiLineLabel( "A source archive change in your checked out version conflicts with a " +
"A source archive change in your checked out version conflicts with a " "source archive change in the latest version.\n" +
+ "source archive change in the latest version.\n" "Select the source archive you want included in the version " +
+ "Select the source archive you want included in the version " "that will result from this check-in.");
+ "that will result from this check-in.");
JPanel labelPanel = new JPanel(); JPanel labelPanel = new JPanel();
labelPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); labelPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));

View file

@ -20,8 +20,10 @@ import java.awt.BorderLayout;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import docking.DockingUtils;
import ghidra.app.merge.util.ConflictUtility; import ghidra.app.merge.util.ConflictUtility;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
import ghidra.util.HTMLUtilities;
/** /**
* <code>ConflictInfoPanel</code> appears above the 4 listings in the ListingMergeWindow. * <code>ConflictInfoPanel</code> appears above the 4 listings in the ListingMergeWindow.
@ -58,8 +60,8 @@ public class ConflictInfoPanel extends JPanel {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBorder(BorderFactory.createTitledBorder("Resolve Current Conflict")); setBorder(BorderFactory.createTitledBorder("Resolve Current Conflict"));
westLabel = new JLabel("<html></html>"); westLabel = DockingUtils.createHtmlLabel("<html></html>");
eastLabel = new JLabel("<html></html>"); eastLabel = DockingUtils.createHtmlLabel("<html></html>");
add(westLabel, BorderLayout.WEST); add(westLabel, BorderLayout.WEST);
add(eastLabel, BorderLayout.EAST); add(eastLabel, BorderLayout.EAST);
} }
@ -154,7 +156,8 @@ public class ConflictInfoPanel extends JPanel {
} }
private void addAddress(StringBuffer buf, Address addr) { private void addAddress(StringBuffer buf, Address addr) {
buf.append("<font color=\"#990000\">" + addr.toString() + "</font>"); buf.append("<font color=\"#990000\">" + HTMLUtilities.friendlyEncodeHTML(addr.toString()) +
"</font>");
} }
private void updateWest() { private void updateWest() {

View file

@ -21,6 +21,7 @@ import java.awt.event.ItemListener;
import javax.swing.*; import javax.swing.*;
import docking.DockingUtils;
import docking.widgets.EmptyBorderButton; import docking.widgets.EmptyBorderButton;
import docking.widgets.fieldpanel.FieldPanel; import docking.widgets.fieldpanel.FieldPanel;
import docking.widgets.fieldpanel.internal.FieldPanelCoordinator; import docking.widgets.fieldpanel.internal.FieldPanelCoordinator;
@ -253,7 +254,7 @@ class ExternalAddConflictPanel extends JPanel implements CodeFormatService {
myTitlePanel = new TitledPanel(MergeConstants.MY_TITLE, myPanel, 5); myTitlePanel = new TitledPanel(MergeConstants.MY_TITLE, myPanel, 5);
latestTitlePanel.addTitleComponent(new ShowHeaderButton()); latestTitlePanel.addTitleComponent(new ShowHeaderButton());
myTitlePanel.addTitleComponent(new JLabel(new EmptyIcon(22, 22))); myTitlePanel.addTitleComponent(DockingUtils.createNonHtmlLabel(new EmptyIcon(22, 22)));
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setResizeWeight(0.5); splitPane.setResizeWeight(0.5);

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,13 +15,14 @@
*/ */
package ghidra.app.merge.listing; package ghidra.app.merge.listing;
import ghidra.app.merge.util.ConflictUtility;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import docking.DockingUtils;
import ghidra.app.merge.util.ConflictUtility;
/** /**
* <code>ExternalConflictInfoPanel</code> appears above the 4 listings in the ListingMergeWindow. * <code>ExternalConflictInfoPanel</code> appears above the 4 listings in the ListingMergeWindow.
* It indicates the Externals phase. * It indicates the Externals phase.
@ -54,8 +54,8 @@ public class ExternalConflictInfoPanel extends JPanel {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBorder(BorderFactory.createTitledBorder("Resolve External Location Conflict")); setBorder(BorderFactory.createTitledBorder("Resolve External Location Conflict"));
westLabel = new JLabel("<html></html>"); westLabel = DockingUtils.createHtmlLabel("<html></html>");
eastLabel = new JLabel("<html></html>"); eastLabel = DockingUtils.createHtmlLabel("<html></html>");
add(westLabel, BorderLayout.WEST); add(westLabel, BorderLayout.WEST);
add(eastLabel, BorderLayout.EAST); add(eastLabel, BorderLayout.EAST);
} }

View file

@ -25,6 +25,7 @@ import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
import docking.DockingUtils;
import docking.widgets.table.AbstractSortedTableModel; import docking.widgets.table.AbstractSortedTableModel;
import docking.widgets.table.GTable; import docking.widgets.table.GTable;
import ghidra.app.merge.util.ConflictUtility; import ghidra.app.merge.util.ConflictUtility;
@ -69,7 +70,7 @@ public class ScrollingListChoicesPanel extends ConflictPanel {
gbl = new GridBagLayout(); gbl = new GridBagLayout();
rowPanel = new JPanel(gbl); rowPanel = new JPanel(gbl);
setLayout(new BorderLayout()); setLayout(new BorderLayout());
headerLabel = new JLabel(" "); headerLabel = DockingUtils.createNonHtmlLabel(" ");
headerLabel.setHorizontalAlignment(SwingConstants.CENTER); headerLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(headerLabel, BorderLayout.NORTH); add(headerLabel, BorderLayout.NORTH);
setHeader(null); setHeader(null);
@ -257,7 +258,7 @@ class ListChoice extends JPanel {
group.add(rb); group.add(rb);
add(rb, BorderLayout.NORTH); add(rb, BorderLayout.NORTH);
model = new AbstractSortedTableModel<String[]>() { model = new AbstractSortedTableModel<>() {
@Override @Override
public Object getColumnValueForRow(String[] t, int columnIndex) { public Object getColumnValueForRow(String[] t, int columnIndex) {
return t[columnIndex]; return t[columnIndex];

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +15,6 @@
*/ */
package ghidra.app.merge.listing; package ghidra.app.merge.listing;
import ghidra.app.merge.util.ConflictUtility;
import ghidra.util.layout.MaximizeSpecificColumnGridLayout;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -29,6 +25,11 @@ import javax.swing.border.Border;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.app.merge.util.ConflictUtility;
import ghidra.util.HTMLUtilities;
import ghidra.util.layout.MaximizeSpecificColumnGridLayout;
/** /**
* <code>VariousChoicesPanel</code> provides a table type of format for resolving * <code>VariousChoicesPanel</code> provides a table type of format for resolving
* multiple conflicts in one panel. Each row that has choices represents the * multiple conflicts in one panel. Each row that has choices represents the
@ -40,8 +41,8 @@ import javax.swing.event.ChangeListener;
public class VariousChoicesPanel extends ConflictPanel { public class VariousChoicesPanel extends ConflictPanel {
private final static long serialVersionUID = 1; private final static long serialVersionUID = 1;
private static final Border UNDERLINE_BORDER = BorderFactory.createMatteBorder(0, 0, 1, 0, private static final Border UNDERLINE_BORDER =
Color.BLACK); BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK);
private JPanel rowPanel; private JPanel rowPanel;
private JLabel headerLabel; private JLabel headerLabel;
@ -71,12 +72,12 @@ public class VariousChoicesPanel extends ConflictPanel {
private void init() { private void init() {
setBorder(BorderFactory.createTitledBorder("Resolve Conflict")); setBorder(BorderFactory.createTitledBorder("Resolve Conflict"));
rows = new ArrayList<ChoiceRow>(); rows = new ArrayList<>();
layout = new MaximizeSpecificColumnGridLayout(5, 5, columnCount); layout = new MaximizeSpecificColumnGridLayout(5, 5, columnCount);
rowPanel = new JPanel(layout); rowPanel = new JPanel(layout);
rowPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); rowPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setLayout(new BorderLayout()); setLayout(new BorderLayout());
headerLabel = new JLabel(" "); headerLabel = DockingUtils.createNonHtmlLabel(" ");
headerLabel.setHorizontalAlignment(SwingConstants.CENTER); headerLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(headerLabel, BorderLayout.NORTH); add(headerLabel, BorderLayout.NORTH);
setHeader(null); setHeader(null);
@ -86,9 +87,8 @@ public class VariousChoicesPanel extends ConflictPanel {
indent = Math.max(rb.getPreferredSize().width, cb.getPreferredSize().width); indent = Math.max(rb.getPreferredSize().width, cb.getPreferredSize().width);
int radioButtonOffset = (rb.getPreferredSize().height - lbl.getPreferredSize().height) / 2; int radioButtonOffset = (rb.getPreferredSize().height - lbl.getPreferredSize().height) / 2;
int checkBoxOffset = (cb.getPreferredSize().height - lbl.getPreferredSize().height) / 2; int checkBoxOffset = (cb.getPreferredSize().height - lbl.getPreferredSize().height) / 2;
radioButtonBorder = radioButtonBorder = BorderFactory.createEmptyBorder(
BorderFactory.createEmptyBorder((radioButtonOffset > 0 ? radioButtonOffset : 0), 0, 0, (radioButtonOffset > 0 ? radioButtonOffset : 0), 0, 0, 0);
0);
checkBoxBorder = checkBoxBorder =
BorderFactory.createEmptyBorder((checkBoxOffset > 0 ? checkBoxOffset : 0), 0, 0, 0); BorderFactory.createEmptyBorder((checkBoxOffset > 0 ? checkBoxOffset : 0), 0, 0, 0);
@ -171,7 +171,8 @@ public class VariousChoicesPanel extends ConflictPanel {
* @param listener listener that gets notified whenever the state of * @param listener listener that gets notified whenever the state of
* one of the radiobuttons in this row changes. * one of the radiobuttons in this row changes.
*/ */
void addSingleChoice(final String title, final String[] choices, final ChangeListener listener) { void addSingleChoice(final String title, final String[] choices,
final ChangeListener listener) {
adjustColumnCount(choices.length + 1); adjustColumnCount(choices.length + 1);
for (int i = 0; i < choices.length; i++) { for (int i = 0; i < choices.length; i++) {
if (choices[i] == null) { if (choices[i] == null) {
@ -225,7 +226,8 @@ public class VariousChoicesPanel extends ConflictPanel {
* @param listener listener that gets notified whenever the state of * @param listener listener that gets notified whenever the state of
* one of the checkboxes in this row changes. * one of the checkboxes in this row changes.
*/ */
void addMultipleChoice(final String title, final String[] choices, final ChangeListener listener) { void addMultipleChoice(final String title, final String[] choices,
final ChangeListener listener) {
adjustColumnCount(choices.length + 1); adjustColumnCount(choices.length + 1);
MyLabel titleComp = new MyLabel(title); MyLabel titleComp = new MyLabel(title);
MyCheckBox[] cb = new MyCheckBox[choices.length]; MyCheckBox[] cb = new MyCheckBox[choices.length];
@ -506,6 +508,7 @@ public class VariousChoicesPanel extends ConflictPanel {
*/ */
public MyLabel(final String text) { public MyLabel(final String text) {
super(text); super(text);
DockingUtils.turnOffHTMLRendering(this);
addComponentListener(new ComponentListener() { addComponentListener(new ComponentListener() {
@Override @Override
@ -522,7 +525,9 @@ public class VariousChoicesPanel extends ConflictPanel {
(displayedFont != null) ? getFontMetrics(displayedFont) : null; (displayedFont != null) ? getFontMetrics(displayedFont) : null;
int stringWidth = int stringWidth =
(fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0; (fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0;
setToolTipText((stringWidth > displayedWidth) ? text : null); setToolTipText((stringWidth > displayedWidth)
? "<html>" + HTMLUtilities.friendlyEncodeHTML(text)
: null);
} }
@Override @Override

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,10 +15,6 @@
*/ */
package ghidra.app.merge.listing; package ghidra.app.merge.listing;
import ghidra.app.merge.util.ConflictUtility;
import ghidra.util.datastruct.LongArrayList;
import ghidra.util.layout.MaximizeSpecificColumnGridLayout;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
@ -29,6 +24,12 @@ import javax.swing.border.Border;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.app.merge.util.ConflictUtility;
import ghidra.util.HTMLUtilities;
import ghidra.util.datastruct.LongArrayList;
import ghidra.util.layout.MaximizeSpecificColumnGridLayout;
/** /**
* <CODE>VerticalChoicesPanel</CODE> is a conflict panel for the Listing Merge. * <CODE>VerticalChoicesPanel</CODE> is a conflict panel for the Listing Merge.
* It lays out rows of information vertically in a table format. * It lays out rows of information vertically in a table format.
@ -88,12 +89,12 @@ public class VerticalChoicesPanel extends ConflictPanel {
setBorder(BorderFactory.createTitledBorder("Resolve Conflict")); setBorder(BorderFactory.createTitledBorder("Resolve Conflict"));
setLayout(new BorderLayout()); setLayout(new BorderLayout());
headerLabel = new JLabel(" "); headerLabel = DockingUtils.createNonHtmlLabel(" ");
headerLabel.setHorizontalAlignment(SwingConstants.CENTER); headerLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(headerLabel, BorderLayout.NORTH); add(headerLabel, BorderLayout.NORTH);
rowComps = new ArrayList<ArrayList<JComponent>>(); rowComps = new ArrayList<>();
rows = new ArrayList<String[]>(); rows = new ArrayList<>();
rowTypes = new LongArrayList(); rowTypes = new LongArrayList();
group = new ButtonGroup(); group = new ButtonGroup();
layout = new MaximizeSpecificColumnGridLayout(5, 5, columnCount); layout = new MaximizeSpecificColumnGridLayout(5, 5, columnCount);
@ -107,26 +108,24 @@ public class VerticalChoicesPanel extends ConflictPanel {
indent = Math.max(rb.getPreferredSize().width, cb.getPreferredSize().width); indent = Math.max(rb.getPreferredSize().width, cb.getPreferredSize().width);
defaultInsets = new Insets(DEFAULT_TOP, DEFAULT_LEFT, DEFAULT_BOTTOM, DEFAULT_RIGHT); defaultInsets = new Insets(DEFAULT_TOP, DEFAULT_LEFT, DEFAULT_BOTTOM, DEFAULT_RIGHT);
int labelHeight = (int) new JLabel("A").getPreferredSize().getHeight(); int labelHeight = (int) DockingUtils.createNonHtmlLabel("A").getPreferredSize().getHeight();
double buttonHeight = double buttonHeight = new MyRadioButton("A",
new MyRadioButton("A", ListingMergeConstants.KEEP_LATEST).getPreferredSize().getHeight(); ListingMergeConstants.KEEP_LATEST).getPreferredSize().getHeight();
int borderHeight; int borderHeight;
borderHeight = (int) ((buttonHeight - labelHeight) / 2); borderHeight = (int) ((buttonHeight - labelHeight) / 2);
if (borderHeight < 0) { if (borderHeight < 0) {
borderHeight = 0; borderHeight = 0;
} }
textVsButtonInsets = textVsButtonInsets = new Insets(DEFAULT_TOP + borderHeight, DEFAULT_LEFT,
new Insets(DEFAULT_TOP + borderHeight, DEFAULT_LEFT, DEFAULT_BOTTOM + borderHeight, DEFAULT_BOTTOM + borderHeight, DEFAULT_RIGHT);
DEFAULT_RIGHT);
double checkBoxHeight = double checkBoxHeight =
new MyCheckBox("A", ListingMergeConstants.KEEP_LATEST).getPreferredSize().getHeight(); new MyCheckBox("A", ListingMergeConstants.KEEP_LATEST).getPreferredSize().getHeight();
borderHeight = (int) ((checkBoxHeight - labelHeight) / 2); borderHeight = (int) ((checkBoxHeight - labelHeight) / 2);
if (borderHeight < 0) { if (borderHeight < 0) {
borderHeight = 0; borderHeight = 0;
} }
textVsCheckBoxInsets = textVsCheckBoxInsets = new Insets(DEFAULT_TOP + borderHeight, DEFAULT_LEFT,
new Insets(DEFAULT_TOP + borderHeight, DEFAULT_LEFT, DEFAULT_BOTTOM + borderHeight, DEFAULT_BOTTOM + borderHeight, DEFAULT_RIGHT);
DEFAULT_RIGHT);
add(createUseForAllCheckBox(), BorderLayout.SOUTH); add(createUseForAllCheckBox(), BorderLayout.SOUTH);
} }
@ -461,6 +460,7 @@ public class VerticalChoicesPanel extends ConflictPanel {
*/ */
public MyLabel(final String text) { public MyLabel(final String text) {
super(text); super(text);
DockingUtils.turnOffHTMLRendering(this);
addComponentListener(new ComponentListener() { addComponentListener(new ComponentListener() {
@Override @Override
@ -481,7 +481,9 @@ public class VerticalChoicesPanel extends ConflictPanel {
(displayedFont != null) ? getFontMetrics(displayedFont) : null; (displayedFont != null) ? getFontMetrics(displayedFont) : null;
int stringWidth = int stringWidth =
(fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0; (fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0;
setToolTipText((stringWidth > displayedWidth) ? text : null); setToolTipText((stringWidth > displayedWidth)
? "<html>" + HTMLUtilities.friendlyEncodeHTML(text)
: null);
} }
@Override @Override
@ -622,7 +624,8 @@ public class VerticalChoicesPanel extends ConflictPanel {
JComponent[] comps = getRowComponents(row); JComponent[] comps = getRowComponents(row);
for (int i = 0; i < comps.length; i++) { for (int i = 0; i < comps.length; i++) {
JComponent component = comps[i]; JComponent component = comps[i];
if (component instanceof MyRadioButton && ((MyRadioButton) component).isSelected()) { if (component instanceof MyRadioButton &&
((MyRadioButton) component).isSelected()) {
conflictOption |= ((MyRadioButton) component).option; conflictOption |= ((MyRadioButton) component).option;
} }
else if (component instanceof MyCheckBox && ((MyCheckBox) component).isSelected()) { else if (component instanceof MyCheckBox && ((MyCheckBox) component).isSelected()) {

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +15,6 @@
*/ */
package ghidra.app.merge.propertylist; package ghidra.app.merge.propertylist;
import ghidra.app.merge.MergeConstants;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
@ -25,6 +22,9 @@ import java.awt.event.ItemListener;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.app.merge.MergeConstants;
/** /**
* Panel that shows differences for properties in Property Lists. * Panel that shows differences for properties in Property Lists.
*/ */
@ -63,27 +63,27 @@ class ConflictPanel extends JPanel {
} }
if (info.isTypeMatch()) { if (info.isTypeMatch()) {
setBorder(BorderFactory.createTitledBorder("Resolve Type Mismatch for Property " + setBorder(BorderFactory.createTitledBorder(
info.getDisplayedPropertyName())); "Resolve Type Mismatch for Property " + info.getDisplayedPropertyName()));
latestRB.setText("Use type '" + info.getLatestTypeString() + "', value = '" + latestRB.setText("Use type '" + info.getLatestTypeString() + "', value = '" +
info.getLatestValue() + "' (" + MergeConstants.LATEST_TITLE + ")"); info.getLatestValue() + "' (" + MergeConstants.LATEST_TITLE + ")");
myRB.setText("Use type '" + info.getMyTypeString() + "', value = '" + myRB.setText("Use type '" + info.getMyTypeString() + "', value = '" +
info.getMyValue() + "' (" + MergeConstants.MY_TITLE + ")"); info.getMyValue() + "' (" + MergeConstants.MY_TITLE + ")");
if (origValue != null) { if (origValue != null) {
origText = origText = "Use type '" + info.getOrigTypeString() + "', value = '" +
"Use type '" + info.getOrigTypeString() + "', value = '" + info.getOrigValue() + info.getOrigValue() + "' (" + MergeConstants.ORIGINAL_TITLE + ")";
"' (" + MergeConstants.ORIGINAL_TITLE + ")";
} }
} }
else { else {
setBorder(BorderFactory.createTitledBorder("Resolve Property Conflict for " + setBorder(BorderFactory.createTitledBorder(
info.getDisplayedPropertyName())); "Resolve Property Conflict for " + info.getDisplayedPropertyName()));
latestRB.setText("Use value '" + info.getLatestValue() + "' (" + latestRB.setText(
MergeConstants.LATEST_TITLE + ")"); "Use value '" + info.getLatestValue() + "' (" + MergeConstants.LATEST_TITLE + ")");
myRB.setText("Use value '" + info.getMyValue() + "' (" + MergeConstants.MY_TITLE + " )"); myRB.setText(
"Use value '" + info.getMyValue() + "' (" + MergeConstants.MY_TITLE + " )");
if (origValue != null) { if (origValue != null) {
origText = "Use value '" + origValue + "' (" + MergeConstants.ORIGINAL_TITLE + " )"; origText = "Use value '" + origValue + "' (" + MergeConstants.ORIGINAL_TITLE + " )";
} }
@ -133,7 +133,7 @@ class ConflictPanel extends JPanel {
panel.setLayout(new BorderLayout()); panel.setLayout(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
propertyGroupLabel = new JLabel("Property Group: "); propertyGroupLabel = DockingUtils.createNonHtmlLabel("Property Group: ");
JPanel namePanel = new JPanel(new BorderLayout()); JPanel namePanel = new JPanel(new BorderLayout());
namePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5)); namePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5));
@ -163,6 +163,7 @@ class ConflictPanel extends JPanel {
panel.add(createUseForAllCheckBox(), BorderLayout.SOUTH); panel.add(createUseForAllCheckBox(), BorderLayout.SOUTH);
ItemListener itemListener = new ItemListener() { ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (listener != null) { if (listener != null) {
listener.stateChanged(null); listener.stateChanged(null);

View file

@ -22,6 +22,7 @@ import java.awt.event.ItemListener;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.app.merge.MergeConstants; import ghidra.app.merge.MergeConstants;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import resources.ResourceManager; import resources.ResourceManager;
@ -58,17 +59,15 @@ class NameConflictsPanel extends JPanel {
text = "Use name '" + latestName + "' (" + MergeConstants.LATEST_TITLE + ")"; text = "Use name '" + latestName + "' (" + MergeConstants.LATEST_TITLE + ")";
} }
else { else {
text = text = "Use '" + latestName + "' (" + MergeConstants.LATEST_TITLE + ") & lose '" +
"Use '" + latestName + "' (" + MergeConstants.LATEST_TITLE + ") & lose '" + myName + myName + "' (" + MergeConstants.MY_TITLE + ")";
"' (" + MergeConstants.MY_TITLE + ")";
} }
keepOtherRB.setText(text); keepOtherRB.setText(text);
String myText; String myText;
if (myName.equals(latestName)) { if (myName.equals(latestName)) {
myText = myText = "Add '" + myName + "' (" + MergeConstants.MY_TITLE + ") as '" +
"Add '" + myName + "' (" + MergeConstants.MY_TITLE + ") as '" + ProgramTreeMergeManager.getUniqueTreeName(resultProgram, myName) + "'";
ProgramTreeMergeManager.getUniqueTreeName(resultProgram, myName) + "'";
} }
else { else {
myText = "Add tree '" + myName + "' (" + MergeConstants.MY_TITLE + ")"; myText = "Add tree '" + myName + "' (" + MergeConstants.MY_TITLE + ")";
@ -82,15 +81,13 @@ class NameConflictsPanel extends JPanel {
} }
else { else {
if (origName.equals(latestName)) { if (origName.equals(latestName)) {
origText = origText = "Restore '" + origName + "' (" + MergeConstants.ORIGINAL_TITLE +
"Restore '" + origName + "' (" + MergeConstants.ORIGINAL_TITLE + ") as '" + ") as '" + ProgramTreeMergeManager.getUniqueTreeName(resultProgram, origName) +
ProgramTreeMergeManager.getUniqueTreeName(resultProgram, origName) + "'" + "'" + " & lose '" + myName + "' (" + MergeConstants.MY_TITLE + ")";
" & lose '" + myName + "' (" + MergeConstants.MY_TITLE + ")";
} }
else { else {
origText = origText = "Restore '" + origName + "' (" + MergeConstants.ORIGINAL_TITLE +
"Restore '" + origName + "' (" + MergeConstants.ORIGINAL_TITLE + ") & lose '" + ") & lose '" + myName + "' (" + MergeConstants.MY_TITLE + ")";
myName + "' (" + MergeConstants.MY_TITLE + ")";
} }
} }
originalRB.setText(origText); originalRB.setText(origText);
@ -129,9 +126,10 @@ class NameConflictsPanel extends JPanel {
JPanel iconPanel = new JPanel(); JPanel iconPanel = new JPanel();
iconPanel.setLayout(new BoxLayout(iconPanel, BoxLayout.X_AXIS)); iconPanel.setLayout(new BoxLayout(iconPanel, BoxLayout.X_AXIS));
conflictsLabel = new JLabel("'My' name already exists in Latest Version"); conflictsLabel =
DockingUtils.createNonHtmlLabel("'My' name already exists in Latest Version");
ImageIcon icon = ResourceManager.loadImage("images/information.png"); ImageIcon icon = ResourceManager.loadImage("images/information.png");
iconPanel.add(new JLabel(icon)); iconPanel.add(DockingUtils.createNonHtmlLabel(icon));
iconPanel.add(Box.createHorizontalStrut(5)); iconPanel.add(Box.createHorizontalStrut(5));
iconPanel.add(conflictsLabel); iconPanel.add(conflictsLabel);
iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,12 +15,12 @@
*/ */
package ghidra.app.merge.tree; package ghidra.app.merge.tree;
import ghidra.util.layout.PairLayout;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import docking.DockingUtils;
import ghidra.util.layout.PairLayout;
import resources.ResourceManager; import resources.ResourceManager;
/** /**
@ -39,8 +38,7 @@ class TreeChangePanel extends JPanel {
private JLabel nameIconLabel; private JLabel nameIconLabel;
private JLabel structureIconLabel; private JLabel structureIconLabel;
private final static ImageIcon CHANGED_ICON = private final static ImageIcon CHANGED_ICON = ResourceManager.loadImage("images/changed16.gif");
ResourceManager.loadImage("images/changed16.gif");
private final static ImageIcon NO_CHANGE_ICON = private final static ImageIcon NO_CHANGE_ICON =
ResourceManager.loadImage("images/EmptyIcon16.gif"); ResourceManager.loadImage("images/EmptyIcon16.gif");
private final static Color CHANGED_COLOR = Color.BLACK; private final static Color CHANGED_COLOR = Color.BLACK;
@ -55,17 +53,18 @@ class TreeChangePanel extends JPanel {
void setStates(String treeName, boolean nameChanged, boolean structureChanged) { void setStates(String treeName, boolean nameChanged, boolean structureChanged) {
treeNameLabel.setText(treeName); treeNameLabel.setText(treeName);
nameLabel.setText(nameChanged? "Name Changed" : "Name Not Changed"); nameLabel.setText(nameChanged ? "Name Changed" : "Name Not Changed");
nameLabel.setForeground(nameChanged? CHANGED_COLOR : NO_CHANGE_COLOR); nameLabel.setForeground(nameChanged ? CHANGED_COLOR : NO_CHANGE_COLOR);
namePanel.remove(nameIconLabel); namePanel.remove(nameIconLabel);
nameIconLabel = new JLabel(nameChanged? CHANGED_ICON : NO_CHANGE_ICON); nameIconLabel =
DockingUtils.createNonHtmlLabel(nameChanged ? CHANGED_ICON : NO_CHANGE_ICON);
namePanel.add(nameIconLabel, 0); namePanel.add(nameIconLabel, 0);
structureLabel.setText(structureChanged? structureLabel.setText(structureChanged ? "Structure Changed" : "Structure Not Changed");
"Structure Changed" : "Structure Not Changed"); structureLabel.setForeground(structureChanged ? CHANGED_COLOR : NO_CHANGE_COLOR);
structureLabel.setForeground(structureChanged? CHANGED_COLOR : NO_CHANGE_COLOR);
structurePanel.remove(structureIconLabel); structurePanel.remove(structureIconLabel);
structureIconLabel = new JLabel(structureChanged? CHANGED_ICON : NO_CHANGE_ICON); structureIconLabel =
DockingUtils.createNonHtmlLabel(structureChanged ? CHANGED_ICON : NO_CHANGE_ICON);
structurePanel.add(structureIconLabel, 0); structurePanel.add(structureIconLabel, 0);
} }
@ -73,22 +72,22 @@ class TreeChangePanel extends JPanel {
JPanel panel = new JPanel(new BorderLayout(0, 5)); JPanel panel = new JPanel(new BorderLayout(0, 5));
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
treeNameLabel = new JLabel("Tree Name"); treeNameLabel = DockingUtils.createNonHtmlLabel("Tree Name");
Font font = treeNameLabel.getFont(); Font font = treeNameLabel.getFont();
font = new Font(font.getName(), Font.BOLD, font.getSize()); font = new Font(font.getName(), Font.BOLD, font.getSize());
treeNameLabel.setFont(font); treeNameLabel.setFont(font);
nameLabel = new JLabel("Name Changed"); nameLabel = DockingUtils.createNonHtmlLabel("Name Changed");
nameIconLabel = new JLabel(CHANGED_ICON); nameIconLabel = DockingUtils.createNonHtmlLabel(CHANGED_ICON);
structureLabel = new JLabel("Structure Changed"); structureLabel = DockingUtils.createNonHtmlLabel("Structure Changed");
structureIconLabel = new JLabel(CHANGED_ICON); structureIconLabel = DockingUtils.createNonHtmlLabel(CHANGED_ICON);
namePanel = new JPanel(new PairLayout(0,5)); namePanel = new JPanel(new PairLayout(0, 5));
namePanel.add(nameIconLabel); namePanel.add(nameIconLabel);
namePanel.add(nameLabel); namePanel.add(nameLabel);
structurePanel = new JPanel(new PairLayout(0,5)); structurePanel = new JPanel(new PairLayout(0, 5));
structurePanel.add(structureIconLabel); structurePanel.add(structureIconLabel);
structurePanel.add(structureLabel); structurePanel.add(structureLabel);

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,6 +18,7 @@ package ghidra.app.merge.util;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressRange; import ghidra.program.model.address.AddressRange;
import ghidra.program.util.DiffUtility; import ghidra.program.util.DiffUtility;
import ghidra.util.HTMLUtilities;
/** /**
* <code>ConflictUtility</code> provides some constants and static methods * <code>ConflictUtility</code> provides some constants and static methods
@ -169,7 +169,8 @@ public class ConflictUtility {
* @param isRange true if the current conflict is for an address range. * @param isRange true if the current conflict is for an address range.
* @return the message string containing HTML tags. * @return the message string containing HTML tags.
*/ */
public static String getAddressConflictCount(int addressNum, int totalAddresses, boolean isRange) { public static String getAddressConflictCount(int addressNum, int totalAddresses,
boolean isRange) {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
if (isRange) { if (isRange) {
buf.append("Address range #"); buf.append("Address range #");
@ -238,7 +239,8 @@ public class ConflictUtility {
* @return the message string containing HTML tags. * @return the message string containing HTML tags.
*/ */
public static String getAddressString(Address address) { public static String getAddressString(Address address) {
return colorString(ADDRESS_COLOR, ((address != null) ? address.toString() : "")); return colorString(ADDRESS_COLOR,
((address != null) ? HTMLUtilities.friendlyEncodeHTML(address.toString()) : ""));
} }
/** /**
@ -248,8 +250,10 @@ public class ConflictUtility {
* @return the message string containing HTML tags. * @return the message string containing HTML tags.
*/ */
public static String getAddressString(Address address, boolean showAddressSpace) { public static String getAddressString(Address address, boolean showAddressSpace) {
return colorString(ADDRESS_COLOR, ((address != null) ? address.toString(showAddressSpace) return colorString(ADDRESS_COLOR,
: "")); ((address != null)
? HTMLUtilities.friendlyEncodeHTML(address.toString(showAddressSpace))
: ""));
} }
/** /**

View file

@ -30,6 +30,7 @@ import javax.swing.table.*;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import docking.DockingUtils;
import docking.options.editor.GenericOptionsComponent; import docking.options.editor.GenericOptionsComponent;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.table.*; import docking.widgets.table.*;
@ -62,8 +63,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
private List<Boolean> analyzerEnablement = new ArrayList<>(); private List<Boolean> analyzerEnablement = new ArrayList<>();
private Set<String> prototypeAnalyzers = new HashSet<>(); private Set<String> prototypeAnalyzers = new HashSet<>();
private Map<String, Component> analyzerToOptionsPanelMap = new HashMap<>(); private Map<String, Component> analyzerToOptionsPanelMap = new HashMap<>();
private Map<String, List<Component>> analyzerManagedComponentsMap = private Map<String, List<Component>> analyzerManagedComponentsMap = new HashMap<>();
new HashMap<>();
private EditorStateFactory editorStateFactory; private EditorStateFactory editorStateFactory;
private JPanel noOptionsPanel; private JPanel noOptionsPanel;
@ -475,7 +475,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
boolean origEnabled = analysisOptions.getBoolean(analyzerName, false); boolean origEnabled = analysisOptions.getBoolean(analyzerName, false);
if (currEnabled != origEnabled) { if (currEnabled != origEnabled) {
propertyChangeListener.propertyChange( propertyChangeListener.propertyChange(
new PropertyChangeEvent(this, analyzerName, origEnabled, currEnabled)); new PropertyChangeEvent(this, analyzerName, origEnabled, currEnabled));
return true; return true;
} }
} }
@ -522,7 +522,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
List<Options> optionGroups = analysisOptions.getChildOptions(); List<Options> optionGroups = analysisOptions.getChildOptions();
noOptionsPanel = new JPanel(new VerticalLayout(5)); noOptionsPanel = new JPanel(new VerticalLayout(5));
noOptionsPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); noOptionsPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
noOptionsPanel.add(new JLabel("No options available.")); noOptionsPanel.add(DockingUtils.createNonHtmlLabel("No options available."));
for (Options optionsGroup : optionGroups) { for (Options optionsGroup : optionGroups) {
String analyzerName = optionsGroup.getName(); String analyzerName = optionsGroup.getName();
@ -539,8 +539,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
List<String> optionNames = getOptionNames(optionsGroup); List<String> optionNames = getOptionNames(optionsGroup);
Collections.sort(optionNames); Collections.sort(optionNames);
List<GenericOptionsComponent> optionComponents = List<GenericOptionsComponent> optionComponents = new ArrayList<>();
new ArrayList<>();
for (String childOptionName : optionNames) { for (String childOptionName : optionNames) {
EditorState childState = EditorState childState =

View file

@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.HTMLEditorKit;
import docking.DockingUtils;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import ghidra.GhidraOptions; import ghidra.GhidraOptions;
import ghidra.app.services.ProgramManager; import ghidra.app.services.ProgramManager;
@ -35,6 +36,7 @@ import ghidra.program.model.lang.CompilerSpecID;
import ghidra.program.model.lang.LanguageID; import ghidra.program.model.lang.LanguageID;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.program.util.GhidraProgramUtilities; import ghidra.program.util.GhidraProgramUtilities;
import ghidra.util.HTMLUtilities;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
import ghidra.util.task.*; import ghidra.util.task.*;
@ -98,7 +100,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
} }
else { else {
// no options dialog--analyze all programs // no options dialog--analyze all programs
validPrograms = new ArrayList<Program>(programs); validPrograms = new ArrayList<>(programs);
} }
analyzePrograms(prototypeAnalysisOptions, validPrograms, monitor); analyzePrograms(prototypeAnalysisOptions, validPrograms, monitor);
@ -175,7 +177,8 @@ class AnalyzeAllOpenProgramsTask extends Task {
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(new Runnable() {
@Override @Override
public void run() { public void run() {
AnalysisOptionsDialog dialog = new AnalysisOptionsDialog(getValidProgramsByArchitecture()); AnalysisOptionsDialog dialog =
new AnalysisOptionsDialog(getValidProgramsByArchitecture());
tool.showDialog(dialog); tool.showDialog(dialog);
boolean shouldAnalyze = dialog.wasAnalyzeButtonSelected(); boolean shouldAnalyze = dialog.wasAnalyzeButtonSelected();
analyze.set(shouldAnalyze); analyze.set(shouldAnalyze);
@ -213,7 +216,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
* @return the list of programs to analyze * @return the list of programs to analyze
*/ */
private List<Program> getValidProgramsByArchitecture() { private List<Program> getValidProgramsByArchitecture() {
List<Program> validList = new ArrayList<Program>(programs); List<Program> validList = new ArrayList<>(programs);
ProgramID protoTypeProgramID = new ProgramID(prototypeProgram); ProgramID protoTypeProgramID = new ProgramID(prototypeProgram);
@ -244,7 +247,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
List<Program> validList = getValidProgramsByArchitecture(); List<Program> validList = getValidProgramsByArchitecture();
if (validList.size() != programs.size()) { if (validList.size() != programs.size()) {
List<Program> invalidList = new ArrayList<Program>(programs); List<Program> invalidList = new ArrayList<>(programs);
invalidList.removeAll(validList); invalidList.removeAll(validList);
if (!showNonMatchingArchitecturesWarning(validList, invalidList)) { if (!showNonMatchingArchitecturesWarning(validList, invalidList)) {
@ -274,7 +277,8 @@ class AnalyzeAllOpenProgramsTask extends Task {
StringBuilder buffy = new StringBuilder(); StringBuilder buffy = new StringBuilder();
buffy.append("<html><BR>"); buffy.append("<html><BR>");
buffy.append("Found open programs with architectures differing from the current program.<BR><BR><BR>"); buffy.append(
"Found open programs with architectures differing from the current program.<BR><BR><BR>");
buffy.append("These programs <B>will</B> be analyzed: <BR><BR>"); buffy.append("These programs <B>will</B> be analyzed: <BR><BR>");
buffy.append("<TABLE BORDER=\"0\" CELLPADDING=\"5\">"); buffy.append("<TABLE BORDER=\"0\" CELLPADDING=\"5\">");
@ -294,7 +298,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
buffy.append("<TR>"); buffy.append("<TR>");
buffy.append("<TD>"); buffy.append("<TD>");
buffy.append(specialFontOpen); buffy.append(specialFontOpen);
buffy.append(program.getName()); buffy.append(HTMLUtilities.friendlyEncodeHTML(program.getName()));
buffy.append(specialFontClose); buffy.append(specialFontClose);
buffy.append("</TD>"); buffy.append("</TD>");
buffy.append("<TD>"); buffy.append("<TD>");
@ -321,7 +325,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
for (Program program : invalidList) { for (Program program : invalidList) {
buffy.append("<TR>"); buffy.append("<TR>");
buffy.append("<TD>"); buffy.append("<TD>");
buffy.append(program.getName()); buffy.append(HTMLUtilities.friendlyEncodeHTML(program.getName()));
buffy.append("</TD>"); buffy.append("</TD>");
buffy.append("<TD>"); buffy.append("<TD>");
buffy.append(program.getLanguageID()); buffy.append(program.getLanguageID());
@ -334,9 +338,8 @@ class AnalyzeAllOpenProgramsTask extends Task {
buffy.append("</TABLE>"); buffy.append("</TABLE>");
OptionDialog dialog = OptionDialog dialog = new ScrollingOptionDialog("Found Differing Architectures--Continue?",
new ScrollingOptionDialog("Found Differing Architectures--Continue?", buffy.toString(), "Continue", OptionDialog.WARNING_MESSAGE);
buffy.toString(), "Continue", OptionDialog.WARNING_MESSAGE);
dialog.show(null); dialog.show(null);
return dialog.getResult() == OptionDialog.OPTION_ONE; return dialog.getResult() == OptionDialog.OPTION_ONE;
} }
@ -467,8 +470,9 @@ class AnalyzeAllOpenProgramsTask extends Task {
} }
if (compilerSpecID == null) { if (compilerSpecID == null) {
if (other.compilerSpecID != null) if (other.compilerSpecID != null) {
return false; return false;
}
} }
else if (!compilerSpecID.equals(other.compilerSpecID)) { else if (!compilerSpecID.equals(other.compilerSpecID)) {
return false; return false;
@ -491,7 +495,8 @@ class AnalyzeAllOpenProgramsTask extends Task {
private class ScrollingOptionDialog extends OptionDialog { private class ScrollingOptionDialog extends OptionDialog {
public ScrollingOptionDialog(String title, String message, String option1, int messageType) { public ScrollingOptionDialog(String title, String message, String option1,
int messageType) {
super(title, message, option1, messageType, null); super(title, message, option1, messageType, null);
} }
@ -503,8 +508,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
editorPane.setName("MESSAGE-COMPONENT"); editorPane.setName("MESSAGE-COMPONENT");
editorPane.setText(message); editorPane.setText(message);
JLabel label = new JLabel(); editorPane.setBackground(DockingUtils.createNonHtmlLabel().getBackground());
editorPane.setBackground(label.getBackground());
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

View file

@ -1098,7 +1098,7 @@ public class AutoAnalysisManager implements DomainObjectListener, DomainObjectCl
} }
if (GhidraProgramUtilities.shouldAskToAnalyze(program)) { if (GhidraProgramUtilities.shouldAskToAnalyze(program)) {
int answer = OptionDialog.showYesNoDialog(tool.getToolFrame(), "Analyze", int answer = OptionDialog.showYesNoDialog(tool.getToolFrame(), "Analyze",
program.getDomainFile().getName() + "<html>" + HTMLUtilities.friendlyEncodeHTML(program.getDomainFile().getName()) +
" has not been analyzed. Would you like to analyze it now?"); " has not been analyzed. Would you like to analyze it now?");
boolean analyzed = answer == OptionDialog.OPTION_ONE; boolean analyzed = answer == OptionDialog.OPTION_ONE;
GhidraProgramUtilities.setAnalyzedFlag(program, analyzed); GhidraProgramUtilities.setAnalyzedFlag(program, analyzed);

View file

@ -21,6 +21,7 @@ import java.io.File;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import ghidra.framework.GenericRunInfo; import ghidra.framework.GenericRunInfo;
@ -75,7 +76,7 @@ public class ArchiveDialog extends DialogComponentProvider {
GridBagLayout gbl = new GridBagLayout(); GridBagLayout gbl = new GridBagLayout();
JPanel outerPanel = new JPanel(gbl); JPanel outerPanel = new JPanel(gbl);
archiveLabel = new JLabel(" Archive File "); archiveLabel = DockingUtils.createNonHtmlLabel(" Archive File ");
archiveField = new JTextField(); archiveField = new JTextField();
archiveField.setName("archiveField"); archiveField.setName("archiveField");
archiveField.setColumns(NUM_TEXT_COLUMNS); archiveField.setColumns(NUM_TEXT_COLUMNS);
@ -153,7 +154,7 @@ public class ArchiveDialog extends DialogComponentProvider {
} }
File file = new File(archive); File file = new File(archive);
if (file.exists() && OptionDialog.showOptionDialog(rootPanel, "Archive File Exists", if (file.exists() && OptionDialog.showOptionDialog(rootPanel, "Archive File Exists",
archive + " exists.\n " + "Do you want to overwrite existing file?", "File " + archive + " exists.\n " + "Do you want to overwrite existing file?",
"Yes") != OptionDialog.OPTION_ONE) { "Yes") != OptionDialog.OPTION_ONE) {
return; return;
} }

View file

@ -1,315 +0,0 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.app.plugin.core.archive;
import java.awt.Component;
import java.awt.Font;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.*;
import generic.io.JarReader;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.*;
import ghidra.util.task.TaskMonitor;
import utilities.util.FileUtilities;
/**
* Class containing some methods for creating project files from a
* Ghidra Version 1 archive file
* that is input via the JarInputStream parameter.
*/
class ProjectJarReader extends JarReader {
private static final String PROJECT_FILE_SUFFIX = ProjectLocator.getProjectExtension();
private static final String PROJECT_DIR_SUFFIX = ProjectLocator.getProjectDirExtension();
private static final String XML_FILE_SUFFIX = ".xml";
private static final String PROPERTIES_FILE_NAME = ".properties";
private static final String ORIGINAL_PROPERTIES_FILE_NAME = "original" + PROPERTIES_FILE_NAME;
private static final int READ_BLOCK_SIZE = 4096;
/**
* Construct a new ProjectJarReader.
* @param jarIn the the jar file input stream the zip entries are
* read from.
*/
ProjectJarReader(JarInputStream jarIn) {
super(jarIn);
}
private static final Pattern PROJECT_DATA_FILE_PATTERN = Pattern.compile(".+\\.rep/data(/.+)");
private static String filterDataPathsOnly(String path) {
path = path.replace('\\', '/');
Matcher matcher = PROJECT_DATA_FILE_PATTERN.matcher(path);
if (matcher.find()) {
return matcher.group(1);
}
return null;
}
/**
* Writes the all zip entries from the jar input stream out to the specified
* project using the reader and any needed services from the service registry.
*
* @param reader the reader for processing special files (entries).
* @param services the service registry
* @param project the project that the files are to be added to.
* @param monitor a task monitor for indicating progress to the user.
*
* @return true if all files are successfully created.
*/
boolean createRecursively(XmlDataReader reader, File restoreDir, PluginTool tool,
Project project, TaskMonitor monitor) throws IOException {
boolean succeeded = true;
StringBuffer errorBuf = new StringBuffer();
List<String> xmlFiles = new ArrayList<>();
boolean done = false;
while (!done && succeeded) {
if (monitor.isCancelled()) {
return false;
}
try {
//Get the zip entry.
JarEntry entry = jarIn.getNextJarEntry();
if (entry == null) {
done = true;
break;
}
String name = entry.getName();
// discard property files
if (name.endsWith(PropertyFile.PROPERTY_EXT) ||
name.endsWith(ORIGINAL_PROPERTIES_FILE_NAME)) {
continue;
}
name = filterDataPathsOnly(name);
if (name == null) {
continue;
}
File file = new File(restoreDir, name);
FileUtilities.mkdirs(file.getParentFile());
// Write it out to the file along with its data.
FileOutputStream out = null;
try {
out = new FileOutputStream(file);
}
catch (FileNotFoundException fnfe) {
String msg = fnfe.getMessage();
if (msg == null) {
msg = fnfe.toString();
}
Msg.showError(this, null, "Restore Failed",
"Couldn't create file " + file.getAbsolutePath() + "\n" + msg);
return false;
}
byte[] bytes = new byte[READ_BLOCK_SIZE];
int numRead = 0;
try {
while ((numRead = jarIn.read(bytes)) != -1) {
if (monitor.isCancelled()) {
break;
}
out.write(bytes, 0, numRead);
}
}
catch (IOException ioe) {
succeeded = false;
String msg = ioe.getMessage();
if (msg == null) {
msg = ioe.toString();
}
errorBuf.append(
"Couldn't create file " + file.getAbsolutePath() + "\n" + msg + "\n");
Msg.error(this, "Unexpected Exception: " + ioe.getMessage(), ioe);
}
finally {
try {
out.close();
}
catch (IOException ioe) {
Msg.error(this, "Unexpected Exception: " + ioe.getMessage(), ioe);
}
}
if (monitor.isCancelled()) {
return false;
}
if (name.endsWith(XML_FILE_SUFFIX) &&
!name.endsWith("projectDataTypes" + XML_FILE_SUFFIX)) {
// the extra check is for backwards compatibility
xmlFiles.add(name);
}
}
catch (IOException ioe) {
succeeded = false;
String msg = ioe.getMessage();
if (msg == null) {
msg = ioe.toString();
}
errorBuf.append("Failed to restore archive entry.\n" + msg + "\n");
done = true;
break;
}
}
// Post-process the XML files that we created specially
for (int i = 0; i < xmlFiles.size(); i++) {
if (monitor.isCancelled()) {
return false;
}
String relName = xmlFiles.get(i);
try {
if (!reader.addXMLObject(tool, restoreDir.getAbsolutePath(), relName, true,
monitor) && !monitor.isCancelled()) {
succeeded = false;
errorBuf.append("Couldn't restore " + relName + ".\n" + "\n");
}
}
catch (Exception e) {
succeeded = false;
String msg = e.getMessage();
if (msg == null) {
msg = e.toString();
}
errorBuf.append("Couldn't restore " + relName + ".\n" + e.getMessage() + "\n");
}
}
// Post-process the .property files to restore ghidra ownership.
// for (int i = 0; i < propertyFiles.size(); i++) {
// if (monitor.isCancelled()) {
// return false;
// }
// String pName = propertyFiles.get(i);
// if (!replacePropertyFile(basePath + pName)) {
// succeeded = false;
// errorBuf.append("Couldn't restore " + pName + ".\n" + "\n");
// }
// }
if (monitor.isCancelled()) {
return false;
}
final String summary = reader.getSummary();
if (summary != null) {
SystemUtilities.runSwingNow(
() -> showErrorDialog(null, "Please review the messages below:", summary));
}
//TODO: Will still need to add code for changing actual file
// ownership on the file system for the files that have been
// created on behalf of restoring other users' stuff.
if (!succeeded) {
String message = errorBuf.toString();
String title = "Error Restoring Project Archive";
project.releaseFiles(tool);
Msg.showError(this, null, title, message);
}
return succeeded;
}
/**
* Displays an error dialog.
*
* @param parent component to which dialog should be parented
* @param title title of error dialog
* @param message message(s) to display, can be multiple lines
*/
private static void showErrorDialog(Component parent, String title, String message) {
if (message.indexOf("\n") >= 0) {
showMultiLineMessage(parent, title, message, JOptionPane.ERROR_MESSAGE);
}
else {
showSingleLineMessage(parent, title, message, JOptionPane.ERROR_MESSAGE);
}
}
private static void showMultiLineMessage(Component parent, String title, String message,
int type) {
JTextArea textArea = new JTextArea(20, 60);
textArea.setFont(new Font("Monospaced", Font.BOLD, 12));
textArea.setEditable(false);
textArea.setText(message);
textArea.setOpaque(false);
JScrollPane scrollPane = new JScrollPane(textArea);
JOptionPane.showMessageDialog(parent, scrollPane, title, type);
}
private static void showSingleLineMessage(Component parent, String title, String message,
int type) {
JLabel textLabel = new JLabel();
textLabel.setText(message);
JOptionPane.showMessageDialog(parent, textLabel, title, type);
}
private boolean replacePropertyFile(String filepath) {
if (!filepath.endsWith(ORIGINAL_PROPERTIES_FILE_NAME)) {
return false;
}
File origFile = new File(filepath);
int endOffset = filepath.length() - ORIGINAL_PROPERTIES_FILE_NAME.length();
filepath = filepath.substring(0, endOffset) + PROPERTIES_FILE_NAME;
File newFile = new File(filepath);
if (newFile.exists() && !newFile.delete()) {
return false;
}
// Need to rename the file from original.properties to .properties
return origFile.renameTo(newFile);
}
private String modifyName(String name, String projectName) {
// Project File?
name = name.replace("\\", File.separator);
if (name.endsWith(PROJECT_FILE_SUFFIX)) {
int start = name.lastIndexOf(File.separator);
if (start == -1) {
return projectName + PROJECT_FILE_SUFFIX;
}
String first = name.substring(0, start);
return first + projectName + PROJECT_FILE_SUFFIX;
}
// Project Folder?
int suffixIndex = name.indexOf(PROJECT_DIR_SUFFIX);
if (suffixIndex > -1) {
String prefix = name.substring(0, suffixIndex);
String suffix = name.substring(suffixIndex);
int end = prefix.lastIndexOf(File.separator);
if (end == -1) {
return projectName + suffix;
}
return prefix.substring(0, end) + projectName + suffix;
}
return name;
}
}

View file

@ -23,6 +23,7 @@ import java.io.File;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import ghidra.framework.GenericRunInfo; import ghidra.framework.GenericRunInfo;
import ghidra.framework.model.ProjectLocator; import ghidra.framework.model.ProjectLocator;
@ -76,7 +77,7 @@ public class RestoreDialog extends DialogComponentProvider {
protected JPanel buildMainPanel() { protected JPanel buildMainPanel() {
// Create the individual components that make up the panel. // Create the individual components that make up the panel.
archiveLabel = new JLabel(" Archive File "); archiveLabel = DockingUtils.createNonHtmlLabel(" Archive File ");
archiveField = new JTextField(); archiveField = new JTextField();
archiveField.setColumns(NUM_TEXT_COLUMNS); archiveField.setColumns(NUM_TEXT_COLUMNS);
archiveField.setName("archiveField"); archiveField.setName("archiveField");
@ -115,7 +116,7 @@ public class RestoreDialog extends DialogComponentProvider {
Font font = archiveBrowse.getFont(); Font font = archiveBrowse.getFont();
archiveBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize())); archiveBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
restoreLabel = new JLabel(" Restore Directory "); restoreLabel = DockingUtils.createNonHtmlLabel(" Restore Directory ");
restoreField = new JTextField(); restoreField = new JTextField();
restoreField.setName("restoreField"); restoreField.setName("restoreField");
restoreField.setColumns(RestoreDialog.NUM_TEXT_COLUMNS); restoreField.setColumns(RestoreDialog.NUM_TEXT_COLUMNS);
@ -132,7 +133,7 @@ public class RestoreDialog extends DialogComponentProvider {
font = restoreBrowse.getFont(); font = restoreBrowse.getFont();
restoreBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize())); restoreBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
projectNameLabel = new JLabel(" Project Name "); projectNameLabel = DockingUtils.createNonHtmlLabel(" Project Name ");
projectNameField = new JTextField(); projectNameField = new JTextField();
projectNameField.setName("projectNameField"); projectNameField.setName("projectNameField");
projectNameField.setColumns(RestoreDialog.NUM_TEXT_COLUMNS); projectNameField.setColumns(RestoreDialog.NUM_TEXT_COLUMNS);

View file

@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import docking.DockingUtils;
import docking.EmptyBorderToggleButton; import docking.EmptyBorderToggleButton;
import docking.widgets.autocomplete.*; import docking.widgets.autocomplete.*;
import docking.widgets.textfield.TextFieldLinker; import docking.widgets.textfield.TextFieldLinker;
@ -705,7 +706,7 @@ public class AssemblyDualTextField {
Box hbox = Box.createHorizontalBox(); Box hbox = Box.createHorizontalBox();
dialog.add(hbox, BorderLayout.NORTH); dialog.add(hbox, BorderLayout.NORTH);
JLabel addrlabel = new JLabel(String.format(ADDR_FORMAT, curAddr)); JLabel addrlabel = DockingUtils.createNonHtmlLabel(String.format(ADDR_FORMAT, curAddr));
hbox.add(addrlabel); hbox.add(addrlabel);
AssemblyDualTextField input = new AssemblyDualTextField(); AssemblyDualTextField input = new AssemblyDualTextField();

View file

@ -26,6 +26,7 @@ import ghidra.program.model.address.AddressSet;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import ghidra.program.util.MarkerLocation; import ghidra.program.util.MarkerLocation;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
import ghidra.util.HTMLUtilities;
import resources.ResourceManager; import resources.ResourceManager;
/** /**
@ -93,9 +94,8 @@ public class BookmarkNavigator {
color = DEFAULT_COLOR; color = DEFAULT_COLOR;
} }
markerSet = markerSet = markerService.createPointMarker(type + " Bookmarks", type + " Bookmarks",
markerService.createPointMarker(type + " Bookmarks", type + " Bookmarks", bookmarkMgr.getProgram(), priority, true, true, false, color, icon);
bookmarkMgr.getProgram(), priority, true, true, false, color, icon);
markerSet.setNavigationListener(new MarkerListener() { markerSet.setNavigationListener(new MarkerListener() {
@Override @Override
@ -118,11 +118,11 @@ public class BookmarkNavigator {
String cat = bookmarks[i].getCategory(); String cat = bookmarks[i].getCategory();
if (cat != null && cat.length() != 0) { if (cat != null && cat.length() != 0) {
buf.append(" ["); buf.append(" [");
buf.append(cat); buf.append(HTMLUtilities.friendlyEncodeHTML(cat));
buf.append("]"); buf.append("]");
} }
buf.append(": "); buf.append(": ");
buf.append(bookmarks[i].getComment()); buf.append(HTMLUtilities.friendlyEncodeHTML(bookmarks[i].getComment()));
} }
return buf.toString(); return buf.toString();
} }
@ -203,10 +203,10 @@ public class BookmarkNavigator {
*/ */
public static void defineBookmarkTypes(Program program) { public static void defineBookmarkTypes(Program program) {
BookmarkManager mgr = program.getBookmarkManager(); BookmarkManager mgr = program.getBookmarkManager();
mgr.defineType(BookmarkType.NOTE, BookmarkNavigator.NOTE_ICON, mgr.defineType(BookmarkType.NOTE, BookmarkNavigator.NOTE_ICON, BookmarkNavigator.NOTE_COLOR,
BookmarkNavigator.NOTE_COLOR, BookmarkNavigator.NOTE_PRIORITY); BookmarkNavigator.NOTE_PRIORITY);
mgr.defineType(BookmarkType.INFO, BookmarkNavigator.INFO_ICON, mgr.defineType(BookmarkType.INFO, BookmarkNavigator.INFO_ICON, BookmarkNavigator.INFO_COLOR,
BookmarkNavigator.INFO_COLOR, BookmarkNavigator.INFO_PRIORITY); BookmarkNavigator.INFO_PRIORITY);
mgr.defineType(BookmarkType.WARNING, BookmarkNavigator.WARNING_ICON, mgr.defineType(BookmarkType.WARNING, BookmarkNavigator.WARNING_ICON,
BookmarkNavigator.WARNING_COLOR, BookmarkNavigator.WARNING_PRIORITY); BookmarkNavigator.WARNING_COLOR, BookmarkNavigator.WARNING_PRIORITY);
mgr.defineType(BookmarkType.ERROR, BookmarkNavigator.ERROR_ICON, mgr.defineType(BookmarkType.ERROR, BookmarkNavigator.ERROR_ICON,

View file

@ -120,11 +120,11 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
ranges = plugin.getProgramSelection().getNumAddressRanges(); ranges = plugin.getProgramSelection().getNumAddressRanges();
} }
JLabel locationLabel = new JLabel("Address: ", SwingConstants.RIGHT); JLabel locationLabel = DockingUtils.createNonHtmlLabel("Address: ", SwingConstants.RIGHT);
locationTextField = new JTextField(50); locationTextField = new JTextField(50);
locationTextField.setText(address.toString()); locationTextField.setText(address.toString());
if (hasSelection && ranges > 1) { if (hasSelection && ranges > 1) {
locationTextField.setText(address.toString() + " (plus " + (ranges-1) + " more)"); locationTextField.setText(address.toString() + " (plus " + (ranges - 1) + " more)");
} }
locationTextField.setCaretPosition(0); locationTextField.setCaretPosition(0);
locationTextField.setEditable(false); locationTextField.setEditable(false);
@ -132,7 +132,7 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
locationTextField.setMinimumSize(locationTextField.getPreferredSize()); locationTextField.setMinimumSize(locationTextField.getPreferredSize());
locationTextField.addKeyListener(listener); locationTextField.addKeyListener(listener);
JLabel categoryLabel = new JLabel("Category: ", SwingConstants.RIGHT); JLabel categoryLabel = DockingUtils.createNonHtmlLabel("Category: ", SwingConstants.RIGHT);
categoryComboBox = new GhidraComboBox<>(getModel()); categoryComboBox = new GhidraComboBox<>(getModel());
categoryComboBox.setEditable(true); categoryComboBox.setEditable(true);
categoryComboBox.addKeyListener(listener); categoryComboBox.addKeyListener(listener);
@ -140,7 +140,8 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
categoryTextField = (JTextField) categoryComboBox.getEditor().getEditorComponent(); categoryTextField = (JTextField) categoryComboBox.getEditor().getEditorComponent();
categoryTextField.addKeyListener(listener); categoryTextField.addKeyListener(listener);
JLabel commentLabel = new JLabel("Description: ", SwingConstants.RIGHT); JLabel commentLabel =
DockingUtils.createNonHtmlLabel("Description: ", SwingConstants.RIGHT);
commentTextField = new JTextField(20); commentTextField = new JTextField(20);
commentTextField.addKeyListener(listener); commentTextField.addKeyListener(listener);
@ -203,7 +204,7 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
mainPanel.add(commentTextField, gbc); mainPanel.add(commentTextField, gbc);
ImageIcon icon = BookmarkNavigator.NOTE_ICON; ImageIcon icon = BookmarkNavigator.NOTE_ICON;
JLabel imageLabel = new JLabel(icon); JLabel imageLabel = DockingUtils.createNonHtmlLabel(icon);
imageLabel.setPreferredSize( imageLabel.setPreferredSize(
new Dimension(icon.getIconWidth() + 20, icon.getIconHeight() + 20)); new Dimension(icon.getIconWidth() + 20, icon.getIconHeight() + 20));

View file

@ -22,6 +22,7 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.app.util.HelpTopics; import ghidra.app.util.HelpTopics;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
@ -59,8 +60,8 @@ class FilterDialog extends DialogComponentProvider {
JPanel p = new JPanel(new BorderLayout()); JPanel p = new JPanel(new BorderLayout());
p.add(buttons[i], BorderLayout.WEST); p.add(buttons[i], BorderLayout.WEST);
buttons[i].setSelected(provider.isShowingType(types[i].getTypeString())); buttons[i].setSelected(provider.isShowingType(types[i].getTypeString()));
JLabel l = JLabel l = DockingUtils.createNonHtmlLabel(types[i].getTypeString(), types[i].getIcon(),
new JLabel(types[i].getTypeString(), types[i].getIcon(), SwingConstants.LEFT); SwingConstants.LEFT);
p.add(l, BorderLayout.CENTER); p.add(l, BorderLayout.CENTER);
panel.add(p); panel.add(p);
} }
@ -69,7 +70,7 @@ class FilterDialog extends DialogComponentProvider {
@Override @Override
protected void okCallback() { protected void okCallback() {
List<String> typesList = new ArrayList<String>(types.length); List<String> typesList = new ArrayList<>(types.length);
for (int i = 0; i < types.length; i++) { for (int i = 0; i < types.length; i++) {
if (buttons[i].isSelected()) { if (buttons[i].isSelected()) {
typesList.add(types[i].getTypeString()); typesList.add(types[i].getTypeString());

View file

@ -24,8 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.*; import javax.swing.*;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import docking.ActionContext; import docking.*;
import docking.WindowPosition;
import docking.action.*; import docking.action.*;
import docking.util.GraphicsUtils; import docking.util.GraphicsUtils;
import docking.widgets.dialogs.NumberInputDialog; import docking.widgets.dialogs.NumberInputDialog;
@ -792,10 +791,8 @@ public class CallTreeProvider extends ComponentProviderAdapter implements Domain
private JPanel createTreePanel(boolean isIncoming, GTree tree) { private JPanel createTreePanel(boolean isIncoming, GTree tree) {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
String name = isIncoming ? "Incoming Calls" : "Outgoing Calls"; panel.add(DockingUtils.createNonHtmlLabel(isIncoming ? "Incoming Calls" : "Outgoing Calls"),
JLabel label = new JLabel(name); BorderLayout.NORTH);
panel.add(label, BorderLayout.NORTH);
panel.add(tree, BorderLayout.CENTER); panel.add(tree, BorderLayout.CENTER);
return panel; return panel;

View file

@ -23,6 +23,7 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import docking.ActionContext; import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*; import docking.action.*;
import ghidra.app.context.ProgramContextAction; import ghidra.app.context.ProgramContextAction;
import ghidra.framework.plugintool.ComponentProviderAdapter; import ghidra.framework.plugintool.ComponentProviderAdapter;
@ -92,7 +93,7 @@ public class ComputeChecksumsProvider extends ComponentProviderAdapter {
resultsMainPanel.add(tablePanel); resultsMainPanel.add(tablePanel);
main.add(resultsMainPanel, BorderLayout.CENTER); main.add(resultsMainPanel, BorderLayout.CENTER);
errorStatus = new JLabel(" "); errorStatus = DockingUtils.createNonHtmlLabel(" ");
errorStatus.setName("message"); errorStatus.setName("message");
errorStatus.setHorizontalAlignment(SwingConstants.CENTER); errorStatus.setHorizontalAlignment(SwingConstants.CENTER);
errorStatus.setForeground(Color.RED); errorStatus.setForeground(Color.RED);

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +15,6 @@
*/ */
package ghidra.app.plugin.core.clear; package ghidra.app.plugin.core.clear;
import ghidra.app.context.ListingActionContext;
import ghidra.util.HelpLocation;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.*; import java.awt.event.*;
@ -28,6 +24,9 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.app.context.ListingActionContext;
import ghidra.util.HelpLocation;
/** /**
* Dialog that shows options for "Clear All." User can choose to clear * Dialog that shows options for "Clear All." User can choose to clear
@ -115,7 +114,7 @@ public class ClearDialog extends DialogComponentProvider {
panel = new JPanel(); panel = new JPanel();
panel.setLayout(new BorderLayout(10, 10)); panel.setLayout(new BorderLayout(10, 10));
JLabel label = new JLabel("Clear Options:"); JLabel label = DockingUtils.createNonHtmlLabel("Clear Options:");
panel.add(label, BorderLayout.NORTH); panel.add(label, BorderLayout.NORTH);
JPanel cbPanel = new JPanel(); JPanel cbPanel = new JPanel();
@ -123,9 +122,8 @@ public class ClearDialog extends DialogComponentProvider {
cbPanel.setLayout(bl); cbPanel.setLayout(bl);
symbolsCb = new JCheckBox("Symbols"); symbolsCb = new JCheckBox("Symbols");
commentsCb = commentsCb = new JCheckBox(
new JCheckBox( "<HTML>Comments <FONT SIZE=\"2\">(does not affect automatic comments)</FONT>");
"<HTML>Comments <FONT SIZE=\"2\">(does not affect automatic comments)</FONT>");
commentsCb.setVerticalTextPosition(SwingConstants.TOP); commentsCb.setVerticalTextPosition(SwingConstants.TOP);
propertiesCb = new JCheckBox("Properties"); propertiesCb = new JCheckBox("Properties");
codeCb = new JCheckBox("Code"); codeCb = new JCheckBox("Code");
@ -179,6 +177,7 @@ public class ClearDialog extends DialogComponentProvider {
// if a user clears the code, then we will force them // if a user clears the code, then we will force them
// to clear all user references... // to clear all user references...
codeCb.addItemListener(new ItemListener() { codeCb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (codeCb.isSelected()) { if (codeCb.isSelected()) {
userReferencesCb.setSelected(true); userReferencesCb.setSelected(true);
@ -205,7 +204,7 @@ public class ClearDialog extends DialogComponentProvider {
systemReferencesCb.setEnabled(false); systemReferencesCb.setEnabled(false);
// record the checkboxes for later use // record the checkboxes for later use
final List<JCheckBox> checkBoxList = new ArrayList<JCheckBox>(10); final List<JCheckBox> checkBoxList = new ArrayList<>(10);
checkBoxList.add(symbolsCb); checkBoxList.add(symbolsCb);
checkBoxList.add(commentsCb); checkBoxList.add(commentsCb);
checkBoxList.add(propertiesCb); checkBoxList.add(propertiesCb);
@ -222,6 +221,7 @@ public class ClearDialog extends DialogComponentProvider {
JPanel buttonPanel = new JPanel(); JPanel buttonPanel = new JPanel();
JButton selectAllButton = new JButton("Select All"); JButton selectAllButton = new JButton("Select All");
selectAllButton.addActionListener(new ActionListener() { selectAllButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
setAllCheckBoxesSelected(true, checkBoxList); setAllCheckBoxesSelected(true, checkBoxList);
} }
@ -229,6 +229,7 @@ public class ClearDialog extends DialogComponentProvider {
JButton deselectAllbutton = new JButton("Deselect All"); JButton deselectAllbutton = new JButton("Deselect All");
deselectAllbutton.addActionListener(new ActionListener() { deselectAllbutton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
setAllCheckBoxesSelected(false, checkBoxList); setAllCheckBoxesSelected(false, checkBoxList);
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +15,6 @@
*/ */
package ghidra.app.plugin.core.clear; package ghidra.app.plugin.core.clear;
import ghidra.app.context.ListingActionContext;
import ghidra.util.HelpLocation;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.*; import java.awt.event.*;
@ -26,6 +22,9 @@ import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.app.context.ListingActionContext;
import ghidra.util.HelpLocation;
/** /**
* Dialog that shows options for "Clear Flow and Repair." User can choose to clear * Dialog that shows options for "Clear Flow and Repair." User can choose to clear
@ -92,7 +91,7 @@ public class ClearFlowDialog extends DialogComponentProvider {
panel = new JPanel(); panel = new JPanel();
panel.setLayout(new BorderLayout(10, 10)); panel.setLayout(new BorderLayout(10, 10));
JLabel label = new JLabel("Clear Flow Options:"); JLabel label = DockingUtils.createNonHtmlLabel("Clear Flow Options:");
panel.add(label, BorderLayout.NORTH); panel.add(label, BorderLayout.NORTH);
JPanel cbPanel = new JPanel(); JPanel cbPanel = new JPanel();

View file

@ -32,6 +32,7 @@ import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.util.AddressFieldLocation; import ghidra.program.util.AddressFieldLocation;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
import ghidra.util.HTMLUtilities;
/** /**
* A hover service to show tool tip text for hovering over a program address in the listing. * A hover service to show tool tip text for hovering over a program address in the listing.
@ -92,7 +93,8 @@ public class ProgramAddressRelationshipListingHover extends AbstractConfigurable
MemoryBlock block = program.getMemory().getBlock(loc); MemoryBlock block = program.getMemory().getBlock(loc);
long memblockOffset = loc.subtract(block.getStart()); long memblockOffset = loc.subtract(block.getStart());
appendTableRow(sb, "Memory Block Offset", block.getName(), memblockOffset); appendTableRow(sb, "Memory Block Offset", HTMLUtilities.friendlyEncodeHTML(block.getName()),
memblockOffset);
addFunctionInfo(program, loc, sb); addFunctionInfo(program, loc, sb);
addDataInfo(program, loc, sb); addDataInfo(program, loc, sb);
@ -141,7 +143,8 @@ public class ProgramAddressRelationshipListingHover extends AbstractConfigurable
Function function = program.getFunctionManager().getFunctionContaining(loc); Function function = program.getFunctionManager().getFunctionContaining(loc);
if (function != null) { if (function != null) {
long functionOffset = loc.subtract(function.getEntryPoint()); long functionOffset = loc.subtract(function.getEntryPoint());
appendTableRow(sb, "Function Offset", function.getName(), functionOffset); appendTableRow(sb, "Function Offset",
HTMLUtilities.friendlyEncodeHTML(function.getName()), functionOffset);
} }
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,12 +15,6 @@
*/ */
package ghidra.app.plugin.core.comments; package ghidra.app.plugin.core.comments;
import ghidra.app.util.viewer.field.AnnotatedStringHandler;
import ghidra.app.util.viewer.field.Annotation;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.CodeUnit;
import ghidra.util.HelpLocation;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
@ -33,6 +26,12 @@ import javax.swing.text.JTextComponent;
import docking.*; import docking.*;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.combobox.GhidraComboBox;
import ghidra.app.util.viewer.field.AnnotatedStringHandler;
import ghidra.app.util.viewer.field.Annotation;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.CodeUnit;
import ghidra.util.HelpLocation;
/** /**
* Dialog for setting the comments for a CodeUnit. * Dialog for setting the comments for a CodeUnit.
@ -45,8 +44,7 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
private JTextArea plateField; private JTextArea plateField;
private JTextArea repeatableField; private JTextArea repeatableField;
private Map<Document, UndoRedoKeeper> documentUndoRedoMap = private Map<Document, UndoRedoKeeper> documentUndoRedoMap = new HashMap<>(9);
new HashMap<Document, UndoRedoKeeper>(9);
private String preComment; private String preComment;
private String postComment; private String postComment;
@ -168,9 +166,8 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
protected void cancelCallback() { protected void cancelCallback() {
if (wasChanged) { if (wasChanged) {
int result = int result = OptionDialog.showYesNoCancelDialog(getComponent(), "Save Changes?",
OptionDialog.showYesNoCancelDialog(getComponent(), "Save Changes?", "Some comments were modified.\nSave Changes?");
"Some comments were modified.\nSave Changes?");
if (result == OptionDialog.OPTION_ONE) { if (result == OptionDialog.OPTION_ONE) {
applyCallback(); applyCallback();
} }
@ -267,9 +264,9 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
JPanel auxiliaryControlPanel = new JPanel(new BorderLayout()); JPanel auxiliaryControlPanel = new JPanel(new BorderLayout());
auxiliaryControlPanel.add(enterBox, BorderLayout.SOUTH); auxiliaryControlPanel.add(enterBox, BorderLayout.SOUTH);
final AnnotationAdapterWrapper[] annotations = getAnnotationAdapterWrappers(); AnnotationAdapterWrapper[] annotations = getAnnotationAdapterWrappers();
Arrays.sort(annotations); Arrays.sort(annotations);
final JComboBox annotationsComboBox = new JComboBox(annotations); JComboBox<AnnotationAdapterWrapper> annotationsComboBox = new GhidraComboBox<>(annotations);
JButton addAnnotationButton = new JButton("Add Annotation"); JButton addAnnotationButton = new JButton("Add Annotation");
addAnnotationButton.addActionListener(new ActionListener() { addAnnotationButton.addActionListener(new ActionListener() {
@Override @Override
@ -277,7 +274,8 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
JTextArea currentTextArea = getSelectedTextArea(); JTextArea currentTextArea = getSelectedTextArea();
AnnotationAdapterWrapper aaw = AnnotationAdapterWrapper aaw =
(AnnotationAdapterWrapper) annotationsComboBox.getSelectedItem(); (AnnotationAdapterWrapper) annotationsComboBox.getSelectedItem();
currentTextArea.insert(aaw.getPrototypeString(), currentTextArea.getCaretPosition()); currentTextArea.insert(aaw.getPrototypeString(),
currentTextArea.getCaretPosition());
currentTextArea.setCaretPosition(currentTextArea.getCaretPosition() - 1); currentTextArea.setCaretPosition(currentTextArea.getCaretPosition() - 1);
} }
}); });
@ -289,6 +287,7 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
panel.add(auxiliaryControlPanel, BorderLayout.SOUTH); panel.add(auxiliaryControlPanel, BorderLayout.SOUTH);
preField = new JTextArea(5, 80) { preField = new JTextArea(5, 80) {
@Override
public boolean getScrollableTracksViewportWidth() { public boolean getScrollableTracksViewportWidth() {
boolean b = super.getScrollableTracksViewportWidth(); boolean b = super.getScrollableTracksViewportWidth();
return b; return b;

View file

@ -23,8 +23,7 @@ import ghidra.program.database.data.DataTypeUtilities;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType; import ghidra.program.model.data.Composite.AlignmentType;
import ghidra.program.model.lang.InsufficientBytesException; import ghidra.program.model.lang.InsufficientBytesException;
import ghidra.util.InvalidNameException; import ghidra.util.*;
import ghidra.util.Msg;
import ghidra.util.exception.*; import ghidra.util.exception.*;
public abstract class CompEditorModel extends CompositeEditorModel { public abstract class CompEditorModel extends CompositeEditorModel {
@ -1417,8 +1416,9 @@ public abstract class CompEditorModel extends CompositeEditorModel {
*/ */
@Override @Override
public boolean isMoveUpAllowed() { public boolean isMoveUpAllowed() {
if (!isContiguousSelection()) if (!isContiguousSelection()) {
return false; return false;
}
int start = selection.getFieldRange(0).getStart().getIndex().intValue(); int start = selection.getFieldRange(0).getStart().getIndex().intValue();
return ((start > 0) && (start < getNumComponents())); return ((start > 0) && (start < getNumComponents()));
} }
@ -1466,7 +1466,8 @@ public abstract class CompEditorModel extends CompositeEditorModel {
originalIsChanging = true; originalIsChanging = true;
try { try {
if (hadChanges) { if (hadChanges) {
String message = oldName + " has changed outside the editor.\n" + String message = "<html>" + HTMLUtilities.friendlyEncodeHTML(oldName) +
" has changed outside the editor.<br>" +
"Discard edits & reload the " + getTypeName() + "?"; "Discard edits & reload the " + getTypeName() + "?";
String title = "Reload " + getTypeName() + " Editor?"; String title = "Reload " + getTypeName() + " Editor?";
int response = OptionDialog.showYesNoDialogWithNoAsDefaultButton( int response = OptionDialog.showYesNoDialogWithNoAsDefaultButton(
@ -1569,7 +1570,8 @@ public abstract class CompEditorModel extends CompositeEditorModel {
consideringReplacedDataType = true; consideringReplacedDataType = true;
try { try {
String message = String message =
oldPath.getPath() + " has changed outside the editor.\n" + "<html>" + HTMLUtilities.friendlyEncodeHTML(oldPath.getPath()) +
" has changed outside the editor.<br>" +
"Discard edits & reload the " + getTypeName() + "?"; "Discard edits & reload the " + getTypeName() + "?";
String title = "Reload " + getTypeName() + " Editor?"; String title = "Reload " + getTypeName() + " Editor?";
int response = OptionDialog.showYesNoDialogWithNoAsDefaultButton( int response = OptionDialog.showYesNoDialogWithNoAsDefaultButton(

View file

@ -25,6 +25,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.text.Document; import javax.swing.text.Document;
import docking.DockingUtils;
import docking.ToolTipManager; import docking.ToolTipManager;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import ghidra.program.model.data.Category; import ghidra.program.model.data.Category;
@ -185,7 +186,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
private void setupName() { private void setupName() {
GridBagConstraints gridBagConstraints = new GridBagConstraints(); GridBagConstraints gridBagConstraints = new GridBagConstraints();
nameLabel = new JLabel("Name:"); nameLabel = DockingUtils.createNonHtmlLabel("Name:");
gridBagConstraints.insets = LEFT_INSETS; gridBagConstraints.insets = LEFT_INSETS;
gridBagConstraints.anchor = GridBagConstraints.LINE_END; gridBagConstraints.anchor = GridBagConstraints.LINE_END;
gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.fill = GridBagConstraints.NONE;
@ -216,7 +217,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
private void setupDescription() { private void setupDescription() {
GridBagConstraints gridBagConstraints = new GridBagConstraints(); GridBagConstraints gridBagConstraints = new GridBagConstraints();
descriptionLabel = new JLabel("Description:"); descriptionLabel = DockingUtils.createNonHtmlLabel("Description:");
gridBagConstraints.insets = LEFT_INSETS; gridBagConstraints.insets = LEFT_INSETS;
gridBagConstraints.anchor = GridBagConstraints.LINE_END; gridBagConstraints.anchor = GridBagConstraints.LINE_END;
gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.fill = GridBagConstraints.NONE;
@ -247,7 +248,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
private void setupCategory() { private void setupCategory() {
GridBagConstraints gridBagConstraints = new GridBagConstraints(); GridBagConstraints gridBagConstraints = new GridBagConstraints();
categoryLabel = new JLabel("Category:"); categoryLabel = DockingUtils.createNonHtmlLabel("Category:");
gridBagConstraints.insets = LEFT_INSETS; gridBagConstraints.insets = LEFT_INSETS;
gridBagConstraints.anchor = GridBagConstraints.LINE_END; gridBagConstraints.anchor = GridBagConstraints.LINE_END;
gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.fill = GridBagConstraints.NONE;
@ -486,7 +487,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
"aligning this data type inside another data type." + "</HTML>"; "aligning this data type inside another data type." + "</HTML>";
JPanel actualAlignmentPanel = new JPanel(new BorderLayout()); JPanel actualAlignmentPanel = new JPanel(new BorderLayout());
actualAlignmentLabel = new JLabel("Alignment:"); actualAlignmentLabel = DockingUtils.createNonHtmlLabel("Alignment:");
gridBagConstraints.insets = new Insets(2, 7, 2, 2); gridBagConstraints.insets = new Insets(2, 7, 2, 2);
gridBagConstraints.anchor = GridBagConstraints.EAST; gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.fill = GridBagConstraints.NONE;
@ -718,7 +719,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
protected void setupSize() { protected void setupSize() {
GridBagConstraints gridBagConstraints = new GridBagConstraints(); GridBagConstraints gridBagConstraints = new GridBagConstraints();
sizeLabel = new JLabel("Size:"); sizeLabel = DockingUtils.createNonHtmlLabel("Size:");
ToolTipManager.setToolTipText(sizeLabel, "The current size in bytes."); ToolTipManager.setToolTipText(sizeLabel, "The current size in bytes.");
gridBagConstraints.anchor = GridBagConstraints.LINE_END; gridBagConstraints.anchor = GridBagConstraints.LINE_END;
gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.fill = GridBagConstraints.NONE;

View file

@ -26,13 +26,13 @@ import java.util.EventObject;
import java.util.List; import java.util.List;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.event.CellEditorListener; import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.table.*; import javax.swing.table.*;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import docking.DockingUtils;
import docking.ToolTipManager; import docking.ToolTipManager;
import docking.action.DockingActionIf; import docking.action.DockingActionIf;
import docking.dnd.*; import docking.dnd.*;
@ -603,7 +603,7 @@ public abstract class CompositeEditorPanel extends JPanel
private JPanel createStatusPanel() { private JPanel createStatusPanel() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
statusLabel = new JLabel(" "); statusLabel = DockingUtils.createNonHtmlLabel(" ");
statusLabel.setHorizontalAlignment(SwingConstants.CENTER); statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
statusLabel.setForeground(Color.blue); statusLabel.setForeground(Color.blue);
statusLabel.addComponentListener(new ComponentAdapter() { statusLabel.addComponentListener(new ComponentAdapter() {
@ -620,7 +620,7 @@ public abstract class CompositeEditorPanel extends JPanel
/** /**
* Sets the currently displayed status message. * Sets the currently displayed status message.
* *
* @param id the new size * @param status non-html message string to be displayed.
*/ */
public void setStatus(String status) { public void setStatus(String status) {
if (statusLabel != null) { if (statusLabel != null) {
@ -657,7 +657,7 @@ public abstract class CompositeEditorPanel extends JPanel
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
JLabel label = new JLabel(name + ":", SwingConstants.RIGHT); JLabel label = DockingUtils.createNonHtmlLabel(name + ":", SwingConstants.RIGHT);
label.setPreferredSize(new Dimension(label.getPreferredSize())); label.setPreferredSize(new Dimension(label.getPreferredSize()));
panel.add(label); panel.add(label);
panel.add(Box.createHorizontalStrut(2)); panel.add(Box.createHorizontalStrut(2));
@ -1190,7 +1190,6 @@ public abstract class CompositeEditorPanel extends JPanel
implements TableCellEditor { implements TableCellEditor {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private DataTypeSelectionEditor editor; private DataTypeSelectionEditor editor;
private JLabel label = new JLabel();
private DataType dt; private DataType dt;
private int maxLength; private int maxLength;
@ -1199,11 +1198,6 @@ public abstract class CompositeEditorPanel extends JPanel
@Override @Override
public Component getTableCellEditorComponent(JTable table1, Object value, public Component getTableCellEditorComponent(JTable table1, Object value,
boolean isSelected, int row, int column) { boolean isSelected, int row, int column) {
if (label == null) {
label = new JLabel();
label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
}
model.clearStatus(); model.clearStatus();
maxLength = model.getMaxAddLength(row); maxLength = model.getMaxAddLength(row);
init(); init();

View file

@ -23,6 +23,7 @@ import javax.swing.border.Border;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import docking.DockingUtils;
import docking.widgets.EmptyBorderButton; import docking.widgets.EmptyBorderButton;
import resources.ResourceManager; import resources.ResourceManager;
@ -42,7 +43,7 @@ public class SearchControlPanel extends JPanel {
this.editorPanel = editorPanel; this.editorPanel = editorPanel;
setLayout(new BorderLayout()); setLayout(new BorderLayout());
JLabel label = new JLabel("Search: "); JLabel label = DockingUtils.createNonHtmlLabel("Search: ");
add(label, BorderLayout.WEST); add(label, BorderLayout.WEST);
textField = new JTextField(20); textField = new JTextField(20);
add(textField, BorderLayout.CENTER); add(textField, BorderLayout.CENTER);

View file

@ -41,8 +41,7 @@ import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.database.data.ProgramDataTypeManager; import ghidra.program.database.data.ProgramDataTypeManager;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation; import ghidra.util.*;
import ghidra.util.Msg;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
//@formatter:off //@formatter:off
@ -302,7 +301,8 @@ public class CParserPlugin extends ProgramPlugin {
} }
list.add(openDTmanagers[i]); list.add(openDTmanagers[i]);
if (!(openDTmanagers[i] instanceof BuiltInDataTypeManager)) { if (!(openDTmanagers[i] instanceof BuiltInDataTypeManager)) {
htmlNamesList += "<li><b>" + openDTmanagers[i].getName() + "</b></li>"; htmlNamesList += "<li><b>" +
HTMLUtilities.friendlyEncodeHTML(openDTmanagers[i].getName()) + "</b></li>";
} }
} }
openDTmanagers = list.toArray(new DataTypeManager[0]); openDTmanagers = list.toArray(new DataTypeManager[0]);

View file

@ -35,8 +35,7 @@ import ghidra.app.util.ToolTipUtils;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation; import ghidra.util.*;
import ghidra.util.InvalidNameException;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import ghidra.util.table.GhidraTable; import ghidra.util.table.GhidraTable;
import ghidra.util.table.GhidraTableFilterPanel; import ghidra.util.table.GhidraTableFilterPanel;
@ -174,7 +173,7 @@ public class CreateStructureDialog extends DialogComponentProvider {
structurePanel.setBorder(structureBorder); structurePanel.setBorder(structureBorder);
GTable table = buildMatchingStructuresTable(); GTable table = buildMatchingStructuresTable();
filterPanel = new GhidraTableFilterPanel<StructureWrapper>(table, structureTableModel) { filterPanel = new GhidraTableFilterPanel<>(table, structureTableModel) {
// make sure our height doesn't stretch // make sure our height doesn't stretch
@Override @Override
public Dimension getMaximumSize() { public Dimension getMaximumSize() {
@ -570,7 +569,8 @@ public class CreateStructureDialog extends DialogComponentProvider {
message = EXISITING_STRUCTURE_STATUS_PREFIX; message = EXISITING_STRUCTURE_STATUS_PREFIX;
} }
setStatusText("<HTML>" + message + "<BR>\"" + name + "\""); setStatusText(
"<HTML>" + message + "<BR>\"" + HTMLUtilities.friendlyEncodeHTML(name) + "\"");
} }
// this class is used instead of a cell renderer so that sorting will // this class is used instead of a cell renderer so that sorting will

View file

@ -719,7 +719,7 @@ public class DataSettingsDialog extends DialogComponentProvider {
final static int BOOLEAN = 1; final static int BOOLEAN = 1;
private int mode; private int mode;
private JComboBox comboBox = new JComboBox(); private JComboBox<String> comboBox = new JComboBox<>();
SettingsEditor() { SettingsEditor() {
comboBox.addItemListener(new ItemListener() { comboBox.addItemListener(new ItemListener() {
@ -747,7 +747,7 @@ public class DataSettingsDialog extends DialogComponentProvider {
private StringChoices getComboBoxEnum() { private StringChoices getComboBoxEnum() {
String[] items = new String[comboBox.getItemCount()]; String[] items = new String[comboBox.getItemCount()];
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
items[i] = (String) comboBox.getItemAt(i); items[i] = comboBox.getItemAt(i);
} }
StringChoices enuum = new StringChoices(items); StringChoices enuum = new StringChoices(items);
enuum.setSelectedValue(comboBox.getSelectedIndex()); enuum.setSelectedValue(comboBox.getSelectedIndex());

View file

@ -17,11 +17,12 @@ package ghidra.app.plugin.core.datamgr;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.HTMLUtilities;
/** /**
* The DataOrganizationDialog * The DataOrganizationDialog
@ -34,7 +35,7 @@ public class DataOrganizationDialog extends DialogComponentProvider {
private JPanel mainPanel; private JPanel mainPanel;
private DataOrganizationPanel alignPanel; private DataOrganizationPanel alignPanel;
private SizeAlignmentPanel sizePanel; private SizeAlignmentPanel sizePanel;
private boolean actionComplete; private boolean actionComplete;
/** /**
* Creates a data type organization dialog for specifying data type alignment information * Creates a data type organization dialog for specifying data type alignment information
@ -46,13 +47,13 @@ public class DataOrganizationDialog extends DialogComponentProvider {
*/ */
public DataOrganizationDialog(DataTypeManager dataTypeManager, public DataOrganizationDialog(DataTypeManager dataTypeManager,
DataOrganizationImpl dataOrganization) { DataOrganizationImpl dataOrganization) {
super(TITLE, true); super(TITLE, true);
this.dataTypeManager = dataTypeManager; this.dataTypeManager = dataTypeManager;
this.dataOrganization = dataOrganization; this.dataOrganization = dataOrganization;
JPanel headerPanel = new JPanel(); JPanel headerPanel = new JPanel();
headerPanel.add(new JLabel("<HTML>Alignment Information for <b>" + headerPanel.add(DockingUtils.createHtmlLabel("<HTML>Alignment Information for <b>" +
dataTypeManager.getName() + "</b>.</HTML>")); HTMLUtilities.friendlyEncodeHTML(dataTypeManager.getName()) + "</b>.</HTML>"));
alignPanel = new DataOrganizationPanel(); alignPanel = new DataOrganizationPanel();
alignPanel.setOrganization(dataOrganization); alignPanel.setOrganization(dataOrganization);
@ -63,35 +64,35 @@ public class DataOrganizationDialog extends DialogComponentProvider {
infoPanel.add(alignPanel, BorderLayout.NORTH); infoPanel.add(alignPanel, BorderLayout.NORTH);
infoPanel.add(sizePanel, BorderLayout.CENTER); infoPanel.add(sizePanel, BorderLayout.CENTER);
mainPanel = new JPanel(new BorderLayout()); mainPanel = new JPanel(new BorderLayout());
mainPanel.add(headerPanel, BorderLayout.NORTH); mainPanel.add(headerPanel, BorderLayout.NORTH);
mainPanel.add(infoPanel, BorderLayout.CENTER); mainPanel.add(infoPanel, BorderLayout.CENTER);
addWorkPanel(mainPanel); addWorkPanel(mainPanel);
initialize(); initialize();
} }
private void initialize() { private void initialize() {
actionComplete = false; actionComplete = false;
addOKButton(); addOKButton();
setOkButtonText("Set"); setOkButtonText("Set");
addCancelButton(); addCancelButton();
// setHelpLocation(new HelpLocation(plugin, "Align_Data_Types_In_Archive")); // setHelpLocation(new HelpLocation(plugin, "Align_Data_Types_In_Archive"));
} }
public boolean userCanceled() { public boolean userCanceled() {
return !actionComplete && !isVisible(); return !actionComplete && !isVisible();
} }
@Override @Override
protected void okCallback() { protected void okCallback() {
actionComplete = true; actionComplete = true;
close(); close();
} }
@Override @Override
protected void cancelCallback() { protected void cancelCallback() {
super.cancelCallback(); super.cancelCallback();
actionComplete = false; actionComplete = false;
} }
public DataOrganization getDataOrganization() { public DataOrganization getDataOrganization() {

View file

@ -21,6 +21,7 @@ import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.program.model.data.DataOrganizationImpl; import ghidra.program.model.data.DataOrganizationImpl;
import ghidra.util.layout.PairLayout; import ghidra.util.layout.PairLayout;
@ -61,41 +62,41 @@ public class DataOrganizationPanel extends JPanel {
setUpDoubleSize(); setUpDoubleSize();
setUpLongDoubleSize(); setUpLongDoubleSize();
add(new JLabel("")); add(DockingUtils.createNonHtmlLabel(""));
add(new JLabel("")); add(DockingUtils.createNonHtmlLabel(""));
add(new JLabel("Absolute Max Alignment")); add(DockingUtils.createNonHtmlLabel("Absolute Max Alignment"));
add(absoluteMaxAlignComponent); add(absoluteMaxAlignComponent);
add(new JLabel("Machine Alignment")); add(DockingUtils.createNonHtmlLabel("Machine Alignment"));
add(machineAlignComponent); add(machineAlignComponent);
add(new JLabel("Default Alignment")); add(DockingUtils.createNonHtmlLabel("Default Alignment"));
add(defaultAlignComponent); add(defaultAlignComponent);
add(new JLabel("Default Pointer Alignment")); add(DockingUtils.createNonHtmlLabel("Default Pointer Alignment"));
add(pointerAlignComponent); add(pointerAlignComponent);
add(new JLabel("")); add(DockingUtils.createNonHtmlLabel(""));
add(new JLabel("")); add(DockingUtils.createNonHtmlLabel(""));
add(new JLabel("Signed-Char:")); add(DockingUtils.createNonHtmlLabel("Signed-Char:"));
add(charIsSignedCheckbox); add(charIsSignedCheckbox);
add(new JLabel("Char Size")); add(DockingUtils.createNonHtmlLabel("Char Size"));
add(charSizeComponent); add(charSizeComponent);
add(new JLabel("Wide-Char Size")); add(DockingUtils.createNonHtmlLabel("Wide-Char Size"));
add(wcharSizeComponent); add(wcharSizeComponent);
add(new JLabel("Short Size")); add(DockingUtils.createNonHtmlLabel("Short Size"));
add(shortSizeComponent); add(shortSizeComponent);
add(new JLabel("Integer Size")); add(DockingUtils.createNonHtmlLabel("Integer Size"));
add(integerSizeComponent); add(integerSizeComponent);
add(new JLabel("Long Size")); add(DockingUtils.createNonHtmlLabel("Long Size"));
add(longSizeComponent); add(longSizeComponent);
add(new JLabel("LongLong Size")); add(DockingUtils.createNonHtmlLabel("LongLong Size"));
add(longLongSizeComponent); add(longLongSizeComponent);
add(new JLabel("Float Size")); add(DockingUtils.createNonHtmlLabel("Float Size"));
add(floatSizeComponent); add(floatSizeComponent);
add(new JLabel("Double Size")); add(DockingUtils.createNonHtmlLabel("Double Size"));
add(doubleSizeComponent); add(doubleSizeComponent);
add(new JLabel("LongDouble Size")); add(DockingUtils.createNonHtmlLabel("LongDouble Size"));
add(longDoubleSizeComponent); add(longDoubleSizeComponent);
add(new JLabel("")); add(DockingUtils.createNonHtmlLabel(""));
add(new JLabel("")); add(DockingUtils.createNonHtmlLabel(""));
} }
public void setOrganization(DataOrganizationImpl dataOrganization) { public void setOrganization(DataOrganizationImpl dataOrganization) {
@ -147,15 +148,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpCharSize() { private void setUpCharSize() {
charSizeComponent = new JTextField(3); charSizeComponent = new JTextField(3);
charSizeComponent.addActionListener(new ActionListener() { charSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedCharSize(); updatedCharSize();
} }
}); });
charSizeComponent.addFocusListener(new FocusListener() { charSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedCharSize(); updatedCharSize();
} }
@ -165,15 +169,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpWideCharSize() { private void setUpWideCharSize() {
wcharSizeComponent = new JTextField(3); wcharSizeComponent = new JTextField(3);
wcharSizeComponent.addActionListener(new ActionListener() { wcharSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedWideCharSize(); updatedWideCharSize();
} }
}); });
wcharSizeComponent.addFocusListener(new FocusListener() { wcharSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedWideCharSize(); updatedWideCharSize();
} }
@ -183,15 +190,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpShortSize() { private void setUpShortSize() {
shortSizeComponent = new JTextField(3); shortSizeComponent = new JTextField(3);
shortSizeComponent.addActionListener(new ActionListener() { shortSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedShortSize(); updatedShortSize();
} }
}); });
shortSizeComponent.addFocusListener(new FocusListener() { shortSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedShortSize(); updatedShortSize();
} }
@ -201,15 +211,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpIntegerSize() { private void setUpIntegerSize() {
integerSizeComponent = new JTextField(3); integerSizeComponent = new JTextField(3);
integerSizeComponent.addActionListener(new ActionListener() { integerSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedIntegerSize(); updatedIntegerSize();
} }
}); });
integerSizeComponent.addFocusListener(new FocusListener() { integerSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedIntegerSize(); updatedIntegerSize();
} }
@ -219,15 +232,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpLongSize() { private void setUpLongSize() {
longSizeComponent = new JTextField(3); longSizeComponent = new JTextField(3);
longSizeComponent.addActionListener(new ActionListener() { longSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedLongSize(); updatedLongSize();
} }
}); });
longSizeComponent.addFocusListener(new FocusListener() { longSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedLongSize(); updatedLongSize();
} }
@ -237,15 +253,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpLongLongSize() { private void setUpLongLongSize() {
longLongSizeComponent = new JTextField(3); longLongSizeComponent = new JTextField(3);
longLongSizeComponent.addActionListener(new ActionListener() { longLongSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedLongLongSize(); updatedLongLongSize();
} }
}); });
longLongSizeComponent.addFocusListener(new FocusListener() { longLongSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedLongLongSize(); updatedLongLongSize();
} }
@ -255,15 +274,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpFloatSize() { private void setUpFloatSize() {
floatSizeComponent = new JTextField(3); floatSizeComponent = new JTextField(3);
floatSizeComponent.addActionListener(new ActionListener() { floatSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedFloatSize(); updatedFloatSize();
} }
}); });
floatSizeComponent.addFocusListener(new FocusListener() { floatSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedFloatSize(); updatedFloatSize();
} }
@ -273,15 +295,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpDoubleSize() { private void setUpDoubleSize() {
doubleSizeComponent = new JTextField(3); doubleSizeComponent = new JTextField(3);
doubleSizeComponent.addActionListener(new ActionListener() { doubleSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedDoubleSize(); updatedDoubleSize();
} }
}); });
doubleSizeComponent.addFocusListener(new FocusListener() { doubleSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedDoubleSize(); updatedDoubleSize();
} }
@ -291,15 +316,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpLongDoubleSize() { private void setUpLongDoubleSize() {
longDoubleSizeComponent = new JTextField(3); longDoubleSizeComponent = new JTextField(3);
longDoubleSizeComponent.addActionListener(new ActionListener() { longDoubleSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedLongDoubleSize(); updatedLongDoubleSize();
} }
}); });
longDoubleSizeComponent.addFocusListener(new FocusListener() { longDoubleSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedLongDoubleSize(); updatedLongDoubleSize();
} }
@ -309,15 +337,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpAbsoluteMaxAlignment() { private void setUpAbsoluteMaxAlignment() {
absoluteMaxAlignComponent = new JTextField(3); absoluteMaxAlignComponent = new JTextField(3);
absoluteMaxAlignComponent.addActionListener(new ActionListener() { absoluteMaxAlignComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedAbsoluteMaxAlignment(); updatedAbsoluteMaxAlignment();
} }
}); });
absoluteMaxAlignComponent.addFocusListener(new FocusListener() { absoluteMaxAlignComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedAbsoluteMaxAlignment(); updatedAbsoluteMaxAlignment();
} }
@ -327,15 +358,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpMachineAlignment() { private void setUpMachineAlignment() {
machineAlignComponent = new JTextField(3); machineAlignComponent = new JTextField(3);
machineAlignComponent.addActionListener(new ActionListener() { machineAlignComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedMachineAlignment(); updatedMachineAlignment();
} }
}); });
machineAlignComponent.addFocusListener(new FocusListener() { machineAlignComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedMachineAlignment(); updatedMachineAlignment();
} }
@ -345,15 +379,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpDefaultAlignment() { private void setUpDefaultAlignment() {
defaultAlignComponent = new JTextField(3); defaultAlignComponent = new JTextField(3);
defaultAlignComponent.addActionListener(new ActionListener() { defaultAlignComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedDefaultAlignment(); updatedDefaultAlignment();
} }
}); });
defaultAlignComponent.addFocusListener(new FocusListener() { defaultAlignComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedDefaultAlignment(); updatedDefaultAlignment();
} }
@ -363,15 +400,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpPointerAlignment() { private void setUpPointerAlignment() {
pointerAlignComponent = new JTextField(3); pointerAlignComponent = new JTextField(3);
pointerAlignComponent.addActionListener(new ActionListener() { pointerAlignComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updatedDefaultPointerAlignment(); updatedDefaultPointerAlignment();
} }
}); });
pointerAlignComponent.addFocusListener(new FocusListener() { pointerAlignComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// TODO // TODO
} }
@Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updatedDefaultPointerAlignment(); updatedDefaultPointerAlignment();
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,17 +15,18 @@
*/ */
package ghidra.app.plugin.core.datamgr; package ghidra.app.plugin.core.datamgr;
import ghidra.app.util.ToolTipUtils;
import ghidra.app.util.html.HTMLDataTypeRepresentation;
import ghidra.program.model.data.DataType;
import ghidra.util.HTMLUtilities;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.app.util.ToolTipUtils;
import ghidra.app.util.html.HTMLDataTypeRepresentation;
import ghidra.program.model.data.DataType;
import ghidra.util.HTMLUtilities;
/** /**
* Panel that displays two data types side by side. * Panel that displays two data types side by side.
*/ */
@ -60,22 +60,22 @@ class DataTypeComparePanel extends JPanel {
leftPanel = new JPanel(new BorderLayout()); leftPanel = new JPanel(new BorderLayout());
rightPanel = new JPanel(new BorderLayout()); rightPanel = new JPanel(new BorderLayout());
leftPanelLabel = new JLabel(); leftPanelLabel = DockingUtils.createHtmlLabel();
rightPanelLabel = new JLabel(); rightPanelLabel = DockingUtils.createHtmlLabel();
leftPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0)); leftPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0));
rightPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0)); rightPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0));
setLabelText(leftPanelLabel, clientName + ":"); setLabelText(leftPanelLabel, HTMLUtilities.friendlyEncodeHTML(clientName) + ":");
setLabelText(rightPanelLabel, sourceName + ":"); setLabelText(rightPanelLabel, HTMLUtilities.friendlyEncodeHTML(sourceName) + ":");
add(leftPanel); add(leftPanel);
add(rightPanel); add(rightPanel);
dtLabel1 = new JLabel(); dtLabel1 = DockingUtils.createHtmlLabel();
dtLabel1.setOpaque(true); dtLabel1.setOpaque(true);
dtLabel1.setBackground(Color.WHITE); dtLabel1.setBackground(Color.WHITE);
dtLabel1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0)); dtLabel1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0));
dtLabel1.setVerticalAlignment(SwingConstants.TOP); dtLabel1.setVerticalAlignment(SwingConstants.TOP);
dtLabel2 = new JLabel(); dtLabel2 = DockingUtils.createHtmlLabel();
dtLabel2.setOpaque(true); dtLabel2.setOpaque(true);
dtLabel2.setBackground(Color.WHITE); dtLabel2.setBackground(Color.WHITE);
dtLabel2.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0)); dtLabel2.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0));
@ -97,12 +97,14 @@ class DataTypeComparePanel extends JPanel {
final JViewport viewport1 = leftScrollPane.getViewport(); final JViewport viewport1 = leftScrollPane.getViewport();
final JViewport viewport2 = rightScrollPane.getViewport(); final JViewport viewport2 = rightScrollPane.getViewport();
viewport1.addChangeListener(new ChangeListener() { viewport1.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
int y = viewport1.getViewPosition().y; int y = viewport1.getViewPosition().y;
viewport2.setViewPosition(new Point(0, y)); viewport2.setViewPosition(new Point(0, y));
} }
}); });
viewport2.addChangeListener(new ChangeListener() { viewport2.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
int y = viewport2.getViewPosition().y; int y = viewport2.getViewPosition().y;
viewport1.setViewPosition(new Point(0, y)); viewport1.setViewPosition(new Point(0, y));

View file

@ -23,6 +23,7 @@ import javax.swing.SwingUtilities;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import docking.DockingUtils;
import ghidra.app.plugin.core.datamgr.archive.DataTypeManagerHandler; import ghidra.app.plugin.core.datamgr.archive.DataTypeManagerHandler;
import ghidra.app.plugin.core.datamgr.archive.SourceArchive; import ghidra.app.plugin.core.datamgr.archive.SourceArchive;
import ghidra.app.util.ToolTipUtils; import ghidra.app.util.ToolTipUtils;
@ -324,7 +325,7 @@ public class DataTypeSynchronizer {
// this string allows us to force both tables to be the same width, which is // this string allows us to force both tables to be the same width, which is
// aesthetically pleasing // aesthetically pleasing
String spacerString = createHTMLSpacerString(htmlContent, otherContent); String spacerString = createHTMLSpacerString(htmlContent, otherContent);
StringBuffer buffy = new StringBuffer(); StringBuilder buffy = new StringBuilder();
buffy.append("<HTML>"); buffy.append("<HTML>");
// -we use CELLPADDING here to allow us to create a narrow column within the table // -we use CELLPADDING here to allow us to create a narrow column within the table
@ -333,7 +334,8 @@ public class DataTypeSynchronizer {
buffy.append("<TR BORDER=LEFT>"); buffy.append("<TR BORDER=LEFT>");
buffy.append("<TD VALIGN=\"TOP\">"); buffy.append("<TD VALIGN=\"TOP\">");
buffy.append("<B>").append(dataTypeManager.getName()).append("</B><HR NOSHADE>"); buffy.append("<B>").append(
HTMLUtilities.friendlyEncodeHTML(dataTypeManager.getName())).append("</B><HR NOSHADE>");
buffy.append(htmlContent); buffy.append(htmlContent);
// horizontal spacer below the inner table in order to force a minimum width // horizontal spacer below the inner table in order to force a minimum width
@ -345,7 +347,8 @@ public class DataTypeSynchronizer {
buffy.append("</TD>"); buffy.append("</TD>");
buffy.append("<TD VALIGN=\"TOP\">"); buffy.append("<TD VALIGN=\"TOP\">");
buffy.append("<B>").append(sourceArchive.getName()).append("</B><HR NOSHADE>"); buffy.append("<B>").append(
HTMLUtilities.friendlyEncodeHTML(sourceArchive.getName())).append("</B><HR NOSHADE>");
buffy.append(otherContent); buffy.append(otherContent);
@ -372,17 +375,15 @@ public class DataTypeSynchronizer {
* an HTML string of spaces that is wide enough to represent that width. * an HTML string of spaces that is wide enough to represent that width.
*/ */
private static String createHTMLSpacerString(String htmlContent, String otherHTMLContent) { private static String createHTMLSpacerString(String htmlContent, String otherHTMLContent) {
StringBuffer buffy = new StringBuffer();
// unfortunately, to get the displayed widths, we have to have rendered content, which // unfortunately, to get the displayed widths, we have to have rendered content, which
// is what the JLabels below are doing for us // is what the JLabels below are doing for us
JLabel label1 = new JLabel("<HTML>" + htmlContent); JLabel label1 = DockingUtils.createHtmlLabel("<HTML>" + htmlContent);
JLabel label2 = new JLabel("<HTML>" + otherHTMLContent); JLabel label2 = DockingUtils.createHtmlLabel("<HTML>" + otherHTMLContent);
int maxPixelWidth = int maxPixelWidth =
Math.max(label1.getPreferredSize().width, label2.getPreferredSize().width); Math.max(label1.getPreferredSize().width, label2.getPreferredSize().width);
FontMetrics fontMetrics = label1.getFontMetrics(label1.getFont()); FontMetrics fontMetrics = label1.getFontMetrics(label1.getFont());
StringBuffer bigBuffy = new StringBuffer(); StringBuilder bigBuffy = new StringBuilder();
String HTMLSpace = "&nbsp"; String HTMLSpace = "&nbsp";
int invisibleCharCount = HTMLSpace.length(); int invisibleCharCount = HTMLSpace.length();
for (int i = 0; i < 150; i++) { for (int i = 0; i < 150; i++) {
@ -396,7 +397,7 @@ public class DataTypeSynchronizer {
} }
} }
return buffy.toString(); return bigBuffy.toString();
} }
public String getClientName() { public String getClientName() {

View file

@ -197,8 +197,8 @@ class OpenDomainFileTask extends Task {
if (dfile.isInWritableProject() && dfile.canRecover()) { if (dfile.isInWritableProject() && dfile.canRecover()) {
Runnable r = () -> { Runnable r = () -> {
int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found", int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found",
dfile.getName() + " has crash data.\n" + "<html>" + HTMLUtilities.friendlyEncodeHTML(dfile.getName()) +
"Would you like to recover unsaved changes?"); " has crash data.<br>" + "Would you like to recover unsaved changes?");
recoverFile[0] = (option == OptionDialog.OPTION_ONE); recoverFile[0] = (option == OptionDialog.OPTION_ONE);
}; };
SwingUtilities.invokeAndWait(r); SwingUtilities.invokeAndWait(r);

View file

@ -62,7 +62,7 @@ public class CreatePointerAction extends DockingAction {
Msg.showInfo(getClass(), gTree, "Pointers Filter Enabled", Msg.showInfo(getClass(), gTree, "Pointers Filter Enabled",
"<html>Newly created pointer is filtered out of view.<br><br>Toggle the " + "<html>Newly created pointer is filtered out of view.<br><br>Toggle the " +
"<b>Filter Pointers " + "Action</b> to view the pointer<br>Pointer: " + "<b>Filter Pointers " + "Action</b> to view the pointer<br>Pointer: " +
newManager.getName() + newPath); HTMLUtilities.friendlyEncodeHTML(newManager.getName() + newPath));
return; return;
} }

View file

@ -15,15 +15,15 @@
*/ */
package ghidra.app.plugin.core.datamgr.actions; package ghidra.app.plugin.core.datamgr.actions;
import java.awt.Component;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.CellEditorListener; import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.list.GListCellRenderer;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin; import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.tree.ArchiveNode; import ghidra.app.plugin.core.datamgr.tree.ArchiveNode;
import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode; import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode;
@ -59,18 +59,18 @@ public class CreateTypeDefDialog extends DialogComponentProvider {
JPanel panel = new JPanel(new PairLayout()); JPanel panel = new JPanel(new PairLayout());
// category info // category info
panel.add(new JLabel("Category:")); panel.add(DockingUtils.createNonHtmlLabel("Category:"));
panel.add(new JLabel(category.getCategoryPath().getPath())); panel.add(DockingUtils.createNonHtmlLabel(category.getCategoryPath().getPath()));
// name info // name info
nameTextField = new JTextField(15); nameTextField = new JTextField(15);
panel.add(new JLabel("Name:")); panel.add(DockingUtils.createNonHtmlLabel("Name:"));
panel.add(nameTextField); panel.add(nameTextField);
// data type info // data type info
dataTypeEditor = dataTypeEditor =
new DataTypeSelectionEditor(plugin.getTool(), Integer.MAX_VALUE, AllowedDataTypes.ALL); new DataTypeSelectionEditor(plugin.getTool(), Integer.MAX_VALUE, AllowedDataTypes.ALL);
panel.add(new JLabel("Data type:")); panel.add(DockingUtils.createNonHtmlLabel("Data type:"));
panel.add(dataTypeEditor.getEditorComponent()); panel.add(dataTypeEditor.getEditorComponent());
dataTypeEditor.addCellEditorListener(new CellEditorListener() { dataTypeEditor.addCellEditorListener(new CellEditorListener() {
@ -88,21 +88,9 @@ public class CreateTypeDefDialog extends DialogComponentProvider {
dataTypeEditor.setDefaultSelectedTreePath(selectedTreePath); dataTypeEditor.setDefaultSelectedTreePath(selectedTreePath);
dataTypeManagerBox = new GhidraComboBox<>(); dataTypeManagerBox = new GhidraComboBox<>();
dataTypeManagerBox.setRenderer(new DefaultListCellRenderer() { dataTypeManagerBox.setRenderer(
@Override GListCellRenderer.createDefaultCellTextRenderer(dtm -> dtm.getName()));
public Component getListCellRendererComponent(JList list, Object value, int index, DockingUtils.turnOffHTMLRendering(dataTypeManagerBox);
boolean isSelected, boolean cellHasFocus) {
JLabel label =
(JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
if (value != null) {
label.setText(((DataTypeManager) value).getName());
}
return label;
}
});
DataTypeManager[] dataTypeManagers = plugin.getDataTypeManagers(); DataTypeManager[] dataTypeManagers = plugin.getDataTypeManagers();
for (DataTypeManager manager : dataTypeManagers) { for (DataTypeManager manager : dataTypeManagers) {
@ -127,7 +115,7 @@ public class CreateTypeDefDialog extends DialogComponentProvider {
dataTypeManagerBox.setSelectedItem(itemToSelect); dataTypeManagerBox.setSelectedItem(itemToSelect);
panel.add(new JLabel("Archive:")); panel.add(DockingUtils.createNonHtmlLabel("Archive:"));
panel.add(dataTypeManagerBox); panel.add(dataTypeManagerBox);
panel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); panel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,12 +15,6 @@
*/ */
package ghidra.app.plugin.core.datamgr.actions; package ghidra.app.plugin.core.datamgr.actions;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.archive.FileArchive;
import ghidra.app.plugin.core.datamgr.tree.*;
import ghidra.util.Msg;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.IOException; import java.io.IOException;
@ -31,6 +24,12 @@ import docking.ActionContext;
import docking.action.*; import docking.action.*;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.tree.GTree; import docking.widgets.tree.GTree;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.archive.FileArchive;
import ghidra.app.plugin.core.datamgr.tree.*;
import ghidra.util.HTMLUtilities;
import ghidra.util.Msg;
public class DeleteArchiveAction extends DockingAction { public class DeleteArchiveAction extends DockingAction {
@ -92,10 +91,13 @@ public class DeleteArchiveAction extends DockingAction {
TreePath[] selectionPaths = gTree.getSelectionPaths(); TreePath[] selectionPaths = gTree.getSelectionPaths();
FileArchiveNode node = (FileArchiveNode) selectionPaths[0].getLastPathComponent(); FileArchiveNode node = (FileArchiveNode) selectionPaths[0].getLastPathComponent();
if (OptionDialog.showOptionDialogWithCancelAsDefaultButton(gTree, "Confirm Delete Operation", if (OptionDialog.showOptionDialogWithCancelAsDefaultButton(gTree,
"<html><b>Are you sure you want to delete archive: " + node.getName() + "?<br><br>" + "Confirm Delete Operation",
"<html><b>Are you sure you want to delete archive: " +
HTMLUtilities.friendlyEncodeHTML(node.getName()) + "?<br><br>" +
"<font color=\"red\">(WARNING: This action will permanently " + "<font color=\"red\">(WARNING: This action will permanently " +
"delete the file from disk.)</font></b>", "Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) { "delete the file from disk.)</font></b>",
"Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
return; return;
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,11 +15,6 @@
*/ */
package ghidra.app.plugin.core.datamgr.actions; package ghidra.app.plugin.core.datamgr.actions;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.archive.*;
import ghidra.app.plugin.core.datamgr.tree.InvalidArchiveNode;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import docking.ActionContext; import docking.ActionContext;
@ -29,6 +23,11 @@ import docking.action.MenuData;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.tree.GTree; import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode; import docking.widgets.tree.GTreeNode;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.archive.*;
import ghidra.app.plugin.core.datamgr.tree.InvalidArchiveNode;
import ghidra.util.HTMLUtilities;
public class RemoveInvalidArchiveFromProgramAction extends DockingAction { public class RemoveInvalidArchiveFromProgramAction extends DockingAction {
@ -38,7 +37,8 @@ public class RemoveInvalidArchiveFromProgramAction extends DockingAction {
super("Remove Invalid Archive", plugin.getName()); super("Remove Invalid Archive", plugin.getName());
this.plugin = plugin; this.plugin = plugin;
setPopupMenuData(new MenuData(new String[] { "Remove Archive From Program" }, null, "File")); setPopupMenuData(
new MenuData(new String[] { "Remove Archive From Program" }, null, "File"));
setDescription("Removes the archive from program and tool"); setDescription("Removes the archive from program and tool");
setEnabled(true); setEnabled(true);
@ -76,11 +76,12 @@ public class RemoveInvalidArchiveFromProgramAction extends DockingAction {
InvalidArchiveNode invalidArchiveNode = (InvalidArchiveNode) pathComponent; InvalidArchiveNode invalidArchiveNode = (InvalidArchiveNode) pathComponent;
if (OptionDialog.showOptionDialog(gtree, "Confirm Remove Invalid Archive(s)", if (OptionDialog.showOptionDialog(gtree, "Confirm Remove Invalid Archive(s)",
"<html><b>Are you sure you want to delete archive: " + invalidArchiveNode.getName() + "<html><b>Are you sure you want to delete archive: " +
HTMLUtilities.friendlyEncodeHTML(invalidArchiveNode.getName()) +
" from the program?<br><br>" + " from the program?<br><br>" +
"<font color=\"red\">(WARNING: This action will disassociate " + "<font color=\"red\">(WARNING: This action will disassociate " +
"all datatypes in the program from this archive.)</font></b>", "Yes", "all datatypes in the program from this archive.)</font></b>",
OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) { "Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
return; return;
} }

View file

@ -1,296 +0,0 @@
/* ###
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.app.plugin.core.datamgr.archive;
import ghidra.framework.plugintool.Plugin;
import ghidra.util.HelpLocation;
import ghidra.util.UniversalID;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import docking.DialogComponentProvider;
public class ChooseArchiveDialog extends DialogComponentProvider {
private JPanel archiveListPanel;
private JTextField filterField;
private boolean removeWasCanceled;
private Archive currentArchive;
private List<Archive> archiveList;
private JList list;
private DefaultListModel listModel;
public ChooseArchiveDialog(Plugin plugin, String title, Archive currentArchive,
List<Archive> archiveList) {
super(title);
this.currentArchive = currentArchive;
this.archiveList = archiveList;
createArchiveListPanel();
filterField = getFilterField();
addWorkPanel(archiveListPanel);
addOKButton();
setOkToolTip("Choose the archive file to synchronize.");
addCancelButton();
setHelpLocation(new HelpLocation(plugin.getName(), "Choose_Archive"));
}
public boolean wasCanceled() {
return removeWasCanceled;
}
@Override
protected void cancelCallback() {
removeWasCanceled = true;
clearStatusText();
close();
}
@Override
protected void okCallback() {
clearStatusText();
Archive selectedArchive = getSelectedArchive();
if (selectedArchive == null) {
setStatusText("Please select an archive to synchronize.");
return;
}
close();
return;
}
/**
* Return the JList component.
*/
JList getList() {
return list;
}
JTextField getFilterField() {
return filterField;
}
/**
* Return the selected data type archive in the JList.
* @return null if no object is selected
*/
public Archive getSelectedArchive() {
int index = list.getSelectedIndex();
if (index >= 0) {
return (Archive) listModel.get(index);
}
return null;
}
void selectArchive(Archive archive) {
int index = listModel.indexOf(archive);
list.setSelectedIndex(index);
}
// @Override
// public void requestFocus() {
// filterField.requestFocus();
// filterField.selectAll();
// filterList( filterField.getText() );
// }
private void createArchiveListPanel() {
archiveListPanel = new JPanel(new BorderLayout());
JPanel northPanel = new JPanel();
String instructions =
"<HTML>Choose the archive to synchronize with <B>" + currentArchive.getName() +
"</B>.</HTML>";
JLabel instructionLabel = new JLabel(instructions);
northPanel.add(instructionLabel, BorderLayout.NORTH);
northPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 8, 3));
archiveListPanel.add(northPanel, BorderLayout.NORTH);
// Create the list
listModel = new DefaultListModel();
initListModel();
list = new JList(listModel);
list.setCellRenderer(new MyListCellRenderer());
list.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)) {
if (list.getSelectedValue() != null) {
okCallback();
}
}
}
});
// Set the preferred row count. This affects the preferredSize
// of the JList when it's in a scrollpane.
int size = listModel.getSize();
list.setVisibleRowCount(size);
JScrollPane scrollPane = new JScrollPane(list);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
JPanel southPanel = new JPanel();
southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS));
filterField = createFilterField();
southPanel.add(new JLabel("Filter: "));
southPanel.add(filterField);
southPanel.setBorder(BorderFactory.createEmptyBorder(8, 3, 8, 3));
archiveListPanel.add(southPanel, BorderLayout.SOUTH);
// Add list to a scrollpane
JPanel listPanel = new JPanel(new BorderLayout());
listPanel.add(scrollPane, BorderLayout.CENTER);
listPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
archiveListPanel.add(listPanel);
}
private JTextField createFilterField() {
JTextField newFilterField = new JTextField(20);
// newFilterField.setBackground( BACKGROUND_COLOR );
// newFilterField.setBorder( BorderFactory.createEmptyBorder( 0, 0, 5, 0 ) );
newFilterField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
filter(e.getDocument());
}
public void insertUpdate(DocumentEvent e) {
filter(e.getDocument());
}
public void removeUpdate(DocumentEvent e) {
filter(e.getDocument());
}
private void filter(Document document) {
try {
String text = document.getText(0, document.getLength());
filterList(text);
}
catch (BadLocationException e) {
// shouldn't happen; don't care
}
}
});
return newFilterField;
}
private void filterList(String filterText) {
List<Archive> allDataList = new ArrayList<Archive>();
allDataList.addAll(archiveList);
boolean hasFilter = filterText.trim().length() != 0;
if (hasFilter) {
String lowerCaseFilterText = filterText.toLowerCase();
for (Iterator<Archive> iterator = allDataList.iterator(); iterator.hasNext();) {
Archive archive = iterator.next();
String archiveString = getStringUsedInList(archive).toLowerCase();
if (archiveString.indexOf(lowerCaseFilterText) < 0) {
iterator.remove();
}
}
}
listModel.clear();
for (Archive archive : allDataList) {
listModel.addElement(archive);
}
// select something in the list so that the user can make a selection from the keyboard
int totalListSize = archiveList.size();
int shownListSize = listModel.getSize();
if (shownListSize > 0) {
int selectedIndex = list.getSelectedIndex();
if (selectedIndex < 0) {
list.setSelectedIndex(0);
}
if (shownListSize == totalListSize) {
clearStatusText();
}
else {
setStatusText("Filter is hiding " + (totalListSize - shownListSize) +
" of the archive choices.");
}
}
else {
setStatusText("Filter is hiding all possible archive choices.");
}
}
private String getStringUsedInList(Archive archive) {
return archive.getName();
}
private void initListModel() {
listModel.clear();
for (int i = 0; i < archiveList.size(); i++) {
Archive archive = archiveList.get(i);
UniversalID sourceID = currentArchive.getDataTypeManager().getUniversalID();
SourceArchive sourceArchive = archive.getDataTypeManager().getSourceArchive(sourceID);
if (sourceArchive != null) {
// This archive at least had a data type from the source archive at one time.
listModel.addElement(archive);
}
}
}
private class MyListCellRenderer extends JLabel implements ListCellRenderer {
MyListCellRenderer() {
setOpaque(true);
}
/* (non-Javadoc)
* @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
*/
public Component getListCellRendererComponent(JList localList, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
Archive archive = (Archive) value;
setIcon(archive.getIcon(false));
setIconTextGap(5);
String text = getStringUsedInList(archive);
setText(text);
if (isSelected) {
setBackground(localList.getSelectionBackground());
setForeground(localList.getSelectionForeground());
}
else {
setBackground(localList.getBackground());
setForeground(localList.getForeground());
}
setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 10));
return this;
}
}
}

View file

@ -1316,7 +1316,7 @@ public class DataTypeManagerHandler {
private boolean acquireSaveLock(UndoableDomainObject undoableDomainObject) { private boolean acquireSaveLock(UndoableDomainObject undoableDomainObject) {
if (!undoableDomainObject.lock(null)) { if (!undoableDomainObject.lock(null)) {
String title = "Save " + CONTENT_NAME + " (Busy)"; String title = "Save " + CONTENT_NAME + " (Busy)";
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
buf.append("The " + CONTENT_NAME + " is currently being modified by \n"); buf.append("The " + CONTENT_NAME + " is currently being modified by \n");
buf.append("the following actions:\n "); buf.append("the following actions:\n ");
Transaction t = undoableDomainObject.getCurrentTransaction(); Transaction t = undoableDomainObject.getCurrentTransaction();

View file

@ -21,6 +21,7 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import docking.ComponentProvider; import docking.ComponentProvider;
import docking.DockingUtils;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import ghidra.app.plugin.core.compositeeditor.*; import ghidra.app.plugin.core.compositeeditor.*;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin; import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
@ -574,7 +575,7 @@ public class DataTypeEditorManager
} }
setCallingConventionChoices(choices); setCallingConventionChoices(choices);
parentPanel.add(new JLabel("Calling Convention:")); parentPanel.add(DockingUtils.createNonHtmlLabel("Calling Convention:"));
parentPanel.add(callingConventionComboBox); parentPanel.add(callingConventionComboBox);
} }

View file

@ -24,6 +24,7 @@ import javax.swing.event.*;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
import docking.DockingUtils;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.table.GTableCellRenderer; import docking.widgets.table.GTableCellRenderer;
@ -381,7 +382,7 @@ class EnumEditorPanel extends JPanel {
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
JLabel label = new JLabel("Name:", SwingConstants.RIGHT); JLabel label = DockingUtils.createNonHtmlLabel("Name:", SwingConstants.RIGHT);
label.setPreferredSize(new Dimension(descLabel.getPreferredSize())); label.setPreferredSize(new Dimension(descLabel.getPreferredSize()));
panel.add(label); panel.add(label);
panel.add(Box.createHorizontalStrut(2)); panel.add(Box.createHorizontalStrut(2));
@ -397,7 +398,7 @@ class EnumEditorPanel extends JPanel {
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
descLabel = new JLabel("Description:", SwingConstants.RIGHT); descLabel = DockingUtils.createNonHtmlLabel("Description:", SwingConstants.RIGHT);
panel.add(descLabel); panel.add(descLabel);
panel.add(Box.createHorizontalStrut(2)); panel.add(Box.createHorizontalStrut(2));
@ -430,13 +431,13 @@ class EnumEditorPanel extends JPanel {
} }
}); });
JLabel label = new JLabel("Category:", SwingConstants.RIGHT); JLabel label = DockingUtils.createNonHtmlLabel("Category:", SwingConstants.RIGHT);
label.setPreferredSize(new Dimension(descLabel.getPreferredSize())); label.setPreferredSize(new Dimension(descLabel.getPreferredSize()));
panel.add(label); panel.add(label);
panel.add(Box.createHorizontalStrut(2)); panel.add(Box.createHorizontalStrut(2));
panel.add(categoryField); panel.add(categoryField);
panel.add(Box.createHorizontalStrut(20)); panel.add(Box.createHorizontalStrut(20));
panel.add(new JLabel("Size:")); panel.add(DockingUtils.createNonHtmlLabel("Size:"));
panel.add(Box.createHorizontalStrut(5)); panel.add(Box.createHorizontalStrut(5));
panel.add(sizeComboBox); panel.add(sizeComboBox);

View file

@ -398,7 +398,8 @@ public class EnumEditorProvider extends ComponentProviderAdapter
newVal = "Missing"; newVal = "Missing";
} }
msg.append(String.format("<li>%s: 0x%s \u2192 <font color=#ff0000>%s</font></li>", msg.append(String.format("<li>%s: 0x%s \u2192 <font color=#ff0000>%s</font></li>",
field, Long.toHexString(originalEnum.getValue(field)), newVal)); HTMLUtilities.friendlyEncodeHTML(field),
Long.toHexString(originalEnum.getValue(field)), newVal));
} }
msg.append("</ul>"); msg.append("</ul>");
msg.append( msg.append(

View file

@ -23,8 +23,7 @@ import docking.widgets.tree.GTreeLazyNode;
import docking.widgets.tree.GTreeNode; import docking.widgets.tree.GTreeNode;
import ghidra.app.plugin.core.datamgr.util.DataTypeUtils; import ghidra.app.plugin.core.datamgr.util.DataTypeUtils;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.InvalidNameException; import ghidra.util.*;
import ghidra.util.Msg;
import ghidra.util.exception.AssertException; import ghidra.util.exception.AssertException;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -67,8 +66,7 @@ public class CategoryNode extends GTreeLazyNode implements DataTypeTreeNode {
Category[] subCategories = category.getCategories(); Category[] subCategories = category.getCategories();
DataType[] dataTypes = category.getDataTypes(); DataType[] dataTypes = category.getDataTypes();
List<GTreeNode> children = List<GTreeNode> children = new ArrayList<>(subCategories.length + dataTypes.length);
new ArrayList<>(subCategories.length + dataTypes.length);
for (Category subCategory : subCategories) { for (Category subCategory : subCategories) {
children.add(new CategoryNode(subCategory)); children.add(new CategoryNode(subCategory));
} }
@ -142,7 +140,7 @@ public class CategoryNode extends GTreeLazyNode implements DataTypeTreeNode {
@Override @Override
public String getToolTip() { public String getToolTip() {
return category.getCategoryPathName(); return "<html>" + HTMLUtilities.friendlyEncodeHTML(category.getCategoryPathName());
} }
@Override @Override

View file

@ -22,6 +22,7 @@ import ghidra.app.plugin.core.datamgr.archive.DomainFileArchive;
import ghidra.framework.model.DomainFile; import ghidra.framework.model.DomainFile;
import ghidra.framework.model.DomainObject; import ghidra.framework.model.DomainObject;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.util.HTMLUtilities;
import resources.MultiIcon; import resources.MultiIcon;
import resources.ResourceManager; import resources.ResourceManager;
import resources.icons.TranslateIcon; import resources.icons.TranslateIcon;
@ -102,7 +103,7 @@ public class DomainFileArchiveNode extends ArchiveNode {
public String getToolTip() { public String getToolTip() {
DomainFile file = ((DomainFileArchive) archive).getDomainFile(); DomainFile file = ((DomainFileArchive) archive).getDomainFile();
if (file != null) { if (file != null) {
return file.getPathname(); return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getPathname());
} }
return "[Unsaved New Domain File Archive]"; return "[Unsaved New Domain File Archive]";
} }

View file

@ -20,6 +20,7 @@ import javax.swing.ImageIcon;
import generic.jar.ResourceFile; import generic.jar.ResourceFile;
import ghidra.app.plugin.core.datamgr.archive.FileArchive; import ghidra.app.plugin.core.datamgr.archive.FileArchive;
import ghidra.util.HTMLUtilities;
import resources.MultiIcon; import resources.MultiIcon;
import resources.ResourceManager; import resources.ResourceManager;
import resources.icons.TranslateIcon; import resources.icons.TranslateIcon;
@ -53,7 +54,7 @@ public class FileArchiveNode extends ArchiveNode {
public String getToolTip() { public String getToolTip() {
ResourceFile file = fileArchive.getFile(); ResourceFile file = fileArchive.getFile();
if (file != null) { if (file != null) {
return file.getAbsolutePath(); return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getAbsolutePath());
} }
return "[Unsaved New Archive]"; return "[Unsaved New Archive]";
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,13 +15,13 @@
*/ */
package ghidra.app.plugin.core.datamgr.tree; package ghidra.app.plugin.core.datamgr.tree;
import ghidra.app.plugin.core.datamgr.archive.Archive;
import ghidra.app.plugin.core.datamgr.archive.InvalidFileArchive;
import ghidra.program.model.data.ArchiveType;
import java.util.List; import java.util.List;
import docking.widgets.tree.GTreeNode; import docking.widgets.tree.GTreeNode;
import ghidra.app.plugin.core.datamgr.archive.Archive;
import ghidra.app.plugin.core.datamgr.archive.InvalidFileArchive;
import ghidra.program.model.data.ArchiveType;
import ghidra.util.HTMLUtilities;
public class InvalidArchiveNode extends ArchiveNode { public class InvalidArchiveNode extends ArchiveNode {
@ -44,7 +43,8 @@ public class InvalidArchiveNode extends ArchiveNode {
public String getToolTip() { public String getToolTip() {
ArchiveType archiveType = ((InvalidFileArchive) archive).getArchiveType(); ArchiveType archiveType = ((InvalidFileArchive) archive).getArchiveType();
String type = archiveType == ArchiveType.FILE ? "File" : "Project"; String type = archiveType == ArchiveType.FILE ? "File" : "Project";
return "Unable to locate " + type + " data type archive: " + archive.getName(); return "<html>Unable to locate " + type + " data type archive: " +
HTMLUtilities.friendlyEncodeHTML(archive.getName());
} }
@Override @Override

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,6 +17,7 @@ package ghidra.app.plugin.core.datamgr.tree;
import ghidra.app.plugin.core.datamgr.archive.ProgramArchive; import ghidra.app.plugin.core.datamgr.archive.ProgramArchive;
import ghidra.framework.model.DomainFile; import ghidra.framework.model.DomainFile;
import ghidra.util.HTMLUtilities;
public class ProgramArchiveNode extends DomainFileArchiveNode { public class ProgramArchiveNode extends DomainFileArchiveNode {
@ -29,7 +29,7 @@ public class ProgramArchiveNode extends DomainFileArchiveNode {
public String getToolTip() { public String getToolTip() {
DomainFile file = ((ProgramArchive) archive).getDomainFile(); DomainFile file = ((ProgramArchive) archive).getDomainFile();
if (file != null) { if (file != null) {
return file.getPathname(); return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getPathname());
} }
return "[Unsaved New Program Archive]"; return "[Unsaved New Program Archive]";
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,6 +17,7 @@ package ghidra.app.plugin.core.datamgr.tree;
import ghidra.app.plugin.core.datamgr.archive.ProjectArchive; import ghidra.app.plugin.core.datamgr.archive.ProjectArchive;
import ghidra.framework.model.DomainFile; import ghidra.framework.model.DomainFile;
import ghidra.util.HTMLUtilities;
public class ProjectArchiveNode extends DomainFileArchiveNode { public class ProjectArchiveNode extends DomainFileArchiveNode {
@ -37,7 +37,7 @@ public class ProjectArchiveNode extends DomainFileArchiveNode {
public String getToolTip() { public String getToolTip() {
DomainFile file = ((ProjectArchive) archive).getDomainFile(); DomainFile file = ((ProjectArchive) archive).getDomainFile();
if (file != null) { if (file != null) {
return file.getPathname(); return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getPathname());
} }
return "[Unsaved New Project Archive]"; return "[Unsaved New Project Archive]";
} }

View file

@ -21,6 +21,7 @@ import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
import resources.ResourceManager; import resources.ResourceManager;
@ -140,9 +141,10 @@ public class ConflictDialog extends DialogComponentProvider {
} }
private JPanel createLabelPanel(String dtName, String categoryPath) { private JPanel createLabelPanel(String dtName, String categoryPath) {
JLabel imageLabel = new JLabel(INFORM_ICON); JLabel imageLabel = DockingUtils.createNonHtmlLabel(INFORM_ICON);
JLabel infoLabel = new JLabel("Conflict exists in " + categoryPath + " for " + dtName); JLabel infoLabel = DockingUtils.createNonHtmlLabel(
"Conflict exists in " + categoryPath + " for " + dtName);
JPanel labelPanel = new JPanel(); JPanel labelPanel = new JPanel();
labelPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 20)); labelPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 20));

View file

@ -24,6 +24,7 @@ import javax.swing.*;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.filter.FilterOptions; import docking.widgets.filter.FilterOptions;
import docking.widgets.filter.TextFilterStrategy; import docking.widgets.filter.TextFilterStrategy;
import docking.widgets.tree.*; import docking.widgets.tree.*;
@ -98,8 +99,7 @@ public class DataTypeChooserDialog extends DialogComponentProvider {
private JComponent createWorkPanel() { private JComponent createWorkPanel() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
String message = "Choose the data type you wish to use."; messageLabel = DockingUtils.createNonHtmlLabel("Choose the data type you wish to use.");
messageLabel = new JLabel(message);
messageLabel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 2)); messageLabel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 2));
panel.add(messageLabel, BorderLayout.NORTH); panel.add(messageLabel, BorderLayout.NORTH);
panel.add(this.tree, BorderLayout.CENTER); panel.add(this.tree, BorderLayout.CENTER);

View file

@ -490,11 +490,11 @@ public class DataTypeUtils {
// JFrame frame = new JFrame(); // JFrame frame = new JFrame();
// JPanel panel = new JPanel(); // JPanel panel = new JPanel();
// //
// JLabel label1 = new JLabel(); // JLabel label1 = DockingUtils.createNonHtmlLabel();
// Icon icon = getOpenFolderIcon( false ); // Icon icon = getOpenFolderIcon( false );
// label1.setIcon( icon ); // label1.setIcon( icon );
// //
// JLabel label2 = new JLabel(); // JLabel label2 = DockingUtils.createNonHtmlLabel();
// Icon icon2 = ResourceManager.getDisabledIcon( (ImageIcon) icon ); // Icon icon2 = ResourceManager.getDisabledIcon( (ImageIcon) icon );
// label2.setIcon( icon2 ); // label2.setIcon( icon2 );
// //

View file

@ -317,7 +317,7 @@ class FilterAction extends ToggleDockingAction {
JPanel filterPanel = new JPanel(new BorderLayout()); JPanel filterPanel = new JPanel(new BorderLayout());
filterField = new FilterTextField(checkboxPanel); filterField = new FilterTextField(checkboxPanel);
filterPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); filterPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
filterPanel.add(new JLabel("Filter:"), BorderLayout.WEST); filterPanel.add(DockingUtils.createNonHtmlLabel("Filter:"), BorderLayout.WEST);
filterPanel.add(filterField, BorderLayout.CENTER); filterPanel.add(filterField, BorderLayout.CENTER);
filterField.addFilterListener(filterListener); filterField.addFilterListener(filterListener);

View file

@ -23,8 +23,7 @@ import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import docking.ActionContext; import docking.*;
import docking.DialogComponentProvider;
import docking.ToolTipManager; import docking.ToolTipManager;
import docking.action.*; import docking.action.*;
import ghidra.app.events.ProgramSelectionPluginEvent; import ghidra.app.events.ProgramSelectionPluginEvent;
@ -148,7 +147,7 @@ public class AddressTableDialog extends DialogComponentProvider {
JPanel searchOptionsPanel = new JPanel(new BorderLayout()); JPanel searchOptionsPanel = new JPanel(new BorderLayout());
searchOptionsPanel.setBorder(BorderFactory.createTitledBorder("Search Options")); searchOptionsPanel.setBorder(BorderFactory.createTitledBorder("Search Options"));
JLabel minLengthLabel = new JLabel("Minimum Length: "); JLabel minLengthLabel = DockingUtils.createNonHtmlLabel("Minimum Length: ");
ToolTipManager.setToolTipText(minLengthLabel, ToolTipManager.setToolTipText(minLengthLabel,
"The minimum number of consecutive addresses that will make an address table."); "The minimum number of consecutive addresses that will make an address table.");
minLengthField = new JTextField(5); minLengthField = new JTextField(5);
@ -159,7 +158,7 @@ public class AddressTableDialog extends DialogComponentProvider {
minLengthPanel.add(minLengthLabel); minLengthPanel.add(minLengthLabel);
minLengthPanel.add(minLengthField); minLengthPanel.add(minLengthField);
alignLabel = new JLabel("Alignment: "); alignLabel = DockingUtils.createNonHtmlLabel("Alignment: ");
alignField = new JTextField(5); alignField = new JTextField(5);
alignField.setName("Alignment"); alignField.setName("Alignment");
ToolTipManager.setToolTipText(alignLabel, ToolTipManager.setToolTipText(alignLabel,
@ -170,7 +169,7 @@ public class AddressTableDialog extends DialogComponentProvider {
} }
alignField.setText("" + align); alignField.setText("" + align);
skipLabel = new JLabel("Skip Length: "); skipLabel = DockingUtils.createNonHtmlLabel("Skip Length: ");
skipField = new JTextField(5); skipField = new JTextField(5);
skipField.setName("Skip"); skipField.setName("Skip");
ToolTipManager.setToolTipText(skipLabel, ToolTipManager.setToolTipText(skipLabel,
@ -230,12 +229,12 @@ public class AddressTableDialog extends DialogComponentProvider {
ToolTipManager.setToolTipText(autoLabelCB, ToolTipManager.setToolTipText(autoLabelCB,
"Label the top of the address table and all members of the table."); "Label the top of the address table and all members of the table.");
offsetLabel = new JLabel("Offset: "); offsetLabel = DockingUtils.createNonHtmlLabel("Offset: ");
ToolTipManager.setToolTipText(offsetLabel, ToolTipManager.setToolTipText(offsetLabel,
"Offset from the beginning of the selected table(s)"); "Offset from the beginning of the selected table(s)");
offsetLabel.setEnabled(false); offsetLabel.setEnabled(false);
JLabel viewOffsetLabel = new JLabel(" "); JLabel viewOffsetLabel = DockingUtils.createNonHtmlLabel(" ");
viewOffsetLabel.setEnabled(false); viewOffsetLabel.setEnabled(false);
viewOffset = new HintTextField(20); viewOffset = new HintTextField(20);

View file

@ -23,6 +23,7 @@ import javax.swing.*;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.WindowPosition; import docking.WindowPosition;
import docking.widgets.list.GListCellRenderer;
import ghidra.GhidraOptions; import ghidra.GhidraOptions;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
import ghidra.app.plugin.PluginCategoryNames; import ghidra.app.plugin.PluginCategoryNames;
@ -42,8 +43,7 @@ import ghidra.program.model.address.AddressOverflowException;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection; import ghidra.program.util.ProgramSelection;
import ghidra.util.HelpLocation; import ghidra.util.*;
import ghidra.util.Msg;
import ghidra.util.exception.UsrException; import ghidra.util.exception.UsrException;
/** /**
@ -421,23 +421,26 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
initializeDisplay(); initializeDisplay();
// we need to do some custom rendering // we need to do some custom rendering
contentList.setCellRenderer(new DefaultListCellRenderer() { contentList.setCellRenderer(new GListCellRenderer<DisassembledAddressInfo>() {
@Override @Override
public Component getListCellRendererComponent(JList<?> list, Object value, protected String getItemText(DisassembledAddressInfo value) {
int index, boolean isSelected, boolean cellHasFocus) { return value.getAddressPreview(addressPreviewFormat);
JLabel renderer = (JLabel) super.getListCellRendererComponent(list, value, }
index, isSelected, cellHasFocus);
renderer.setFont(font); @Override
public Component getListCellRendererComponent(
JList<? extends DisassembledAddressInfo> list,
DisassembledAddressInfo value, int index, boolean isSelected,
boolean cellHasFocus) {
renderer.setToolTipText(TOOLTIP_TEXT_PREPEND + currentLocation.getAddress()); super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
// first let's set the text to the user-defined option, if setFont(font);
// we have the correct type of class
if (value instanceof DisassembledAddressInfo) { setToolTipText(TOOLTIP_TEXT_PREPEND +
renderer.setText(((DisassembledAddressInfo) value).getAddressPreview( HTMLUtilities.friendlyEncodeHTML(currentLocation.getAddress().toString()));
addressPreviewFormat));
}
// make sure the first value is highlighted to indicate // make sure the first value is highlighted to indicate
// that it is the selected program location // that it is the selected program location
@ -450,13 +453,12 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
background = background.darker(); background = background.darker();
} }
renderer.setForeground(foreground); setForeground(foreground);
renderer.setBackground(background); setBackground(background);
} }
return renderer; return this;
} }
}); });
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,13 +15,6 @@
*/ */
package ghidra.app.plugin.core.disassembler; package ghidra.app.plugin.core.disassembler;
import ghidra.app.util.bean.FixedBitSizeValueField;
import ghidra.program.model.lang.Register;
import ghidra.program.model.lang.RegisterValue;
import ghidra.program.model.listing.ProgramContext;
import ghidra.util.HelpLocation;
import ghidra.util.layout.PairLayout;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -33,107 +25,114 @@ import java.util.ArrayList;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.app.util.bean.FixedBitSizeValueField;
import ghidra.program.model.lang.Register;
import ghidra.program.model.lang.RegisterValue;
import ghidra.program.model.listing.ProgramContext;
import ghidra.util.HelpLocation;
import ghidra.util.layout.PairLayout;
public class ProcessorStateDialog extends DialogComponentProvider { public class ProcessorStateDialog extends DialogComponentProvider {
private JPanel mainPanel; private JPanel mainPanel;
private final static String TITLE = "Specify Processor Disassembly Options"; private final static String TITLE = "Specify Processor Disassembly Options";
private FixedBitSizeValueField[] fields; private FixedBitSizeValueField[] fields;
private java.util.List<Register> registerList; private java.util.List<Register> registerList;
private ProgramContext programContext; private ProgramContext programContext;
public ProcessorStateDialog(ProgramContext programContext) { public ProcessorStateDialog(ProgramContext programContext) {
super(TITLE, true, false, true, false); super(TITLE, true, false, true, false);
this.programContext = programContext; this.programContext = programContext;
Register[] contextRegisters = programContext.getProcessorStateRegisters(); Register[] contextRegisters = programContext.getProcessorStateRegisters();
registerList = new ArrayList<Register>(); registerList = new ArrayList<>();
for (Register register : contextRegisters) { for (Register register : contextRegisters) {
if (!register.isBaseRegister()) { if (!register.isBaseRegister()) {
registerList.add(register); registerList.add(register);
} }
} }
RegisterValue currentContext = programContext.getDefaultDisassemblyContext(); RegisterValue currentContext = programContext.getDefaultDisassemblyContext();
addOKButton(); addOKButton();
addCancelButton(); addCancelButton();
JPanel workPanel = new JPanel(new PairLayout(4,4)); JPanel workPanel = new JPanel(new PairLayout(4, 4));
workPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); workPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
fields = new FixedBitSizeValueField[registerList.size()]; fields = new FixedBitSizeValueField[registerList.size()];
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {
Register register = registerList.get(i); Register register = registerList.get(i);
int numbits = register.getBitLength(); int numbits = register.getBitLength();
JLabel label = new JLabel(register.getName()+" [ "+register.getBitLength() JLabel label = DockingUtils.createNonHtmlLabel(register.getName() + " [ " +
+ " bit" + ((numbits == 1) ? "" : "s") + " ] :"); register.getBitLength() + " bit" + ((numbits == 1) ? "" : "s") + " ] :");
label.setHorizontalAlignment(SwingConstants.TRAILING); label.setHorizontalAlignment(SwingConstants.TRAILING);
label.setToolTipText(register.getDescription()); label.setToolTipText(register.getDescription());
workPanel.add(label); workPanel.add(label);
fields[i] = new FixedBitSizeValueField(register.getBitLength(), false, false); fields[i] = new FixedBitSizeValueField(register.getBitLength(), false, false);
fields[i].setValue( currentContext.getRegisterValue(register).getUnsignedValue() ); fields[i].setValue(currentContext.getRegisterValue(register).getUnsignedValue());
workPanel.add(fields[i]); workPanel.add(fields[i]);
} }
mainPanel = new JPanel(new BorderLayout()); mainPanel = new JPanel(new BorderLayout());
JScrollPane scrollPane = new JScrollPane(workPanel); JScrollPane scrollPane = new JScrollPane(workPanel);
mainPanel.add(scrollPane, BorderLayout.CENTER); mainPanel.add(scrollPane, BorderLayout.CENTER);
JPanel radioPanel = new JPanel(new FlowLayout()); JPanel radioPanel = new JPanel(new FlowLayout());
mainPanel.add(radioPanel, BorderLayout.SOUTH); mainPanel.add(radioPanel, BorderLayout.SOUTH);
JRadioButton hexButton = new JRadioButton("Hex"); JRadioButton hexButton = new JRadioButton("Hex");
JRadioButton decimalButton = new JRadioButton("Decimal"); JRadioButton decimalButton = new JRadioButton("Decimal");
hexButton.setSelected(true); hexButton.setSelected(true);
ButtonGroup group = new ButtonGroup(); ButtonGroup group = new ButtonGroup();
group.add(hexButton); group.add(hexButton);
group.add(decimalButton); group.add(decimalButton);
radioPanel.add(hexButton); radioPanel.add(hexButton);
radioPanel.add(decimalButton); radioPanel.add(decimalButton);
hexButton.addActionListener(new ActionListener() { hexButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
setRadix(16); setRadix(16);
} }
}); });
decimalButton.addActionListener(new ActionListener() { decimalButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
setRadix(10); setRadix(10);
} }
}); });
addWorkPanel(mainPanel); addWorkPanel(mainPanel);
setHelpLocation(new HelpLocation("DisassemblerPlugin","ProcessorOptions")); setHelpLocation(new HelpLocation("DisassemblerPlugin", "ProcessorOptions"));
setRememberSize( false ); setRememberSize(false);
} }
protected void setRadix(int radix) {
protected void setRadix(int radix) { for (FixedBitSizeValueField field : fields) {
for (FixedBitSizeValueField field : fields) {
field.setFormat(radix, false); field.setFormat(radix, false);
} }
} }
private RegisterValue setRegisterValue(RegisterValue registerValue, Register register, BigInteger value) { private RegisterValue setRegisterValue(RegisterValue registerValue, Register register,
BigInteger value) {
RegisterValue newValue = new RegisterValue(register, value); RegisterValue newValue = new RegisterValue(register, value);
return registerValue.combineValues(newValue); return registerValue.combineValues(newValue);
} }
/** /**
* The callback method for when the "OK" button is pressed. * The callback method for when the "OK" button is pressed.
*/ */
@Override @Override
public void okCallback() { public void okCallback() {
RegisterValue newValue = new RegisterValue(programContext.getBaseContextRegister()); RegisterValue newValue = new RegisterValue(programContext.getBaseContextRegister());
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {
BigInteger value = fields[i].getValue(); BigInteger value = fields[i].getValue();
if (value != null) { if (value != null) {
newValue = setRegisterValue(newValue, registerList.get(i), value); newValue = setRegisterValue(newValue, registerList.get(i), value);
} }
} }
programContext.setDefaultDisassemblyContext(newValue); programContext.setDefaultDisassemblyContext(newValue);
close(); close();
} }
public void dispose() { public void dispose() {
close(); close();
} }
} }

View file

@ -18,6 +18,7 @@ package ghidra.app.plugin.core.disassembler;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import ghidra.app.cmd.disassemble.SetFlowOverrideCmd; import ghidra.app.cmd.disassemble.SetFlowOverrideCmd;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
@ -96,8 +97,8 @@ class SetFlowOverrideDialog extends DialogComponentProvider {
FlowType flowType = instruction.getFlowType(); FlowType flowType = instruction.getFlowType();
panel.add(new JLabel("Current Flow: " + flowType.getName() + panel.add(DockingUtils.createNonHtmlLabel(
(flowType.isConditional() ? "*" : ""))); "Current Flow: " + flowType.getName() + (flowType.isConditional() ? "*" : "")));
panel.add(Box.createGlue()); panel.add(Box.createGlue());
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
@ -110,7 +111,7 @@ class SetFlowOverrideDialog extends DialogComponentProvider {
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JLabel(note)); panel.add(DockingUtils.createNonHtmlLabel(note));
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
@ -139,7 +140,7 @@ class SetFlowOverrideDialog extends DialogComponentProvider {
flowOverrideComboBox.setSelectedItem(flowOverride); flowOverrideComboBox.setSelectedItem(flowOverride);
} }
panel.add(new JLabel("Instruction Flow:")); panel.add(DockingUtils.createNonHtmlLabel("Instruction Flow:"));
panel.add(flowOverrideComboBox); panel.add(flowOverrideComboBox);
panel.add(Box.createGlue()); panel.add(Box.createGlue());
@ -191,8 +192,8 @@ class SetFlowOverrideDialog extends DialogComponentProvider {
return true; return true;
} }
else { else {
tool.executeBackgroundCommand( tool.executeBackgroundCommand(new SetFlowOverrideCmd(instruction.getMinAddress(), flow),
new SetFlowOverrideCmd(instruction.getMinAddress(), flow), program); program);
} }
return true; return true;
} }

View file

@ -24,6 +24,7 @@ import javax.swing.*;
import javax.swing.table.*; import javax.swing.table.*;
import docking.ActionContext; import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*; import docking.action.*;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import ghidra.app.context.ProgramActionContext; import ghidra.app.context.ProgramActionContext;
@ -218,7 +219,8 @@ public class EquateTableProvider extends ComponentProviderAdapter {
setEquateTableRenderer(); setEquateTableRenderer();
JPanel equatesPanel = new JPanel(new BorderLayout()); JPanel equatesPanel = new JPanel(new BorderLayout());
equatesPanel.add(new JLabel("Equates", SwingConstants.CENTER), BorderLayout.NORTH); equatesPanel.add(DockingUtils.createNonHtmlLabel("Equates", SwingConstants.CENTER),
BorderLayout.NORTH);
equatesPanel.add(equatesTablePane, BorderLayout.CENTER); equatesPanel.add(equatesTablePane, BorderLayout.CENTER);
equatesPanel.add(equatesFilterPanel, BorderLayout.SOUTH); equatesPanel.add(equatesFilterPanel, BorderLayout.SOUTH);
@ -245,7 +247,8 @@ public class EquateTableProvider extends ComponentProviderAdapter {
setReferenceTableRenderer(); setReferenceTableRenderer();
JPanel referencesPanel = new JPanel(new BorderLayout()); JPanel referencesPanel = new JPanel(new BorderLayout());
referencesPanel.add(new JLabel("References", SwingConstants.CENTER), "North"); referencesPanel.add(DockingUtils.createNonHtmlLabel("References", SwingConstants.CENTER),
"North");
referencesPanel.add(referencesTablePane, "Center"); referencesPanel.add(referencesTablePane, "Center");
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////

View file

@ -27,6 +27,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.options.editor.ButtonPanelFactory; import docking.options.editor.ButtonPanelFactory;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
@ -183,16 +184,16 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
private Component buildMainPanel() { private Component buildMainPanel() {
JPanel panel = new JPanel(new PairLayout(5, 5)); JPanel panel = new JPanel(new PairLayout(5, 5));
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
panel.add(new JLabel("Format: ", SwingConstants.RIGHT)); panel.add(DockingUtils.createNonHtmlLabel("Format: ", SwingConstants.RIGHT));
panel.add(buildFormatChooser()); panel.add(buildFormatChooser());
panel.add(new JLabel("Output File: ", SwingConstants.RIGHT)); panel.add(DockingUtils.createNonHtmlLabel("Output File: ", SwingConstants.RIGHT));
panel.add(buildFilePanel()); panel.add(buildFilePanel());
return panel; return panel;
} }
private Component buildSelectionCheckboxPanel() { private Component buildSelectionCheckboxPanel() {
JPanel panel = new JPanel(new PairLayout(5, 5)); JPanel panel = new JPanel(new PairLayout(5, 5));
selectionOnlyLabel = new JLabel("Selection Only:"); selectionOnlyLabel = DockingUtils.createNonHtmlLabel("Selection Only:");
panel.add(selectionOnlyLabel); panel.add(selectionOnlyLabel);
panel.add(buildSelectionCheckbox()); panel.add(buildSelectionCheckbox());
return panel; return panel;

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,10 +15,6 @@
*/ */
package ghidra.app.plugin.core.fallthrough; package ghidra.app.plugin.core.fallthrough;
import ghidra.app.util.AddressInput;
import ghidra.program.model.address.Address;
import ghidra.util.HelpLocation;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -30,9 +25,13 @@ import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import resources.ResourceManager;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.ToolTipManager; import docking.ToolTipManager;
import ghidra.app.util.AddressInput;
import ghidra.program.model.address.Address;
import ghidra.util.HelpLocation;
import resources.ResourceManager;
/** /**
* Dialog to prompt for overriding a fallthrough address on an * Dialog to prompt for overriding a fallthrough address on an
@ -65,11 +64,12 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
updateState(); updateState();
model.setChangeListener(this); model.setChangeListener(this);
} }
/** /**
* @see ghidra.util.bean.GhidraDialog#applyCallback() * @see ghidra.util.bean.GhidraDialog#applyCallback()
*/ */
@Override @Override
protected void applyCallback() { protected void applyCallback() {
model.execute(); model.execute();
} }
@ -77,14 +77,15 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
* @see ghidra.util.bean.GhidraDialog#cancelCallback() * @see ghidra.util.bean.GhidraDialog#cancelCallback()
*/ */
@Override @Override
protected void cancelCallback() { protected void cancelCallback() {
close(); close();
} }
/** /**
* @see ghidra.util.bean.GhidraDialog#okCallback() * @see ghidra.util.bean.GhidraDialog#okCallback()
*/ */
@Override @Override
protected void okCallback() { protected void okCallback() {
if (model.execute()) { if (model.execute()) {
cancelCallback(); cancelCallback();
} }
@ -133,12 +134,14 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
setStatusText(msg); setStatusText(msg);
} }
} }
private void addressChanged() { private void addressChanged() {
if (changing) { if (changing) {
return; return;
} }
Runnable r = new Runnable() { Runnable r = new Runnable() {
@Override
public void run() { public void run() {
Address addr = addrField.getAddress(); Address addr = addrField.getAddress();
if (addr != null || addrField.getValue().length() == 0) { if (addr != null || addrField.getValue().length() == 0) {
@ -156,15 +159,17 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
private JPanel create() { private JPanel create() {
JPanel panel = new JPanel(new BorderLayout(0, 10)); JPanel panel = new JPanel(new BorderLayout(0, 10));
panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
addrField = new AddressInput(); addrField = new AddressInput();
addrField.setAddressFactory(model.getProgram().getAddressFactory()); addrField.setAddressFactory(model.getProgram().getAddressFactory());
addrField.addChangeListener(new ChangeListener() { addrField.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
addressChanged(); addressChanged();
} }
}); });
addrField.addActionListener(new ActionListener() { addrField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
model.setCurrentFallthrough(addrField.getAddress()); model.setCurrentFallthrough(addrField.getAddress());
} }
@ -187,37 +192,38 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(new TitledBorder("Home")); panel.setBorder(new TitledBorder("Home"));
addressLabel = new JLabel("01001000"); addressLabel = DockingUtils.createNonHtmlLabel("01001000");
Font font = addressLabel.getFont(); Font font = addressLabel.getFont();
Font monoFont = new Font("monospaced", font.getStyle(), Font monoFont = new Font("monospaced", font.getStyle(), font.getSize());
font.getSize()); addressLabel.setFont(monoFont);
addressLabel.setFont(monoFont);
instLabel = new JLabel("jmp DAT_01001000"); instLabel = DockingUtils.createNonHtmlLabel("jmp DAT_01001000");
instLabel.setFont(monoFont); instLabel.setFont(monoFont);
homeButton = createButton("images/go-home.png", "Home"); homeButton = createButton("images/go-home.png", "Home");
homeButton.addActionListener(new ActionListener() { homeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
plugin.goTo(model.getAddress()); plugin.goTo(model.getAddress());
} }
}); });
JPanel innerPanel = new JPanel(); JPanel innerPanel = new JPanel();
BoxLayout bl = new BoxLayout(innerPanel,BoxLayout.X_AXIS); BoxLayout bl = new BoxLayout(innerPanel, BoxLayout.X_AXIS);
innerPanel.setLayout(bl); innerPanel.setLayout(bl);
innerPanel.add(Box.createHorizontalStrut(5)); innerPanel.add(Box.createHorizontalStrut(5));
innerPanel.add(homeButton); innerPanel.add(homeButton);
innerPanel.add(Box.createHorizontalStrut(10)); innerPanel.add(Box.createHorizontalStrut(10));
innerPanel.add(addressLabel); innerPanel.add(addressLabel);
innerPanel.add(Box.createHorizontalStrut(20)); innerPanel.add(Box.createHorizontalStrut(20));
innerPanel.add(instLabel); innerPanel.add(instLabel);
innerPanel.add(Box.createHorizontalStrut(10)); innerPanel.add(Box.createHorizontalStrut(10));
panel.add(innerPanel, BorderLayout.CENTER); panel.add(innerPanel, BorderLayout.CENTER);
return panel; return panel;
} }
private JPanel createRadioButtonPanel() { private JPanel createRadioButtonPanel() {
JPanel panel = new JPanel(); JPanel panel = new JPanel();
@ -227,6 +233,7 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
ButtonGroup group = new ButtonGroup(); ButtonGroup group = new ButtonGroup();
defaultRB = new JRadioButton("Default", true); defaultRB = new JRadioButton("Default", true);
defaultRB.addActionListener(new ActionListener() { defaultRB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
model.defaultSelected(); model.defaultSelected();
} }
@ -235,6 +242,7 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
userRB = new JRadioButton("User", false); userRB = new JRadioButton("User", false);
userRB.addActionListener(new ActionListener() { userRB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
model.userSelected(); model.userSelected();
} }
@ -251,21 +259,24 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
outerPanel.add(panel); outerPanel.add(panel);
return outerPanel; return outerPanel;
} }
private JButton createButton(String filename, String altText) {
JButton button = new JButton(); private JButton createButton(String filename, String altText) {
URL imageURL = ResourceManager.getResource(filename); JButton button = new JButton();
if (imageURL != null) { URL imageURL = ResourceManager.getResource(filename);
ImageIcon icon = new ImageIcon(imageURL); if (imageURL != null) {
button = new JButton(icon); ImageIcon icon = new ImageIcon(imageURL);
Insets noInsets = new Insets(0,0,0,0); button = new JButton(icon);
button.setMargin(noInsets); Insets noInsets = new Insets(0, 0, 0, 0);
} button.setMargin(noInsets);
else { }
button = new JButton(altText); else {
} button = new JButton(altText);
}
ToolTipManager.setToolTipText(button, "Go back to home address"); ToolTipManager.setToolTipText(button, "Go back to home address");
return button; return button;
} }
@Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
updateState(); updateState();
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,16 +15,17 @@
*/ */
package ghidra.app.plugin.core.flowarrow; package ghidra.app.plugin.core.flowarrow;
import ghidra.program.model.address.*;
import ghidra.program.model.symbol.RefType;
import ghidra.util.exception.AssertException;
import java.awt.*; import java.awt.*;
import java.awt.geom.PathIterator; import java.awt.geom.PathIterator;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.program.model.address.*;
import ghidra.program.model.symbol.RefType;
import ghidra.util.HTMLUtilities;
import ghidra.util.exception.AssertException;
abstract class FlowArrow { abstract class FlowArrow {
private static final int MIN_LINE_SPACING = 9; private static final int MIN_LINE_SPACING = 9;
@ -50,7 +50,7 @@ abstract class FlowArrow {
protected Shape arrowHead; protected Shape arrowHead;
/** The shape of the arrow body, but with added size */ /** The shape of the arrow body, but with added size */
private List<Shape> clickableShapes = new ArrayList<Shape>(); private List<Shape> clickableShapes = new ArrayList<>();
FlowArrow(FlowArrowPlugin plugin, Component canvas, Address start, Address end, FlowArrow(FlowArrowPlugin plugin, Component canvas, Address start, Address end,
RefType referenceType) { RefType referenceType) {
@ -153,7 +153,7 @@ abstract class FlowArrow {
} }
private void createClickableShapes() { private void createClickableShapes() {
List<Shape> shapes = new ArrayList<Shape>(); List<Shape> shapes = new ArrayList<>();
Rectangle r = null; Rectangle r = null;
PathIterator it = arrowBody.getPathIterator(null); PathIterator it = arrowBody.getPathIterator(null);
float[] coords = new float[6]; float[] coords = new float[6];
@ -242,13 +242,11 @@ abstract class FlowArrow {
int displayWidth = canvas.getWidth();// - FlowArrowPlugin.LEFT_OFFSET; int displayWidth = canvas.getWidth();// - FlowArrowPlugin.LEFT_OFFSET;
int lineWidth = calculateLineWidth(displayWidth); int lineWidth = calculateLineWidth(displayWidth);
arrowBody = arrowBody = FlowArrowShapeFactory.createArrowBody(plugin, this, displayWidth, displayHeight,
FlowArrowShapeFactory.createArrowBody(plugin, this, displayWidth, displayHeight, lineWidth);
lineWidth);
arrowHead = arrowHead = FlowArrowShapeFactory.createArrowHead(plugin, this, displayWidth, displayHeight,
FlowArrowShapeFactory.createArrowHead(plugin, this, displayWidth, displayHeight, lineWidth);
lineWidth);
} }
private int calculateLineWidth(int displayWidth) { private int calculateLineWidth(int displayWidth) {
@ -323,8 +321,10 @@ abstract class FlowArrow {
} }
public String getDisplayString() { public String getDisplayString() {
return "<html><table><tr><td>start</td><td>" + start + "</td><tr><td>end</td><td>" + end + return "<html><table><tr><td>start</td><td>" +
"</td><tr><td>ref type</td><td>" + refType + "</td></tr></table>"; HTMLUtilities.friendlyEncodeHTML(start.toString()) + "</td><tr><td>end</td><td>" +
HTMLUtilities.friendlyEncodeHTML(end.toString()) + "</td><tr><td>ref type</td><td>" +
refType + "</td></tr></table>";
} }
@Override @Override

View file

@ -22,6 +22,7 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import ghidra.app.cmd.function.ApplyFunctionSignatureCmd; import ghidra.app.cmd.function.ApplyFunctionSignatureCmd;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
@ -127,7 +128,7 @@ public class EditFunctionSignatureDialog extends DialogComponentProvider {
String signature = function.getPrototypeString(false, false); String signature = function.getPrototypeString(false, false);
signatureField = new JTextField(signature.length()); // add some extra room to edit signatureField = new JTextField(signature.length()); // add some extra room to edit
signatureField.setText(signature); signatureField.setText(signature);
signatureLabel = new JLabel("Signature:"); signatureLabel = DockingUtils.createNonHtmlLabel("Signature:");
signaturePanel.add(signatureLabel); signaturePanel.add(signatureLabel);
signaturePanel.add(signatureField); signaturePanel.add(signatureField);
@ -164,7 +165,7 @@ public class EditFunctionSignatureDialog extends DialogComponentProvider {
function.getProgram().getFunctionManager().getCallingConventionNames(); function.getProgram().getFunctionManager().getCallingConventionNames();
String[] choices = callingConventions.toArray(new String[callingConventions.size()]); String[] choices = callingConventions.toArray(new String[callingConventions.size()]);
setCallingConventionChoices(choices); setCallingConventionChoices(choices);
parentPanel.add(new JLabel("Calling Convention:")); parentPanel.add(DockingUtils.createNonHtmlLabel("Calling Convention:"));
parentPanel.add(callingConventionComboBox); parentPanel.add(callingConventionComboBox);
} }
@ -214,7 +215,7 @@ public class EditFunctionSignatureDialog extends DialogComponentProvider {
callFixupComboBox.setSelectedItem(callFixupName); callFixupComboBox.setSelectedItem(callFixupName);
} }
callFixupPanel.add(new JLabel("Call-Fixup:")); callFixupPanel.add(DockingUtils.createNonHtmlLabel("Call-Fixup:"));
callFixupPanel.add(callFixupComboBox); callFixupPanel.add(callFixupComboBox);
callFixupPanel.add(Box.createGlue()); callFixupPanel.add(Box.createGlue());

View file

@ -389,7 +389,7 @@ public class FunctionPlugin extends Plugin implements DataService {
return program.getFunctionManager().getFunctionsOverlapping(new AddressSet(loc, loc)); return program.getFunctionManager().getFunctionsOverlapping(new AddressSet(loc, loc));
} }
//return an empty iterator.... //return an empty iterator....
return new Iterator<Function>() { return new Iterator<>() {
@Override @Override
public void remove() { public void remove() {
// not supported // not supported
@ -580,8 +580,8 @@ public class FunctionPlugin extends Plugin implements DataService {
catch (VariableSizeException e) { catch (VariableSizeException e) {
tool.setStatusInfo(e.getMessage()); tool.setStatusInfo(e.getMessage());
if (e.canForce() && promptForConflictRemoval) { if (e.canForce() && promptForConflictRemoval) {
String msg = variable.getName() + " size change resulted in \n" + e.getMessage() + String msg = varType + " " + variable.getName() + " size change resulted in \n" +
"\n \nDelete conflicting " + varType + "(s)"; e.getMessage() + "\n \nDelete conflicting " + varType + "(s)";
if (OptionDialog.YES_OPTION == OptionDialog.showYesNoDialog(tool.getActiveWindow(), if (OptionDialog.YES_OPTION == OptionDialog.showYesNoDialog(tool.getActiveWindow(),
varType + " Conflict", msg)) { varType + " Conflict", msg)) {
tool.setStatusInfo(""); tool.setStatusInfo("");

View file

@ -21,6 +21,7 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.app.util.*; import ghidra.app.util.*;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@ -357,7 +358,7 @@ public class ThunkReferenceAddressDialog extends DialogComponentProvider {
JPanel mainPanel = new JPanel(new PairLayout(5, 5)); JPanel mainPanel = new JPanel(new PairLayout(5, 5));
refFunctionField = new JTextField(20); refFunctionField = new JTextField(20);
mainPanel.add(new JLabel("Destination Function/Address:")); mainPanel.add(DockingUtils.createNonHtmlLabel("Destination Function/Address:"));
mainPanel.add(refFunctionField); mainPanel.add(refFunctionField);
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));

View file

@ -290,9 +290,9 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 15, 15)); panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 15, 15));
JPanel leftPanel = new JPanel(new PairLayout(4, 8)); JPanel leftPanel = new JPanel(new PairLayout(4, 8));
leftPanel.add(new JLabel("Function Name:")); leftPanel.add(DockingUtils.createNonHtmlLabel("Function Name:"));
leftPanel.add(createNameField()); leftPanel.add(createNameField());
leftPanel.add(new JLabel("Calling Convention")); leftPanel.add(DockingUtils.createNonHtmlLabel("Calling Convention"));
leftPanel.add(createCallingConventionCombo()); leftPanel.add(createCallingConventionCombo());
leftPanel.setBorder(BorderFactory.createEmptyBorder(14, 0, 0, 10)); leftPanel.setBorder(BorderFactory.createEmptyBorder(14, 0, 0, 10));
@ -601,7 +601,8 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
color = Color.red; color = Color.red;
} }
String toolTipText = ToolTipUtils.getToolTipText(dataType); String toolTipText = ToolTipUtils.getToolTipText(dataType);
String headerText = "<HTML><b>" + dataType.getPathName() + "</b><BR>"; String headerText = "<HTML><b>" +
HTMLUtilities.friendlyEncodeHTML(dataType.getPathName()) + "</b><BR>";
toolTipText = toolTipText.replace("<HTML>", headerText); toolTipText = toolTipText.replace("<HTML>", headerText);
setToolTipText(toolTipText); setToolTipText(toolTipText);
} }

View file

@ -20,7 +20,6 @@ import java.awt.event.*;
import java.util.EventObject; import java.util.EventObject;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.event.CellEditorListener; import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
@ -35,7 +34,6 @@ import ghidra.util.data.DataTypeParser;
class ParameterDataTypeCellEditor extends AbstractCellEditor implements TableCellEditor { class ParameterDataTypeCellEditor extends AbstractCellEditor implements TableCellEditor {
private DataTypeSelectionEditor editor; private DataTypeSelectionEditor editor;
private JLabel label = new JLabel();
private DropDownSelectionTextField<DataType> textField; private DropDownSelectionTextField<DataType> textField;
private JButton dataTypeChooserButton; private JButton dataTypeChooserButton;
private DataType dt; private DataType dt;
@ -44,8 +42,7 @@ class ParameterDataTypeCellEditor extends AbstractCellEditor implements TableCel
private DataTypeManagerService service; private DataTypeManagerService service;
private DialogComponentProvider dialog; private DialogComponentProvider dialog;
ParameterDataTypeCellEditor(DialogComponentProvider dialog, ParameterDataTypeCellEditor(DialogComponentProvider dialog, DataTypeManagerService service) {
DataTypeManagerService service) {
this.dialog = dialog; this.dialog = dialog;
this.service = service; this.service = service;
@ -54,11 +51,6 @@ class ParameterDataTypeCellEditor extends AbstractCellEditor implements TableCel
@Override @Override
public Component getTableCellEditorComponent(JTable table1, Object value, boolean isSelected, public Component getTableCellEditorComponent(JTable table1, Object value, boolean isSelected,
int row, int column) { int row, int column) {
if (label == null) {
label = new JLabel();
label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
}
init(); init();
dt = (DataType) value; dt = (DataType) value;

View file

@ -25,6 +25,7 @@ import javax.swing.event.*;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.DropDownSelectionTextField; import docking.widgets.DropDownSelectionTextField;
import docking.widgets.table.GTable; import docking.widgets.table.GTable;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
@ -37,8 +38,8 @@ import ghidra.util.Msg;
import ghidra.util.layout.PairLayout; import ghidra.util.layout.PairLayout;
import ghidra.util.layout.VerticalLayout; import ghidra.util.layout.VerticalLayout;
public class StorageAddressEditorDialog extends DialogComponentProvider implements public class StorageAddressEditorDialog extends DialogComponentProvider
ModelChangeListener { implements ModelChangeListener {
private FunctionVariableData variableData; private FunctionVariableData variableData;
private StorageAddressModel model; private StorageAddressModel model;
private VarnodeTableModel varnodeTableModel; private VarnodeTableModel varnodeTableModel;
@ -160,10 +161,9 @@ public class StorageAddressEditorDialog extends DialogComponentProvider implemen
JPanel panel = new JPanel(new PairLayout(10, 4)); JPanel panel = new JPanel(new PairLayout(10, 4));
panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
panel.add(new JLabel("Datatype: ")); panel.add(DockingUtils.createNonHtmlLabel("Datatype: "));
dataTypeEditor = dataTypeEditor = new ParameterDataTypeCellEditor(this, service);
new ParameterDataTypeCellEditor(this, service);
dataTypeEditor.addCellEditorListener(new CellEditorListener() { dataTypeEditor.addCellEditorListener(new CellEditorListener() {
@ -211,11 +211,11 @@ public class StorageAddressEditorDialog extends DialogComponentProvider implemen
}); });
panel.add(dataTypeEditComponent); panel.add(dataTypeEditComponent);
panel.add(new JLabel("Datatype Size: ")); panel.add(DockingUtils.createNonHtmlLabel("Datatype Size: "));
sizeLabel = new JLabel("" + size); sizeLabel = DockingUtils.createNonHtmlLabel("" + size);
panel.add(sizeLabel); panel.add(sizeLabel);
panel.add(new JLabel("Allocated Size:")); panel.add(DockingUtils.createNonHtmlLabel("Allocated Size:"));
currentSizeLabel = new JLabel(""); currentSizeLabel = DockingUtils.createNonHtmlLabel("");
panel.add(currentSizeLabel); panel.add(currentSizeLabel);
setFocusComponent(textField); setFocusComponent(textField);

View file

@ -21,7 +21,9 @@ import java.awt.event.MouseEvent;
import javax.swing.*; import javax.swing.*;
import docking.widgets.list.GListCellRenderer;
import ghidra.program.model.listing.FunctionTag; import ghidra.program.model.listing.FunctionTag;
import ghidra.util.HTMLUtilities;
/** /**
* Simple list for displaying {@link FunctionTag} items. The only part of the tag * Simple list for displaying {@link FunctionTag} items. The only part of the tag
@ -48,7 +50,7 @@ public class FunctionTagList extends JList<FunctionTag> {
return "<no comment set>"; return "<no comment set>";
} }
return tag.getComment(); return "<html>" + HTMLUtilities.friendlyEncodeHTML(tag.getComment());
} }
return ""; return "";
@ -62,25 +64,29 @@ public class FunctionTagList extends JList<FunctionTag> {
*/ */
@Override @Override
public ListCellRenderer<? super FunctionTag> getCellRenderer() { public ListCellRenderer<? super FunctionTag> getCellRenderer() {
return new DefaultListCellRenderer() { return new GListCellRenderer<>() {
@Override @Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, protected String getItemText(FunctionTag value) {
boolean isSelected, boolean cellHasFocus) { return value.getName();
FunctionTag tag = (FunctionTag) value; }
Component listCellRendererComponent = super.getListCellRendererComponent(list,
tag.getName(), index, isSelected, cellHasFocus); @Override
public Component getListCellRendererComponent(JList<? extends FunctionTag> list,
FunctionTag value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
// If this tag is a temporary one (ie: read-in from a file), then it is // If this tag is a temporary one (ie: read-in from a file), then it is
// read-only and should be indicated to the user as a different color. // read-only and should be indicated to the user as a different color.
if (value instanceof FunctionTagTemp) { if (value instanceof FunctionTagTemp) {
if (cellHasFocus) { if (cellHasFocus) {
listCellRendererComponent.setForeground(Color.white); setForeground(Color.white);
} }
else { else {
listCellRendererComponent.setForeground(Color.blue); setForeground(Color.blue);
} }
} }
return listCellRendererComponent; return this;
} }
}; };
} }

View file

@ -23,6 +23,7 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import docking.DockingUtils;
import docking.widgets.textfield.HintTextField; import docking.widgets.textfield.HintTextField;
import ghidra.app.cmd.function.CreateFunctionTagCmd; import ghidra.app.cmd.function.CreateFunctionTagCmd;
import ghidra.app.context.ProgramActionContext; import ghidra.app.context.ProgramActionContext;
@ -376,7 +377,7 @@ public class FunctionTagsComponentProvider extends ComponentProviderAdapter
*/ */
private JPanel createFilterPanel() { private JPanel createFilterPanel() {
filterPanel = new JPanel(new BorderLayout()); filterPanel = new JPanel(new BorderLayout());
JLabel label = new JLabel(" Filter:"); JLabel label = DockingUtils.createNonHtmlLabel(" Filter:");
filterInputTF = new HintTextField(""); filterInputTF = new HintTextField("");
filterInputTF.setName("filterInputTF"); filterInputTF.setName("filterInputTF");
@ -411,7 +412,7 @@ public class FunctionTagsComponentProvider extends ComponentProviderAdapter
private JPanel createInputPanel() { private JPanel createInputPanel() {
inputPanel = new JPanel(new BorderLayout()); inputPanel = new JPanel(new BorderLayout());
JLabel label = new JLabel(" Create new tag(s):"); JLabel label = DockingUtils.createNonHtmlLabel(" Create new tag(s):");
tagInputTF = new HintTextField("tag 1, tag 2, ..."); tagInputTF = new HintTextField("tag 1, tag 2, ...");
tagInputTF.setName("tagInputTF"); tagInputTF.setName("tagInputTF");
tagInputTF.addActionListener(e -> processCreates()); tagInputTF.addActionListener(e -> processCreates());

View file

@ -22,6 +22,7 @@ import java.util.*;
import javax.swing.*; import javax.swing.*;
import docking.DockingUtils;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.dialogs.InputDialog; import docking.widgets.dialogs.InputDialog;
@ -64,8 +65,7 @@ public abstract class TagListPanel extends JPanel {
* @param tool the plugin tool * @param tool the plugin tool
* @param title the title of the panel * @param title the title of the panel
*/ */
public TagListPanel(FunctionTagsComponentProvider provider, PluginTool tool, public TagListPanel(FunctionTagsComponentProvider provider, PluginTool tool, String title) {
String title) {
this.tool = tool; this.tool = tool;
setLayout(new BorderLayout()); setLayout(new BorderLayout());
@ -97,9 +97,9 @@ public abstract class TagListPanel extends JPanel {
// If the tag is a temporary one, it's not editable. Show a message to the user. // If the tag is a temporary one, it's not editable. Show a message to the user.
if (tag instanceof FunctionTagTemp) { if (tag instanceof FunctionTagTemp) {
Msg.showWarn(list, list, "Tag Not Editable", Msg.showWarn(list, list, "Tag Not Editable", "Tag " + "\"" + tag.getName() +
"Tag " + "\"" + tag.getName() + "\"" + "\"" +
" was loaded from an external source and cannot be edited or deleted"); " was loaded from an external source and cannot be edited or deleted");
return; return;
} }
@ -150,7 +150,7 @@ public abstract class TagListPanel extends JPanel {
} }
}); });
JLabel label = new JLabel(title); JLabel label = DockingUtils.createNonHtmlLabel(title);
add(label, BorderLayout.NORTH); add(label, BorderLayout.NORTH);
add(list, BorderLayout.CENTER); add(list, BorderLayout.CENTER);
@ -245,8 +245,8 @@ public abstract class TagListPanel extends JPanel {
// Show a confirmation message - users may not be aware that deleting a tag is more // Show a confirmation message - users may not be aware that deleting a tag is more
// than just removing it from a function. // than just removing it from a function.
int option = OptionDialog.showOptionDialog(this, "Function Tag Delete", int option = OptionDialog.showOptionDialog(this, "Function Tag Delete",
"Are you sure? \nThis will delete the tag from all functions in the program.", "Are you sure? \nThis will delete the tag from all functions in the program.", "OK",
"OK", OptionDialog.WARNING_MESSAGE); OptionDialog.WARNING_MESSAGE);
switch (option) { switch (option) {
case OptionDialog.OPTION_ONE: case OptionDialog.OPTION_ONE:

View file

@ -21,8 +21,7 @@ import java.util.*;
import javax.swing.*; import javax.swing.*;
import docking.ActionContext; import docking.*;
import docking.ComponentProvider;
import docking.action.*; import docking.action.*;
import docking.help.Help; import docking.help.Help;
import docking.help.HelpService; import docking.help.HelpService;
@ -161,6 +160,7 @@ public abstract class FunctionChoiceComparisonPanel extends FunctionComparisonPa
private Component createLeftChoicePanel() { private Component createLeftChoicePanel() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
leftComboBox = new JComboBox<>(leftWrappedFunctions); leftComboBox = new JComboBox<>(leftWrappedFunctions);
DockingUtils.turnOffHTMLRendering(leftComboBox);
adjustSelectedLeftFunction(); adjustSelectedLeftFunction();
leftComboBox.addItemListener(e -> { leftComboBox.addItemListener(e -> {
WrappedFunction wrappedFunction = (WrappedFunction) leftComboBox.getSelectedItem(); WrappedFunction wrappedFunction = (WrappedFunction) leftComboBox.getSelectedItem();
@ -174,6 +174,7 @@ public abstract class FunctionChoiceComparisonPanel extends FunctionComparisonPa
private Component createRightChoicePanel() { private Component createRightChoicePanel() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
rightComboBox = new JComboBox<>(rightWrappedFunctions); rightComboBox = new JComboBox<>(rightWrappedFunctions);
DockingUtils.turnOffHTMLRendering(rightComboBox);
adjustSelectedRightFunction(); adjustSelectedRightFunction();
rightComboBox.addItemListener(e -> { rightComboBox.addItemListener(e -> {
WrappedFunction wrappedFunction = (WrappedFunction) rightComboBox.getSelectedItem(); WrappedFunction wrappedFunction = (WrappedFunction) rightComboBox.getSelectedItem();

View file

@ -21,6 +21,8 @@ import java.awt.FlowLayout;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import docking.DockingUtils;
/** /**
* Simple panel containing a JLabel for displaying error messages. * Simple panel containing a JLabel for displaying error messages.
* *
@ -35,14 +37,14 @@ public class MessagePanel extends JPanel {
*/ */
public MessagePanel() { public MessagePanel() {
setLayout(new FlowLayout(FlowLayout.CENTER)); setLayout(new FlowLayout(FlowLayout.CENTER));
msgLabel = new JLabel(NO_STATUS); msgLabel = DockingUtils.createNonHtmlLabel(NO_STATUS);
add(msgLabel); add(msgLabel);
} }
/** /**
* Sets the text to be displayed. * Sets the text to be displayed.
* *
* @param text the new text * @param text the new non-html text
* @param foregroundColor the text color * @param foregroundColor the text color
*/ */
public void setMessageText(String text, Color foregroundColor) { public void setMessageText(String text, Color foregroundColor) {

View file

@ -18,6 +18,7 @@ package ghidra.app.plugin.core.label;
import javax.swing.*; import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import ghidra.app.cmd.label.AddLabelCmd; import ghidra.app.cmd.label.AddLabelCmd;
import ghidra.app.cmd.refs.AssociateSymbolCmd; import ghidra.app.cmd.refs.AssociateSymbolCmd;
@ -59,7 +60,7 @@ public class OperandLabelDialog extends DialogComponentProvider {
JPanel mainPanel = new JPanel(new PairLayout(5, 5)); JPanel mainPanel = new JPanel(new PairLayout(5, 5));
mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
label = new JLabel("Label: "); label = DockingUtils.createNonHtmlLabel("Label: ");
myChoice = new GhidraComboBox<>(); myChoice = new GhidraComboBox<>();
myChoice.setName("MYCHOICE"); myChoice.setName("MYCHOICE");

View file

@ -22,6 +22,7 @@ import javax.swing.*;
import javax.swing.event.*; import javax.swing.event.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import ghidra.app.plugin.core.misc.RegisterField; import ghidra.app.plugin.core.misc.RegisterField;
import ghidra.app.util.*; import ghidra.app.util.*;
@ -144,31 +145,31 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
lengthField.setChangeListener(e -> lengthChanged()); lengthField.setChangeListener(e -> lengthChanged());
addrField.addChangeListener(ev -> addrChanged()); addrField.addChangeListener(ev -> addrChanged());
JLabel readLabel = new JLabel("Read"); JLabel readLabel = DockingUtils.createNonHtmlLabel("Read");
readCB = new JCheckBox(); readCB = new JCheckBox();
readCB.setName("Read"); readCB.setName("Read");
JLabel writeLabel = new JLabel("Write"); JLabel writeLabel = DockingUtils.createNonHtmlLabel("Write");
writeCB = new JCheckBox(); writeCB = new JCheckBox();
writeCB.setName("Write"); writeCB.setName("Write");
JLabel executeLabel = new JLabel("Execute"); JLabel executeLabel = DockingUtils.createNonHtmlLabel("Execute");
executeCB = new JCheckBox(); executeCB = new JCheckBox();
executeCB.setName("Execute"); executeCB.setName("Execute");
JLabel volatileLabel = new JLabel("Volatile"); JLabel volatileLabel = DockingUtils.createNonHtmlLabel("Volatile");
volatileCB = new JCheckBox(); volatileCB = new JCheckBox();
volatileCB.setName("Volatile"); volatileCB.setName("Volatile");
JPanel topPanel = new JPanel(new PairLayout(4, 10, 150)); JPanel topPanel = new JPanel(new PairLayout(4, 10, 150));
topPanel.setBorder(BorderFactory.createEmptyBorder(5, 7, 4, 5)); topPanel.setBorder(BorderFactory.createEmptyBorder(5, 7, 4, 5));
topPanel.add(new JLabel("Block Name:", SwingConstants.RIGHT)); topPanel.add(DockingUtils.createNonHtmlLabel("Block Name:", SwingConstants.RIGHT));
topPanel.add(nameField); topPanel.add(nameField);
topPanel.add(new JLabel("Start Addr:", SwingConstants.RIGHT)); topPanel.add(DockingUtils.createNonHtmlLabel("Start Addr:", SwingConstants.RIGHT));
topPanel.add(addrField); topPanel.add(addrField);
topPanel.add(new JLabel("Length:", SwingConstants.RIGHT)); topPanel.add(DockingUtils.createNonHtmlLabel("Length:", SwingConstants.RIGHT));
topPanel.add(lengthField); topPanel.add(lengthField);
topPanel.add(new JLabel("Comment:", SwingConstants.RIGHT)); topPanel.add(DockingUtils.createNonHtmlLabel("Comment:", SwingConstants.RIGHT));
topPanel.add(commentField); topPanel.add(commentField);
JPanel execPanel = new JPanel(); JPanel execPanel = new JPanel();
@ -234,7 +235,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
nameField.setText(""); nameField.setText("");
addrField.setAddress(model.getStartAddress()); addrField.setAddress(model.getStartAddress());
lengthField.setValue(new Long(0)); lengthField.setValue(Long.valueOf(0));
model.setLength(0); model.setLength(0);
commentField.setText(""); commentField.setText("");
@ -243,7 +244,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
executeCB.setSelected(false); executeCB.setSelected(false);
volatileCB.setSelected(false); volatileCB.setSelected(false);
initialValueField.setValue(new Long(0)); initialValueField.setValue(Long.valueOf(0));
model.setBlockType(MemoryBlockType.DEFAULT); model.setBlockType(MemoryBlockType.DEFAULT);
model.setIsInitialized(initializedRB.isSelected()); model.setIsInitialized(initializedRB.isSelected());
model.setInitialValue(0); model.setInitialValue(0);
@ -411,7 +412,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
} }
private void createInitializedPanel() { private void createInitializedPanel() {
initialValueLabel = new JLabel("Initial Value"); initialValueLabel = DockingUtils.createNonHtmlLabel("Initial Value");
initialValueField = new RegisterField(8, null, false); initialValueField = new RegisterField(8, null, false);
initialValueField.setName("Initial Value"); initialValueField.setName("Initial Value");
initialValueField.setEnabled(false); initialValueField.setEnabled(false);
@ -427,7 +428,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
private JPanel createAddressPanel() { private JPanel createAddressPanel() {
JPanel addressPanel = new JPanel(new PairLayout()); JPanel addressPanel = new JPanel(new PairLayout());
JLabel addrToAddLabel = new JLabel("Source Addr:"); JLabel addrToAddLabel = DockingUtils.createNonHtmlLabel("Source Addr:");
baseAddrField = new AddressInput(); baseAddrField = new AddressInput();
baseAddrField.setAddressFactory(addrFactory); baseAddrField.setAddressFactory(addrFactory);
baseAddrField.setName("Source Addr"); baseAddrField.setName("Source Addr");

View file

@ -24,8 +24,7 @@ import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.ComponentProvider; import docking.*;
import docking.DialogComponentProvider;
import ghidra.app.plugin.core.misc.RegisterField; import ghidra.app.plugin.core.misc.RegisterField;
import ghidra.app.util.*; import ghidra.app.util.*;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
@ -58,6 +57,7 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
private ExpandBlockModel model; private ExpandBlockModel model;
private boolean isChanging; private boolean isChanging;
private PluginTool tool; private PluginTool tool;
/** /**
* Constructor * Constructor
* @param parent * @param parent
@ -65,15 +65,14 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
* @param af * @param af
* @param dialogType * @param dialogType
*/ */
ExpandBlockDialog(PluginTool tool, ExpandBlockModel model, MemoryBlock block, ExpandBlockDialog(PluginTool tool, ExpandBlockModel model, MemoryBlock block, AddressFactory af,
AddressFactory af, int dialogType) { int dialogType) {
super(dialogType == EXPAND_UP? EXPAND_UP_TITLE : EXPAND_DOWN_TITLE, super(dialogType == EXPAND_UP ? EXPAND_UP_TITLE : EXPAND_DOWN_TITLE, true);
true);
this.tool = tool; this.tool = tool;
this.model = model; this.model = model;
this.dialogType = dialogType; this.dialogType = dialogType;
setHelpLocation(new HelpLocation(HelpTopics.MEMORY_MAP, setHelpLocation(new HelpLocation(HelpTopics.MEMORY_MAP,
dialogType == EXPAND_UP? EXPAND_UP_TITLE : EXPAND_DOWN_TITLE)); dialogType == EXPAND_UP ? EXPAND_UP_TITLE : EXPAND_DOWN_TITLE));
addrFactory = af; addrFactory = af;
model.setChangeListener(this); model.setChangeListener(this);
addWorkPanel(create(block)); addWorkPanel(create(block));
@ -88,9 +87,10 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
* @see ghidra.util.bean.GhidraDialog#okCallback() * @see ghidra.util.bean.GhidraDialog#okCallback()
*/ */
@Override @Override
protected void okCallback() { protected void okCallback() {
Runnable doExpand = new Runnable() { Runnable doExpand = new Runnable() {
@Override
public void run() { public void run() {
if (model.execute()) { if (model.execute()) {
close(); close();
@ -112,7 +112,7 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
* @return JPanel * @return JPanel
*/ */
private JPanel create(MemoryBlock block) { private JPanel create(MemoryBlock block) {
JPanel panel = new JPanel(new PairLayout(5,5, 150)); JPanel panel = new JPanel(new PairLayout(5, 5, 150));
startAddressInput = new AddressInput(); startAddressInput = new AddressInput();
startAddressInput.setName("NewStartAddress"); startAddressInput.setName("NewStartAddress");
startAddressInput.setAddressFactory(addrFactory); startAddressInput.setAddressFactory(addrFactory);
@ -134,8 +134,8 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
startField.setText(start.toString()); startField.setText(start.toString());
endField.setText(end.toString()); endField.setText(end.toString());
JLabel startLabel = new JLabel("Start Address:", SwingConstants.RIGHT); JLabel startLabel = DockingUtils.createNonHtmlLabel("Start Address:", SwingConstants.RIGHT);
JLabel endLabel = new JLabel("End Address:", SwingConstants.RIGHT); JLabel endLabel = DockingUtils.createNonHtmlLabel("End Address:", SwingConstants.RIGHT);
if (dialogType == EXPAND_UP) { if (dialogType == EXPAND_UP) {
endField.setEnabled(false); endField.setEnabled(false);
@ -147,15 +147,13 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
} }
lengthField = new RegisterField(32, null, false); lengthField = new RegisterField(32, null, false);
lengthField.setName("BlockLength"); lengthField.setName("BlockLength");
lengthField.setValue(new Long(model.getLength())); lengthField.setValue(Long.valueOf(model.getLength()));
panel.add(startLabel); panel.add(startLabel);
panel.add((dialogType == EXPAND_UP)? panel.add((dialogType == EXPAND_UP) ? (JComponent) startAddressInput : startField);
(JComponent)startAddressInput : startField);
panel.add(endLabel); panel.add(endLabel);
panel.add((dialogType == EXPAND_UP)? panel.add((dialogType == EXPAND_UP) ? (JComponent) endField : endAddressInput);
(JComponent)endField : endAddressInput); panel.add(DockingUtils.createNonHtmlLabel("Block Length:", SwingConstants.RIGHT));
panel.add(new JLabel("Block Length:", SwingConstants.RIGHT));
panel.add(lengthField); panel.add(lengthField);
JPanel mainPanel = new JPanel(new BorderLayout()); JPanel mainPanel = new JPanel(new BorderLayout());
@ -170,6 +168,7 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
lengthField.setChangeListener(new LengthChangeListener()); lengthField.setChangeListener(new LengthChangeListener());
ActionListener al = new ActionListener() { ActionListener al = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
setStatusText(""); setStatusText("");
} }
@ -187,6 +186,7 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
*/ */
private class LengthChangeListener implements ChangeListener { private class LengthChangeListener implements ChangeListener {
@Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
if (isChanging) { if (isChanging) {
return; return;
@ -214,6 +214,7 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
*/ */
private class AddressChangeListener implements ChangeListener { private class AddressChangeListener implements ChangeListener {
@Override
public void stateChanged(ChangeEvent event) { public void stateChanged(ChangeEvent event) {
if (isChanging) { if (isChanging) {
return; return;
@ -249,22 +250,23 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
/** /**
* @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
*/ */
@Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
String message = model.getMessage(); String message = model.getMessage();
setStatusText(message); setStatusText(message);
setOkEnabled(message.length() == 0); setOkEnabled(message.length() == 0);
lengthField.setValue(new Long(model.getLength())); lengthField.setValue(new Long(model.getLength()));
Address startAddr = model.getStartAddress(); Address startAddr = model.getStartAddress();
Address endAddr = model.getEndAddress(); Address endAddr = model.getEndAddress();
isChanging = true; isChanging = true;
if (dialogType == EXPAND_UP && startAddr != null) { if (dialogType == EXPAND_UP && startAddr != null) {
startAddressInput.setAddress(startAddr); startAddressInput.setAddress(startAddr);
} }
else if (endAddr != null) { else if (endAddr != null) {
endAddressInput.setAddress(endAddr); endAddressInput.setAddress(endAddr);
} }
isChanging = false; isChanging = false;
if (!isVisible()) { if (!isVisible()) {
setOkEnabled(false); setOkEnabled(false);

View file

@ -24,6 +24,7 @@ import javax.swing.table.TableColumn;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
import docking.ActionContext; import docking.ActionContext;
import docking.DockingUtils;
import docking.action.DockingAction; import docking.action.DockingAction;
import docking.action.ToolBarData; import docking.action.ToolBarData;
import docking.widgets.table.*; import docking.widgets.table.*;
@ -176,7 +177,8 @@ class MemoryMapProvider extends ComponentProviderAdapter {
enableOptions(model); enableOptions(model);
}); });
memPanel.add(new JLabel("Memory Blocks", SwingConstants.CENTER), BorderLayout.NORTH); memPanel.add(DockingUtils.createNonHtmlLabel("Memory Blocks", SwingConstants.CENTER),
BorderLayout.NORTH);
memPanel.add(memPane, BorderLayout.CENTER); memPanel.add(memPane, BorderLayout.CENTER);
return memPanel; return memPanel;

View file

@ -22,6 +22,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.app.cmd.memory.MoveBlockListener; import ghidra.app.cmd.memory.MoveBlockListener;
import ghidra.app.cmd.memory.MoveBlockTask; import ghidra.app.cmd.memory.MoveBlockTask;
import ghidra.app.util.*; import ghidra.app.util.*;
@ -156,16 +157,16 @@ public class MoveBlockDialog extends DialogComponentProvider implements MoveBloc
private JPanel buildMainPanel() { private JPanel buildMainPanel() {
JPanel panel = new JPanel(new PairLayout(5, 20, 150)); JPanel panel = new JPanel(new PairLayout(5, 20, 150));
panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
blockNameLabel = new JLabel(".text"); blockNameLabel = DockingUtils.createNonHtmlLabel(".text");
blockNameLabel.setName("blockName"); // name components for junits blockNameLabel.setName("blockName"); // name components for junits
origStartLabel = new JLabel("1001000"); origStartLabel = DockingUtils.createNonHtmlLabel("1001000");
origStartLabel.setName("origStart"); origStartLabel.setName("origStart");
origEndLabel = new JLabel("1002000"); origEndLabel = DockingUtils.createNonHtmlLabel("1002000");
origEndLabel.setName("origEnd"); origEndLabel.setName("origEnd");
lengthLabel = new JLabel("4096 (0x1000)"); lengthLabel = DockingUtils.createNonHtmlLabel("4096 (0x1000)");
lengthLabel.setName("length"); lengthLabel.setName("length");
newStartField = new AddressInput(); newStartField = new AddressInput();
@ -187,17 +188,17 @@ public class MoveBlockDialog extends DialogComponentProvider implements MoveBloc
} }
}); });
panel.add(new JLabel("Name:", SwingConstants.RIGHT)); panel.add(DockingUtils.createNonHtmlLabel("Name:", SwingConstants.RIGHT));
panel.add(blockNameLabel); panel.add(blockNameLabel);
panel.add(new JLabel("Start Address:", SwingConstants.RIGHT)); panel.add(DockingUtils.createNonHtmlLabel("Start Address:", SwingConstants.RIGHT));
panel.add(origStartLabel); panel.add(origStartLabel);
panel.add(new JLabel("End Address:", SwingConstants.RIGHT)); panel.add(DockingUtils.createNonHtmlLabel("End Address:", SwingConstants.RIGHT));
panel.add(origEndLabel); panel.add(origEndLabel);
panel.add(new JLabel("Length:", SwingConstants.RIGHT)); panel.add(DockingUtils.createNonHtmlLabel("Length:", SwingConstants.RIGHT));
panel.add(lengthLabel); panel.add(lengthLabel);
panel.add(new JLabel("New Start Address:", SwingConstants.RIGHT)); panel.add(DockingUtils.createNonHtmlLabel("New Start Address:", SwingConstants.RIGHT));
panel.add(newStartField); panel.add(newStartField);
panel.add(new JLabel("New End Address:", SwingConstants.RIGHT)); panel.add(DockingUtils.createNonHtmlLabel("New End Address:", SwingConstants.RIGHT));
panel.add(newEndField); panel.add(newEndField);
return panel; return panel;
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,16 +15,6 @@
*/ */
package ghidra.app.plugin.core.memory; package ghidra.app.plugin.core.memory;
import ghidra.app.plugin.core.misc.RegisterField;
import ghidra.app.util.AddressInput;
import ghidra.app.util.HelpTopics;
import ghidra.program.model.address.*;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.util.HelpLocation;
import ghidra.util.NamingUtilities;
import ghidra.util.exception.InvalidInputException;
import ghidra.util.layout.PairLayout;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -35,6 +24,16 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.app.plugin.core.misc.RegisterField;
import ghidra.app.util.AddressInput;
import ghidra.app.util.HelpTopics;
import ghidra.program.model.address.*;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.util.HelpLocation;
import ghidra.util.NamingUtilities;
import ghidra.util.exception.InvalidInputException;
import ghidra.util.layout.PairLayout;
/** /**
* *
@ -119,13 +118,13 @@ class SplitBlockDialog extends DialogComponentProvider {
blockOneLengthField = new RegisterField(32, null, false); blockOneLengthField = new RegisterField(32, null, false);
blockOneLengthField.setName("BlockOneLength"); blockOneLengthField.setName("BlockOneLength");
panelOne.add(new JLabel("Block Name:", SwingConstants.RIGHT)); panelOne.add(DockingUtils.createNonHtmlLabel("Block Name:", SwingConstants.RIGHT));
panelOne.add(blockOneNameField); panelOne.add(blockOneNameField);
panelOne.add(new JLabel("Start Address:", SwingConstants.RIGHT)); panelOne.add(DockingUtils.createNonHtmlLabel("Start Address:", SwingConstants.RIGHT));
panelOne.add(blockOneStartField); panelOne.add(blockOneStartField);
panelOne.add(new JLabel("End Address:", SwingConstants.RIGHT)); panelOne.add(DockingUtils.createNonHtmlLabel("End Address:", SwingConstants.RIGHT));
panelOne.add(blockOneEnd); panelOne.add(blockOneEnd);
panelOne.add(new JLabel("Block Length:", SwingConstants.RIGHT)); panelOne.add(DockingUtils.createNonHtmlLabel("Block Length:", SwingConstants.RIGHT));
panelOne.add(blockOneLengthField); panelOne.add(blockOneLengthField);
JPanel panelTwo = new JPanel(new PairLayout(5, 5, 150)); JPanel panelTwo = new JPanel(new PairLayout(5, 5, 150));
@ -140,13 +139,13 @@ class SplitBlockDialog extends DialogComponentProvider {
blockTwoLengthField = new RegisterField(32, null, false); blockTwoLengthField = new RegisterField(32, null, false);
blockTwoLengthField.setName("BlockTwoLength"); blockTwoLengthField.setName("BlockTwoLength");
panelTwo.add(new JLabel("Block Name:", SwingConstants.RIGHT)); panelTwo.add(DockingUtils.createNonHtmlLabel("Block Name:", SwingConstants.RIGHT));
panelTwo.add(blockTwoNameField); panelTwo.add(blockTwoNameField);
panelTwo.add(new JLabel("Start Address:", SwingConstants.RIGHT)); panelTwo.add(DockingUtils.createNonHtmlLabel("Start Address:", SwingConstants.RIGHT));
panelTwo.add(blockTwoStart); panelTwo.add(blockTwoStart);
panelTwo.add(new JLabel("End Address:", SwingConstants.RIGHT)); panelTwo.add(DockingUtils.createNonHtmlLabel("End Address:", SwingConstants.RIGHT));
panelTwo.add(blockTwoEndField); panelTwo.add(blockTwoEndField);
panelTwo.add(new JLabel("Block Length:", SwingConstants.RIGHT)); panelTwo.add(DockingUtils.createNonHtmlLabel("Block Length:", SwingConstants.RIGHT));
panelTwo.add(blockTwoLengthField); panelTwo.add(blockTwoLengthField);
JPanel mainPanel = new JPanel(); JPanel mainPanel = new JPanel();
@ -202,6 +201,7 @@ class SplitBlockDialog extends DialogComponentProvider {
blockTwoStart.addChangeListener(new AddressChangeListener(blockTwoStart)); blockTwoStart.addChangeListener(new AddressChangeListener(blockTwoStart));
ActionListener al = new ActionListener() { ActionListener al = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
setStatusText(""); setStatusText("");
} }
@ -227,6 +227,7 @@ class SplitBlockDialog extends DialogComponentProvider {
this.source = source; this.source = source;
} }
@Override
public void stateChanged(ChangeEvent event) { public void stateChanged(ChangeEvent event) {
setStatusText(""); setStatusText("");
boolean ok = false; boolean ok = false;
@ -331,6 +332,7 @@ class SplitBlockDialog extends DialogComponentProvider {
this.source = source; this.source = source;
} }
@Override
public void stateChanged(ChangeEvent event) { public void stateChanged(ChangeEvent event) {
setStatusText(""); setStatusText("");
boolean ok = false; boolean ok = false;
@ -385,8 +387,8 @@ class SplitBlockDialog extends DialogComponentProvider {
} }
long blockSize = block.getSize(); long blockSize = block.getSize();
if (length > blockSize) { if (length > blockSize) {
setStatusText("End address must be less than original block end (" + setStatusText(
block.getEnd() + ")"); "End address must be less than original block end (" + block.getEnd() + ")");
return false; return false;
} }
blockOneLengthField.setValue(new Long(length)); blockOneLengthField.setValue(new Long(length));

View file

@ -90,11 +90,11 @@ public class AddressTypeOverviewColorService
AddressType addressType = getAddressType(address); AddressType addressType = getAddressType(address);
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("<b>"); buffer.append("<b>");
buffer.append(getName()); buffer.append(HTMLUtilities.friendlyEncodeHTML(getName()));
buffer.append("</b>\n"); buffer.append("</b>\n");
buffer.append(addressType.getDescription()); buffer.append(addressType.getDescription());
buffer.append(" ("); buffer.append(" (");
buffer.append(getBlockName(address)); buffer.append(HTMLUtilities.friendlyEncodeHTML(getBlockName(address)));
buffer.append(" "); buffer.append(" ");
buffer.append(address); buffer.append(address);
buffer.append(" )"); buffer.append(" )");

View file

@ -21,6 +21,7 @@ import java.awt.event.MouseEvent;
import javax.swing.*; import javax.swing.*;
import docking.DockingUtils;
import ghidra.util.layout.PairLayout; import ghidra.util.layout.PairLayout;
/** /**
@ -50,7 +51,7 @@ public class AddressTypeOverviewLegendPanel extends JPanel {
for (AddressType addressType : values) { for (AddressType addressType : values) {
JPanel panel = new ColorPanel(addressType); JPanel panel = new ColorPanel(addressType);
add(panel); add(panel);
add(new JLabel(addressType.getDescription())); add(DockingUtils.createNonHtmlLabel(addressType.getDescription()));
} }
} }

View file

@ -86,19 +86,19 @@ public class EntropyOverviewColorService implements OverviewColorService {
} }
int entropyScaled = computeEntropy(address); int entropyScaled = computeEntropy(address);
double entropy = (entropyScaled * 8.0d) / 255; // convert back from palette scale to original entropy value double entropy = (entropyScaled * 8.0d) / 255; // convert back from palette scale to original entropy value
StringBuffer buffer = new StringBuffer(); StringBuilder buffer = new StringBuilder();
buffer.append("<b>"); buffer.append("<b>");
buffer.append(getName()); buffer.append(HTMLUtilities.friendlyEncodeHTML(getName()));
buffer.append("</b>\n"); buffer.append("</b>\n");
buffer.append(" "); buffer.append(" ");
buffer.append(formatter.format(entropy)); buffer.append(formatter.format(entropy));
buffer.append(" "); buffer.append(" ");
buffer.append(getKnotName(entropyScaled)); buffer.append(HTMLUtilities.friendlyEncodeHTML(getKnotName(entropyScaled)));
buffer.append(" "); buffer.append(" ");
buffer.append(" &nbsp&nbsp&nbsp("); buffer.append(" &nbsp&nbsp&nbsp(");
buffer.append(getBlockName(address)); buffer.append(HTMLUtilities.friendlyEncodeHTML(getBlockName(address)));
buffer.append(" "); buffer.append(" ");
buffer.append(address); buffer.append(HTMLUtilities.friendlyEncodeHTML(address.toString()));
buffer.append(" )"); buffer.append(" )");
return HTMLUtilities.toWrappedHTML(buffer.toString(), 0); return HTMLUtilities.toWrappedHTML(buffer.toString(), 0);
} }

View file

@ -25,6 +25,7 @@ import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import docking.util.GraphicsUtils; import docking.util.GraphicsUtils;
/** /**
@ -133,7 +134,7 @@ public class KnotPanel extends JPanel implements ComponentListener {
ArrayList<KnotRecord> knots = palette.getKnots(); ArrayList<KnotRecord> knots = palette.getKnots();
for (KnotRecord record : knots) { for (KnotRecord record : knots) {
JLabel label = new JLabel(record.name); JLabel label = DockingUtils.createNonHtmlLabel(record.name);
label.setFont(FONT); label.setFont(FONT);
label.setBorder(new ToplessLineBorder(Color.BLACK)); label.setBorder(new ToplessLineBorder(Color.BLACK));
label.setHorizontalAlignment(SwingConstants.CENTER); label.setHorizontalAlignment(SwingConstants.CENTER);

View file

@ -17,7 +17,8 @@ package ghidra.app.plugin.core.overview.entropy;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.JPanel;
/** /**
* Panel for display the Entropy color legend. * Panel for display the Entropy color legend.
@ -33,22 +34,12 @@ public class LegendPanel extends JPanel {
add(buildHeader(), BorderLayout.NORTH); add(buildHeader(), BorderLayout.NORTH);
add(palettePanel, BorderLayout.WEST); add(palettePanel, BorderLayout.WEST);
add(knotPanel, BorderLayout.CENTER); add(knotPanel, BorderLayout.CENTER);
// add(buildFooter(), BorderLayout.SOUTH);
setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
} }
private Component buildHeader() { private Component buildHeader() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
// panel.add(new JLabel("Entropy range: 0.0 - 8.0"), BorderLayout.CENTER);
// panel.add(new JLabel("Min Entropy (0.0)"), BorderLayout.CENTER);
return panel;
}
private Component buildFooter() {
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
panel.add(new JLabel("Max Entropy (8.0)"), BorderLayout.CENTER);
return panel; return panel;
} }

View file

@ -113,11 +113,12 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
} }
}; };
setLanguageAction.setPopupMenuData(new MenuData(new String[] { "Set Language..." }, setLanguageAction.setPopupMenuData(
"Language")); new MenuData(new String[] { "Set Language..." }, "Language"));
setLanguageAction.setEnabled(true); setLanguageAction.setEnabled(true);
setLanguageAction.setHelpLocation(new HelpLocation("LanguageProviderPlugin", "set language")); setLanguageAction.setHelpLocation(
new HelpLocation("LanguageProviderPlugin", "set language"));
tool.addAction(setLanguageAction); tool.addAction(setLanguageAction);
} }
@ -142,22 +143,23 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
String dfName = domainFile.getName(); String dfName = domainFile.getName();
if (domainFile.isReadOnly()) { if (domainFile.isReadOnly()) {
Msg.showInfo(getClass(), tool.getToolFrame(), "Permission Denied", dfName + Msg.showInfo(getClass(), tool.getToolFrame(), "Permission Denied", "Program " + dfName +
" is read-only!\n" + "Set language may not be done on a read-only Program."); " is read-only!\n" + "Set language may not be done on a read-only Program.");
return; return;
} }
if (!domainFile.getConsumers().isEmpty() || domainFile.isBusy()) { if (!domainFile.getConsumers().isEmpty() || domainFile.isBusy()) {
Msg.showInfo(getClass(), tool.getToolFrame(), "File In-Use", dfName + " is in-use!\n" + Msg.showInfo(getClass(), tool.getToolFrame(), "File In-Use",
"Set language may not be done while the associated file is\n" + "Program " + dfName + " is in-use!\n" +
"open or in-use. Be sure the file is not open in a tool."); "Set language may not be done while the associated file is\n" +
"open or in-use. Be sure the file is not open in a tool.");
return; return;
} }
if (domainFile.isCheckedOut() && !domainFile.isCheckedOutExclusive()) { if (domainFile.isCheckedOut() && !domainFile.isCheckedOutExclusive()) {
String msg = String msg = (domainFile.modifiedSinceCheckout() || domainFile.isChanged())
(domainFile.modifiedSinceCheckout() || domainFile.isChanged()) ? "check-in this file" ? "check-in this file"
: "undo your checkout"; : "undo your checkout";
Msg.showInfo(getClass(), tool.getToolFrame(), "Exclusive Checkout Required", Msg.showInfo(getClass(), tool.getToolFrame(), "Exclusive Checkout Required",
"You do not have an exclusive checkout of: " + dfName + "\n \n" + "You do not have an exclusive checkout of: " + dfName + "\n \n" +
@ -171,28 +173,25 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
String msg = "Setting the language can not be undone!\n"; String msg = "Setting the language can not be undone!\n";
if (domainFile.modifiedSinceCheckout()) { if (domainFile.modifiedSinceCheckout()) {
msg += msg += "\nIt is highly recommended that you check-in your recent\n" +
"\nIt is highly recommended that you check-in your recent\n" "changes before performing this operation.";
+ "changes before performing this operation.";
} }
else if (!domainFile.isCheckedOut()) { else if (!domainFile.isCheckedOut()) {
msg += msg += "\nIt is highly recommended that you make a copy of the\n" +
"\nIt is highly recommended that you make a copy of the\n" "selected file before performing this operation.";
+ "selected file before performing this operation.";
} }
ToolTemplate defaultToolTemplate = ToolTemplate defaultToolTemplate =
tool.getToolServices().getDefaultToolTemplate(domainFile); tool.getToolServices().getDefaultToolTemplate(domainFile);
String toolMsg = String toolMsg = defaultToolTemplate == null
defaultToolTemplate == null ? "WARNING! Without a default tool the file " ? "WARNING! Without a default tool the file " +
+ "will be overwritten\nwhen the Set Language is complete." "will be overwritten\nwhen the Set Language is complete."
: "When complete you can Save the results or Open the results\nin the " + : "When complete you can Save the results or Open the results\nin the " +
defaultToolTemplate.getName() + " tool"; defaultToolTemplate.getName() + " tool";
int result = int result = OptionDialog.showOptionDialog(tool.getToolFrame(), "Set Language: " + dfName,
OptionDialog.showOptionDialog(tool.getToolFrame(), "Set Language: " + dfName, msg + msg + "\n \n" + toolMsg + "\n \nDo you want to continue?", "Ok",
"\n \n" + toolMsg + "\n \nDo you want to continue?", "Ok", OptionDialog.WARNING_MESSAGE);
OptionDialog.WARNING_MESSAGE);
if (result > 0) { if (result > 0) {
final SetLanguageTask task = new SetLanguageTask(domainFile); final SetLanguageTask task = new SetLanguageTask(domainFile);
new TaskLauncher(task, tool.getToolFrame(), 0); new TaskLauncher(task, tool.getToolFrame(), 0);
@ -326,8 +325,7 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
try { try {
SwingUtilities.invokeAndWait(() -> { SwingUtilities.invokeAndWait(() -> {
ToolServices toolServices = tool.getToolServices(); ToolServices toolServices = tool.getToolServices();
String defaultToolName = String defaultToolName = toolServices.getDefaultToolTemplate(file).getName();
toolServices.getDefaultToolTemplate(file).getName();
for (Tool t : toolServices.getRunningTools()) { for (Tool t : toolServices.getRunningTools()) {
if (t.getName().equals(defaultToolName)) { if (t.getName().equals(defaultToolName)) {
openTool = (PluginTool) t; openTool = (PluginTool) t;

View file

@ -27,8 +27,7 @@ import java.util.List;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import docking.ActionContext; import docking.*;
import docking.ToolTipManager;
import docking.action.DockingAction; import docking.action.DockingAction;
import docking.action.MenuData; import docking.action.MenuData;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
@ -95,7 +94,7 @@ public class ShowInstructionInfoPlugin extends ProgramPlugin {
private void createStatusPanels() { private void createStatusPanels() {
instructionPanel = new JPanel(new BorderLayout()); instructionPanel = new JPanel(new BorderLayout());
instructionLabel = new JLabel(" "); instructionLabel = DockingUtils.createNonHtmlLabel(" ");
instructionPanel.setPreferredSize( instructionPanel.setPreferredSize(
new Dimension(200, instructionLabel.getPreferredSize().height)); new Dimension(200, instructionLabel.getPreferredSize().height));
ToolTipManager.setToolTipText(instructionLabel, CURRENT_INSTRUCTION_PREPEND_STRING); ToolTipManager.setToolTipText(instructionLabel, CURRENT_INSTRUCTION_PREPEND_STRING);
@ -104,7 +103,7 @@ public class ShowInstructionInfoPlugin extends ProgramPlugin {
tool.addStatusComponent(instructionPanel, true, false); tool.addStatusComponent(instructionPanel, true, false);
functionPanel = new JPanel(new BorderLayout()); functionPanel = new JPanel(new BorderLayout());
functionLabel = new JLabel(" "); functionLabel = DockingUtils.createNonHtmlLabel(" ");
functionLabel.addMouseListener(new MouseAdapter() { functionLabel.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@ -122,7 +121,7 @@ public class ShowInstructionInfoPlugin extends ProgramPlugin {
tool.addStatusComponent(functionPanel, true, false); tool.addStatusComponent(functionPanel, true, false);
addressPanel = new JPanel(new BorderLayout()); addressPanel = new JPanel(new BorderLayout());
addressLabel = new JLabel(" "); addressLabel = DockingUtils.createNonHtmlLabel(" ");
addressPanel.setPreferredSize(new Dimension(95, addressLabel.getPreferredSize().height)); addressPanel.setPreferredSize(new Dimension(95, addressLabel.getPreferredSize().height));
ToolTipManager.setToolTipText(addressLabel, "Current Address"); ToolTipManager.setToolTipText(addressLabel, "Current Address");
addressPanel.add(addressLabel); addressPanel.add(addressLabel);

View file

@ -24,6 +24,7 @@ import java.util.Map.Entry;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import docking.DockingUtils;
import docking.util.KeyBindingUtils; import docking.util.KeyBindingUtils;
import generic.util.WindowUtilities; import generic.util.WindowUtilities;
import ghidra.framework.model.ProjectLocator; import ghidra.framework.model.ProjectLocator;
@ -227,7 +228,7 @@ public class MultiTabPanel extends JPanel {
final JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 1)); final JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 1));
labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10)); labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10));
final JLabel nameLabel = new JLabel(); JLabel nameLabel = DockingUtils.createNonHtmlLabel();
nameLabel.setIconTextGap(1); nameLabel.setIconTextGap(1);
nameLabel.setName("objectName"); // junit access nameLabel.setName("objectName"); // junit access
nameLabel.setFont(LABEL_FONT); nameLabel.setFont(LABEL_FONT);
@ -236,7 +237,7 @@ public class MultiTabPanel extends JPanel {
labelPanel.add(nameLabel); labelPanel.add(nameLabel);
final JLabel iconLabel = new JLabel(EMPTY16_ICON); JLabel iconLabel = DockingUtils.createNonHtmlLabel(EMPTY16_ICON);
Icon icon = isSelected ? CLOSE_ICON : EMPTY16_ICON; Icon icon = isSelected ? CLOSE_ICON : EMPTY16_ICON;
iconLabel.setIcon(icon); iconLabel.setIcon(icon);
@ -642,7 +643,7 @@ public class MultiTabPanel extends JPanel {
} }
private JLabel createLabel() { private JLabel createLabel() {
final JLabel newLabel = new JLabel(LIST_ICON, SwingConstants.LEFT); JLabel newLabel = DockingUtils.createNonHtmlLabel(LIST_ICON, SwingConstants.LEFT);
newLabel.setIconTextGap(0); newLabel.setIconTextGap(0);
newLabel.setFont(LIST_LABEL_FONT); newLabel.setFont(LIST_LABEL_FONT);
newLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4)); newLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4));

View file

@ -29,10 +29,13 @@ import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.Document; import javax.swing.text.Document;
import docking.widgets.list.GListCellRenderer;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
/** /**
* Panel that shows a JList * Panel that displays the overflow of currently open programs that can be choosen.
* <p>
* Programs that don't have a visible tab are displayed in bold.
*/ */
class ProgramListPanel extends JPanel { class ProgramListPanel extends JPanel {
@ -123,7 +126,7 @@ class ProgramListPanel extends JPanel {
} }
}); });
programList.setCellRenderer(new MyListCellRenderer<Program>()); programList.setCellRenderer(new ProgramListCellRenderer());
JScrollPane sp = new JScrollPane(); JScrollPane sp = new JScrollPane();
sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
@ -187,7 +190,7 @@ class ProgramListPanel extends JPanel {
} }
private void filterList(String filterText) { private void filterList(String filterText) {
List<Program> allDataList = new ArrayList<Program>(); List<Program> allDataList = new ArrayList<>();
allDataList.addAll(hiddenList); allDataList.addAll(hiddenList);
allDataList.addAll(shownList); allDataList.addAll(shownList);
@ -227,31 +230,20 @@ class ProgramListPanel extends JPanel {
} }
} }
private class MyListCellRenderer<T> extends JLabel implements ListCellRenderer<T> { private class ProgramListCellRenderer extends GListCellRenderer<Program> {
private Font boldFont;
private Font font;
MyListCellRenderer() { @Override
setOpaque(true); protected String getItemText(Program program) {
return multiTabPlugin.getStringUsedInList(program);
} }
@Override @Override
public Component getListCellRendererComponent(JList<? extends T> list, T value, int index, public Component getListCellRendererComponent(JList<? extends Program> list, Program value,
boolean isSelected, boolean cellHasFocus) { int index, boolean isSelected, boolean hasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, hasFocus);
if (font == null) {
font = list.getFont();
font = new Font(font.getName(), Font.PLAIN, font.getSize());
boldFont = new Font(font.getName(), Font.BOLD, font.getSize());
}
String text = multiTabPlugin.getStringUsedInList((Program) value);
setText(text);
if (hiddenList.contains(value)) { if (hiddenList.contains(value)) {
setFont(boldFont); setBold();
}
else {
setFont(font);
} }
if (isSelected) { if (isSelected) {
setBackground(list.getSelectionBackground()); setBackground(list.getSelectionBackground());
@ -261,7 +253,7 @@ class ProgramListPanel extends JPanel {
setBackground(list.getBackground()); setBackground(list.getBackground());
setForeground(list.getForeground()); setForeground(list.getForeground());
} }
setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 10));
return this; return this;
} }
} }

Some files were not shown because too many files have changed in this diff Show more