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
@@ -162,7 +162,7 @@ public class SampleTableProvider extends ComponentProviderAdapter implements Opt
StringBuilder buffer = new StringBuilder();
buffer.append("Writing the following objects to file: ");
buffer.append(fileChooserPanel.getFileName());
buffer.append(HTMLUtilities.friendlyEncodeHTML(fileChooserPanel.getFileName()));
List<FunctionStatsRowObject> selectedObjects = filterTable.getSelectedRowObjects();
for (FunctionStatsRowObject stats : selectedObjects) {
@@ -28,8 +28,7 @@ import javax.swing.event.DocumentListener;
import org.apache.commons.lang3.StringUtils;
import docking.ActionContext;
import docking.ComponentProvider;
import docking.*;
import docking.action.ToggleDockingAction;
import docking.action.ToolBarData;
import docking.menu.ActionState;
@@ -146,7 +145,7 @@ public class SampleGraphProvider extends ComponentProviderAdapter {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
JLabel label = new JLabel("Vertex Filter: ");
JLabel label = DockingUtils.createNonHtmlLabel("Vertex Filter: ");
label.setToolTipText(
"Vertices with names matching the filter will remain, along with connected vertices");
panel.add(label);
@@ -198,7 +197,7 @@ public class SampleGraphProvider extends ComponentProviderAdapter {
fadedButton.setSelected(true);
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(removedButton);
return panel;
@@ -207,7 +206,7 @@ public class SampleGraphProvider extends ComponentProviderAdapter {
private void installTooltipProvider() {
VertexTooltipProvider<SampleVertex, SampleEdge> tooltipProvider =
new VertexTooltipProvider<SampleVertex, SampleEdge>() {
new VertexTooltipProvider<>() {
@Override
public JComponent getTooltip(SampleVertex v) {
@@ -342,8 +341,7 @@ public class SampleGraphProvider extends ComponentProviderAdapter {
private void addLayoutAction() {
MultiStateDockingAction<LayoutProvider<SampleVertex, SampleEdge, SampleGraph>> layoutAction =
new MultiStateDockingAction<LayoutProvider<SampleVertex, SampleEdge, SampleGraph>>(
RELAYOUT_GRAPH_ACTION_NAME, plugin.getName()) {
new MultiStateDockingAction<>(RELAYOUT_GRAPH_ACTION_NAME, plugin.getName()) {
@Override
protected void doActionPerformed(ActionContext context) {
@@ -23,6 +23,8 @@ import java.awt.event.ActionListener;
import javax.swing.*;
import docking.DockingUtils;
public class SearchGuiSingle extends SearchBaseExtended {
private JButton searchButton;
@@ -48,7 +50,7 @@ public class SearchGuiSingle extends SearchBaseExtended {
opTwoCheckBox = new JCheckBox("Operand 2", false);
constCheckBox = new JCheckBox("Constants", false);
searchButton = new JButton();
jLabel1 = new JLabel();
jLabel1 = DockingUtils.createNonHtmlLabel();
GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
@@ -20,8 +20,7 @@ import java.awt.event.*;
import javax.swing.*;
import docking.ActionContext;
import docking.WindowPosition;
import docking.*;
import docking.options.editor.ButtonPanelFactory;
import docking.widgets.OptionDialog;
import ghidra.app.context.ListingActionContext;
@@ -106,9 +105,9 @@ class MergeManagerProvider extends ComponentProviderAdapter {
ListingMergePanel listingMergePanel = (ListingMergePanel) currentComponent;
Object actionContext = listingMergePanel.getActionContext(event);
if (actionContext instanceof ProgramLocation) {
ListingActionContext listingActionContext =
new ListingActionContext(this, navigatable, (ProgramLocation) actionContext);
return listingActionContext;
ListingActionContext listingActionContext = new ListingActionContext(this,
navigatable, (ProgramLocation) actionContext);
return listingActionContext;
}
}
ProgramLocation programLocation = navigatable.getLocation();
@@ -206,11 +205,11 @@ class MergeManagerProvider extends ComponentProviderAdapter {
mainPanel.setLayout(new BorderLayout(0, 10));
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();
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(iconLabel);
iconPanel.add(Box.createHorizontalStrut(5));
@@ -248,9 +247,8 @@ class MergeManagerProvider extends ComponentProviderAdapter {
}
});
JPanel panel =
ButtonPanelFactory.createButtonPanel(new JButton[] { applyButton, cancelButton },
ButtonPanelFactory.X_AXIS);
JPanel panel = ButtonPanelFactory.createButtonPanel(
new JButton[] { applyButton, cancelButton }, ButtonPanelFactory.X_AXIS);
return panel;
}
@@ -264,7 +262,7 @@ class MergeManagerProvider extends ComponentProviderAdapter {
phasePanel = new PhaseProgressPanel("Progress In Current Phase");
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.
conflictPanel.add(defaultPanel, DEFAULT_ID);
conflictPanel.setPreferredSize(new Dimension(610, 500));
@@ -22,6 +22,7 @@ import java.util.HashMap;
import javax.swing.*;
import javax.swing.border.Border;
import docking.DockingUtils;
import ghidra.util.Msg;
import ghidra.util.layout.VerticalLayout;
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 COMPLETED_ICON =
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;
/**
@@ -56,18 +57,18 @@ public class MergeProgressPanel extends JPanel {
BoxLayout bl = new BoxLayout(phasesTitlePanel, BoxLayout.X_AXIS);
phasesTitlePanel.setLayout(bl);
phasesTitlePanel.add(Box.createHorizontalStrut(5));
phasesTitlePanel.add(new JLabel("Merge Status"));
phasesTitlePanel.add(DockingUtils.createNonHtmlLabel("Merge Status"));
phasesTitlePanel.add(Box.createHorizontalStrut(15));
phasesTitlePanel.add(new JLabel("( "));
phasesTitlePanel.add(new JLabel(DEFINED_ICON));
phasesTitlePanel.add(new JLabel(" = Pending"));
phasesTitlePanel.add(DockingUtils.createNonHtmlLabel("( "));
phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(DEFINED_ICON));
phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(" = Pending"));
phasesTitlePanel.add(Box.createHorizontalStrut(10));
phasesTitlePanel.add(new JLabel(IN_PROGRESS_ICON));
phasesTitlePanel.add(new JLabel(" = In Progress"));
phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(IN_PROGRESS_ICON));
phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(" = In Progress"));
phasesTitlePanel.add(Box.createHorizontalStrut(10));
phasesTitlePanel.add(new JLabel(COMPLETED_ICON));
phasesTitlePanel.add(new JLabel(" = Completed"));
phasesTitlePanel.add(new JLabel(" )"));
phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(COMPLETED_ICON));
phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(" = Completed"));
phasesTitlePanel.add(DockingUtils.createNonHtmlLabel(" )"));
phasesTitlePanel.add(Box.createHorizontalStrut(5));
return phasesTitlePanel;
}
@@ -83,8 +84,8 @@ public class MergeProgressPanel extends JPanel {
*/
public JPanel addInfo(String[] phase) {
int phaseDepth = phase.length - 1;
JLabel imageLabel = new JLabel(DEFINED_ICON);
JLabel infoLabel = new JLabel(phase[phaseDepth]);
JLabel imageLabel = DockingUtils.createNonHtmlLabel(DEFINED_ICON);
JLabel infoLabel = DockingUtils.createNonHtmlLabel(phase[phaseDepth]);
JPanel labelPanel = new JPanel();
labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
BoxLayout bl = new BoxLayout(labelPanel, BoxLayout.X_AXIS);
@@ -22,9 +22,9 @@ import java.awt.event.ActionListener;
import javax.swing.*;
import docking.DockingUtils;
import resources.ResourceManager;
/**
* The PhaseProgressPanel provides a title, progress bar and message for the current phase that is
* in progress
@@ -33,7 +33,7 @@ public class PhaseProgressPanel extends JPanel {
private final static String DEFAULT_INFO = "Merge programs in progress...";
private ImageIcon INFORM_ICON = ResourceManager.loadImage("images/information.png");
private JLabel titleLabel;
private JProgressBar progressBar;
private JPanel progressMessagePanel;
@@ -43,13 +43,13 @@ public class PhaseProgressPanel extends JPanel {
private boolean isShowingMessage = false;
private String title;
private SpringLayout progressLayout;
private Timer updateTimer;
private boolean isTimerRunning;
private String message;
private int progress;
private int lastProgress =-1;
private int lastProgress = -1;
public PhaseProgressPanel(String title) {
this.title = title;
progressLayout = new SpringLayout();
@@ -57,13 +57,13 @@ public class PhaseProgressPanel extends JPanel {
createProgressPanel();
adjustPreferredSize();
}
/**
* Determines and sets the preferred size of this panel.
*/
private void adjustPreferredSize() {
int width = titleLabel.getPreferredSize().width+5;
int height = titleLabel.getPreferredSize().height+5;
int width = titleLabel.getPreferredSize().width + 5;
int height = titleLabel.getPreferredSize().height + 5;
if (isShowingProgress) {
height += 5;
height += progressBar.getPreferredSize().height;
@@ -79,28 +79,30 @@ public class PhaseProgressPanel extends JPanel {
}
private void createProgressPanel() {
titleLabel = new JLabel(title);
titleLabel = DockingUtils.createNonHtmlLabel(title);
add(titleLabel);
progressLayout.putConstraint(SpringLayout.WEST, titleLabel, 5, SpringLayout.WEST, this);
progressLayout.putConstraint(SpringLayout.NORTH, titleLabel, 5, SpringLayout.NORTH, this);
progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
Dimension dim = progressBar.getPreferredSize();
progressBar.setPreferredSize(new Dimension(500, (int)dim.getHeight()));
progressBar.setPreferredSize(new Dimension(500, (int) dim.getHeight()));
progressBar.setMaximum(100);
progressLayout.putConstraint(SpringLayout.NORTH, progressBar, 5, SpringLayout.SOUTH, titleLabel);
progressLayout.putConstraint(SpringLayout.WEST, progressBar, 0, SpringLayout.WEST, titleLabel);
progressLayout.putConstraint(SpringLayout.NORTH, progressBar, 5, SpringLayout.SOUTH,
titleLabel);
progressLayout.putConstraint(SpringLayout.WEST, progressBar, 0, SpringLayout.WEST,
titleLabel);
doSetProgress(0);
progressMessagePanel = new JPanel(new BorderLayout());
messageIcon = new JLabel(INFORM_ICON);
messageIcon = DockingUtils.createNonHtmlLabel(INFORM_ICON);
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(messageLabel, BorderLayout.CENTER);
doSetMessage(DEFAULT_INFO);
// Sets up the timer for updating the GUI.
updateTimer = new Timer(250, new ActionListener() {
@Override
@@ -109,7 +111,7 @@ public class PhaseProgressPanel extends JPanel {
}
});
}
// Method for use by the timer to update the progress bar or message.
private synchronized void update() {
boolean changed = false;
@@ -128,7 +130,7 @@ public class PhaseProgressPanel extends JPanel {
isTimerRunning = false;
}
}
/**
* Method to get the panel to update with changes when already on the screen.
*/
@@ -137,7 +139,7 @@ public class PhaseProgressPanel extends JPanel {
repaint();
adjustPreferredSize();
}
/**
* Sets the title line displayed by this panel.
* @param newTitle the new title string
@@ -146,7 +148,7 @@ public class PhaseProgressPanel extends JPanel {
titleLabel.setText(newTitle);
doValidate();
}
/**
* Sets the progress message within this panel.
* @param newMessage the new message text to be displayed.
@@ -155,15 +157,15 @@ public class PhaseProgressPanel extends JPanel {
messageLabel.setText(newMessage);
if (!isShowingMessage) {
add(progressMessagePanel);
progressLayout.putConstraint(SpringLayout.WEST, progressMessagePanel, 0,
SpringLayout.WEST, titleLabel);
progressLayout.putConstraint(SpringLayout.NORTH, progressMessagePanel, 5,
SpringLayout.SOUTH, (isShowingProgress ? progressBar : titleLabel));
isShowingMessage = true;
}
doValidate();
progressLayout.putConstraint(SpringLayout.WEST, progressMessagePanel, 0,
SpringLayout.WEST, titleLabel);
progressLayout.putConstraint(SpringLayout.NORTH, progressMessagePanel, 5,
SpringLayout.SOUTH, (isShowingProgress ? progressBar : titleLabel));
isShowingMessage = true;
}
doValidate();
}
/**
* Sets the progress message within this panel.
* @param message the new message text to be displayed.
@@ -175,23 +177,24 @@ public class PhaseProgressPanel extends JPanel {
isTimerRunning = true;
}
}
/**
* Fills in the progress bar to the indicated percent.
* @param progressPercentage total percent of the progress bar that should be filled in.
*/
private void doSetProgress(final int progressPercentage) {
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) {
add(progressBar);
isShowingProgress = true;
}
isShowingProgress = true;
}
progressBar.setValue(progressPercentage);
doValidate();
}
/**
* Fills in the progress bar to the indicated percent.
* @param progressPercentage total percent of the progress bar that should be filled in.
@@ -203,7 +206,7 @@ public class PhaseProgressPanel extends JPanel {
isTimerRunning = true;
}
}
/**
* Removes the message from being displayed by this panel.
* Setting the message text will cause it to get added again.
@@ -213,7 +216,7 @@ public class PhaseProgressPanel extends JPanel {
isShowingMessage = false;
doValidate();
}
/**
* Removes the progress bar from being displayed by this panel.
* Setting progress will cause it to get added again.
@@ -221,12 +224,13 @@ public class PhaseProgressPanel extends JPanel {
public void removeProgress() {
remove(progressBar);
if (isShowingMessage) {
progressLayout.putConstraint(SpringLayout.NORTH, messageIcon, 5, SpringLayout.SOUTH, titleLabel);
progressLayout.putConstraint(SpringLayout.NORTH, messageIcon, 5, SpringLayout.SOUTH,
titleLabel);
}
isShowingProgress = false;
doValidate();
}
// /**
// * @param args
// */
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +22,7 @@ import java.awt.event.ItemListener;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.app.merge.MergeConstants;
/**
@@ -31,10 +31,10 @@ import ghidra.app.merge.MergeConstants;
*
*/
class CategoryConflictPanel extends JPanel {
public static final String LATEST_BUTTON_NAME = "LatestVersionRB";
public static final String CHECKED_OUT_BUTTON_NAME = "CheckedOutVersionRB";
public static final String ORIGINAL_BUTTON_NAME = "OriginalVersionRB";
public static final String LATEST_BUTTON_NAME = "LatestVersionRB";
public static final String CHECKED_OUT_BUTTON_NAME = "CheckedOutVersionRB";
public static final String ORIGINAL_BUTTON_NAME = "OriginalVersionRB";
private ChangeListener listener;
private JRadioButton latestRB;
private JRadioButton myRB;
@@ -42,7 +42,6 @@ class CategoryConflictPanel extends JPanel {
private ButtonGroup group;
private JPanel rbPanel;
private JLabel categoryLabel;
CategoryConflictPanel(String title, ChangeListener listener) {
super(new BorderLayout());
@@ -50,24 +49,24 @@ class CategoryConflictPanel extends JPanel {
create();
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);
group.remove(latestRB);
group.remove(myRB);
group.remove(originalRB);
latestRB.setText(latestStr);
latestRB.setText(latestStr);
myRB.setText(myStr);
originalRB.setText(origStr);
latestRB.setSelected(false);
myRB.setSelected(false);
originalRB.setSelected(false);
addToButtonGroup();
}
int getSelectedOption() {
if (latestRB.isSelected()) {
return DataTypeMergeManager.OPTION_LATEST;
@@ -85,39 +84,40 @@ class CategoryConflictPanel extends JPanel {
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JLabel clabel = new JLabel("Category: ");
categoryLabel = new JLabel("CategoryName");
JLabel clabel = DockingUtils.createNonHtmlLabel("Category: ");
categoryLabel = DockingUtils.createNonHtmlLabel("CategoryName");
categoryLabel.setForeground(MergeConstants.CONFLICT_COLOR);
JPanel labelPanel = new JPanel();
labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.X_AXIS));
labelPanel.add(clabel);
labelPanel.add(Box.createHorizontalStrut(5));
labelPanel.add(categoryLabel);
latestRB = new JRadioButton("Use Latest");
myRB = new JRadioButton("Use My Version");
originalRB = new JRadioButton("Use Original");
latestRB.setName(LATEST_BUTTON_NAME);
myRB.setName(CHECKED_OUT_BUTTON_NAME);
originalRB.setName(ORIGINAL_BUTTON_NAME);
group = new ButtonGroup();
addToButtonGroup();
rbPanel = new JPanel();
rbPanel.setLayout(new BoxLayout(rbPanel, BoxLayout.Y_AXIS));
rbPanel.add(latestRB);
rbPanel.add(myRB);
rbPanel.add(originalRB);
panel.add(labelPanel, BorderLayout.NORTH);
panel.add(rbPanel, BorderLayout.CENTER);
add(panel);
ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (listener != null) {
listener.stateChanged(null);
@@ -129,9 +129,10 @@ class CategoryConflictPanel extends JPanel {
originalRB.addItemListener(itemListener);
}
private void addToButtonGroup() {
group.add(latestRB);
group.add(myRB);
group.add(originalRB);
}
}
}
@@ -22,6 +22,7 @@ import java.awt.event.ItemListener;
import javax.swing.*;
import docking.DockingUtils;
import docking.widgets.MultiLineLabel;
import ghidra.app.merge.MergeConstants;
import ghidra.app.merge.util.ConflictCountPanel;
@@ -178,13 +179,13 @@ class DataTypeMergePanel extends JPanel {
private JPanel createInfoPanel() {
Icon icon = ResourceManager.loadImage("images/information.png");
JLabel imageLabel = new JLabel(icon);
JLabel imageLabel = DockingUtils.createNonHtmlLabel(icon);
MultiLineLabel label =
new MultiLineLabel("A data type change in your checked out version conflicts with a "
+ "data type change in the latest version.\n"
+ "Select the data type change you want included in the version "
+ "that will result from this check-in.");
new MultiLineLabel("A data type change in your checked out version conflicts with a " +
"data type change in the latest version.\n" +
"Select the data type change you want included in the version " +
"that will result from this check-in.");
JPanel labelPanel = new JPanel();
labelPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));
@@ -22,6 +22,7 @@ import java.awt.event.ItemListener;
import javax.swing.*;
import docking.DockingUtils;
import docking.widgets.MultiLineLabel;
import ghidra.app.merge.MergeConstants;
import ghidra.app.merge.util.ConflictCountPanel;
@@ -173,14 +174,13 @@ class SourceArchiveMergePanel extends JPanel {
private JPanel createInfoPanel() {
Icon icon = ResourceManager.loadImage("images/information.png");
JLabel imageLabel = new JLabel(icon);
JLabel imageLabel = DockingUtils.createNonHtmlLabel(icon);
MultiLineLabel label =
new MultiLineLabel(
"A source archive change in your checked out version conflicts with a "
+ "source archive change in the latest version.\n"
+ "Select the source archive you want included in the version "
+ "that will result from this check-in.");
MultiLineLabel label = new MultiLineLabel(
"A source archive change in your checked out version conflicts with a " +
"source archive change in the latest version.\n" +
"Select the source archive you want included in the version " +
"that will result from this check-in.");
JPanel labelPanel = new JPanel();
labelPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));
@@ -20,8 +20,10 @@ import java.awt.BorderLayout;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import docking.DockingUtils;
import ghidra.app.merge.util.ConflictUtility;
import ghidra.program.model.address.*;
import ghidra.util.HTMLUtilities;
/**
* <code>ConflictInfoPanel</code> appears above the 4 listings in the ListingMergeWindow.
@@ -58,8 +60,8 @@ public class ConflictInfoPanel extends JPanel {
setLayout(new BorderLayout());
setBorder(BorderFactory.createTitledBorder("Resolve Current Conflict"));
westLabel = new JLabel("<html></html>");
eastLabel = new JLabel("<html></html>");
westLabel = DockingUtils.createHtmlLabel("<html></html>");
eastLabel = DockingUtils.createHtmlLabel("<html></html>");
add(westLabel, BorderLayout.WEST);
add(eastLabel, BorderLayout.EAST);
}
@@ -154,7 +156,8 @@ public class ConflictInfoPanel extends JPanel {
}
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() {
@@ -21,6 +21,7 @@ import java.awt.event.ItemListener;
import javax.swing.*;
import docking.DockingUtils;
import docking.widgets.EmptyBorderButton;
import docking.widgets.fieldpanel.FieldPanel;
import docking.widgets.fieldpanel.internal.FieldPanelCoordinator;
@@ -253,7 +254,7 @@ class ExternalAddConflictPanel extends JPanel implements CodeFormatService {
myTitlePanel = new TitledPanel(MergeConstants.MY_TITLE, myPanel, 5);
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);
splitPane.setResizeWeight(0.5);
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +15,14 @@
*/
package ghidra.app.merge.listing;
import ghidra.app.merge.util.ConflictUtility;
import java.awt.BorderLayout;
import javax.swing.*;
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.
* It indicates the Externals phase.
@@ -54,8 +54,8 @@ public class ExternalConflictInfoPanel extends JPanel {
setLayout(new BorderLayout());
setBorder(BorderFactory.createTitledBorder("Resolve External Location Conflict"));
westLabel = new JLabel("<html></html>");
eastLabel = new JLabel("<html></html>");
westLabel = DockingUtils.createHtmlLabel("<html></html>");
eastLabel = DockingUtils.createHtmlLabel("<html></html>");
add(westLabel, BorderLayout.WEST);
add(eastLabel, BorderLayout.EAST);
}
@@ -25,6 +25,7 @@ import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeListener;
import javax.swing.table.TableModel;
import docking.DockingUtils;
import docking.widgets.table.AbstractSortedTableModel;
import docking.widgets.table.GTable;
import ghidra.app.merge.util.ConflictUtility;
@@ -69,7 +70,7 @@ public class ScrollingListChoicesPanel extends ConflictPanel {
gbl = new GridBagLayout();
rowPanel = new JPanel(gbl);
setLayout(new BorderLayout());
headerLabel = new JLabel(" ");
headerLabel = DockingUtils.createNonHtmlLabel(" ");
headerLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(headerLabel, BorderLayout.NORTH);
setHeader(null);
@@ -257,7 +258,7 @@ class ListChoice extends JPanel {
group.add(rb);
add(rb, BorderLayout.NORTH);
model = new AbstractSortedTableModel<String[]>() {
model = new AbstractSortedTableModel<>() {
@Override
public Object getColumnValueForRow(String[] t, int columnIndex) {
return t[columnIndex];
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +15,6 @@
*/
package ghidra.app.merge.listing;
import ghidra.app.merge.util.ConflictUtility;
import ghidra.util.layout.MaximizeSpecificColumnGridLayout;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
@@ -29,6 +25,11 @@ import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
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
* 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 {
private final static long serialVersionUID = 1;
private static final Border UNDERLINE_BORDER = BorderFactory.createMatteBorder(0, 0, 1, 0,
Color.BLACK);
private static final Border UNDERLINE_BORDER =
BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK);
private JPanel rowPanel;
private JLabel headerLabel;
@@ -71,12 +72,12 @@ public class VariousChoicesPanel extends ConflictPanel {
private void init() {
setBorder(BorderFactory.createTitledBorder("Resolve Conflict"));
rows = new ArrayList<ChoiceRow>();
rows = new ArrayList<>();
layout = new MaximizeSpecificColumnGridLayout(5, 5, columnCount);
rowPanel = new JPanel(layout);
rowPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setLayout(new BorderLayout());
headerLabel = new JLabel(" ");
headerLabel = DockingUtils.createNonHtmlLabel(" ");
headerLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(headerLabel, BorderLayout.NORTH);
setHeader(null);
@@ -86,9 +87,8 @@ public class VariousChoicesPanel extends ConflictPanel {
indent = Math.max(rb.getPreferredSize().width, cb.getPreferredSize().width);
int radioButtonOffset = (rb.getPreferredSize().height - lbl.getPreferredSize().height) / 2;
int checkBoxOffset = (cb.getPreferredSize().height - lbl.getPreferredSize().height) / 2;
radioButtonBorder =
BorderFactory.createEmptyBorder((radioButtonOffset > 0 ? radioButtonOffset : 0), 0, 0,
0);
radioButtonBorder = BorderFactory.createEmptyBorder(
(radioButtonOffset > 0 ? radioButtonOffset : 0), 0, 0, 0);
checkBoxBorder =
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
* 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);
for (int i = 0; i < choices.length; i++) {
if (choices[i] == null) {
@@ -225,7 +226,8 @@ public class VariousChoicesPanel extends ConflictPanel {
* @param listener listener that gets notified whenever the state of
* 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);
MyLabel titleComp = new MyLabel(title);
MyCheckBox[] cb = new MyCheckBox[choices.length];
@@ -506,6 +508,7 @@ public class VariousChoicesPanel extends ConflictPanel {
*/
public MyLabel(final String text) {
super(text);
DockingUtils.turnOffHTMLRendering(this);
addComponentListener(new ComponentListener() {
@Override
@@ -522,7 +525,9 @@ public class VariousChoicesPanel extends ConflictPanel {
(displayedFont != null) ? getFontMetrics(displayedFont) : null;
int stringWidth =
(fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0;
setToolTipText((stringWidth > displayedWidth) ? text : null);
setToolTipText((stringWidth > displayedWidth)
? "<html>" + HTMLUtilities.friendlyEncodeHTML(text)
: null);
}
@Override
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,10 +15,6 @@
*/
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.event.*;
import java.util.*;
@@ -29,6 +24,12 @@ import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
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.
* 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"));
setLayout(new BorderLayout());
headerLabel = new JLabel(" ");
headerLabel = DockingUtils.createNonHtmlLabel(" ");
headerLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(headerLabel, BorderLayout.NORTH);
rowComps = new ArrayList<ArrayList<JComponent>>();
rows = new ArrayList<String[]>();
rowComps = new ArrayList<>();
rows = new ArrayList<>();
rowTypes = new LongArrayList();
group = new ButtonGroup();
layout = new MaximizeSpecificColumnGridLayout(5, 5, columnCount);
@@ -107,26 +108,24 @@ public class VerticalChoicesPanel extends ConflictPanel {
indent = Math.max(rb.getPreferredSize().width, cb.getPreferredSize().width);
defaultInsets = new Insets(DEFAULT_TOP, DEFAULT_LEFT, DEFAULT_BOTTOM, DEFAULT_RIGHT);
int labelHeight = (int) new JLabel("A").getPreferredSize().getHeight();
double buttonHeight =
new MyRadioButton("A", ListingMergeConstants.KEEP_LATEST).getPreferredSize().getHeight();
int labelHeight = (int) DockingUtils.createNonHtmlLabel("A").getPreferredSize().getHeight();
double buttonHeight = new MyRadioButton("A",
ListingMergeConstants.KEEP_LATEST).getPreferredSize().getHeight();
int borderHeight;
borderHeight = (int) ((buttonHeight - labelHeight) / 2);
if (borderHeight < 0) {
borderHeight = 0;
}
textVsButtonInsets =
new Insets(DEFAULT_TOP + borderHeight, DEFAULT_LEFT, DEFAULT_BOTTOM + borderHeight,
DEFAULT_RIGHT);
textVsButtonInsets = new Insets(DEFAULT_TOP + borderHeight, DEFAULT_LEFT,
DEFAULT_BOTTOM + borderHeight, DEFAULT_RIGHT);
double checkBoxHeight =
new MyCheckBox("A", ListingMergeConstants.KEEP_LATEST).getPreferredSize().getHeight();
borderHeight = (int) ((checkBoxHeight - labelHeight) / 2);
if (borderHeight < 0) {
borderHeight = 0;
}
textVsCheckBoxInsets =
new Insets(DEFAULT_TOP + borderHeight, DEFAULT_LEFT, DEFAULT_BOTTOM + borderHeight,
DEFAULT_RIGHT);
textVsCheckBoxInsets = new Insets(DEFAULT_TOP + borderHeight, DEFAULT_LEFT,
DEFAULT_BOTTOM + borderHeight, DEFAULT_RIGHT);
add(createUseForAllCheckBox(), BorderLayout.SOUTH);
}
@@ -461,6 +460,7 @@ public class VerticalChoicesPanel extends ConflictPanel {
*/
public MyLabel(final String text) {
super(text);
DockingUtils.turnOffHTMLRendering(this);
addComponentListener(new ComponentListener() {
@Override
@@ -481,7 +481,9 @@ public class VerticalChoicesPanel extends ConflictPanel {
(displayedFont != null) ? getFontMetrics(displayedFont) : null;
int stringWidth =
(fontMetrics != null) ? fontMetrics.stringWidth(displayedText) : 0;
setToolTipText((stringWidth > displayedWidth) ? text : null);
setToolTipText((stringWidth > displayedWidth)
? "<html>" + HTMLUtilities.friendlyEncodeHTML(text)
: null);
}
@Override
@@ -622,7 +624,8 @@ public class VerticalChoicesPanel extends ConflictPanel {
JComponent[] comps = getRowComponents(row);
for (int i = 0; i < comps.length; i++) {
JComponent component = comps[i];
if (component instanceof MyRadioButton && ((MyRadioButton) component).isSelected()) {
if (component instanceof MyRadioButton &&
((MyRadioButton) component).isSelected()) {
conflictOption |= ((MyRadioButton) component).option;
}
else if (component instanceof MyCheckBox && ((MyCheckBox) component).isSelected()) {
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +15,6 @@
*/
package ghidra.app.merge.propertylist;
import ghidra.app.merge.MergeConstants;
import java.awt.BorderLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
@@ -25,6 +22,9 @@ import java.awt.event.ItemListener;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.app.merge.MergeConstants;
/**
* Panel that shows differences for properties in Property Lists.
*/
@@ -63,27 +63,27 @@ class ConflictPanel extends JPanel {
}
if (info.isTypeMatch()) {
setBorder(BorderFactory.createTitledBorder("Resolve Type Mismatch for Property " +
info.getDisplayedPropertyName()));
setBorder(BorderFactory.createTitledBorder(
"Resolve Type Mismatch for Property " + info.getDisplayedPropertyName()));
latestRB.setText("Use type '" + info.getLatestTypeString() + "', value = '" +
info.getLatestValue() + "' (" + MergeConstants.LATEST_TITLE + ")");
myRB.setText("Use type '" + info.getMyTypeString() + "', value = '" +
info.getMyValue() + "' (" + MergeConstants.MY_TITLE + ")");
if (origValue != null) {
origText =
"Use type '" + info.getOrigTypeString() + "', value = '" + info.getOrigValue() +
"' (" + MergeConstants.ORIGINAL_TITLE + ")";
origText = "Use type '" + info.getOrigTypeString() + "', value = '" +
info.getOrigValue() + "' (" + MergeConstants.ORIGINAL_TITLE + ")";
}
}
else {
setBorder(BorderFactory.createTitledBorder("Resolve Property Conflict for " +
info.getDisplayedPropertyName()));
setBorder(BorderFactory.createTitledBorder(
"Resolve Property Conflict for " + info.getDisplayedPropertyName()));
latestRB.setText("Use value '" + info.getLatestValue() + "' (" +
MergeConstants.LATEST_TITLE + ")");
myRB.setText("Use value '" + info.getMyValue() + "' (" + MergeConstants.MY_TITLE + " )");
latestRB.setText(
"Use value '" + info.getLatestValue() + "' (" + MergeConstants.LATEST_TITLE + ")");
myRB.setText(
"Use value '" + info.getMyValue() + "' (" + MergeConstants.MY_TITLE + " )");
if (origValue != null) {
origText = "Use value '" + origValue + "' (" + MergeConstants.ORIGINAL_TITLE + " )";
}
@@ -133,7 +133,7 @@ class ConflictPanel extends JPanel {
panel.setLayout(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
propertyGroupLabel = new JLabel("Property Group: ");
propertyGroupLabel = DockingUtils.createNonHtmlLabel("Property Group: ");
JPanel namePanel = new JPanel(new BorderLayout());
namePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5));
@@ -163,6 +163,7 @@ class ConflictPanel extends JPanel {
panel.add(createUseForAllCheckBox(), BorderLayout.SOUTH);
ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (listener != null) {
listener.stateChanged(null);
@@ -22,6 +22,7 @@ import java.awt.event.ItemListener;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.app.merge.MergeConstants;
import ghidra.program.model.listing.Program;
import resources.ResourceManager;
@@ -58,17 +59,15 @@ class NameConflictsPanel extends JPanel {
text = "Use name '" + latestName + "' (" + MergeConstants.LATEST_TITLE + ")";
}
else {
text =
"Use '" + latestName + "' (" + MergeConstants.LATEST_TITLE + ") & lose '" + myName +
"' (" + MergeConstants.MY_TITLE + ")";
text = "Use '" + latestName + "' (" + MergeConstants.LATEST_TITLE + ") & lose '" +
myName + "' (" + MergeConstants.MY_TITLE + ")";
}
keepOtherRB.setText(text);
String myText;
if (myName.equals(latestName)) {
myText =
"Add '" + myName + "' (" + MergeConstants.MY_TITLE + ") as '" +
ProgramTreeMergeManager.getUniqueTreeName(resultProgram, myName) + "'";
myText = "Add '" + myName + "' (" + MergeConstants.MY_TITLE + ") as '" +
ProgramTreeMergeManager.getUniqueTreeName(resultProgram, myName) + "'";
}
else {
myText = "Add tree '" + myName + "' (" + MergeConstants.MY_TITLE + ")";
@@ -82,15 +81,13 @@ class NameConflictsPanel extends JPanel {
}
else {
if (origName.equals(latestName)) {
origText =
"Restore '" + origName + "' (" + MergeConstants.ORIGINAL_TITLE + ") as '" +
ProgramTreeMergeManager.getUniqueTreeName(resultProgram, origName) + "'" +
" & lose '" + myName + "' (" + MergeConstants.MY_TITLE + ")";
origText = "Restore '" + origName + "' (" + MergeConstants.ORIGINAL_TITLE +
") as '" + ProgramTreeMergeManager.getUniqueTreeName(resultProgram, origName) +
"'" + " & lose '" + myName + "' (" + MergeConstants.MY_TITLE + ")";
}
else {
origText =
"Restore '" + origName + "' (" + MergeConstants.ORIGINAL_TITLE + ") & lose '" +
myName + "' (" + MergeConstants.MY_TITLE + ")";
origText = "Restore '" + origName + "' (" + MergeConstants.ORIGINAL_TITLE +
") & lose '" + myName + "' (" + MergeConstants.MY_TITLE + ")";
}
}
originalRB.setText(origText);
@@ -129,9 +126,10 @@ class NameConflictsPanel extends JPanel {
JPanel iconPanel = new JPanel();
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");
iconPanel.add(new JLabel(icon));
iconPanel.add(DockingUtils.createNonHtmlLabel(icon));
iconPanel.add(Box.createHorizontalStrut(5));
iconPanel.add(conflictsLabel);
iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +15,12 @@
*/
package ghidra.app.merge.tree;
import ghidra.util.layout.PairLayout;
import java.awt.*;
import javax.swing.*;
import docking.DockingUtils;
import ghidra.util.layout.PairLayout;
import resources.ResourceManager;
/**
@@ -30,7 +29,7 @@ import resources.ResourceManager;
*
*/
class TreeChangePanel extends JPanel {
private JLabel treeNameLabel;
private JLabel nameLabel;
private JLabel structureLabel;
@@ -38,67 +37,67 @@ class TreeChangePanel extends JPanel {
private JPanel structurePanel;
private JLabel nameIconLabel;
private JLabel structureIconLabel;
private final static ImageIcon CHANGED_ICON =
ResourceManager.loadImage("images/changed16.gif");
private final static ImageIcon CHANGED_ICON = ResourceManager.loadImage("images/changed16.gif");
private final static ImageIcon NO_CHANGE_ICON =
ResourceManager.loadImage("images/EmptyIcon16.gif");
private final static Color CHANGED_COLOR = Color.BLACK;
private final static Color NO_CHANGE_COLOR = Color.GRAY;
TreeChangePanel(String title) {
super(new BorderLayout());
setBorder(BorderFactory.createTitledBorder(title));
create();
}
void setStates(String treeName, boolean nameChanged, boolean structureChanged) {
treeNameLabel.setText(treeName);
nameLabel.setText(nameChanged? "Name Changed" : "Name Not Changed");
nameLabel.setForeground(nameChanged? CHANGED_COLOR : NO_CHANGE_COLOR);
nameLabel.setText(nameChanged ? "Name Changed" : "Name Not Changed");
nameLabel.setForeground(nameChanged ? CHANGED_COLOR : NO_CHANGE_COLOR);
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);
structureLabel.setText(structureChanged?
"Structure Changed" : "Structure Not Changed");
structureLabel.setForeground(structureChanged? CHANGED_COLOR : NO_CHANGE_COLOR);
structureLabel.setText(structureChanged ? "Structure Changed" : "Structure Not Changed");
structureLabel.setForeground(structureChanged ? CHANGED_COLOR : NO_CHANGE_COLOR);
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);
}
private void create() {
JPanel panel = new JPanel(new BorderLayout(0, 5));
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
treeNameLabel = new JLabel("Tree Name");
treeNameLabel = DockingUtils.createNonHtmlLabel("Tree Name");
Font font = treeNameLabel.getFont();
font = new Font(font.getName(), Font.BOLD, font.getSize());
treeNameLabel.setFont(font);
nameLabel = new JLabel("Name Changed");
nameIconLabel = new JLabel(CHANGED_ICON);
structureLabel = new JLabel("Structure Changed");
structureIconLabel = new JLabel(CHANGED_ICON);
namePanel = new JPanel(new PairLayout(0,5));
nameLabel = DockingUtils.createNonHtmlLabel("Name Changed");
nameIconLabel = DockingUtils.createNonHtmlLabel(CHANGED_ICON);
structureLabel = DockingUtils.createNonHtmlLabel("Structure Changed");
structureIconLabel = DockingUtils.createNonHtmlLabel(CHANGED_ICON);
namePanel = new JPanel(new PairLayout(0, 5));
namePanel.add(nameIconLabel);
namePanel.add(nameLabel);
structurePanel = new JPanel(new PairLayout(0,5));
structurePanel = new JPanel(new PairLayout(0, 5));
structurePanel.add(structureIconLabel);
structurePanel.add(structureLabel);
JPanel labelPanel = new JPanel();
labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.Y_AXIS));
labelPanel.add(namePanel);
labelPanel.add(structurePanel);
panel.add(treeNameLabel, BorderLayout.NORTH);
panel.add(labelPanel, BorderLayout.CENTER);
add(panel);
add(panel);
}
}
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +18,7 @@ package ghidra.app.merge.util;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressRange;
import ghidra.program.util.DiffUtility;
import ghidra.util.HTMLUtilities;
/**
* <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.
* @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();
if (isRange) {
buf.append("Address range #");
@@ -238,7 +239,8 @@ public class ConflictUtility {
* @return the message string containing HTML tags.
*/
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.
*/
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))
: ""));
}
/**
@@ -30,6 +30,7 @@ import javax.swing.table.*;
import org.apache.commons.collections4.CollectionUtils;
import docking.DockingUtils;
import docking.options.editor.GenericOptionsComponent;
import docking.widgets.OptionDialog;
import docking.widgets.table.*;
@@ -62,8 +63,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
private List<Boolean> analyzerEnablement = new ArrayList<>();
private Set<String> prototypeAnalyzers = new HashSet<>();
private Map<String, Component> analyzerToOptionsPanelMap = new HashMap<>();
private Map<String, List<Component>> analyzerManagedComponentsMap =
new HashMap<>();
private Map<String, List<Component>> analyzerManagedComponentsMap = new HashMap<>();
private EditorStateFactory editorStateFactory;
private JPanel noOptionsPanel;
@@ -79,7 +79,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
PropertyChangeListener propertyChangeListener) {
this(List.of(program), editorStateFactory, propertyChangeListener);
}
/**
* Constructor
*
@@ -89,23 +89,23 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
*/
AnalysisPanel(List<Program> programs, EditorStateFactory editorStateFactory,
PropertyChangeListener propertyChangeListener) {
// Do a quick check to make sure we have at least one program. If not, we
// shouldn't even be here (the menus should be disabled).
if (CollectionUtils.isEmpty(programs)) {
throw new AssertException("Must provide a program to run analysis");
}
this.programs = programs;
this.propertyChangeListener = propertyChangeListener;
this.editorStateFactory = editorStateFactory;
analysisOptions = programs.get(0).getOptions(Program.ANALYSIS_PROPERTIES);
setName("Analysis Panel");
build();
load();
}
private void load() {
editorList.clear();
analyzerNames.clear();
@@ -127,9 +127,9 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
}
private void loadAnalyzers() {
AutoAnalysisManager manager = AutoAnalysisManager.getAnalysisManager(programs.get(0));
List<String> propertyNames = analysisOptions.getOptionNames();
Collections.sort(propertyNames, new Comparator<String>() {
@Override
@@ -475,7 +475,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
boolean origEnabled = analysisOptions.getBoolean(analyzerName, false);
if (currEnabled != origEnabled) {
propertyChangeListener.propertyChange(
new PropertyChangeEvent(this, analyzerName, origEnabled, currEnabled));
new PropertyChangeEvent(this, analyzerName, origEnabled, currEnabled));
return true;
}
}
@@ -495,11 +495,11 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
* analyzed.
*/
void applyChanges() {
for (int i = 0; i < analyzerNames.size(); ++i) {
String analyzerName = analyzerNames.get(i);
boolean enabled = analyzerEnablement.get(i);
int id = programs.get(0).startTransaction("setting analysis options");
boolean commit = false;
try {
@@ -512,7 +512,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
updateOptionForAllPrograms(analyzerName, enabled);
}
for (EditorState info : editorList) {
info.applyValue();
}
@@ -522,7 +522,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
List<Options> optionGroups = analysisOptions.getChildOptions();
noOptionsPanel = new JPanel(new VerticalLayout(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) {
String analyzerName = optionsGroup.getName();
@@ -539,8 +539,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
List<String> optionNames = getOptionNames(optionsGroup);
Collections.sort(optionNames);
List<GenericOptionsComponent> optionComponents =
new ArrayList<>();
List<GenericOptionsComponent> optionComponents = new ArrayList<>();
for (String childOptionName : optionNames) {
EditorState childState =
@@ -579,7 +578,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
PropertyEditor editor = options.getPropertyEditor(optionName);
return options.getObject(optionName, null) != null || editor != null;
}
/**
* Updates the enablement of the given analyzer for all programs being analyzed.
* <p>
@@ -602,21 +601,21 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
*/
public void updateOptionForAllPrograms(String analyzerName, boolean enabled) {
for (Program program : programs) {
boolean commit = false;
int id = program.startTransaction("Setting analysis property");
try {
Options options = program.getOptions(Program.ANALYSIS_PROPERTIES);
// Sanity check to make sure that the analyzer is appropriate for
// this program. This should always be the case but it doesn't
// hurt to check.
if (!options.getOptionNames().contains(analyzerName)) {
continue;
}
options.setBoolean(analyzerName, enabled);
commit = true;
}
finally {
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import javax.swing.*;
import javax.swing.text.html.HTMLEditorKit;
import docking.DockingUtils;
import docking.widgets.OptionDialog;
import ghidra.GhidraOptions;
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.listing.Program;
import ghidra.program.util.GhidraProgramUtilities;
import ghidra.util.HTMLUtilities;
import ghidra.util.Msg;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.*;
@@ -98,7 +100,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
}
else {
// no options dialog--analyze all programs
validPrograms = new ArrayList<Program>(programs);
validPrograms = new ArrayList<>(programs);
}
analyzePrograms(prototypeAnalysisOptions, validPrograms, monitor);
@@ -175,7 +177,8 @@ class AnalyzeAllOpenProgramsTask extends Task {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
AnalysisOptionsDialog dialog = new AnalysisOptionsDialog(getValidProgramsByArchitecture());
AnalysisOptionsDialog dialog =
new AnalysisOptionsDialog(getValidProgramsByArchitecture());
tool.showDialog(dialog);
boolean shouldAnalyze = dialog.wasAnalyzeButtonSelected();
analyze.set(shouldAnalyze);
@@ -202,7 +205,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
return true;
}
/**
* Returns a list of all programs that should be analyzed.
* <p>
@@ -213,7 +216,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
* @return the list of programs to analyze
*/
private List<Program> getValidProgramsByArchitecture() {
List<Program> validList = new ArrayList<Program>(programs);
List<Program> validList = new ArrayList<>(programs);
ProgramID protoTypeProgramID = new ProgramID(prototypeProgram);
@@ -223,7 +226,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
validList.remove(program);
}
}
return validList;
}
@@ -244,7 +247,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
List<Program> validList = getValidProgramsByArchitecture();
if (validList.size() != programs.size()) {
List<Program> invalidList = new ArrayList<Program>(programs);
List<Program> invalidList = new ArrayList<>(programs);
invalidList.removeAll(validList);
if (!showNonMatchingArchitecturesWarning(validList, invalidList)) {
@@ -274,7 +277,8 @@ class AnalyzeAllOpenProgramsTask extends Task {
StringBuilder buffy = new StringBuilder();
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("<TABLE BORDER=\"0\" CELLPADDING=\"5\">");
@@ -294,7 +298,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
buffy.append("<TR>");
buffy.append("<TD>");
buffy.append(specialFontOpen);
buffy.append(program.getName());
buffy.append(HTMLUtilities.friendlyEncodeHTML(program.getName()));
buffy.append(specialFontClose);
buffy.append("</TD>");
buffy.append("<TD>");
@@ -321,7 +325,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
for (Program program : invalidList) {
buffy.append("<TR>");
buffy.append("<TD>");
buffy.append(program.getName());
buffy.append(HTMLUtilities.friendlyEncodeHTML(program.getName()));
buffy.append("</TD>");
buffy.append("<TD>");
buffy.append(program.getLanguageID());
@@ -334,9 +338,8 @@ class AnalyzeAllOpenProgramsTask extends Task {
buffy.append("</TABLE>");
OptionDialog dialog =
new ScrollingOptionDialog("Found Differing Architectures--Continue?",
buffy.toString(), "Continue", OptionDialog.WARNING_MESSAGE);
OptionDialog dialog = new ScrollingOptionDialog("Found Differing Architectures--Continue?",
buffy.toString(), "Continue", OptionDialog.WARNING_MESSAGE);
dialog.show(null);
return dialog.getResult() == OptionDialog.OPTION_ONE;
}
@@ -467,8 +470,9 @@ class AnalyzeAllOpenProgramsTask extends Task {
}
if (compilerSpecID == null) {
if (other.compilerSpecID != null)
if (other.compilerSpecID != null) {
return false;
}
}
else if (!compilerSpecID.equals(other.compilerSpecID)) {
return false;
@@ -491,7 +495,8 @@ class AnalyzeAllOpenProgramsTask extends Task {
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);
}
@@ -503,8 +508,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
editorPane.setName("MESSAGE-COMPONENT");
editorPane.setText(message);
JLabel label = new JLabel();
editorPane.setBackground(label.getBackground());
editorPane.setBackground(DockingUtils.createNonHtmlLabel().getBackground());
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
@@ -1098,7 +1098,7 @@ public class AutoAnalysisManager implements DomainObjectListener, DomainObjectCl
}
if (GhidraProgramUtilities.shouldAskToAnalyze(program)) {
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?");
boolean analyzed = answer == OptionDialog.OPTION_ONE;
GhidraProgramUtilities.setAnalyzedFlag(program, analyzed);
@@ -21,6 +21,7 @@ import java.io.File;
import javax.swing.*;
import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.OptionDialog;
import docking.widgets.filechooser.GhidraFileChooser;
import ghidra.framework.GenericRunInfo;
@@ -75,7 +76,7 @@ public class ArchiveDialog extends DialogComponentProvider {
GridBagLayout gbl = new GridBagLayout();
JPanel outerPanel = new JPanel(gbl);
archiveLabel = new JLabel(" Archive File ");
archiveLabel = DockingUtils.createNonHtmlLabel(" Archive File ");
archiveField = new JTextField();
archiveField.setName("archiveField");
archiveField.setColumns(NUM_TEXT_COLUMNS);
@@ -153,7 +154,7 @@ public class ArchiveDialog extends DialogComponentProvider {
}
File file = new File(archive);
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) {
return;
}
@@ -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;
}
}
@@ -23,6 +23,7 @@ import java.io.File;
import javax.swing.*;
import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.filechooser.GhidraFileChooser;
import ghidra.framework.GenericRunInfo;
import ghidra.framework.model.ProjectLocator;
@@ -76,7 +77,7 @@ public class RestoreDialog extends DialogComponentProvider {
protected JPanel buildMainPanel() {
// Create the individual components that make up the panel.
archiveLabel = new JLabel(" Archive File ");
archiveLabel = DockingUtils.createNonHtmlLabel(" Archive File ");
archiveField = new JTextField();
archiveField.setColumns(NUM_TEXT_COLUMNS);
archiveField.setName("archiveField");
@@ -115,7 +116,7 @@ public class RestoreDialog extends DialogComponentProvider {
Font font = archiveBrowse.getFont();
archiveBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
restoreLabel = new JLabel(" Restore Directory ");
restoreLabel = DockingUtils.createNonHtmlLabel(" Restore Directory ");
restoreField = new JTextField();
restoreField.setName("restoreField");
restoreField.setColumns(RestoreDialog.NUM_TEXT_COLUMNS);
@@ -132,7 +133,7 @@ public class RestoreDialog extends DialogComponentProvider {
font = restoreBrowse.getFont();
restoreBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
projectNameLabel = new JLabel(" Project Name ");
projectNameLabel = DockingUtils.createNonHtmlLabel(" Project Name ");
projectNameField = new JTextField();
projectNameField.setName("projectNameField");
projectNameField.setColumns(RestoreDialog.NUM_TEXT_COLUMNS);
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.swing.*;
import javax.swing.text.BadLocationException;
import docking.DockingUtils;
import docking.EmptyBorderToggleButton;
import docking.widgets.autocomplete.*;
import docking.widgets.textfield.TextFieldLinker;
@@ -705,7 +706,7 @@ public class AssemblyDualTextField {
Box hbox = Box.createHorizontalBox();
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);
AssemblyDualTextField input = new AssemblyDualTextField();
@@ -26,6 +26,7 @@ import ghidra.program.model.address.AddressSet;
import ghidra.program.model.listing.*;
import ghidra.program.util.MarkerLocation;
import ghidra.program.util.ProgramLocation;
import ghidra.util.HTMLUtilities;
import resources.ResourceManager;
/**
@@ -93,9 +94,8 @@ public class BookmarkNavigator {
color = DEFAULT_COLOR;
}
markerSet =
markerService.createPointMarker(type + " Bookmarks", type + " Bookmarks",
bookmarkMgr.getProgram(), priority, true, true, false, color, icon);
markerSet = markerService.createPointMarker(type + " Bookmarks", type + " Bookmarks",
bookmarkMgr.getProgram(), priority, true, true, false, color, icon);
markerSet.setNavigationListener(new MarkerListener() {
@Override
@@ -118,11 +118,11 @@ public class BookmarkNavigator {
String cat = bookmarks[i].getCategory();
if (cat != null && cat.length() != 0) {
buf.append(" [");
buf.append(cat);
buf.append(HTMLUtilities.friendlyEncodeHTML(cat));
buf.append("]");
}
buf.append(": ");
buf.append(bookmarks[i].getComment());
buf.append(HTMLUtilities.friendlyEncodeHTML(bookmarks[i].getComment()));
}
return buf.toString();
}
@@ -203,10 +203,10 @@ public class BookmarkNavigator {
*/
public static void defineBookmarkTypes(Program program) {
BookmarkManager mgr = program.getBookmarkManager();
mgr.defineType(BookmarkType.NOTE, BookmarkNavigator.NOTE_ICON,
BookmarkNavigator.NOTE_COLOR, BookmarkNavigator.NOTE_PRIORITY);
mgr.defineType(BookmarkType.INFO, BookmarkNavigator.INFO_ICON,
BookmarkNavigator.INFO_COLOR, BookmarkNavigator.INFO_PRIORITY);
mgr.defineType(BookmarkType.NOTE, BookmarkNavigator.NOTE_ICON, BookmarkNavigator.NOTE_COLOR,
BookmarkNavigator.NOTE_PRIORITY);
mgr.defineType(BookmarkType.INFO, BookmarkNavigator.INFO_ICON, BookmarkNavigator.INFO_COLOR,
BookmarkNavigator.INFO_PRIORITY);
mgr.defineType(BookmarkType.WARNING, BookmarkNavigator.WARNING_ICON,
BookmarkNavigator.WARNING_COLOR, BookmarkNavigator.WARNING_PRIORITY);
mgr.defineType(BookmarkType.ERROR, BookmarkNavigator.ERROR_ICON,
@@ -112,7 +112,7 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
}
}
};
// Some items in the dialog change depending on whether we have multiple selection
// ranges, so capture that information here.
int ranges = 0;
@@ -120,11 +120,11 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
ranges = plugin.getProgramSelection().getNumAddressRanges();
}
JLabel locationLabel = new JLabel("Address: ", SwingConstants.RIGHT);
JLabel locationLabel = DockingUtils.createNonHtmlLabel("Address: ", SwingConstants.RIGHT);
locationTextField = new JTextField(50);
locationTextField.setText(address.toString());
if (hasSelection && ranges > 1) {
locationTextField.setText(address.toString() + " (plus " + (ranges-1) + " more)");
locationTextField.setText(address.toString() + " (plus " + (ranges - 1) + " more)");
}
locationTextField.setCaretPosition(0);
locationTextField.setEditable(false);
@@ -132,7 +132,7 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
locationTextField.setMinimumSize(locationTextField.getPreferredSize());
locationTextField.addKeyListener(listener);
JLabel categoryLabel = new JLabel("Category: ", SwingConstants.RIGHT);
JLabel categoryLabel = DockingUtils.createNonHtmlLabel("Category: ", SwingConstants.RIGHT);
categoryComboBox = new GhidraComboBox<>(getModel());
categoryComboBox.setEditable(true);
categoryComboBox.addKeyListener(listener);
@@ -140,7 +140,8 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
categoryTextField = (JTextField) categoryComboBox.getEditor().getEditorComponent();
categoryTextField.addKeyListener(listener);
JLabel commentLabel = new JLabel("Description: ", SwingConstants.RIGHT);
JLabel commentLabel =
DockingUtils.createNonHtmlLabel("Description: ", SwingConstants.RIGHT);
commentTextField = new JTextField(20);
commentTextField.addKeyListener(listener);
@@ -203,7 +204,7 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
mainPanel.add(commentTextField, gbc);
ImageIcon icon = BookmarkNavigator.NOTE_ICON;
JLabel imageLabel = new JLabel(icon);
JLabel imageLabel = DockingUtils.createNonHtmlLabel(icon);
imageLabel.setPreferredSize(
new Dimension(icon.getIconWidth() + 20, icon.getIconHeight() + 20));
@@ -22,6 +22,7 @@ import java.util.List;
import javax.swing.*;
import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.app.util.HelpTopics;
import ghidra.program.model.listing.*;
import ghidra.util.HelpLocation;
@@ -59,8 +60,8 @@ class FilterDialog extends DialogComponentProvider {
JPanel p = new JPanel(new BorderLayout());
p.add(buttons[i], BorderLayout.WEST);
buttons[i].setSelected(provider.isShowingType(types[i].getTypeString()));
JLabel l =
new JLabel(types[i].getTypeString(), types[i].getIcon(), SwingConstants.LEFT);
JLabel l = DockingUtils.createNonHtmlLabel(types[i].getTypeString(), types[i].getIcon(),
SwingConstants.LEFT);
p.add(l, BorderLayout.CENTER);
panel.add(p);
}
@@ -69,7 +70,7 @@ class FilterDialog extends DialogComponentProvider {
@Override
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++) {
if (buttons[i].isSelected()) {
typesList.add(types[i].getTypeString());
@@ -24,8 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.*;
import javax.swing.tree.TreePath;
import docking.ActionContext;
import docking.WindowPosition;
import docking.*;
import docking.action.*;
import docking.util.GraphicsUtils;
import docking.widgets.dialogs.NumberInputDialog;
@@ -792,10 +791,8 @@ public class CallTreeProvider extends ComponentProviderAdapter implements Domain
private JPanel createTreePanel(boolean isIncoming, GTree tree) {
JPanel panel = new JPanel(new BorderLayout());
String name = isIncoming ? "Incoming Calls" : "Outgoing Calls";
JLabel label = new JLabel(name);
panel.add(label, BorderLayout.NORTH);
panel.add(DockingUtils.createNonHtmlLabel(isIncoming ? "Incoming Calls" : "Outgoing Calls"),
BorderLayout.NORTH);
panel.add(tree, BorderLayout.CENTER);
return panel;
@@ -23,6 +23,7 @@ import java.util.List;
import javax.swing.*;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import ghidra.app.context.ProgramContextAction;
import ghidra.framework.plugintool.ComponentProviderAdapter;
@@ -92,7 +93,7 @@ public class ComputeChecksumsProvider extends ComponentProviderAdapter {
resultsMainPanel.add(tablePanel);
main.add(resultsMainPanel, BorderLayout.CENTER);
errorStatus = new JLabel(" ");
errorStatus = DockingUtils.createNonHtmlLabel(" ");
errorStatus.setName("message");
errorStatus.setHorizontalAlignment(SwingConstants.CENTER);
errorStatus.setForeground(Color.RED);
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +15,6 @@
*/
package ghidra.app.plugin.core.clear;
import ghidra.app.context.ListingActionContext;
import ghidra.util.HelpLocation;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.*;
@@ -28,6 +24,9 @@ import java.util.List;
import javax.swing.*;
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
@@ -115,7 +114,7 @@ public class ClearDialog extends DialogComponentProvider {
panel = new JPanel();
panel.setLayout(new BorderLayout(10, 10));
JLabel label = new JLabel("Clear Options:");
JLabel label = DockingUtils.createNonHtmlLabel("Clear Options:");
panel.add(label, BorderLayout.NORTH);
JPanel cbPanel = new JPanel();
@@ -123,9 +122,8 @@ public class ClearDialog extends DialogComponentProvider {
cbPanel.setLayout(bl);
symbolsCb = new JCheckBox("Symbols");
commentsCb =
new JCheckBox(
"<HTML>Comments <FONT SIZE=\"2\">(does not affect automatic comments)</FONT>");
commentsCb = new JCheckBox(
"<HTML>Comments <FONT SIZE=\"2\">(does not affect automatic comments)</FONT>");
commentsCb.setVerticalTextPosition(SwingConstants.TOP);
propertiesCb = new JCheckBox("Properties");
codeCb = new JCheckBox("Code");
@@ -179,6 +177,7 @@ public class ClearDialog extends DialogComponentProvider {
// if a user clears the code, then we will force them
// to clear all user references...
codeCb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (codeCb.isSelected()) {
userReferencesCb.setSelected(true);
@@ -205,7 +204,7 @@ public class ClearDialog extends DialogComponentProvider {
systemReferencesCb.setEnabled(false);
// 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(commentsCb);
checkBoxList.add(propertiesCb);
@@ -222,6 +221,7 @@ public class ClearDialog extends DialogComponentProvider {
JPanel buttonPanel = new JPanel();
JButton selectAllButton = new JButton("Select All");
selectAllButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setAllCheckBoxesSelected(true, checkBoxList);
}
@@ -229,6 +229,7 @@ public class ClearDialog extends DialogComponentProvider {
JButton deselectAllbutton = new JButton("Deselect All");
deselectAllbutton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setAllCheckBoxesSelected(false, checkBoxList);
}
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +15,6 @@
*/
package ghidra.app.plugin.core.clear;
import ghidra.app.context.ListingActionContext;
import ghidra.util.HelpLocation;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.*;
@@ -26,6 +22,9 @@ import java.awt.event.*;
import javax.swing.*;
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
@@ -92,7 +91,7 @@ public class ClearFlowDialog extends DialogComponentProvider {
panel = new JPanel();
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);
JPanel cbPanel = new JPanel();
@@ -32,6 +32,7 @@ import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.util.AddressFieldLocation;
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.
@@ -92,7 +93,8 @@ public class ProgramAddressRelationshipListingHover extends AbstractConfigurable
MemoryBlock block = program.getMemory().getBlock(loc);
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);
addDataInfo(program, loc, sb);
@@ -141,7 +143,8 @@ public class ProgramAddressRelationshipListingHover extends AbstractConfigurable
Function function = program.getFunctionManager().getFunctionContaining(loc);
if (function != null) {
long functionOffset = loc.subtract(function.getEntryPoint());
appendTableRow(sb, "Function Offset", function.getName(), functionOffset);
appendTableRow(sb, "Function Offset",
HTMLUtilities.friendlyEncodeHTML(function.getName()), functionOffset);
}
}
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +15,6 @@
*/
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.event.*;
import java.util.*;
@@ -33,6 +26,12 @@ import javax.swing.text.JTextComponent;
import docking.*;
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.
@@ -45,8 +44,7 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
private JTextArea plateField;
private JTextArea repeatableField;
private Map<Document, UndoRedoKeeper> documentUndoRedoMap =
new HashMap<Document, UndoRedoKeeper>(9);
private Map<Document, UndoRedoKeeper> documentUndoRedoMap = new HashMap<>(9);
private String preComment;
private String postComment;
@@ -168,9 +166,8 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
protected void cancelCallback() {
if (wasChanged) {
int result =
OptionDialog.showYesNoCancelDialog(getComponent(), "Save Changes?",
"Some comments were modified.\nSave Changes?");
int result = OptionDialog.showYesNoCancelDialog(getComponent(), "Save Changes?",
"Some comments were modified.\nSave Changes?");
if (result == OptionDialog.OPTION_ONE) {
applyCallback();
}
@@ -267,9 +264,9 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
JPanel auxiliaryControlPanel = new JPanel(new BorderLayout());
auxiliaryControlPanel.add(enterBox, BorderLayout.SOUTH);
final AnnotationAdapterWrapper[] annotations = getAnnotationAdapterWrappers();
AnnotationAdapterWrapper[] annotations = getAnnotationAdapterWrappers();
Arrays.sort(annotations);
final JComboBox annotationsComboBox = new JComboBox(annotations);
JComboBox<AnnotationAdapterWrapper> annotationsComboBox = new GhidraComboBox<>(annotations);
JButton addAnnotationButton = new JButton("Add Annotation");
addAnnotationButton.addActionListener(new ActionListener() {
@Override
@@ -277,7 +274,8 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
JTextArea currentTextArea = getSelectedTextArea();
AnnotationAdapterWrapper aaw =
(AnnotationAdapterWrapper) annotationsComboBox.getSelectedItem();
currentTextArea.insert(aaw.getPrototypeString(), currentTextArea.getCaretPosition());
currentTextArea.insert(aaw.getPrototypeString(),
currentTextArea.getCaretPosition());
currentTextArea.setCaretPosition(currentTextArea.getCaretPosition() - 1);
}
});
@@ -289,6 +287,7 @@ public class CommentsDialog extends DialogComponentProvider implements KeyListen
panel.add(auxiliaryControlPanel, BorderLayout.SOUTH);
preField = new JTextArea(5, 80) {
@Override
public boolean getScrollableTracksViewportWidth() {
boolean b = super.getScrollableTracksViewportWidth();
return b;
@@ -23,8 +23,7 @@ import ghidra.program.database.data.DataTypeUtilities;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite.AlignmentType;
import ghidra.program.model.lang.InsufficientBytesException;
import ghidra.util.InvalidNameException;
import ghidra.util.Msg;
import ghidra.util.*;
import ghidra.util.exception.*;
public abstract class CompEditorModel extends CompositeEditorModel {
@@ -1417,8 +1416,9 @@ public abstract class CompEditorModel extends CompositeEditorModel {
*/
@Override
public boolean isMoveUpAllowed() {
if (!isContiguousSelection())
if (!isContiguousSelection()) {
return false;
}
int start = selection.getFieldRange(0).getStart().getIndex().intValue();
return ((start > 0) && (start < getNumComponents()));
}
@@ -1466,7 +1466,8 @@ public abstract class CompEditorModel extends CompositeEditorModel {
originalIsChanging = true;
try {
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() + "?";
String title = "Reload " + getTypeName() + " Editor?";
int response = OptionDialog.showYesNoDialogWithNoAsDefaultButton(
@@ -1569,7 +1570,8 @@ public abstract class CompEditorModel extends CompositeEditorModel {
consideringReplacedDataType = true;
try {
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() + "?";
String title = "Reload " + getTypeName() + " Editor?";
int response = OptionDialog.showYesNoDialogWithNoAsDefaultButton(
@@ -25,6 +25,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import docking.DockingUtils;
import docking.ToolTipManager;
import docking.widgets.OptionDialog;
import ghidra.program.model.data.Category;
@@ -185,7 +186,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
private void setupName() {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
nameLabel = new JLabel("Name:");
nameLabel = DockingUtils.createNonHtmlLabel("Name:");
gridBagConstraints.insets = LEFT_INSETS;
gridBagConstraints.anchor = GridBagConstraints.LINE_END;
gridBagConstraints.fill = GridBagConstraints.NONE;
@@ -216,7 +217,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
private void setupDescription() {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
descriptionLabel = new JLabel("Description:");
descriptionLabel = DockingUtils.createNonHtmlLabel("Description:");
gridBagConstraints.insets = LEFT_INSETS;
gridBagConstraints.anchor = GridBagConstraints.LINE_END;
gridBagConstraints.fill = GridBagConstraints.NONE;
@@ -247,7 +248,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
private void setupCategory() {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
categoryLabel = new JLabel("Category:");
categoryLabel = DockingUtils.createNonHtmlLabel("Category:");
gridBagConstraints.insets = LEFT_INSETS;
gridBagConstraints.anchor = GridBagConstraints.LINE_END;
gridBagConstraints.fill = GridBagConstraints.NONE;
@@ -486,7 +487,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
"aligning this data type inside another data type." + "</HTML>";
JPanel actualAlignmentPanel = new JPanel(new BorderLayout());
actualAlignmentLabel = new JLabel("Alignment:");
actualAlignmentLabel = DockingUtils.createNonHtmlLabel("Alignment:");
gridBagConstraints.insets = new Insets(2, 7, 2, 2);
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.fill = GridBagConstraints.NONE;
@@ -718,7 +719,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
protected void setupSize() {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
sizeLabel = new JLabel("Size:");
sizeLabel = DockingUtils.createNonHtmlLabel("Size:");
ToolTipManager.setToolTipText(sizeLabel, "The current size in bytes.");
gridBagConstraints.anchor = GridBagConstraints.LINE_END;
gridBagConstraints.fill = GridBagConstraints.NONE;
@@ -26,13 +26,13 @@ import java.util.EventObject;
import java.util.List;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.table.*;
import javax.swing.text.JTextComponent;
import docking.DockingUtils;
import docking.ToolTipManager;
import docking.action.DockingActionIf;
import docking.dnd.*;
@@ -603,7 +603,7 @@ public abstract class CompositeEditorPanel extends JPanel
private JPanel createStatusPanel() {
JPanel panel = new JPanel(new BorderLayout());
statusLabel = new JLabel(" ");
statusLabel = DockingUtils.createNonHtmlLabel(" ");
statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
statusLabel.setForeground(Color.blue);
statusLabel.addComponentListener(new ComponentAdapter() {
@@ -620,7 +620,7 @@ public abstract class CompositeEditorPanel extends JPanel
/**
* 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) {
if (statusLabel != null) {
@@ -657,7 +657,7 @@ public abstract class CompositeEditorPanel extends JPanel
JPanel panel = new JPanel();
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()));
panel.add(label);
panel.add(Box.createHorizontalStrut(2));
@@ -1190,7 +1190,6 @@ public abstract class CompositeEditorPanel extends JPanel
implements TableCellEditor {
private static final long serialVersionUID = 1L;
private DataTypeSelectionEditor editor;
private JLabel label = new JLabel();
private DataType dt;
private int maxLength;
@@ -1199,11 +1198,6 @@ public abstract class CompositeEditorPanel extends JPanel
@Override
public Component getTableCellEditorComponent(JTable table1, Object value,
boolean isSelected, int row, int column) {
if (label == null) {
label = new JLabel();
label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
}
model.clearStatus();
maxLength = model.getMaxAddLength(row);
init();
@@ -23,6 +23,7 @@ import javax.swing.border.Border;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import docking.DockingUtils;
import docking.widgets.EmptyBorderButton;
import resources.ResourceManager;
@@ -42,7 +43,7 @@ public class SearchControlPanel extends JPanel {
this.editorPanel = editorPanel;
setLayout(new BorderLayout());
JLabel label = new JLabel("Search: ");
JLabel label = DockingUtils.createNonHtmlLabel("Search: ");
add(label, BorderLayout.WEST);
textField = new JTextField(20);
add(textField, BorderLayout.CENTER);
@@ -41,8 +41,7 @@ import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.database.data.ProgramDataTypeManager;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.*;
import ghidra.util.task.TaskMonitor;
//@formatter:off
@@ -302,7 +301,8 @@ public class CParserPlugin extends ProgramPlugin {
}
list.add(openDTmanagers[i]);
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]);
@@ -35,8 +35,7 @@ import ghidra.app.util.ToolTipUtils;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation;
import ghidra.util.InvalidNameException;
import ghidra.util.*;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.table.GhidraTable;
import ghidra.util.table.GhidraTableFilterPanel;
@@ -174,7 +173,7 @@ public class CreateStructureDialog extends DialogComponentProvider {
structurePanel.setBorder(structureBorder);
GTable table = buildMatchingStructuresTable();
filterPanel = new GhidraTableFilterPanel<StructureWrapper>(table, structureTableModel) {
filterPanel = new GhidraTableFilterPanel<>(table, structureTableModel) {
// make sure our height doesn't stretch
@Override
public Dimension getMaximumSize() {
@@ -570,7 +569,8 @@ public class CreateStructureDialog extends DialogComponentProvider {
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
@@ -719,7 +719,7 @@ public class DataSettingsDialog extends DialogComponentProvider {
final static int BOOLEAN = 1;
private int mode;
private JComboBox comboBox = new JComboBox();
private JComboBox<String> comboBox = new JComboBox<>();
SettingsEditor() {
comboBox.addItemListener(new ItemListener() {
@@ -747,7 +747,7 @@ public class DataSettingsDialog extends DialogComponentProvider {
private StringChoices getComboBoxEnum() {
String[] items = new String[comboBox.getItemCount()];
for (int i = 0; i < items.length; i++) {
items[i] = (String) comboBox.getItemAt(i);
items[i] = comboBox.getItemAt(i);
}
StringChoices enuum = new StringChoices(items);
enuum.setSelectedValue(comboBox.getSelectedIndex());
@@ -17,11 +17,12 @@ package ghidra.app.plugin.core.datamgr;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import docking.DialogComponentProvider;
import docking.DockingUtils;
import ghidra.program.model.data.*;
import ghidra.util.HTMLUtilities;
/**
* The DataOrganizationDialog
@@ -34,8 +35,8 @@ public class DataOrganizationDialog extends DialogComponentProvider {
private JPanel mainPanel;
private DataOrganizationPanel alignPanel;
private SizeAlignmentPanel sizePanel;
private boolean actionComplete;
private boolean actionComplete;
/**
* Creates a data type organization dialog for specifying data type alignment information
* for a single data type manager. This dialog allows the user to align all data types in
@@ -46,52 +47,52 @@ public class DataOrganizationDialog extends DialogComponentProvider {
*/
public DataOrganizationDialog(DataTypeManager dataTypeManager,
DataOrganizationImpl dataOrganization) {
super(TITLE, true);
this.dataTypeManager = dataTypeManager;
this.dataOrganization = dataOrganization;
super(TITLE, true);
this.dataTypeManager = dataTypeManager;
this.dataOrganization = dataOrganization;
JPanel headerPanel = new JPanel();
headerPanel.add(new JLabel("<HTML>Alignment Information for <b>" +
dataTypeManager.getName() + "</b>.</HTML>"));
headerPanel.add(DockingUtils.createHtmlLabel("<HTML>Alignment Information for <b>" +
HTMLUtilities.friendlyEncodeHTML(dataTypeManager.getName()) + "</b>.</HTML>"));
alignPanel = new DataOrganizationPanel();
alignPanel.setOrganization(dataOrganization);
sizePanel = new SizeAlignmentPanel();
sizePanel.setOrganization(dataOrganization);
JPanel infoPanel = new JPanel(new BorderLayout());
infoPanel.add(alignPanel, BorderLayout.NORTH);
infoPanel.add(sizePanel, BorderLayout.CENTER);
mainPanel = new JPanel(new BorderLayout());
mainPanel.add(headerPanel, BorderLayout.NORTH);
mainPanel.add(infoPanel, BorderLayout.CENTER);
addWorkPanel(mainPanel);
initialize();
}
private void initialize() {
actionComplete = false;
addOKButton();
setOkButtonText("Set");
addCancelButton();
mainPanel = new JPanel(new BorderLayout());
mainPanel.add(headerPanel, BorderLayout.NORTH);
mainPanel.add(infoPanel, BorderLayout.CENTER);
addWorkPanel(mainPanel);
initialize();
}
private void initialize() {
actionComplete = false;
addOKButton();
setOkButtonText("Set");
addCancelButton();
// setHelpLocation(new HelpLocation(plugin, "Align_Data_Types_In_Archive"));
}
public boolean userCanceled() {
return !actionComplete && !isVisible();
}
}
public boolean userCanceled() {
return !actionComplete && !isVisible();
}
@Override
protected void okCallback() {
actionComplete = true;
actionComplete = true;
close();
}
@Override
protected void cancelCallback() {
super.cancelCallback();
actionComplete = false;
actionComplete = false;
}
public DataOrganization getDataOrganization() {
@@ -21,6 +21,7 @@ import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.program.model.data.DataOrganizationImpl;
import ghidra.util.layout.PairLayout;
@@ -61,41 +62,41 @@ public class DataOrganizationPanel extends JPanel {
setUpDoubleSize();
setUpLongDoubleSize();
add(new JLabel(""));
add(new JLabel(""));
add(new JLabel("Absolute Max Alignment"));
add(DockingUtils.createNonHtmlLabel(""));
add(DockingUtils.createNonHtmlLabel(""));
add(DockingUtils.createNonHtmlLabel("Absolute Max Alignment"));
add(absoluteMaxAlignComponent);
add(new JLabel("Machine Alignment"));
add(DockingUtils.createNonHtmlLabel("Machine Alignment"));
add(machineAlignComponent);
add(new JLabel("Default Alignment"));
add(DockingUtils.createNonHtmlLabel("Default Alignment"));
add(defaultAlignComponent);
add(new JLabel("Default Pointer Alignment"));
add(DockingUtils.createNonHtmlLabel("Default Pointer Alignment"));
add(pointerAlignComponent);
add(new JLabel(""));
add(new JLabel(""));
add(new JLabel("Signed-Char:"));
add(DockingUtils.createNonHtmlLabel(""));
add(DockingUtils.createNonHtmlLabel(""));
add(DockingUtils.createNonHtmlLabel("Signed-Char:"));
add(charIsSignedCheckbox);
add(new JLabel("Char Size"));
add(DockingUtils.createNonHtmlLabel("Char Size"));
add(charSizeComponent);
add(new JLabel("Wide-Char Size"));
add(DockingUtils.createNonHtmlLabel("Wide-Char Size"));
add(wcharSizeComponent);
add(new JLabel("Short Size"));
add(DockingUtils.createNonHtmlLabel("Short Size"));
add(shortSizeComponent);
add(new JLabel("Integer Size"));
add(DockingUtils.createNonHtmlLabel("Integer Size"));
add(integerSizeComponent);
add(new JLabel("Long Size"));
add(DockingUtils.createNonHtmlLabel("Long Size"));
add(longSizeComponent);
add(new JLabel("LongLong Size"));
add(DockingUtils.createNonHtmlLabel("LongLong Size"));
add(longLongSizeComponent);
add(new JLabel("Float Size"));
add(DockingUtils.createNonHtmlLabel("Float Size"));
add(floatSizeComponent);
add(new JLabel("Double Size"));
add(DockingUtils.createNonHtmlLabel("Double Size"));
add(doubleSizeComponent);
add(new JLabel("LongDouble Size"));
add(DockingUtils.createNonHtmlLabel("LongDouble Size"));
add(longDoubleSizeComponent);
add(new JLabel(""));
add(new JLabel(""));
add(DockingUtils.createNonHtmlLabel(""));
add(DockingUtils.createNonHtmlLabel(""));
}
public void setOrganization(DataOrganizationImpl dataOrganization) {
@@ -133,7 +134,7 @@ public class DataOrganizationPanel extends JPanel {
doubleSizeComponent.setText(Integer.toString(doubleSize));
longDoubleSizeComponent.setText(Integer.toString(longDoubleSize));
}
private void setUpSignedChar() {
charIsSignedCheckbox = new JCheckBox();
charIsSignedCheckbox.addChangeListener(new ChangeListener() {
@@ -143,19 +144,22 @@ public class DataOrganizationPanel extends JPanel {
}
});
}
private void setUpCharSize() {
charSizeComponent = new JTextField(3);
charSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedCharSize();
}
});
charSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedCharSize();
}
@@ -165,15 +169,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpWideCharSize() {
wcharSizeComponent = new JTextField(3);
wcharSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedWideCharSize();
}
});
wcharSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedWideCharSize();
}
@@ -183,15 +190,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpShortSize() {
shortSizeComponent = new JTextField(3);
shortSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedShortSize();
}
});
shortSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedShortSize();
}
@@ -201,15 +211,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpIntegerSize() {
integerSizeComponent = new JTextField(3);
integerSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedIntegerSize();
}
});
integerSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedIntegerSize();
}
@@ -219,15 +232,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpLongSize() {
longSizeComponent = new JTextField(3);
longSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedLongSize();
}
});
longSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedLongSize();
}
@@ -237,15 +253,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpLongLongSize() {
longLongSizeComponent = new JTextField(3);
longLongSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedLongLongSize();
}
});
longLongSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedLongLongSize();
}
@@ -255,15 +274,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpFloatSize() {
floatSizeComponent = new JTextField(3);
floatSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedFloatSize();
}
});
floatSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedFloatSize();
}
@@ -273,15 +295,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpDoubleSize() {
doubleSizeComponent = new JTextField(3);
doubleSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedDoubleSize();
}
});
doubleSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedDoubleSize();
}
@@ -291,15 +316,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpLongDoubleSize() {
longDoubleSizeComponent = new JTextField(3);
longDoubleSizeComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedLongDoubleSize();
}
});
longDoubleSizeComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedLongDoubleSize();
}
@@ -309,15 +337,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpAbsoluteMaxAlignment() {
absoluteMaxAlignComponent = new JTextField(3);
absoluteMaxAlignComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedAbsoluteMaxAlignment();
}
});
absoluteMaxAlignComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedAbsoluteMaxAlignment();
}
@@ -327,15 +358,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpMachineAlignment() {
machineAlignComponent = new JTextField(3);
machineAlignComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedMachineAlignment();
}
});
machineAlignComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedMachineAlignment();
}
@@ -345,15 +379,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpDefaultAlignment() {
defaultAlignComponent = new JTextField(3);
defaultAlignComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedDefaultAlignment();
}
});
defaultAlignComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedDefaultAlignment();
}
@@ -363,15 +400,18 @@ public class DataOrganizationPanel extends JPanel {
private void setUpPointerAlignment() {
pointerAlignComponent = new JTextField(3);
pointerAlignComponent.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatedDefaultPointerAlignment();
}
});
pointerAlignComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// TODO
}
@Override
public void focusLost(FocusEvent e) {
updatedDefaultPointerAlignment();
}
@@ -382,7 +422,7 @@ public class DataOrganizationPanel extends JPanel {
boolean isSigned = charIsSignedCheckbox.isSelected();
dataOrganization.setCharIsSigned(isSigned);
}
protected void updatedCharSize() {
int charSize = Integer.decode(charSizeComponent.getText()).intValue();
dataOrganization.setCharSize(charSize);
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,17 +15,18 @@
*/
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 javax.swing.*;
import javax.swing.event.ChangeEvent;
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.
*/
@@ -60,22 +60,22 @@ class DataTypeComparePanel extends JPanel {
leftPanel = new JPanel(new BorderLayout());
rightPanel = new JPanel(new BorderLayout());
leftPanelLabel = new JLabel();
rightPanelLabel = new JLabel();
leftPanelLabel = DockingUtils.createHtmlLabel();
rightPanelLabel = DockingUtils.createHtmlLabel();
leftPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0));
rightPanelLabel.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 0));
setLabelText(leftPanelLabel, clientName + ":");
setLabelText(rightPanelLabel, sourceName + ":");
setLabelText(leftPanelLabel, HTMLUtilities.friendlyEncodeHTML(clientName) + ":");
setLabelText(rightPanelLabel, HTMLUtilities.friendlyEncodeHTML(sourceName) + ":");
add(leftPanel);
add(rightPanel);
dtLabel1 = new JLabel();
dtLabel1 = DockingUtils.createHtmlLabel();
dtLabel1.setOpaque(true);
dtLabel1.setBackground(Color.WHITE);
dtLabel1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0));
dtLabel1.setVerticalAlignment(SwingConstants.TOP);
dtLabel2 = new JLabel();
dtLabel2 = DockingUtils.createHtmlLabel();
dtLabel2.setOpaque(true);
dtLabel2.setBackground(Color.WHITE);
dtLabel2.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0));
@@ -97,12 +97,14 @@ class DataTypeComparePanel extends JPanel {
final JViewport viewport1 = leftScrollPane.getViewport();
final JViewport viewport2 = rightScrollPane.getViewport();
viewport1.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int y = viewport1.getViewPosition().y;
viewport2.setViewPosition(new Point(0, y));
}
});
viewport2.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int y = viewport2.getViewPosition().y;
viewport1.setViewPosition(new Point(0, y));
@@ -23,6 +23,7 @@ import javax.swing.SwingUtilities;
import org.apache.commons.lang3.StringUtils;
import docking.DockingUtils;
import ghidra.app.plugin.core.datamgr.archive.DataTypeManagerHandler;
import ghidra.app.plugin.core.datamgr.archive.SourceArchive;
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
// aesthetically pleasing
String spacerString = createHTMLSpacerString(htmlContent, otherContent);
StringBuffer buffy = new StringBuffer();
StringBuilder buffy = new StringBuilder();
buffy.append("<HTML>");
// -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("<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);
// 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 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);
@@ -372,17 +375,15 @@ public class DataTypeSynchronizer {
* an HTML string of spaces that is wide enough to represent that width.
*/
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
// is what the JLabels below are doing for us
JLabel label1 = new JLabel("<HTML>" + htmlContent);
JLabel label2 = new JLabel("<HTML>" + otherHTMLContent);
JLabel label1 = DockingUtils.createHtmlLabel("<HTML>" + htmlContent);
JLabel label2 = DockingUtils.createHtmlLabel("<HTML>" + otherHTMLContent);
int maxPixelWidth =
Math.max(label1.getPreferredSize().width, label2.getPreferredSize().width);
FontMetrics fontMetrics = label1.getFontMetrics(label1.getFont());
StringBuffer bigBuffy = new StringBuffer();
StringBuilder bigBuffy = new StringBuilder();
String HTMLSpace = "&nbsp";
int invisibleCharCount = HTMLSpace.length();
for (int i = 0; i < 150; i++) {
@@ -396,7 +397,7 @@ public class DataTypeSynchronizer {
}
}
return buffy.toString();
return bigBuffy.toString();
}
public String getClientName() {
@@ -197,8 +197,8 @@ class OpenDomainFileTask extends Task {
if (dfile.isInWritableProject() && dfile.canRecover()) {
Runnable r = () -> {
int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found",
dfile.getName() + " has crash data.\n" +
"Would you like to recover unsaved changes?");
"<html>" + HTMLUtilities.friendlyEncodeHTML(dfile.getName()) +
" has crash data.<br>" + "Would you like to recover unsaved changes?");
recoverFile[0] = (option == OptionDialog.OPTION_ONE);
};
SwingUtilities.invokeAndWait(r);
@@ -62,7 +62,7 @@ public class CreatePointerAction extends DockingAction {
Msg.showInfo(getClass(), gTree, "Pointers Filter Enabled",
"<html>Newly created pointer is filtered out of view.<br><br>Toggle the " +
"<b>Filter Pointers " + "Action</b> to view the pointer<br>Pointer: " +
newManager.getName() + newPath);
HTMLUtilities.friendlyEncodeHTML(newManager.getName() + newPath));
return;
}
@@ -15,15 +15,15 @@
*/
package ghidra.app.plugin.core.datamgr.actions;
import java.awt.Component;
import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.tree.TreePath;
import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.list.GListCellRenderer;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.tree.ArchiveNode;
import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode;
@@ -59,18 +59,18 @@ public class CreateTypeDefDialog extends DialogComponentProvider {
JPanel panel = new JPanel(new PairLayout());
// category info
panel.add(new JLabel("Category:"));
panel.add(new JLabel(category.getCategoryPath().getPath()));
panel.add(DockingUtils.createNonHtmlLabel("Category:"));
panel.add(DockingUtils.createNonHtmlLabel(category.getCategoryPath().getPath()));
// name info
nameTextField = new JTextField(15);
panel.add(new JLabel("Name:"));
panel.add(DockingUtils.createNonHtmlLabel("Name:"));
panel.add(nameTextField);
// data type info
dataTypeEditor =
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());
dataTypeEditor.addCellEditorListener(new CellEditorListener() {
@@ -88,21 +88,9 @@ public class CreateTypeDefDialog extends DialogComponentProvider {
dataTypeEditor.setDefaultSelectedTreePath(selectedTreePath);
dataTypeManagerBox = new GhidraComboBox<>();
dataTypeManagerBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
JLabel label =
(JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
if (value != null) {
label.setText(((DataTypeManager) value).getName());
}
return label;
}
});
dataTypeManagerBox.setRenderer(
GListCellRenderer.createDefaultCellTextRenderer(dtm -> dtm.getName()));
DockingUtils.turnOffHTMLRendering(dataTypeManagerBox);
DataTypeManager[] dataTypeManagers = plugin.getDataTypeManagers();
for (DataTypeManager manager : dataTypeManagers) {
@@ -127,7 +115,7 @@ public class CreateTypeDefDialog extends DialogComponentProvider {
dataTypeManagerBox.setSelectedItem(itemToSelect);
panel.add(new JLabel("Archive:"));
panel.add(DockingUtils.createNonHtmlLabel("Archive:"));
panel.add(dataTypeManagerBox);
panel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +15,6 @@
*/
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.io.IOException;
@@ -31,6 +24,12 @@ import docking.ActionContext;
import docking.action.*;
import docking.widgets.OptionDialog;
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 {
@@ -92,10 +91,13 @@ public class DeleteArchiveAction extends DockingAction {
TreePath[] selectionPaths = gTree.getSelectionPaths();
FileArchiveNode node = (FileArchiveNode) selectionPaths[0].getLastPathComponent();
if (OptionDialog.showOptionDialogWithCancelAsDefaultButton(gTree, "Confirm Delete Operation",
"<html><b>Are you sure you want to delete archive: " + node.getName() + "?<br><br>" +
if (OptionDialog.showOptionDialogWithCancelAsDefaultButton(gTree,
"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 " +
"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;
}

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