mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-24 13:11:47 +00:00
GT-2698 refactor UI elements to lock down HTML rendering
This commit is contained in:
parent
a03c96d37b
commit
e0c25b0590
@ -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 = " ";
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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,11 +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.*;
|
||||
import ghidra.app.plugin.core.datamgr.tree.InvalidArchiveNode;
|
||||
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import docking.ActionContext;
|
||||
@ -29,6 +23,11 @@ import docking.action.MenuData;
|
||||
import docking.widgets.OptionDialog;
|
||||
import docking.widgets.tree.GTree;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
|
||||
import ghidra.app.plugin.core.datamgr.archive.*;
|
||||
import ghidra.app.plugin.core.datamgr.tree.InvalidArchiveNode;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
|
||||
public class RemoveInvalidArchiveFromProgramAction extends DockingAction {
|
||||
|
||||
@ -38,7 +37,8 @@ public class RemoveInvalidArchiveFromProgramAction extends DockingAction {
|
||||
super("Remove Invalid Archive", plugin.getName());
|
||||
this.plugin = plugin;
|
||||
|
||||
setPopupMenuData(new MenuData(new String[] { "Remove Archive From Program" }, null, "File"));
|
||||
setPopupMenuData(
|
||||
new MenuData(new String[] { "Remove Archive From Program" }, null, "File"));
|
||||
|
||||
setDescription("Removes the archive from program and tool");
|
||||
setEnabled(true);
|
||||
@ -76,11 +76,12 @@ public class RemoveInvalidArchiveFromProgramAction extends DockingAction {
|
||||
InvalidArchiveNode invalidArchiveNode = (InvalidArchiveNode) pathComponent;
|
||||
|
||||
if (OptionDialog.showOptionDialog(gtree, "Confirm Remove Invalid Archive(s)",
|
||||
"<html><b>Are you sure you want to delete archive: " + invalidArchiveNode.getName() +
|
||||
"<html><b>Are you sure you want to delete archive: " +
|
||||
HTMLUtilities.friendlyEncodeHTML(invalidArchiveNode.getName()) +
|
||||
" from the program?<br><br>" +
|
||||
"<font color=\"red\">(WARNING: This action will disassociate " +
|
||||
"all datatypes in the program from this archive.)</font></b>", "Yes",
|
||||
OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
|
||||
"all datatypes in the program from this archive.)</font></b>",
|
||||
"Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,296 +0,0 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.core.datamgr.archive;
|
||||
|
||||
import ghidra.framework.plugintool.Plugin;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.UniversalID;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Document;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
|
||||
public class ChooseArchiveDialog extends DialogComponentProvider {
|
||||
|
||||
private JPanel archiveListPanel;
|
||||
private JTextField filterField;
|
||||
private boolean removeWasCanceled;
|
||||
private Archive currentArchive;
|
||||
private List<Archive> archiveList;
|
||||
private JList list;
|
||||
private DefaultListModel listModel;
|
||||
|
||||
public ChooseArchiveDialog(Plugin plugin, String title, Archive currentArchive,
|
||||
List<Archive> archiveList) {
|
||||
super(title);
|
||||
this.currentArchive = currentArchive;
|
||||
this.archiveList = archiveList;
|
||||
createArchiveListPanel();
|
||||
filterField = getFilterField();
|
||||
addWorkPanel(archiveListPanel);
|
||||
addOKButton();
|
||||
setOkToolTip("Choose the archive file to synchronize.");
|
||||
addCancelButton();
|
||||
setHelpLocation(new HelpLocation(plugin.getName(), "Choose_Archive"));
|
||||
}
|
||||
|
||||
public boolean wasCanceled() {
|
||||
return removeWasCanceled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelCallback() {
|
||||
removeWasCanceled = true;
|
||||
clearStatusText();
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void okCallback() {
|
||||
clearStatusText();
|
||||
Archive selectedArchive = getSelectedArchive();
|
||||
|
||||
if (selectedArchive == null) {
|
||||
setStatusText("Please select an archive to synchronize.");
|
||||
return;
|
||||
}
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the JList component.
|
||||
*/
|
||||
JList getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
JTextField getFilterField() {
|
||||
return filterField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the selected data type archive in the JList.
|
||||
* @return null if no object is selected
|
||||
*/
|
||||
public Archive getSelectedArchive() {
|
||||
int index = list.getSelectedIndex();
|
||||
if (index >= 0) {
|
||||
return (Archive) listModel.get(index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void selectArchive(Archive archive) {
|
||||
int index = listModel.indexOf(archive);
|
||||
list.setSelectedIndex(index);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void requestFocus() {
|
||||
// filterField.requestFocus();
|
||||
// filterField.selectAll();
|
||||
// filterList( filterField.getText() );
|
||||
// }
|
||||
|
||||
private void createArchiveListPanel() {
|
||||
|
||||
archiveListPanel = new JPanel(new BorderLayout());
|
||||
JPanel northPanel = new JPanel();
|
||||
String instructions =
|
||||
"<HTML>Choose the archive to synchronize with <B>" + currentArchive.getName() +
|
||||
"</B>.</HTML>";
|
||||
JLabel instructionLabel = new JLabel(instructions);
|
||||
northPanel.add(instructionLabel, BorderLayout.NORTH);
|
||||
northPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 8, 3));
|
||||
archiveListPanel.add(northPanel, BorderLayout.NORTH);
|
||||
|
||||
// Create the list
|
||||
listModel = new DefaultListModel();
|
||||
initListModel();
|
||||
list = new JList(listModel);
|
||||
list.setCellRenderer(new MyListCellRenderer());
|
||||
list.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)) {
|
||||
if (list.getSelectedValue() != null) {
|
||||
okCallback();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Set the preferred row count. This affects the preferredSize
|
||||
// of the JList when it's in a scrollpane.
|
||||
int size = listModel.getSize();
|
||||
list.setVisibleRowCount(size);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(list);
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrollPane.setBorder(BorderFactory.createEmptyBorder());
|
||||
|
||||
JPanel southPanel = new JPanel();
|
||||
southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS));
|
||||
|
||||
filterField = createFilterField();
|
||||
southPanel.add(new JLabel("Filter: "));
|
||||
southPanel.add(filterField);
|
||||
southPanel.setBorder(BorderFactory.createEmptyBorder(8, 3, 8, 3));
|
||||
|
||||
archiveListPanel.add(southPanel, BorderLayout.SOUTH);
|
||||
|
||||
// Add list to a scrollpane
|
||||
JPanel listPanel = new JPanel(new BorderLayout());
|
||||
listPanel.add(scrollPane, BorderLayout.CENTER);
|
||||
listPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
|
||||
archiveListPanel.add(listPanel);
|
||||
}
|
||||
|
||||
private JTextField createFilterField() {
|
||||
JTextField newFilterField = new JTextField(20);
|
||||
// newFilterField.setBackground( BACKGROUND_COLOR );
|
||||
// newFilterField.setBorder( BorderFactory.createEmptyBorder( 0, 0, 5, 0 ) );
|
||||
|
||||
newFilterField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
filter(e.getDocument());
|
||||
}
|
||||
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
filter(e.getDocument());
|
||||
}
|
||||
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
filter(e.getDocument());
|
||||
}
|
||||
|
||||
private void filter(Document document) {
|
||||
try {
|
||||
String text = document.getText(0, document.getLength());
|
||||
filterList(text);
|
||||
}
|
||||
catch (BadLocationException e) {
|
||||
// shouldn't happen; don't care
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return newFilterField;
|
||||
}
|
||||
|
||||
private void filterList(String filterText) {
|
||||
List<Archive> allDataList = new ArrayList<Archive>();
|
||||
allDataList.addAll(archiveList);
|
||||
|
||||
boolean hasFilter = filterText.trim().length() != 0;
|
||||
if (hasFilter) {
|
||||
String lowerCaseFilterText = filterText.toLowerCase();
|
||||
for (Iterator<Archive> iterator = allDataList.iterator(); iterator.hasNext();) {
|
||||
Archive archive = iterator.next();
|
||||
String archiveString = getStringUsedInList(archive).toLowerCase();
|
||||
if (archiveString.indexOf(lowerCaseFilterText) < 0) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
listModel.clear();
|
||||
for (Archive archive : allDataList) {
|
||||
listModel.addElement(archive);
|
||||
}
|
||||
|
||||
// select something in the list so that the user can make a selection from the keyboard
|
||||
int totalListSize = archiveList.size();
|
||||
int shownListSize = listModel.getSize();
|
||||
if (shownListSize > 0) {
|
||||
int selectedIndex = list.getSelectedIndex();
|
||||
if (selectedIndex < 0) {
|
||||
list.setSelectedIndex(0);
|
||||
}
|
||||
if (shownListSize == totalListSize) {
|
||||
clearStatusText();
|
||||
}
|
||||
else {
|
||||
setStatusText("Filter is hiding " + (totalListSize - shownListSize) +
|
||||
" of the archive choices.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
setStatusText("Filter is hiding all possible archive choices.");
|
||||
}
|
||||
}
|
||||
|
||||
private String getStringUsedInList(Archive archive) {
|
||||
return archive.getName();
|
||||
}
|
||||
|
||||
private void initListModel() {
|
||||
listModel.clear();
|
||||
for (int i = 0; i < archiveList.size(); i++) {
|
||||
Archive archive = archiveList.get(i);
|
||||
UniversalID sourceID = currentArchive.getDataTypeManager().getUniversalID();
|
||||
SourceArchive sourceArchive = archive.getDataTypeManager().getSourceArchive(sourceID);
|
||||
if (sourceArchive != null) {
|
||||
// This archive at least had a data type from the source archive at one time.
|
||||
listModel.addElement(archive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MyListCellRenderer extends JLabel implements ListCellRenderer {
|
||||
|
||||
MyListCellRenderer() {
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
|
||||
*/
|
||||
public Component getListCellRendererComponent(JList localList, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
Archive archive = (Archive) value;
|
||||
setIcon(archive.getIcon(false));
|
||||
setIconTextGap(5);
|
||||
|
||||
String text = getStringUsedInList(archive);
|
||||
setText(text);
|
||||
if (isSelected) {
|
||||
setBackground(localList.getSelectionBackground());
|
||||
setForeground(localList.getSelectionForeground());
|
||||
}
|
||||
else {
|
||||
setBackground(localList.getBackground());
|
||||
setForeground(localList.getForeground());
|
||||
}
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 10));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@ -1316,7 +1316,7 @@ public class DataTypeManagerHandler {
|
||||
private boolean acquireSaveLock(UndoableDomainObject undoableDomainObject) {
|
||||
if (!undoableDomainObject.lock(null)) {
|
||||
String title = "Save " + CONTENT_NAME + " (Busy)";
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("The " + CONTENT_NAME + " is currently being modified by \n");
|
||||
buf.append("the following actions:\n ");
|
||||
Transaction t = undoableDomainObject.getCurrentTransaction();
|
||||
|
@ -21,6 +21,7 @@ import java.util.List;
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.ComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
import ghidra.app.plugin.core.compositeeditor.*;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
|
||||
@ -574,7 +575,7 @@ public class DataTypeEditorManager
|
||||
}
|
||||
|
||||
setCallingConventionChoices(choices);
|
||||
parentPanel.add(new JLabel("Calling Convention:"));
|
||||
parentPanel.add(DockingUtils.createNonHtmlLabel("Calling Convention:"));
|
||||
parentPanel.add(callingConventionComboBox);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import javax.swing.event.*;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.OptionDialog;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
import docking.widgets.table.GTableCellRenderer;
|
||||
@ -381,7 +382,7 @@ class EnumEditorPanel 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(descLabel.getPreferredSize()));
|
||||
panel.add(label);
|
||||
panel.add(Box.createHorizontalStrut(2));
|
||||
@ -397,7 +398,7 @@ class EnumEditorPanel extends JPanel {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
||||
|
||||
descLabel = new JLabel("Description:", SwingConstants.RIGHT);
|
||||
descLabel = DockingUtils.createNonHtmlLabel("Description:", SwingConstants.RIGHT);
|
||||
|
||||
panel.add(descLabel);
|
||||
panel.add(Box.createHorizontalStrut(2));
|
||||
@ -430,13 +431,13 @@ class EnumEditorPanel extends JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
JLabel label = new JLabel("Category:", SwingConstants.RIGHT);
|
||||
JLabel label = DockingUtils.createNonHtmlLabel("Category:", SwingConstants.RIGHT);
|
||||
label.setPreferredSize(new Dimension(descLabel.getPreferredSize()));
|
||||
panel.add(label);
|
||||
panel.add(Box.createHorizontalStrut(2));
|
||||
panel.add(categoryField);
|
||||
panel.add(Box.createHorizontalStrut(20));
|
||||
panel.add(new JLabel("Size:"));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Size:"));
|
||||
panel.add(Box.createHorizontalStrut(5));
|
||||
panel.add(sizeComboBox);
|
||||
|
||||
|
@ -398,7 +398,8 @@ public class EnumEditorProvider extends ComponentProviderAdapter
|
||||
newVal = "Missing";
|
||||
}
|
||||
msg.append(String.format("<li>%s: 0x%s \u2192 <font color=#ff0000>%s</font></li>",
|
||||
field, Long.toHexString(originalEnum.getValue(field)), newVal));
|
||||
HTMLUtilities.friendlyEncodeHTML(field),
|
||||
Long.toHexString(originalEnum.getValue(field)), newVal));
|
||||
}
|
||||
msg.append("</ul>");
|
||||
msg.append(
|
||||
|
@ -23,8 +23,7 @@ import docking.widgets.tree.GTreeLazyNode;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import ghidra.app.plugin.core.datamgr.util.DataTypeUtils;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.util.InvalidNameException;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.exception.DuplicateNameException;
|
||||
|
||||
@ -67,8 +66,7 @@ public class CategoryNode extends GTreeLazyNode implements DataTypeTreeNode {
|
||||
|
||||
Category[] subCategories = category.getCategories();
|
||||
DataType[] dataTypes = category.getDataTypes();
|
||||
List<GTreeNode> children =
|
||||
new ArrayList<>(subCategories.length + dataTypes.length);
|
||||
List<GTreeNode> children = new ArrayList<>(subCategories.length + dataTypes.length);
|
||||
for (Category subCategory : subCategories) {
|
||||
children.add(new CategoryNode(subCategory));
|
||||
}
|
||||
@ -142,7 +140,7 @@ public class CategoryNode extends GTreeLazyNode implements DataTypeTreeNode {
|
||||
|
||||
@Override
|
||||
public String getToolTip() {
|
||||
return category.getCategoryPathName();
|
||||
return "<html>" + HTMLUtilities.friendlyEncodeHTML(category.getCategoryPathName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,7 @@ import ghidra.app.plugin.core.datamgr.archive.DomainFileArchive;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import resources.MultiIcon;
|
||||
import resources.ResourceManager;
|
||||
import resources.icons.TranslateIcon;
|
||||
@ -102,7 +103,7 @@ public class DomainFileArchiveNode extends ArchiveNode {
|
||||
public String getToolTip() {
|
||||
DomainFile file = ((DomainFileArchive) archive).getDomainFile();
|
||||
if (file != null) {
|
||||
return file.getPathname();
|
||||
return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getPathname());
|
||||
}
|
||||
return "[Unsaved New Domain File Archive]";
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import javax.swing.ImageIcon;
|
||||
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.app.plugin.core.datamgr.archive.FileArchive;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import resources.MultiIcon;
|
||||
import resources.ResourceManager;
|
||||
import resources.icons.TranslateIcon;
|
||||
@ -53,7 +54,7 @@ public class FileArchiveNode extends ArchiveNode {
|
||||
public String getToolTip() {
|
||||
ResourceFile file = fileArchive.getFile();
|
||||
if (file != null) {
|
||||
return file.getAbsolutePath();
|
||||
return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getAbsolutePath());
|
||||
}
|
||||
return "[Unsaved New Archive]";
|
||||
}
|
||||
|
@ -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,13 @@
|
||||
*/
|
||||
package ghidra.app.plugin.core.datamgr.tree;
|
||||
|
||||
import ghidra.app.plugin.core.datamgr.archive.Archive;
|
||||
import ghidra.app.plugin.core.datamgr.archive.InvalidFileArchive;
|
||||
import ghidra.program.model.data.ArchiveType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import ghidra.app.plugin.core.datamgr.archive.Archive;
|
||||
import ghidra.app.plugin.core.datamgr.archive.InvalidFileArchive;
|
||||
import ghidra.program.model.data.ArchiveType;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
|
||||
public class InvalidArchiveNode extends ArchiveNode {
|
||||
|
||||
@ -44,7 +43,8 @@ public class InvalidArchiveNode extends ArchiveNode {
|
||||
public String getToolTip() {
|
||||
ArchiveType archiveType = ((InvalidFileArchive) archive).getArchiveType();
|
||||
String type = archiveType == ArchiveType.FILE ? "File" : "Project";
|
||||
return "Unable to locate " + type + " data type archive: " + archive.getName();
|
||||
return "<html>Unable to locate " + type + " data type archive: " +
|
||||
HTMLUtilities.friendlyEncodeHTML(archive.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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.
|
||||
@ -18,6 +17,7 @@ package ghidra.app.plugin.core.datamgr.tree;
|
||||
|
||||
import ghidra.app.plugin.core.datamgr.archive.ProgramArchive;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
|
||||
public class ProgramArchiveNode extends DomainFileArchiveNode {
|
||||
|
||||
@ -29,7 +29,7 @@ public class ProgramArchiveNode extends DomainFileArchiveNode {
|
||||
public String getToolTip() {
|
||||
DomainFile file = ((ProgramArchive) archive).getDomainFile();
|
||||
if (file != null) {
|
||||
return file.getPathname();
|
||||
return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getPathname());
|
||||
}
|
||||
return "[Unsaved New Program Archive]";
|
||||
}
|
||||
|
@ -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.
|
||||
@ -18,6 +17,7 @@ package ghidra.app.plugin.core.datamgr.tree;
|
||||
|
||||
import ghidra.app.plugin.core.datamgr.archive.ProjectArchive;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
|
||||
public class ProjectArchiveNode extends DomainFileArchiveNode {
|
||||
|
||||
@ -37,7 +37,7 @@ public class ProjectArchiveNode extends DomainFileArchiveNode {
|
||||
public String getToolTip() {
|
||||
DomainFile file = ((ProjectArchive) archive).getDomainFile();
|
||||
if (file != null) {
|
||||
return file.getPathname();
|
||||
return "<html>" + HTMLUtilities.friendlyEncodeHTML(file.getPathname());
|
||||
}
|
||||
return "[Unsaved New Project Archive]";
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.util.HelpLocation;
|
||||
import resources.ResourceManager;
|
||||
|
||||
@ -140,9 +141,10 @@ public class ConflictDialog extends DialogComponentProvider {
|
||||
}
|
||||
|
||||
private JPanel createLabelPanel(String dtName, String categoryPath) {
|
||||
JLabel imageLabel = new JLabel(INFORM_ICON);
|
||||
JLabel imageLabel = DockingUtils.createNonHtmlLabel(INFORM_ICON);
|
||||
|
||||
JLabel infoLabel = new JLabel("Conflict exists in " + categoryPath + " for " + dtName);
|
||||
JLabel infoLabel = DockingUtils.createNonHtmlLabel(
|
||||
"Conflict exists in " + categoryPath + " for " + dtName);
|
||||
|
||||
JPanel labelPanel = new JPanel();
|
||||
labelPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 20));
|
||||
|
@ -24,6 +24,7 @@ import javax.swing.*;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.filter.FilterOptions;
|
||||
import docking.widgets.filter.TextFilterStrategy;
|
||||
import docking.widgets.tree.*;
|
||||
@ -98,8 +99,7 @@ public class DataTypeChooserDialog extends DialogComponentProvider {
|
||||
|
||||
private JComponent createWorkPanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
String message = "Choose the data type you wish to use.";
|
||||
messageLabel = new JLabel(message);
|
||||
messageLabel = DockingUtils.createNonHtmlLabel("Choose the data type you wish to use.");
|
||||
messageLabel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 2));
|
||||
panel.add(messageLabel, BorderLayout.NORTH);
|
||||
panel.add(this.tree, BorderLayout.CENTER);
|
||||
|
@ -490,11 +490,11 @@ public class DataTypeUtils {
|
||||
// JFrame frame = new JFrame();
|
||||
// JPanel panel = new JPanel();
|
||||
//
|
||||
// JLabel label1 = new JLabel();
|
||||
// JLabel label1 = DockingUtils.createNonHtmlLabel();
|
||||
// Icon icon = getOpenFolderIcon( false );
|
||||
// label1.setIcon( icon );
|
||||
//
|
||||
// JLabel label2 = new JLabel();
|
||||
// JLabel label2 = DockingUtils.createNonHtmlLabel();
|
||||
// Icon icon2 = ResourceManager.getDisabledIcon( (ImageIcon) icon );
|
||||
// label2.setIcon( icon2 );
|
||||
//
|
||||
|
@ -317,7 +317,7 @@ class FilterAction extends ToggleDockingAction {
|
||||
JPanel filterPanel = new JPanel(new BorderLayout());
|
||||
filterField = new FilterTextField(checkboxPanel);
|
||||
filterPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
|
||||
filterPanel.add(new JLabel("Filter:"), BorderLayout.WEST);
|
||||
filterPanel.add(DockingUtils.createNonHtmlLabel("Filter:"), BorderLayout.WEST);
|
||||
|
||||
filterPanel.add(filterField, BorderLayout.CENTER);
|
||||
filterField.addFilterListener(filterListener);
|
||||
|
@ -23,8 +23,7 @@ import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.*;
|
||||
import docking.ToolTipManager;
|
||||
import docking.action.*;
|
||||
import ghidra.app.events.ProgramSelectionPluginEvent;
|
||||
@ -148,7 +147,7 @@ public class AddressTableDialog extends DialogComponentProvider {
|
||||
JPanel searchOptionsPanel = new JPanel(new BorderLayout());
|
||||
searchOptionsPanel.setBorder(BorderFactory.createTitledBorder("Search Options"));
|
||||
|
||||
JLabel minLengthLabel = new JLabel("Minimum Length: ");
|
||||
JLabel minLengthLabel = DockingUtils.createNonHtmlLabel("Minimum Length: ");
|
||||
ToolTipManager.setToolTipText(minLengthLabel,
|
||||
"The minimum number of consecutive addresses that will make an address table.");
|
||||
minLengthField = new JTextField(5);
|
||||
@ -159,7 +158,7 @@ public class AddressTableDialog extends DialogComponentProvider {
|
||||
minLengthPanel.add(minLengthLabel);
|
||||
minLengthPanel.add(minLengthField);
|
||||
|
||||
alignLabel = new JLabel("Alignment: ");
|
||||
alignLabel = DockingUtils.createNonHtmlLabel("Alignment: ");
|
||||
alignField = new JTextField(5);
|
||||
alignField.setName("Alignment");
|
||||
ToolTipManager.setToolTipText(alignLabel,
|
||||
@ -170,7 +169,7 @@ public class AddressTableDialog extends DialogComponentProvider {
|
||||
}
|
||||
alignField.setText("" + align);
|
||||
|
||||
skipLabel = new JLabel("Skip Length: ");
|
||||
skipLabel = DockingUtils.createNonHtmlLabel("Skip Length: ");
|
||||
skipField = new JTextField(5);
|
||||
skipField.setName("Skip");
|
||||
ToolTipManager.setToolTipText(skipLabel,
|
||||
@ -230,12 +229,12 @@ public class AddressTableDialog extends DialogComponentProvider {
|
||||
ToolTipManager.setToolTipText(autoLabelCB,
|
||||
"Label the top of the address table and all members of the table.");
|
||||
|
||||
offsetLabel = new JLabel("Offset: ");
|
||||
offsetLabel = DockingUtils.createNonHtmlLabel("Offset: ");
|
||||
ToolTipManager.setToolTipText(offsetLabel,
|
||||
"Offset from the beginning of the selected table(s)");
|
||||
offsetLabel.setEnabled(false);
|
||||
|
||||
JLabel viewOffsetLabel = new JLabel(" ");
|
||||
JLabel viewOffsetLabel = DockingUtils.createNonHtmlLabel(" ");
|
||||
viewOffsetLabel.setEnabled(false);
|
||||
|
||||
viewOffset = new HintTextField(20);
|
||||
|
@ -23,6 +23,7 @@ import javax.swing.*;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.WindowPosition;
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
import ghidra.GhidraOptions;
|
||||
import ghidra.app.CorePluginPackage;
|
||||
import ghidra.app.plugin.PluginCategoryNames;
|
||||
@ -42,8 +43,7 @@ import ghidra.program.model.address.AddressOverflowException;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
import ghidra.program.util.ProgramSelection;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.exception.UsrException;
|
||||
|
||||
/**
|
||||
@ -421,23 +421,26 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
|
||||
initializeDisplay();
|
||||
|
||||
// we need to do some custom rendering
|
||||
contentList.setCellRenderer(new DefaultListCellRenderer() {
|
||||
contentList.setCellRenderer(new GListCellRenderer<DisassembledAddressInfo>() {
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value,
|
||||
int index, boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel renderer = (JLabel) super.getListCellRendererComponent(list, value,
|
||||
index, isSelected, cellHasFocus);
|
||||
protected String getItemText(DisassembledAddressInfo value) {
|
||||
return value.getAddressPreview(addressPreviewFormat);
|
||||
}
|
||||
|
||||
renderer.setFont(font);
|
||||
@Override
|
||||
public Component getListCellRendererComponent(
|
||||
JList<? extends DisassembledAddressInfo> list,
|
||||
DisassembledAddressInfo value, int index, boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
|
||||
renderer.setToolTipText(TOOLTIP_TEXT_PREPEND + currentLocation.getAddress());
|
||||
super.getListCellRendererComponent(list, value, index, isSelected,
|
||||
cellHasFocus);
|
||||
|
||||
// first let's set the text to the user-defined option, if
|
||||
// we have the correct type of class
|
||||
if (value instanceof DisassembledAddressInfo) {
|
||||
renderer.setText(((DisassembledAddressInfo) value).getAddressPreview(
|
||||
addressPreviewFormat));
|
||||
}
|
||||
setFont(font);
|
||||
|
||||
setToolTipText(TOOLTIP_TEXT_PREPEND +
|
||||
HTMLUtilities.friendlyEncodeHTML(currentLocation.getAddress().toString()));
|
||||
|
||||
// make sure the first value is highlighted to indicate
|
||||
// that it is the selected program location
|
||||
@ -450,13 +453,12 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
|
||||
background = background.darker();
|
||||
}
|
||||
|
||||
renderer.setForeground(foreground);
|
||||
renderer.setBackground(background);
|
||||
setForeground(foreground);
|
||||
setBackground(background);
|
||||
}
|
||||
|
||||
return renderer;
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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,6 @@
|
||||
*/
|
||||
package ghidra.app.plugin.core.disassembler;
|
||||
|
||||
import ghidra.app.util.bean.FixedBitSizeValueField;
|
||||
import ghidra.program.model.lang.Register;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
import ghidra.program.model.listing.ProgramContext;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
@ -33,107 +25,114 @@ import java.util.ArrayList;
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.app.util.bean.FixedBitSizeValueField;
|
||||
import ghidra.program.model.lang.Register;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
import ghidra.program.model.listing.ProgramContext;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
public class ProcessorStateDialog extends DialogComponentProvider {
|
||||
|
||||
private JPanel mainPanel;
|
||||
private JPanel mainPanel;
|
||||
|
||||
private final static String TITLE = "Specify Processor Disassembly Options";
|
||||
private final static String TITLE = "Specify Processor Disassembly Options";
|
||||
|
||||
private FixedBitSizeValueField[] fields;
|
||||
private java.util.List<Register> registerList;
|
||||
private FixedBitSizeValueField[] fields;
|
||||
private java.util.List<Register> registerList;
|
||||
private ProgramContext programContext;
|
||||
|
||||
|
||||
public ProcessorStateDialog(ProgramContext programContext) {
|
||||
super(TITLE, true, false, true, false);
|
||||
super(TITLE, true, false, true, false);
|
||||
this.programContext = programContext;
|
||||
Register[] contextRegisters = programContext.getProcessorStateRegisters();
|
||||
registerList = new ArrayList<Register>();
|
||||
registerList = new ArrayList<>();
|
||||
for (Register register : contextRegisters) {
|
||||
if (!register.isBaseRegister()) {
|
||||
registerList.add(register);
|
||||
}
|
||||
}
|
||||
RegisterValue currentContext = programContext.getDefaultDisassemblyContext();
|
||||
addOKButton();
|
||||
addCancelButton();
|
||||
RegisterValue currentContext = programContext.getDefaultDisassemblyContext();
|
||||
addOKButton();
|
||||
addCancelButton();
|
||||
|
||||
JPanel workPanel = new JPanel(new PairLayout(4,4));
|
||||
workPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
|
||||
fields = new FixedBitSizeValueField[registerList.size()];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
Register register = registerList.get(i);
|
||||
int numbits = register.getBitLength();
|
||||
JLabel label = new JLabel(register.getName()+" [ "+register.getBitLength()
|
||||
+ " bit" + ((numbits == 1) ? "" : "s") + " ] :");
|
||||
label.setHorizontalAlignment(SwingConstants.TRAILING);
|
||||
label.setToolTipText(register.getDescription());
|
||||
workPanel.add(label);
|
||||
JPanel workPanel = new JPanel(new PairLayout(4, 4));
|
||||
workPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
|
||||
fields = new FixedBitSizeValueField[registerList.size()];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
Register register = registerList.get(i);
|
||||
int numbits = register.getBitLength();
|
||||
JLabel label = DockingUtils.createNonHtmlLabel(register.getName() + " [ " +
|
||||
register.getBitLength() + " bit" + ((numbits == 1) ? "" : "s") + " ] :");
|
||||
label.setHorizontalAlignment(SwingConstants.TRAILING);
|
||||
label.setToolTipText(register.getDescription());
|
||||
workPanel.add(label);
|
||||
fields[i] = new FixedBitSizeValueField(register.getBitLength(), false, false);
|
||||
fields[i].setValue( currentContext.getRegisterValue(register).getUnsignedValue() );
|
||||
fields[i].setValue(currentContext.getRegisterValue(register).getUnsignedValue());
|
||||
workPanel.add(fields[i]);
|
||||
}
|
||||
mainPanel = new JPanel(new BorderLayout());
|
||||
JScrollPane scrollPane = new JScrollPane(workPanel);
|
||||
mainPanel.add(scrollPane, BorderLayout.CENTER);
|
||||
JPanel radioPanel = new JPanel(new FlowLayout());
|
||||
mainPanel.add(radioPanel, BorderLayout.SOUTH);
|
||||
JRadioButton hexButton = new JRadioButton("Hex");
|
||||
JRadioButton decimalButton = new JRadioButton("Decimal");
|
||||
hexButton.setSelected(true);
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(hexButton);
|
||||
group.add(decimalButton);
|
||||
radioPanel.add(hexButton);
|
||||
radioPanel.add(decimalButton);
|
||||
hexButton.addActionListener(new ActionListener() {
|
||||
mainPanel = new JPanel(new BorderLayout());
|
||||
JScrollPane scrollPane = new JScrollPane(workPanel);
|
||||
mainPanel.add(scrollPane, BorderLayout.CENTER);
|
||||
JPanel radioPanel = new JPanel(new FlowLayout());
|
||||
mainPanel.add(radioPanel, BorderLayout.SOUTH);
|
||||
JRadioButton hexButton = new JRadioButton("Hex");
|
||||
JRadioButton decimalButton = new JRadioButton("Decimal");
|
||||
hexButton.setSelected(true);
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(hexButton);
|
||||
group.add(decimalButton);
|
||||
radioPanel.add(hexButton);
|
||||
radioPanel.add(decimalButton);
|
||||
hexButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setRadix(16);
|
||||
}
|
||||
});
|
||||
decimalButton.addActionListener(new ActionListener() {
|
||||
decimalButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setRadix(10);
|
||||
}
|
||||
});
|
||||
|
||||
addWorkPanel(mainPanel);
|
||||
setHelpLocation(new HelpLocation("DisassemblerPlugin","ProcessorOptions"));
|
||||
setRememberSize( false );
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void setRadix(int radix) {
|
||||
for (FixedBitSizeValueField field : fields) {
|
||||
addWorkPanel(mainPanel);
|
||||
setHelpLocation(new HelpLocation("DisassemblerPlugin", "ProcessorOptions"));
|
||||
setRememberSize(false);
|
||||
|
||||
}
|
||||
|
||||
protected void setRadix(int radix) {
|
||||
for (FixedBitSizeValueField field : fields) {
|
||||
field.setFormat(radix, false);
|
||||
}
|
||||
}
|
||||
|
||||
private RegisterValue setRegisterValue(RegisterValue registerValue, Register register, BigInteger value) {
|
||||
private RegisterValue setRegisterValue(RegisterValue registerValue, Register register,
|
||||
BigInteger value) {
|
||||
RegisterValue newValue = new RegisterValue(register, value);
|
||||
return registerValue.combineValues(newValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The callback method for when the "OK" button is pressed.
|
||||
*/
|
||||
@Override
|
||||
public void okCallback() {
|
||||
RegisterValue newValue = new RegisterValue(programContext.getBaseContextRegister());
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
BigInteger value = fields[i].getValue();
|
||||
if (value != null) {
|
||||
newValue = setRegisterValue(newValue, registerList.get(i), value);
|
||||
}
|
||||
* The callback method for when the "OK" button is pressed.
|
||||
*/
|
||||
@Override
|
||||
public void okCallback() {
|
||||
RegisterValue newValue = new RegisterValue(programContext.getBaseContextRegister());
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
BigInteger value = fields[i].getValue();
|
||||
if (value != null) {
|
||||
newValue = setRegisterValue(newValue, registerList.get(i), value);
|
||||
}
|
||||
}
|
||||
programContext.setDefaultDisassemblyContext(newValue);
|
||||
close();
|
||||
}
|
||||
|
||||
programContext.setDefaultDisassemblyContext(newValue);
|
||||
close();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ package ghidra.app.plugin.core.disassembler;
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
import ghidra.app.cmd.disassemble.SetFlowOverrideCmd;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
@ -96,8 +97,8 @@ class SetFlowOverrideDialog extends DialogComponentProvider {
|
||||
|
||||
FlowType flowType = instruction.getFlowType();
|
||||
|
||||
panel.add(new JLabel("Current Flow: " + flowType.getName() +
|
||||
(flowType.isConditional() ? "*" : "")));
|
||||
panel.add(DockingUtils.createNonHtmlLabel(
|
||||
"Current Flow: " + flowType.getName() + (flowType.isConditional() ? "*" : "")));
|
||||
|
||||
panel.add(Box.createGlue());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
@ -110,7 +111,7 @@ class SetFlowOverrideDialog extends DialogComponentProvider {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
||||
|
||||
panel.add(new JLabel(note));
|
||||
panel.add(DockingUtils.createNonHtmlLabel(note));
|
||||
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
|
||||
@ -139,7 +140,7 @@ class SetFlowOverrideDialog extends DialogComponentProvider {
|
||||
flowOverrideComboBox.setSelectedItem(flowOverride);
|
||||
}
|
||||
|
||||
panel.add(new JLabel("Instruction Flow:"));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Instruction Flow:"));
|
||||
panel.add(flowOverrideComboBox);
|
||||
|
||||
panel.add(Box.createGlue());
|
||||
@ -191,8 +192,8 @@ class SetFlowOverrideDialog extends DialogComponentProvider {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
tool.executeBackgroundCommand(
|
||||
new SetFlowOverrideCmd(instruction.getMinAddress(), flow), program);
|
||||
tool.executeBackgroundCommand(new SetFlowOverrideCmd(instruction.getMinAddress(), flow),
|
||||
program);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DockingUtils;
|
||||
import docking.action.*;
|
||||
import docking.widgets.OptionDialog;
|
||||
import ghidra.app.context.ProgramActionContext;
|
||||
@ -218,7 +219,8 @@ public class EquateTableProvider extends ComponentProviderAdapter {
|
||||
setEquateTableRenderer();
|
||||
|
||||
JPanel equatesPanel = new JPanel(new BorderLayout());
|
||||
equatesPanel.add(new JLabel("Equates", SwingConstants.CENTER), BorderLayout.NORTH);
|
||||
equatesPanel.add(DockingUtils.createNonHtmlLabel("Equates", SwingConstants.CENTER),
|
||||
BorderLayout.NORTH);
|
||||
equatesPanel.add(equatesTablePane, BorderLayout.CENTER);
|
||||
equatesPanel.add(equatesFilterPanel, BorderLayout.SOUTH);
|
||||
|
||||
@ -245,7 +247,8 @@ public class EquateTableProvider extends ComponentProviderAdapter {
|
||||
setReferenceTableRenderer();
|
||||
|
||||
JPanel referencesPanel = new JPanel(new BorderLayout());
|
||||
referencesPanel.add(new JLabel("References", SwingConstants.CENTER), "North");
|
||||
referencesPanel.add(DockingUtils.createNonHtmlLabel("References", SwingConstants.CENTER),
|
||||
"North");
|
||||
referencesPanel.add(referencesTablePane, "Center");
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
@ -27,6 +27,7 @@ import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.options.editor.ButtonPanelFactory;
|
||||
import docking.widgets.OptionDialog;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
@ -183,16 +184,16 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
||||
private Component buildMainPanel() {
|
||||
JPanel panel = new JPanel(new PairLayout(5, 5));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
panel.add(new JLabel("Format: ", SwingConstants.RIGHT));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Format: ", SwingConstants.RIGHT));
|
||||
panel.add(buildFormatChooser());
|
||||
panel.add(new JLabel("Output File: ", SwingConstants.RIGHT));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Output File: ", SwingConstants.RIGHT));
|
||||
panel.add(buildFilePanel());
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component buildSelectionCheckboxPanel() {
|
||||
JPanel panel = new JPanel(new PairLayout(5, 5));
|
||||
selectionOnlyLabel = new JLabel("Selection Only:");
|
||||
selectionOnlyLabel = DockingUtils.createNonHtmlLabel("Selection Only:");
|
||||
panel.add(selectionOnlyLabel);
|
||||
panel.add(buildSelectionCheckbox());
|
||||
return 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.
|
||||
@ -16,10 +15,6 @@
|
||||
*/
|
||||
package ghidra.app.plugin.core.fallthrough;
|
||||
|
||||
import ghidra.app.util.AddressInput;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@ -30,9 +25,13 @@ import javax.swing.border.TitledBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import resources.ResourceManager;
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.ToolTipManager;
|
||||
import ghidra.app.util.AddressInput;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.util.HelpLocation;
|
||||
import resources.ResourceManager;
|
||||
|
||||
/**
|
||||
* Dialog to prompt for overriding a fallthrough address on an
|
||||
@ -48,11 +47,11 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
|
||||
private JButton homeButton;
|
||||
private FallThroughPlugin plugin;
|
||||
private FallThroughModel model;
|
||||
private AddressInput addrField;
|
||||
private AddressInput addrField;
|
||||
private JRadioButton defaultRB;
|
||||
private JRadioButton userRB;
|
||||
private JRadioButton userRB;
|
||||
private boolean changing;
|
||||
|
||||
|
||||
FallThroughDialog(FallThroughPlugin plugin, FallThroughModel model) {
|
||||
super("Set Fallthrough Address", true);
|
||||
setHelpLocation(new HelpLocation(plugin.getName(), "Set Fallthrough"));
|
||||
@ -65,11 +64,12 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
|
||||
updateState();
|
||||
model.setChangeListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.util.bean.GhidraDialog#applyCallback()
|
||||
*/
|
||||
@Override
|
||||
protected void applyCallback() {
|
||||
protected void applyCallback() {
|
||||
model.execute();
|
||||
}
|
||||
|
||||
@ -77,14 +77,15 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
|
||||
* @see ghidra.util.bean.GhidraDialog#cancelCallback()
|
||||
*/
|
||||
@Override
|
||||
protected void cancelCallback() {
|
||||
protected void cancelCallback() {
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.util.bean.GhidraDialog#okCallback()
|
||||
*/
|
||||
@Override
|
||||
protected void okCallback() {
|
||||
protected void okCallback() {
|
||||
if (model.execute()) {
|
||||
cancelCallback();
|
||||
}
|
||||
@ -99,18 +100,18 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
|
||||
cancelCallback();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
changing = true;
|
||||
addressLabel.setText(addr.toString());
|
||||
instLabel.setText(model.getInstructionRepresentation());
|
||||
|
||||
|
||||
if (model.isDefaultFallthrough()) {
|
||||
defaultRB.setSelected(true);
|
||||
}
|
||||
else if (model.isUserDefinedFallthrough()) {
|
||||
userRB.setSelected(true);
|
||||
}
|
||||
|
||||
|
||||
Address ftAddr = model.getCurrentFallthrough();
|
||||
if (ftAddr != null) {
|
||||
if (!ftAddr.equals(addrField.getAddress())) {
|
||||
@ -122,7 +123,7 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
|
||||
}
|
||||
boolean enabled = model.allowAddressEdits();
|
||||
addrField.setEnabled(enabled);
|
||||
|
||||
|
||||
changing = false;
|
||||
if (model.isValidInput()) {
|
||||
setOkEnabled(true);
|
||||
@ -133,12 +134,14 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
|
||||
setStatusText(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private void addressChanged() {
|
||||
if (changing) {
|
||||
return;
|
||||
}
|
||||
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Address addr = addrField.getAddress();
|
||||
if (addr != null || addrField.getValue().length() == 0) {
|
||||
@ -153,20 +156,22 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
|
||||
};
|
||||
SwingUtilities.invokeLater(r);
|
||||
}
|
||||
|
||||
|
||||
private JPanel create() {
|
||||
JPanel panel = new JPanel(new BorderLayout(0, 10));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
|
||||
addrField = new AddressInput();
|
||||
addrField.setAddressFactory(model.getProgram().getAddressFactory());
|
||||
addrField.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
addressChanged();
|
||||
}
|
||||
});
|
||||
addrField.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
model.setCurrentFallthrough(addrField.getAddress());
|
||||
model.setCurrentFallthrough(addrField.getAddress());
|
||||
}
|
||||
});
|
||||
panel.add(createHomePanel(), BorderLayout.NORTH);
|
||||
@ -180,92 +185,98 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
|
||||
|
||||
panel.add(addrField, BorderLayout.NORTH);
|
||||
panel.add(createRadioButtonPanel(), BorderLayout.CENTER);
|
||||
return panel;
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JPanel createHomePanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(new TitledBorder("Home"));
|
||||
|
||||
addressLabel = new JLabel("01001000");
|
||||
|
||||
Font font = addressLabel.getFont();
|
||||
Font monoFont = new Font("monospaced", font.getStyle(),
|
||||
font.getSize());
|
||||
addressLabel.setFont(monoFont);
|
||||
|
||||
instLabel = new JLabel("jmp DAT_01001000");
|
||||
instLabel.setFont(monoFont);
|
||||
|
||||
homeButton = createButton("images/go-home.png", "Home");
|
||||
|
||||
addressLabel = DockingUtils.createNonHtmlLabel("01001000");
|
||||
|
||||
Font font = addressLabel.getFont();
|
||||
Font monoFont = new Font("monospaced", font.getStyle(), font.getSize());
|
||||
addressLabel.setFont(monoFont);
|
||||
|
||||
instLabel = DockingUtils.createNonHtmlLabel("jmp DAT_01001000");
|
||||
instLabel.setFont(monoFont);
|
||||
|
||||
homeButton = createButton("images/go-home.png", "Home");
|
||||
homeButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
plugin.goTo(model.getAddress());
|
||||
}
|
||||
});
|
||||
|
||||
JPanel innerPanel = new JPanel();
|
||||
BoxLayout bl = new BoxLayout(innerPanel,BoxLayout.X_AXIS);
|
||||
innerPanel.setLayout(bl);
|
||||
|
||||
innerPanel.add(Box.createHorizontalStrut(5));
|
||||
innerPanel.add(homeButton);
|
||||
innerPanel.add(Box.createHorizontalStrut(10));
|
||||
innerPanel.add(addressLabel);
|
||||
innerPanel.add(Box.createHorizontalStrut(20));
|
||||
innerPanel.add(instLabel);
|
||||
innerPanel.add(Box.createHorizontalStrut(10));
|
||||
panel.add(innerPanel, BorderLayout.CENTER);
|
||||
return panel;
|
||||
|
||||
JPanel innerPanel = new JPanel();
|
||||
BoxLayout bl = new BoxLayout(innerPanel, BoxLayout.X_AXIS);
|
||||
innerPanel.setLayout(bl);
|
||||
|
||||
innerPanel.add(Box.createHorizontalStrut(5));
|
||||
innerPanel.add(homeButton);
|
||||
innerPanel.add(Box.createHorizontalStrut(10));
|
||||
innerPanel.add(addressLabel);
|
||||
innerPanel.add(Box.createHorizontalStrut(20));
|
||||
innerPanel.add(instLabel);
|
||||
innerPanel.add(Box.createHorizontalStrut(10));
|
||||
panel.add(innerPanel, BorderLayout.CENTER);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JPanel createRadioButtonPanel() {
|
||||
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
BoxLayout bl = new BoxLayout(panel, BoxLayout.X_AXIS);
|
||||
panel.setLayout(bl);
|
||||
|
||||
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
defaultRB = new JRadioButton("Default", true);
|
||||
defaultRB.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ev) {
|
||||
model.defaultSelected();
|
||||
}
|
||||
});
|
||||
ToolTipManager.setToolTipText(defaultRB, "Use default fallthrough address");
|
||||
|
||||
|
||||
userRB = new JRadioButton("User", false);
|
||||
userRB.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ev) {
|
||||
model.userSelected();
|
||||
}
|
||||
});
|
||||
ToolTipManager.setToolTipText(userRB, "Override default fallthrough address");
|
||||
|
||||
|
||||
group.add(defaultRB);
|
||||
group.add(userRB);
|
||||
|
||||
|
||||
panel.add(defaultRB);
|
||||
panel.add(userRB);
|
||||
|
||||
|
||||
JPanel outerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||
outerPanel.add(panel);
|
||||
return outerPanel;
|
||||
}
|
||||
private JButton createButton(String filename, String altText) {
|
||||
JButton button = new JButton();
|
||||
URL imageURL = ResourceManager.getResource(filename);
|
||||
if (imageURL != null) {
|
||||
ImageIcon icon = new ImageIcon(imageURL);
|
||||
button = new JButton(icon);
|
||||
Insets noInsets = new Insets(0,0,0,0);
|
||||
button.setMargin(noInsets);
|
||||
}
|
||||
else {
|
||||
button = new JButton(altText);
|
||||
}
|
||||
}
|
||||
|
||||
private JButton createButton(String filename, String altText) {
|
||||
JButton button = new JButton();
|
||||
URL imageURL = ResourceManager.getResource(filename);
|
||||
if (imageURL != null) {
|
||||
ImageIcon icon = new ImageIcon(imageURL);
|
||||
button = new JButton(icon);
|
||||
Insets noInsets = new Insets(0, 0, 0, 0);
|
||||
button.setMargin(noInsets);
|
||||
}
|
||||
else {
|
||||
button = new JButton(altText);
|
||||
}
|
||||
ToolTipManager.setToolTipText(button, "Go back to home address");
|
||||
return button;
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
updateState();
|
||||
}
|
||||
|
@ -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,16 +15,17 @@
|
||||
*/
|
||||
package ghidra.app.plugin.core.flowarrow;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.symbol.RefType;
|
||||
import ghidra.util.exception.AssertException;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.symbol.RefType;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.exception.AssertException;
|
||||
|
||||
abstract class FlowArrow {
|
||||
|
||||
private static final int MIN_LINE_SPACING = 9;
|
||||
@ -50,7 +50,7 @@ abstract class FlowArrow {
|
||||
protected Shape arrowHead;
|
||||
|
||||
/** The shape of the arrow body, but with added size */
|
||||
private List<Shape> clickableShapes = new ArrayList<Shape>();
|
||||
private List<Shape> clickableShapes = new ArrayList<>();
|
||||
|
||||
FlowArrow(FlowArrowPlugin plugin, Component canvas, Address start, Address end,
|
||||
RefType referenceType) {
|
||||
@ -153,7 +153,7 @@ abstract class FlowArrow {
|
||||
}
|
||||
|
||||
private void createClickableShapes() {
|
||||
List<Shape> shapes = new ArrayList<Shape>();
|
||||
List<Shape> shapes = new ArrayList<>();
|
||||
Rectangle r = null;
|
||||
PathIterator it = arrowBody.getPathIterator(null);
|
||||
float[] coords = new float[6];
|
||||
@ -242,13 +242,11 @@ abstract class FlowArrow {
|
||||
int displayWidth = canvas.getWidth();// - FlowArrowPlugin.LEFT_OFFSET;
|
||||
int lineWidth = calculateLineWidth(displayWidth);
|
||||
|
||||
arrowBody =
|
||||
FlowArrowShapeFactory.createArrowBody(plugin, this, displayWidth, displayHeight,
|
||||
lineWidth);
|
||||
arrowBody = FlowArrowShapeFactory.createArrowBody(plugin, this, displayWidth, displayHeight,
|
||||
lineWidth);
|
||||
|
||||
arrowHead =
|
||||
FlowArrowShapeFactory.createArrowHead(plugin, this, displayWidth, displayHeight,
|
||||
lineWidth);
|
||||
arrowHead = FlowArrowShapeFactory.createArrowHead(plugin, this, displayWidth, displayHeight,
|
||||
lineWidth);
|
||||
}
|
||||
|
||||
private int calculateLineWidth(int displayWidth) {
|
||||
@ -323,8 +321,10 @@ abstract class FlowArrow {
|
||||
}
|
||||
|
||||
public String getDisplayString() {
|
||||
return "<html><table><tr><td>start</td><td>" + start + "</td><tr><td>end</td><td>" + end +
|
||||
"</td><tr><td>ref type</td><td>" + refType + "</td></tr></table>";
|
||||
return "<html><table><tr><td>start</td><td>" +
|
||||
HTMLUtilities.friendlyEncodeHTML(start.toString()) + "</td><tr><td>end</td><td>" +
|
||||
HTMLUtilities.friendlyEncodeHTML(end.toString()) + "</td><tr><td>ref type</td><td>" +
|
||||
refType + "</td></tr></table>";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
import ghidra.app.cmd.function.ApplyFunctionSignatureCmd;
|
||||
import ghidra.app.services.DataTypeManagerService;
|
||||
@ -127,7 +128,7 @@ public class EditFunctionSignatureDialog extends DialogComponentProvider {
|
||||
String signature = function.getPrototypeString(false, false);
|
||||
signatureField = new JTextField(signature.length()); // add some extra room to edit
|
||||
signatureField.setText(signature);
|
||||
signatureLabel = new JLabel("Signature:");
|
||||
signatureLabel = DockingUtils.createNonHtmlLabel("Signature:");
|
||||
signaturePanel.add(signatureLabel);
|
||||
signaturePanel.add(signatureField);
|
||||
|
||||
@ -164,7 +165,7 @@ public class EditFunctionSignatureDialog extends DialogComponentProvider {
|
||||
function.getProgram().getFunctionManager().getCallingConventionNames();
|
||||
String[] choices = callingConventions.toArray(new String[callingConventions.size()]);
|
||||
setCallingConventionChoices(choices);
|
||||
parentPanel.add(new JLabel("Calling Convention:"));
|
||||
parentPanel.add(DockingUtils.createNonHtmlLabel("Calling Convention:"));
|
||||
parentPanel.add(callingConventionComboBox);
|
||||
}
|
||||
|
||||
@ -214,7 +215,7 @@ public class EditFunctionSignatureDialog extends DialogComponentProvider {
|
||||
callFixupComboBox.setSelectedItem(callFixupName);
|
||||
}
|
||||
|
||||
callFixupPanel.add(new JLabel("Call-Fixup:"));
|
||||
callFixupPanel.add(DockingUtils.createNonHtmlLabel("Call-Fixup:"));
|
||||
callFixupPanel.add(callFixupComboBox);
|
||||
|
||||
callFixupPanel.add(Box.createGlue());
|
||||
|
@ -389,7 +389,7 @@ public class FunctionPlugin extends Plugin implements DataService {
|
||||
return program.getFunctionManager().getFunctionsOverlapping(new AddressSet(loc, loc));
|
||||
}
|
||||
//return an empty iterator....
|
||||
return new Iterator<Function>() {
|
||||
return new Iterator<>() {
|
||||
@Override
|
||||
public void remove() {
|
||||
// not supported
|
||||
@ -580,8 +580,8 @@ public class FunctionPlugin extends Plugin implements DataService {
|
||||
catch (VariableSizeException e) {
|
||||
tool.setStatusInfo(e.getMessage());
|
||||
if (e.canForce() && promptForConflictRemoval) {
|
||||
String msg = variable.getName() + " size change resulted in \n" + e.getMessage() +
|
||||
"\n \nDelete conflicting " + varType + "(s)";
|
||||
String msg = varType + " " + variable.getName() + " size change resulted in \n" +
|
||||
e.getMessage() + "\n \nDelete conflicting " + varType + "(s)";
|
||||
if (OptionDialog.YES_OPTION == OptionDialog.showYesNoDialog(tool.getActiveWindow(),
|
||||
varType + " Conflict", msg)) {
|
||||
tool.setStatusInfo("");
|
||||
|
@ -21,6 +21,7 @@ import java.util.List;
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.app.util.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.model.address.Address;
|
||||
@ -357,7 +358,7 @@ public class ThunkReferenceAddressDialog extends DialogComponentProvider {
|
||||
|
||||
JPanel mainPanel = new JPanel(new PairLayout(5, 5));
|
||||
refFunctionField = new JTextField(20);
|
||||
mainPanel.add(new JLabel("Destination Function/Address:"));
|
||||
mainPanel.add(DockingUtils.createNonHtmlLabel("Destination Function/Address:"));
|
||||
mainPanel.add(refFunctionField);
|
||||
|
||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
|
||||
|
@ -290,9 +290,9 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 15, 15));
|
||||
|
||||
JPanel leftPanel = new JPanel(new PairLayout(4, 8));
|
||||
leftPanel.add(new JLabel("Function Name:"));
|
||||
leftPanel.add(DockingUtils.createNonHtmlLabel("Function Name:"));
|
||||
leftPanel.add(createNameField());
|
||||
leftPanel.add(new JLabel("Calling Convention"));
|
||||
leftPanel.add(DockingUtils.createNonHtmlLabel("Calling Convention"));
|
||||
leftPanel.add(createCallingConventionCombo());
|
||||
leftPanel.setBorder(BorderFactory.createEmptyBorder(14, 0, 0, 10));
|
||||
|
||||
@ -601,7 +601,8 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
|
||||
color = Color.red;
|
||||
}
|
||||
String toolTipText = ToolTipUtils.getToolTipText(dataType);
|
||||
String headerText = "<HTML><b>" + dataType.getPathName() + "</b><BR>";
|
||||
String headerText = "<HTML><b>" +
|
||||
HTMLUtilities.friendlyEncodeHTML(dataType.getPathName()) + "</b><BR>";
|
||||
toolTipText = toolTipText.replace("<HTML>", headerText);
|
||||
setToolTipText(toolTipText);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import java.awt.event.*;
|
||||
import java.util.EventObject;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.event.CellEditorListener;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
@ -35,7 +34,6 @@ import ghidra.util.data.DataTypeParser;
|
||||
|
||||
class ParameterDataTypeCellEditor extends AbstractCellEditor implements TableCellEditor {
|
||||
private DataTypeSelectionEditor editor;
|
||||
private JLabel label = new JLabel();
|
||||
private DropDownSelectionTextField<DataType> textField;
|
||||
private JButton dataTypeChooserButton;
|
||||
private DataType dt;
|
||||
@ -44,8 +42,7 @@ class ParameterDataTypeCellEditor extends AbstractCellEditor implements TableCel
|
||||
private DataTypeManagerService service;
|
||||
private DialogComponentProvider dialog;
|
||||
|
||||
ParameterDataTypeCellEditor(DialogComponentProvider dialog,
|
||||
DataTypeManagerService service) {
|
||||
ParameterDataTypeCellEditor(DialogComponentProvider dialog, DataTypeManagerService service) {
|
||||
this.dialog = dialog;
|
||||
this.service = service;
|
||||
|
||||
@ -54,11 +51,6 @@ class ParameterDataTypeCellEditor extends AbstractCellEditor implements TableCel
|
||||
@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));
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
dt = (DataType) value;
|
||||
|
@ -25,6 +25,7 @@ import javax.swing.event.*;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.DropDownSelectionTextField;
|
||||
import docking.widgets.table.GTable;
|
||||
import ghidra.app.services.DataTypeManagerService;
|
||||
@ -37,8 +38,8 @@ import ghidra.util.Msg;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
import ghidra.util.layout.VerticalLayout;
|
||||
|
||||
public class StorageAddressEditorDialog extends DialogComponentProvider implements
|
||||
ModelChangeListener {
|
||||
public class StorageAddressEditorDialog extends DialogComponentProvider
|
||||
implements ModelChangeListener {
|
||||
private FunctionVariableData variableData;
|
||||
private StorageAddressModel model;
|
||||
private VarnodeTableModel varnodeTableModel;
|
||||
@ -160,10 +161,9 @@ public class StorageAddressEditorDialog extends DialogComponentProvider implemen
|
||||
JPanel panel = new JPanel(new PairLayout(10, 4));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
||||
|
||||
panel.add(new JLabel("Datatype: "));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Datatype: "));
|
||||
|
||||
dataTypeEditor =
|
||||
new ParameterDataTypeCellEditor(this, service);
|
||||
dataTypeEditor = new ParameterDataTypeCellEditor(this, service);
|
||||
|
||||
dataTypeEditor.addCellEditorListener(new CellEditorListener() {
|
||||
|
||||
@ -211,11 +211,11 @@ public class StorageAddressEditorDialog extends DialogComponentProvider implemen
|
||||
});
|
||||
|
||||
panel.add(dataTypeEditComponent);
|
||||
panel.add(new JLabel("Datatype Size: "));
|
||||
sizeLabel = new JLabel("" + size);
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Datatype Size: "));
|
||||
sizeLabel = DockingUtils.createNonHtmlLabel("" + size);
|
||||
panel.add(sizeLabel);
|
||||
panel.add(new JLabel("Allocated Size:"));
|
||||
currentSizeLabel = new JLabel("");
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Allocated Size:"));
|
||||
currentSizeLabel = DockingUtils.createNonHtmlLabel("");
|
||||
panel.add(currentSizeLabel);
|
||||
|
||||
setFocusComponent(textField);
|
||||
|
@ -21,7 +21,9 @@ import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
import ghidra.program.model.listing.FunctionTag;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
|
||||
/**
|
||||
* Simple list for displaying {@link FunctionTag} items. The only part of the tag
|
||||
@ -48,7 +50,7 @@ public class FunctionTagList extends JList<FunctionTag> {
|
||||
return "<no comment set>";
|
||||
}
|
||||
|
||||
return tag.getComment();
|
||||
return "<html>" + HTMLUtilities.friendlyEncodeHTML(tag.getComment());
|
||||
}
|
||||
|
||||
return "";
|
||||
@ -62,25 +64,29 @@ public class FunctionTagList extends JList<FunctionTag> {
|
||||
*/
|
||||
@Override
|
||||
public ListCellRenderer<? super FunctionTag> getCellRenderer() {
|
||||
return new DefaultListCellRenderer() {
|
||||
return new GListCellRenderer<>() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
FunctionTag tag = (FunctionTag) value;
|
||||
Component listCellRendererComponent = super.getListCellRendererComponent(list,
|
||||
tag.getName(), index, isSelected, cellHasFocus);
|
||||
protected String getItemText(FunctionTag value) {
|
||||
return value.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends FunctionTag> list,
|
||||
FunctionTag value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
// If this tag is a temporary one (ie: read-in from a file), then it is
|
||||
// read-only and should be indicated to the user as a different color.
|
||||
if (value instanceof FunctionTagTemp) {
|
||||
if (cellHasFocus) {
|
||||
listCellRendererComponent.setForeground(Color.white);
|
||||
setForeground(Color.white);
|
||||
}
|
||||
else {
|
||||
listCellRendererComponent.setForeground(Color.blue);
|
||||
setForeground(Color.blue);
|
||||
}
|
||||
}
|
||||
return listCellRendererComponent;
|
||||
return this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.textfield.HintTextField;
|
||||
import ghidra.app.cmd.function.CreateFunctionTagCmd;
|
||||
import ghidra.app.context.ProgramActionContext;
|
||||
@ -376,7 +377,7 @@ public class FunctionTagsComponentProvider extends ComponentProviderAdapter
|
||||
*/
|
||||
private JPanel createFilterPanel() {
|
||||
filterPanel = new JPanel(new BorderLayout());
|
||||
JLabel label = new JLabel(" Filter:");
|
||||
JLabel label = DockingUtils.createNonHtmlLabel(" Filter:");
|
||||
|
||||
filterInputTF = new HintTextField("");
|
||||
filterInputTF.setName("filterInputTF");
|
||||
@ -411,7 +412,7 @@ public class FunctionTagsComponentProvider extends ComponentProviderAdapter
|
||||
private JPanel createInputPanel() {
|
||||
|
||||
inputPanel = new JPanel(new BorderLayout());
|
||||
JLabel label = new JLabel(" Create new tag(s):");
|
||||
JLabel label = DockingUtils.createNonHtmlLabel(" Create new tag(s):");
|
||||
tagInputTF = new HintTextField("tag 1, tag 2, ...");
|
||||
tagInputTF.setName("tagInputTF");
|
||||
tagInputTF.addActionListener(e -> processCreates());
|
||||
|
@ -22,6 +22,7 @@ import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.widgets.OptionDialog;
|
||||
import docking.widgets.dialogs.InputDialog;
|
||||
@ -64,8 +65,7 @@ public abstract class TagListPanel extends JPanel {
|
||||
* @param tool the plugin tool
|
||||
* @param title the title of the panel
|
||||
*/
|
||||
public TagListPanel(FunctionTagsComponentProvider provider, PluginTool tool,
|
||||
String title) {
|
||||
public TagListPanel(FunctionTagsComponentProvider provider, PluginTool tool, String title) {
|
||||
this.tool = tool;
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
@ -97,18 +97,18 @@ public abstract class TagListPanel extends JPanel {
|
||||
|
||||
// If the tag is a temporary one, it's not editable. Show a message to the user.
|
||||
if (tag instanceof FunctionTagTemp) {
|
||||
Msg.showWarn(list, list, "Tag Not Editable",
|
||||
"Tag " + "\"" + tag.getName() + "\"" +
|
||||
" was loaded from an external source and cannot be edited or deleted");
|
||||
Msg.showWarn(list, list, "Tag Not Editable", "Tag " + "\"" + tag.getName() +
|
||||
"\"" +
|
||||
" was loaded from an external source and cannot be edited or deleted");
|
||||
return;
|
||||
}
|
||||
|
||||
String[] labels = new String[] { "Name:", "Comment:" };
|
||||
String[] init = new String[] { tag.getName(), tag.getComment() };
|
||||
|
||||
|
||||
InputDialog dialog = new InputDialog("Edit Tag", labels, init, true, d -> {
|
||||
String[] results = d.getValues();
|
||||
|
||||
|
||||
if (results == null || results.length != 2) {
|
||||
Msg.error(this, "Error retrieving data from edit dialog"); // shouldn't happen
|
||||
return false;
|
||||
@ -139,10 +139,10 @@ public abstract class TagListPanel extends JPanel {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
dialog.setPreferredSize(400, 150);
|
||||
DockingWindowManager.showDialog(list, dialog);
|
||||
|
||||
|
||||
if (dialog.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
@ -150,7 +150,7 @@ public abstract class TagListPanel extends JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
JLabel label = new JLabel(title);
|
||||
JLabel label = DockingUtils.createNonHtmlLabel(title);
|
||||
|
||||
add(label, BorderLayout.NORTH);
|
||||
add(list, BorderLayout.CENTER);
|
||||
@ -245,8 +245,8 @@ public abstract class TagListPanel extends JPanel {
|
||||
// Show a confirmation message - users may not be aware that deleting a tag is more
|
||||
// than just removing it from a function.
|
||||
int option = OptionDialog.showOptionDialog(this, "Function Tag Delete",
|
||||
"Are you sure? \nThis will delete the tag from all functions in the program.",
|
||||
"OK", OptionDialog.WARNING_MESSAGE);
|
||||
"Are you sure? \nThis will delete the tag from all functions in the program.", "OK",
|
||||
OptionDialog.WARNING_MESSAGE);
|
||||
|
||||
switch (option) {
|
||||
case OptionDialog.OPTION_ONE:
|
||||
|
@ -21,8 +21,7 @@ import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.ComponentProvider;
|
||||
import docking.*;
|
||||
import docking.action.*;
|
||||
import docking.help.Help;
|
||||
import docking.help.HelpService;
|
||||
@ -161,6 +160,7 @@ public abstract class FunctionChoiceComparisonPanel extends FunctionComparisonPa
|
||||
private Component createLeftChoicePanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
leftComboBox = new JComboBox<>(leftWrappedFunctions);
|
||||
DockingUtils.turnOffHTMLRendering(leftComboBox);
|
||||
adjustSelectedLeftFunction();
|
||||
leftComboBox.addItemListener(e -> {
|
||||
WrappedFunction wrappedFunction = (WrappedFunction) leftComboBox.getSelectedItem();
|
||||
@ -174,6 +174,7 @@ public abstract class FunctionChoiceComparisonPanel extends FunctionComparisonPa
|
||||
private Component createRightChoicePanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
rightComboBox = new JComboBox<>(rightWrappedFunctions);
|
||||
DockingUtils.turnOffHTMLRendering(rightComboBox);
|
||||
adjustSelectedRightFunction();
|
||||
rightComboBox.addItemListener(e -> {
|
||||
WrappedFunction wrappedFunction = (WrappedFunction) rightComboBox.getSelectedItem();
|
||||
|
@ -21,6 +21,8 @@ import java.awt.FlowLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import docking.DockingUtils;
|
||||
|
||||
/**
|
||||
* Simple panel containing a JLabel for displaying error messages.
|
||||
*
|
||||
@ -35,14 +37,14 @@ public class MessagePanel extends JPanel {
|
||||
*/
|
||||
public MessagePanel() {
|
||||
setLayout(new FlowLayout(FlowLayout.CENTER));
|
||||
msgLabel = new JLabel(NO_STATUS);
|
||||
msgLabel = DockingUtils.createNonHtmlLabel(NO_STATUS);
|
||||
add(msgLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text to be displayed.
|
||||
*
|
||||
* @param text the new text
|
||||
* @param text the new non-html text
|
||||
* @param foregroundColor the text color
|
||||
*/
|
||||
public void setMessageText(String text, Color foregroundColor) {
|
||||
|
@ -18,6 +18,7 @@ package ghidra.app.plugin.core.label;
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
import ghidra.app.cmd.label.AddLabelCmd;
|
||||
import ghidra.app.cmd.refs.AssociateSymbolCmd;
|
||||
@ -59,7 +60,7 @@ public class OperandLabelDialog extends DialogComponentProvider {
|
||||
JPanel mainPanel = new JPanel(new PairLayout(5, 5));
|
||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
|
||||
label = new JLabel("Label: ");
|
||||
label = DockingUtils.createNonHtmlLabel("Label: ");
|
||||
|
||||
myChoice = new GhidraComboBox<>();
|
||||
myChoice.setName("MYCHOICE");
|
||||
|
@ -22,6 +22,7 @@ import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
import ghidra.app.plugin.core.misc.RegisterField;
|
||||
import ghidra.app.util.*;
|
||||
@ -144,31 +145,31 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
||||
lengthField.setChangeListener(e -> lengthChanged());
|
||||
addrField.addChangeListener(ev -> addrChanged());
|
||||
|
||||
JLabel readLabel = new JLabel("Read");
|
||||
JLabel readLabel = DockingUtils.createNonHtmlLabel("Read");
|
||||
readCB = new JCheckBox();
|
||||
readCB.setName("Read");
|
||||
|
||||
JLabel writeLabel = new JLabel("Write");
|
||||
JLabel writeLabel = DockingUtils.createNonHtmlLabel("Write");
|
||||
writeCB = new JCheckBox();
|
||||
writeCB.setName("Write");
|
||||
|
||||
JLabel executeLabel = new JLabel("Execute");
|
||||
JLabel executeLabel = DockingUtils.createNonHtmlLabel("Execute");
|
||||
executeCB = new JCheckBox();
|
||||
executeCB.setName("Execute");
|
||||
|
||||
JLabel volatileLabel = new JLabel("Volatile");
|
||||
JLabel volatileLabel = DockingUtils.createNonHtmlLabel("Volatile");
|
||||
volatileCB = new JCheckBox();
|
||||
volatileCB.setName("Volatile");
|
||||
|
||||
JPanel topPanel = new JPanel(new PairLayout(4, 10, 150));
|
||||
topPanel.setBorder(BorderFactory.createEmptyBorder(5, 7, 4, 5));
|
||||
topPanel.add(new JLabel("Block Name:", SwingConstants.RIGHT));
|
||||
topPanel.add(DockingUtils.createNonHtmlLabel("Block Name:", SwingConstants.RIGHT));
|
||||
topPanel.add(nameField);
|
||||
topPanel.add(new JLabel("Start Addr:", SwingConstants.RIGHT));
|
||||
topPanel.add(DockingUtils.createNonHtmlLabel("Start Addr:", SwingConstants.RIGHT));
|
||||
topPanel.add(addrField);
|
||||
topPanel.add(new JLabel("Length:", SwingConstants.RIGHT));
|
||||
topPanel.add(DockingUtils.createNonHtmlLabel("Length:", SwingConstants.RIGHT));
|
||||
topPanel.add(lengthField);
|
||||
topPanel.add(new JLabel("Comment:", SwingConstants.RIGHT));
|
||||
topPanel.add(DockingUtils.createNonHtmlLabel("Comment:", SwingConstants.RIGHT));
|
||||
topPanel.add(commentField);
|
||||
|
||||
JPanel execPanel = new JPanel();
|
||||
@ -234,7 +235,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
||||
nameField.setText("");
|
||||
addrField.setAddress(model.getStartAddress());
|
||||
|
||||
lengthField.setValue(new Long(0));
|
||||
lengthField.setValue(Long.valueOf(0));
|
||||
model.setLength(0);
|
||||
commentField.setText("");
|
||||
|
||||
@ -243,7 +244,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
||||
executeCB.setSelected(false);
|
||||
volatileCB.setSelected(false);
|
||||
|
||||
initialValueField.setValue(new Long(0));
|
||||
initialValueField.setValue(Long.valueOf(0));
|
||||
model.setBlockType(MemoryBlockType.DEFAULT);
|
||||
model.setIsInitialized(initializedRB.isSelected());
|
||||
model.setInitialValue(0);
|
||||
@ -411,7 +412,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
||||
}
|
||||
|
||||
private void createInitializedPanel() {
|
||||
initialValueLabel = new JLabel("Initial Value");
|
||||
initialValueLabel = DockingUtils.createNonHtmlLabel("Initial Value");
|
||||
initialValueField = new RegisterField(8, null, false);
|
||||
initialValueField.setName("Initial Value");
|
||||
initialValueField.setEnabled(false);
|
||||
@ -427,7 +428,7 @@ class AddBlockDialog extends DialogComponentProvider implements ChangeListener {
|
||||
private JPanel createAddressPanel() {
|
||||
JPanel addressPanel = new JPanel(new PairLayout());
|
||||
|
||||
JLabel addrToAddLabel = new JLabel("Source Addr:");
|
||||
JLabel addrToAddLabel = DockingUtils.createNonHtmlLabel("Source Addr:");
|
||||
baseAddrField = new AddressInput();
|
||||
baseAddrField.setAddressFactory(addrFactory);
|
||||
baseAddrField.setName("Source Addr");
|
||||
|
@ -24,8 +24,7 @@ import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.ComponentProvider;
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.*;
|
||||
import ghidra.app.plugin.core.misc.RegisterField;
|
||||
import ghidra.app.util.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
@ -42,10 +41,10 @@ import ghidra.util.layout.PairLayout;
|
||||
*
|
||||
*/
|
||||
class ExpandBlockDialog extends DialogComponentProvider implements ChangeListener {
|
||||
|
||||
|
||||
final static int EXPAND_UP = 0;
|
||||
final static int EXPAND_DOWN = 1;
|
||||
|
||||
|
||||
private final static String EXPAND_UP_TITLE = "Expand Block Up";
|
||||
private final static String EXPAND_DOWN_TITLE = "Expand Block Down";
|
||||
private int dialogType;
|
||||
@ -58,6 +57,7 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
private ExpandBlockModel model;
|
||||
private boolean isChanging;
|
||||
private PluginTool tool;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param parent
|
||||
@ -65,15 +65,14 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
* @param af
|
||||
* @param dialogType
|
||||
*/
|
||||
ExpandBlockDialog(PluginTool tool, ExpandBlockModel model, MemoryBlock block,
|
||||
AddressFactory af, int dialogType) {
|
||||
super(dialogType == EXPAND_UP? EXPAND_UP_TITLE : EXPAND_DOWN_TITLE,
|
||||
true);
|
||||
ExpandBlockDialog(PluginTool tool, ExpandBlockModel model, MemoryBlock block, AddressFactory af,
|
||||
int dialogType) {
|
||||
super(dialogType == EXPAND_UP ? EXPAND_UP_TITLE : EXPAND_DOWN_TITLE, true);
|
||||
this.tool = tool;
|
||||
this.model = model;
|
||||
this.dialogType = dialogType;
|
||||
setHelpLocation(new HelpLocation(HelpTopics.MEMORY_MAP,
|
||||
dialogType == EXPAND_UP? EXPAND_UP_TITLE : EXPAND_DOWN_TITLE));
|
||||
dialogType == EXPAND_UP ? EXPAND_UP_TITLE : EXPAND_DOWN_TITLE));
|
||||
addrFactory = af;
|
||||
model.setChangeListener(this);
|
||||
addWorkPanel(create(block));
|
||||
@ -88,9 +87,10 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
* @see ghidra.util.bean.GhidraDialog#okCallback()
|
||||
*/
|
||||
@Override
|
||||
protected void okCallback() {
|
||||
|
||||
protected void okCallback() {
|
||||
|
||||
Runnable doExpand = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (model.execute()) {
|
||||
close();
|
||||
@ -102,18 +102,18 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
rootPanel.setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
rootPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
SwingUtilities.invokeLater(doExpand);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create the main work panel.
|
||||
* @return JPanel
|
||||
*/
|
||||
private JPanel create(MemoryBlock block) {
|
||||
JPanel panel = new JPanel(new PairLayout(5,5, 150));
|
||||
startAddressInput = new AddressInput();
|
||||
JPanel panel = new JPanel(new PairLayout(5, 5, 150));
|
||||
startAddressInput = new AddressInput();
|
||||
startAddressInput.setName("NewStartAddress");
|
||||
startAddressInput.setAddressFactory(addrFactory);
|
||||
endAddressInput = new AddressInput();
|
||||
@ -121,22 +121,22 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
endAddressInput.setAddressFactory(addrFactory);
|
||||
Address start = block.getStart();
|
||||
Address end = block.getEnd();
|
||||
|
||||
|
||||
startAddressInput.setAddress(start);
|
||||
startAddressInput.setAddressSpaceEditable(false);
|
||||
endAddressInput.setAddress(end);
|
||||
endAddressInput.setAddressSpaceEditable(false);
|
||||
|
||||
|
||||
startField = new JTextField(10);
|
||||
startField.setName("StartAddress");
|
||||
endField = new JTextField(10);
|
||||
endField.setName("EndAddress");
|
||||
startField.setText(start.toString());
|
||||
endField.setText(end.toString());
|
||||
|
||||
JLabel startLabel = new JLabel("Start Address:", SwingConstants.RIGHT);
|
||||
JLabel endLabel = new JLabel("End Address:", SwingConstants.RIGHT);
|
||||
|
||||
|
||||
JLabel startLabel = DockingUtils.createNonHtmlLabel("Start Address:", SwingConstants.RIGHT);
|
||||
JLabel endLabel = DockingUtils.createNonHtmlLabel("End Address:", SwingConstants.RIGHT);
|
||||
|
||||
if (dialogType == EXPAND_UP) {
|
||||
endField.setEnabled(false);
|
||||
startLabel.setText("New Start Address:");
|
||||
@ -147,29 +147,28 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
}
|
||||
lengthField = new RegisterField(32, null, false);
|
||||
lengthField.setName("BlockLength");
|
||||
lengthField.setValue(new Long(model.getLength()));
|
||||
|
||||
lengthField.setValue(Long.valueOf(model.getLength()));
|
||||
|
||||
panel.add(startLabel);
|
||||
panel.add((dialogType == EXPAND_UP)?
|
||||
(JComponent)startAddressInput : startField);
|
||||
panel.add((dialogType == EXPAND_UP) ? (JComponent) startAddressInput : startField);
|
||||
panel.add(endLabel);
|
||||
panel.add((dialogType == EXPAND_UP)?
|
||||
(JComponent)endField : endAddressInput);
|
||||
panel.add(new JLabel("Block Length:", SwingConstants.RIGHT));
|
||||
panel.add((dialogType == EXPAND_UP) ? (JComponent) endField : endAddressInput);
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Block Length:", SwingConstants.RIGHT));
|
||||
panel.add(lengthField);
|
||||
|
||||
|
||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
mainPanel.add(panel, BorderLayout.CENTER);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
|
||||
|
||||
startAddressInput.addChangeListener(new AddressChangeListener());
|
||||
endAddressInput.addChangeListener(new AddressChangeListener());
|
||||
lengthField.setChangeListener(new LengthChangeListener());
|
||||
|
||||
|
||||
ActionListener al = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setStatusText("");
|
||||
}
|
||||
@ -180,13 +179,14 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
startAddressInput.addActionListener(al);
|
||||
endAddressInput.addActionListener(al);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Listener on the length text fields; update other fields
|
||||
* according to the entered value.
|
||||
*/
|
||||
private class LengthChangeListener implements ChangeListener {
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
if (isChanging) {
|
||||
return;
|
||||
@ -194,7 +194,7 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
setStatusText("");
|
||||
lengthChanged();
|
||||
}
|
||||
|
||||
|
||||
private void lengthChanged() {
|
||||
long length = 0;
|
||||
Long val = lengthField.getValue();
|
||||
@ -207,13 +207,14 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
model.setLength(length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Listener on the AddressInput field; update length field when the
|
||||
* address input field changes.
|
||||
*/
|
||||
private class AddressChangeListener implements ChangeListener {
|
||||
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent event) {
|
||||
if (isChanging) {
|
||||
return;
|
||||
@ -221,8 +222,8 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
setStatusText("");
|
||||
addressChanged();
|
||||
}
|
||||
|
||||
private void addressChanged() {
|
||||
|
||||
private void addressChanged() {
|
||||
if (dialogType == EXPAND_UP) {
|
||||
Address startAddr = startAddressInput.getAddress();
|
||||
if (startAddr == null) {
|
||||
@ -238,34 +239,35 @@ class ExpandBlockDialog extends DialogComponentProvider implements ChangeListene
|
||||
if (endAddr == null) {
|
||||
if (endAddressInput.hasInput()) {
|
||||
setStatusText("Invalid Address");
|
||||
}
|
||||
}
|
||||
setOkEnabled(false);
|
||||
}
|
||||
model.setEndAddress(endAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
|
||||
*/
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
|
||||
|
||||
String message = model.getMessage();
|
||||
setStatusText(message);
|
||||
setOkEnabled(message.length() == 0);
|
||||
lengthField.setValue(new Long(model.getLength()));
|
||||
Address startAddr = model.getStartAddress();
|
||||
Address endAddr = model.getEndAddress();
|
||||
isChanging = true;
|
||||
if (dialogType == EXPAND_UP && startAddr != null) {
|
||||
startAddressInput.setAddress(startAddr);
|
||||
}
|
||||
else if (endAddr != null) {
|
||||
endAddressInput.setAddress(endAddr);
|
||||
}
|
||||
isChanging = false;
|
||||
|
||||
Address startAddr = model.getStartAddress();
|
||||
Address endAddr = model.getEndAddress();
|
||||
isChanging = true;
|
||||
if (dialogType == EXPAND_UP && startAddr != null) {
|
||||
startAddressInput.setAddress(startAddr);
|
||||
}
|
||||
else if (endAddr != null) {
|
||||
endAddressInput.setAddress(endAddr);
|
||||
}
|
||||
isChanging = false;
|
||||
|
||||
if (!isVisible()) {
|
||||
setOkEnabled(false);
|
||||
ComponentProvider provider = tool.getComponentProvider(PluginConstants.MEMORY_MAP);
|
||||
|
@ -24,6 +24,7 @@ import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DockingUtils;
|
||||
import docking.action.DockingAction;
|
||||
import docking.action.ToolBarData;
|
||||
import docking.widgets.table.*;
|
||||
@ -176,7 +177,8 @@ class MemoryMapProvider extends ComponentProviderAdapter {
|
||||
enableOptions(model);
|
||||
});
|
||||
|
||||
memPanel.add(new JLabel("Memory Blocks", SwingConstants.CENTER), BorderLayout.NORTH);
|
||||
memPanel.add(DockingUtils.createNonHtmlLabel("Memory Blocks", SwingConstants.CENTER),
|
||||
BorderLayout.NORTH);
|
||||
memPanel.add(memPane, BorderLayout.CENTER);
|
||||
|
||||
return memPanel;
|
||||
|
@ -22,6 +22,7 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.app.cmd.memory.MoveBlockListener;
|
||||
import ghidra.app.cmd.memory.MoveBlockTask;
|
||||
import ghidra.app.util.*;
|
||||
@ -156,16 +157,16 @@ public class MoveBlockDialog extends DialogComponentProvider implements MoveBloc
|
||||
private JPanel buildMainPanel() {
|
||||
JPanel panel = new JPanel(new PairLayout(5, 20, 150));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
||||
blockNameLabel = new JLabel(".text");
|
||||
blockNameLabel = DockingUtils.createNonHtmlLabel(".text");
|
||||
blockNameLabel.setName("blockName"); // name components for junits
|
||||
|
||||
origStartLabel = new JLabel("1001000");
|
||||
origStartLabel = DockingUtils.createNonHtmlLabel("1001000");
|
||||
origStartLabel.setName("origStart");
|
||||
|
||||
origEndLabel = new JLabel("1002000");
|
||||
origEndLabel = DockingUtils.createNonHtmlLabel("1002000");
|
||||
origEndLabel.setName("origEnd");
|
||||
|
||||
lengthLabel = new JLabel("4096 (0x1000)");
|
||||
lengthLabel = DockingUtils.createNonHtmlLabel("4096 (0x1000)");
|
||||
lengthLabel.setName("length");
|
||||
|
||||
newStartField = new AddressInput();
|
||||
@ -187,17 +188,17 @@ public class MoveBlockDialog extends DialogComponentProvider implements MoveBloc
|
||||
}
|
||||
});
|
||||
|
||||
panel.add(new JLabel("Name:", SwingConstants.RIGHT));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Name:", SwingConstants.RIGHT));
|
||||
panel.add(blockNameLabel);
|
||||
panel.add(new JLabel("Start Address:", SwingConstants.RIGHT));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Start Address:", SwingConstants.RIGHT));
|
||||
panel.add(origStartLabel);
|
||||
panel.add(new JLabel("End Address:", SwingConstants.RIGHT));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("End Address:", SwingConstants.RIGHT));
|
||||
panel.add(origEndLabel);
|
||||
panel.add(new JLabel("Length:", SwingConstants.RIGHT));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("Length:", SwingConstants.RIGHT));
|
||||
panel.add(lengthLabel);
|
||||
panel.add(new JLabel("New Start Address:", SwingConstants.RIGHT));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("New Start Address:", SwingConstants.RIGHT));
|
||||
panel.add(newStartField);
|
||||
panel.add(new JLabel("New End Address:", SwingConstants.RIGHT));
|
||||
panel.add(DockingUtils.createNonHtmlLabel("New End Address:", SwingConstants.RIGHT));
|
||||
panel.add(newEndField);
|
||||
return 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.
|
||||
@ -16,16 +15,6 @@
|
||||
*/
|
||||
package ghidra.app.plugin.core.memory;
|
||||
|
||||
import ghidra.app.plugin.core.misc.RegisterField;
|
||||
import ghidra.app.util.AddressInput;
|
||||
import ghidra.app.util.HelpTopics;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.mem.MemoryBlock;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.NamingUtilities;
|
||||
import ghidra.util.exception.InvalidInputException;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@ -35,6 +24,16 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.app.plugin.core.misc.RegisterField;
|
||||
import ghidra.app.util.AddressInput;
|
||||
import ghidra.app.util.HelpTopics;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.mem.MemoryBlock;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.NamingUtilities;
|
||||
import ghidra.util.exception.InvalidInputException;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -119,13 +118,13 @@ class SplitBlockDialog extends DialogComponentProvider {
|
||||
blockOneLengthField = new RegisterField(32, null, false);
|
||||
blockOneLengthField.setName("BlockOneLength");
|
||||
|
||||
panelOne.add(new JLabel("Block Name:", SwingConstants.RIGHT));
|
||||
panelOne.add(DockingUtils.createNonHtmlLabel("Block Name:", SwingConstants.RIGHT));
|
||||
panelOne.add(blockOneNameField);
|
||||
panelOne.add(new JLabel("Start Address:", SwingConstants.RIGHT));
|
||||
panelOne.add(DockingUtils.createNonHtmlLabel("Start Address:", SwingConstants.RIGHT));
|
||||
panelOne.add(blockOneStartField);
|
||||
panelOne.add(new JLabel("End Address:", SwingConstants.RIGHT));
|
||||
panelOne.add(DockingUtils.createNonHtmlLabel("End Address:", SwingConstants.RIGHT));
|
||||
panelOne.add(blockOneEnd);
|
||||
panelOne.add(new JLabel("Block Length:", SwingConstants.RIGHT));
|
||||
panelOne.add(DockingUtils.createNonHtmlLabel("Block Length:", SwingConstants.RIGHT));
|
||||
panelOne.add(blockOneLengthField);
|
||||
|
||||
JPanel panelTwo = new JPanel(new PairLayout(5, 5, 150));
|
||||
@ -140,13 +139,13 @@ class SplitBlockDialog extends DialogComponentProvider {
|
||||
blockTwoLengthField = new RegisterField(32, null, false);
|
||||
blockTwoLengthField.setName("BlockTwoLength");
|
||||
|
||||
panelTwo.add(new JLabel("Block Name:", SwingConstants.RIGHT));
|
||||
panelTwo.add(DockingUtils.createNonHtmlLabel("Block Name:", SwingConstants.RIGHT));
|
||||
panelTwo.add(blockTwoNameField);
|
||||
panelTwo.add(new JLabel("Start Address:", SwingConstants.RIGHT));
|
||||
panelTwo.add(DockingUtils.createNonHtmlLabel("Start Address:", SwingConstants.RIGHT));
|
||||
panelTwo.add(blockTwoStart);
|
||||
panelTwo.add(new JLabel("End Address:", SwingConstants.RIGHT));
|
||||
panelTwo.add(DockingUtils.createNonHtmlLabel("End Address:", SwingConstants.RIGHT));
|
||||
panelTwo.add(blockTwoEndField);
|
||||
panelTwo.add(new JLabel("Block Length:", SwingConstants.RIGHT));
|
||||
panelTwo.add(DockingUtils.createNonHtmlLabel("Block Length:", SwingConstants.RIGHT));
|
||||
panelTwo.add(blockTwoLengthField);
|
||||
|
||||
JPanel mainPanel = new JPanel();
|
||||
@ -202,6 +201,7 @@ class SplitBlockDialog extends DialogComponentProvider {
|
||||
blockTwoStart.addChangeListener(new AddressChangeListener(blockTwoStart));
|
||||
|
||||
ActionListener al = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setStatusText("");
|
||||
}
|
||||
@ -227,6 +227,7 @@ class SplitBlockDialog extends DialogComponentProvider {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent event) {
|
||||
setStatusText("");
|
||||
boolean ok = false;
|
||||
@ -331,6 +332,7 @@ class SplitBlockDialog extends DialogComponentProvider {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent event) {
|
||||
setStatusText("");
|
||||
boolean ok = false;
|
||||
@ -385,8 +387,8 @@ class SplitBlockDialog extends DialogComponentProvider {
|
||||
}
|
||||
long blockSize = block.getSize();
|
||||
if (length > blockSize) {
|
||||
setStatusText("End address must be less than original block end (" +
|
||||
block.getEnd() + ")");
|
||||
setStatusText(
|
||||
"End address must be less than original block end (" + block.getEnd() + ")");
|
||||
return false;
|
||||
}
|
||||
blockOneLengthField.setValue(new Long(length));
|
||||
|
@ -90,11 +90,11 @@ public class AddressTypeOverviewColorService
|
||||
AddressType addressType = getAddressType(address);
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("<b>");
|
||||
buffer.append(getName());
|
||||
buffer.append(HTMLUtilities.friendlyEncodeHTML(getName()));
|
||||
buffer.append("</b>\n");
|
||||
buffer.append(addressType.getDescription());
|
||||
buffer.append(" (");
|
||||
buffer.append(getBlockName(address));
|
||||
buffer.append(HTMLUtilities.friendlyEncodeHTML(getBlockName(address)));
|
||||
buffer.append(" ");
|
||||
buffer.append(address);
|
||||
buffer.append(" )");
|
||||
|
@ -21,6 +21,7 @@ import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
/**
|
||||
@ -50,7 +51,7 @@ public class AddressTypeOverviewLegendPanel extends JPanel {
|
||||
for (AddressType addressType : values) {
|
||||
JPanel panel = new ColorPanel(addressType);
|
||||
add(panel);
|
||||
add(new JLabel(addressType.getDescription()));
|
||||
add(DockingUtils.createNonHtmlLabel(addressType.getDescription()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,19 +86,19 @@ public class EntropyOverviewColorService implements OverviewColorService {
|
||||
}
|
||||
int entropyScaled = computeEntropy(address);
|
||||
double entropy = (entropyScaled * 8.0d) / 255; // convert back from palette scale to original entropy value
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("<b>");
|
||||
buffer.append(getName());
|
||||
buffer.append(HTMLUtilities.friendlyEncodeHTML(getName()));
|
||||
buffer.append("</b>\n");
|
||||
buffer.append(" ");
|
||||
buffer.append(formatter.format(entropy));
|
||||
buffer.append(" ");
|
||||
buffer.append(getKnotName(entropyScaled));
|
||||
buffer.append(HTMLUtilities.friendlyEncodeHTML(getKnotName(entropyScaled)));
|
||||
buffer.append(" ");
|
||||
buffer.append("    (");
|
||||
buffer.append(getBlockName(address));
|
||||
buffer.append(HTMLUtilities.friendlyEncodeHTML(getBlockName(address)));
|
||||
buffer.append(" ");
|
||||
buffer.append(address);
|
||||
buffer.append(HTMLUtilities.friendlyEncodeHTML(address.toString()));
|
||||
buffer.append(" )");
|
||||
return HTMLUtilities.toWrappedHTML(buffer.toString(), 0);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import javax.swing.border.LineBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.util.GraphicsUtils;
|
||||
|
||||
/**
|
||||
@ -133,7 +134,7 @@ public class KnotPanel extends JPanel implements ComponentListener {
|
||||
|
||||
ArrayList<KnotRecord> knots = palette.getKnots();
|
||||
for (KnotRecord record : knots) {
|
||||
JLabel label = new JLabel(record.name);
|
||||
JLabel label = DockingUtils.createNonHtmlLabel(record.name);
|
||||
label.setFont(FONT);
|
||||
label.setBorder(new ToplessLineBorder(Color.BLACK));
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
@ -17,7 +17,8 @@ package ghidra.app.plugin.core.overview.entropy;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
* Panel for display the Entropy color legend.
|
||||
@ -33,22 +34,12 @@ public class LegendPanel extends JPanel {
|
||||
add(buildHeader(), BorderLayout.NORTH);
|
||||
add(palettePanel, BorderLayout.WEST);
|
||||
add(knotPanel, BorderLayout.CENTER);
|
||||
// add(buildFooter(), BorderLayout.SOUTH);
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
|
||||
}
|
||||
|
||||
private Component buildHeader() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
|
||||
// panel.add(new JLabel("Entropy range: 0.0 - 8.0"), BorderLayout.CENTER);
|
||||
// panel.add(new JLabel("Min Entropy (0.0)"), BorderLayout.CENTER);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Component buildFooter() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
|
||||
panel.add(new JLabel("Max Entropy (8.0)"), BorderLayout.CENTER);
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
@ -113,11 +113,12 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
|
||||
}
|
||||
|
||||
};
|
||||
setLanguageAction.setPopupMenuData(new MenuData(new String[] { "Set Language..." },
|
||||
"Language"));
|
||||
setLanguageAction.setPopupMenuData(
|
||||
new MenuData(new String[] { "Set Language..." }, "Language"));
|
||||
|
||||
setLanguageAction.setEnabled(true);
|
||||
setLanguageAction.setHelpLocation(new HelpLocation("LanguageProviderPlugin", "set language"));
|
||||
setLanguageAction.setHelpLocation(
|
||||
new HelpLocation("LanguageProviderPlugin", "set language"));
|
||||
tool.addAction(setLanguageAction);
|
||||
}
|
||||
|
||||
@ -142,22 +143,23 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
|
||||
String dfName = domainFile.getName();
|
||||
|
||||
if (domainFile.isReadOnly()) {
|
||||
Msg.showInfo(getClass(), tool.getToolFrame(), "Permission Denied", dfName +
|
||||
Msg.showInfo(getClass(), tool.getToolFrame(), "Permission Denied", "Program " + dfName +
|
||||
" is read-only!\n" + "Set language may not be done on a read-only Program.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!domainFile.getConsumers().isEmpty() || domainFile.isBusy()) {
|
||||
Msg.showInfo(getClass(), tool.getToolFrame(), "File In-Use", dfName + " is in-use!\n" +
|
||||
"Set language may not be done while the associated file is\n" +
|
||||
"open or in-use. Be sure the file is not open in a tool.");
|
||||
Msg.showInfo(getClass(), tool.getToolFrame(), "File In-Use",
|
||||
"Program " + dfName + " is in-use!\n" +
|
||||
"Set language may not be done while the associated file is\n" +
|
||||
"open or in-use. Be sure the file is not open in a tool.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (domainFile.isCheckedOut() && !domainFile.isCheckedOutExclusive()) {
|
||||
String msg =
|
||||
(domainFile.modifiedSinceCheckout() || domainFile.isChanged()) ? "check-in this file"
|
||||
: "undo your checkout";
|
||||
String msg = (domainFile.modifiedSinceCheckout() || domainFile.isChanged())
|
||||
? "check-in this file"
|
||||
: "undo your checkout";
|
||||
|
||||
Msg.showInfo(getClass(), tool.getToolFrame(), "Exclusive Checkout Required",
|
||||
"You do not have an exclusive checkout of: " + dfName + "\n \n" +
|
||||
@ -171,28 +173,25 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
|
||||
String msg = "Setting the language can not be undone!\n";
|
||||
|
||||
if (domainFile.modifiedSinceCheckout()) {
|
||||
msg +=
|
||||
"\nIt is highly recommended that you check-in your recent\n"
|
||||
+ "changes before performing this operation.";
|
||||
msg += "\nIt is highly recommended that you check-in your recent\n" +
|
||||
"changes before performing this operation.";
|
||||
}
|
||||
else if (!domainFile.isCheckedOut()) {
|
||||
msg +=
|
||||
"\nIt is highly recommended that you make a copy of the\n"
|
||||
+ "selected file before performing this operation.";
|
||||
msg += "\nIt is highly recommended that you make a copy of the\n" +
|
||||
"selected file before performing this operation.";
|
||||
}
|
||||
|
||||
ToolTemplate defaultToolTemplate =
|
||||
tool.getToolServices().getDefaultToolTemplate(domainFile);
|
||||
String toolMsg =
|
||||
defaultToolTemplate == null ? "WARNING! Without a default tool the file "
|
||||
+ "will be overwritten\nwhen the Set Language is complete."
|
||||
: "When complete you can Save the results or Open the results\nin the " +
|
||||
defaultToolTemplate.getName() + " tool";
|
||||
String toolMsg = defaultToolTemplate == null
|
||||
? "WARNING! Without a default tool the file " +
|
||||
"will be overwritten\nwhen the Set Language is complete."
|
||||
: "When complete you can Save the results or Open the results\nin the " +
|
||||
defaultToolTemplate.getName() + " tool";
|
||||
|
||||
int result =
|
||||
OptionDialog.showOptionDialog(tool.getToolFrame(), "Set Language: " + dfName, msg +
|
||||
"\n \n" + toolMsg + "\n \nDo you want to continue?", "Ok",
|
||||
OptionDialog.WARNING_MESSAGE);
|
||||
int result = OptionDialog.showOptionDialog(tool.getToolFrame(), "Set Language: " + dfName,
|
||||
msg + "\n \n" + toolMsg + "\n \nDo you want to continue?", "Ok",
|
||||
OptionDialog.WARNING_MESSAGE);
|
||||
if (result > 0) {
|
||||
final SetLanguageTask task = new SetLanguageTask(domainFile);
|
||||
new TaskLauncher(task, tool.getToolFrame(), 0);
|
||||
@ -326,8 +325,7 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
ToolServices toolServices = tool.getToolServices();
|
||||
String defaultToolName =
|
||||
toolServices.getDefaultToolTemplate(file).getName();
|
||||
String defaultToolName = toolServices.getDefaultToolTemplate(file).getName();
|
||||
for (Tool t : toolServices.getRunningTools()) {
|
||||
if (t.getName().equals(defaultToolName)) {
|
||||
openTool = (PluginTool) t;
|
||||
|
@ -27,8 +27,7 @@ import java.util.List;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.ToolTipManager;
|
||||
import docking.*;
|
||||
import docking.action.DockingAction;
|
||||
import docking.action.MenuData;
|
||||
import ghidra.app.CorePluginPackage;
|
||||
@ -95,7 +94,7 @@ public class ShowInstructionInfoPlugin extends ProgramPlugin {
|
||||
|
||||
private void createStatusPanels() {
|
||||
instructionPanel = new JPanel(new BorderLayout());
|
||||
instructionLabel = new JLabel(" ");
|
||||
instructionLabel = DockingUtils.createNonHtmlLabel(" ");
|
||||
instructionPanel.setPreferredSize(
|
||||
new Dimension(200, instructionLabel.getPreferredSize().height));
|
||||
ToolTipManager.setToolTipText(instructionLabel, CURRENT_INSTRUCTION_PREPEND_STRING);
|
||||
@ -104,7 +103,7 @@ public class ShowInstructionInfoPlugin extends ProgramPlugin {
|
||||
tool.addStatusComponent(instructionPanel, true, false);
|
||||
|
||||
functionPanel = new JPanel(new BorderLayout());
|
||||
functionLabel = new JLabel(" ");
|
||||
functionLabel = DockingUtils.createNonHtmlLabel(" ");
|
||||
functionLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@ -122,7 +121,7 @@ public class ShowInstructionInfoPlugin extends ProgramPlugin {
|
||||
tool.addStatusComponent(functionPanel, true, false);
|
||||
|
||||
addressPanel = new JPanel(new BorderLayout());
|
||||
addressLabel = new JLabel(" ");
|
||||
addressLabel = DockingUtils.createNonHtmlLabel(" ");
|
||||
addressPanel.setPreferredSize(new Dimension(95, addressLabel.getPreferredSize().height));
|
||||
ToolTipManager.setToolTipText(addressLabel, "Current Address");
|
||||
addressPanel.add(addressLabel);
|
||||
|
@ -24,6 +24,7 @@ import java.util.Map.Entry;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.util.KeyBindingUtils;
|
||||
import generic.util.WindowUtilities;
|
||||
import ghidra.framework.model.ProjectLocator;
|
||||
@ -227,7 +228,7 @@ public class MultiTabPanel extends JPanel {
|
||||
final JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 1));
|
||||
labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10));
|
||||
|
||||
final JLabel nameLabel = new JLabel();
|
||||
JLabel nameLabel = DockingUtils.createNonHtmlLabel();
|
||||
nameLabel.setIconTextGap(1);
|
||||
nameLabel.setName("objectName"); // junit access
|
||||
nameLabel.setFont(LABEL_FONT);
|
||||
@ -236,7 +237,7 @@ public class MultiTabPanel extends JPanel {
|
||||
|
||||
labelPanel.add(nameLabel);
|
||||
|
||||
final JLabel iconLabel = new JLabel(EMPTY16_ICON);
|
||||
JLabel iconLabel = DockingUtils.createNonHtmlLabel(EMPTY16_ICON);
|
||||
Icon icon = isSelected ? CLOSE_ICON : EMPTY16_ICON;
|
||||
iconLabel.setIcon(icon);
|
||||
|
||||
@ -642,7 +643,7 @@ public class MultiTabPanel extends JPanel {
|
||||
}
|
||||
|
||||
private JLabel createLabel() {
|
||||
final JLabel newLabel = new JLabel(LIST_ICON, SwingConstants.LEFT);
|
||||
JLabel newLabel = DockingUtils.createNonHtmlLabel(LIST_ICON, SwingConstants.LEFT);
|
||||
newLabel.setIconTextGap(0);
|
||||
newLabel.setFont(LIST_LABEL_FONT);
|
||||
newLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4));
|
||||
|
@ -29,10 +29,13 @@ import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Document;
|
||||
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
/**
|
||||
* Panel that shows a JList
|
||||
* Panel that displays the overflow of currently open programs that can be choosen.
|
||||
* <p>
|
||||
* Programs that don't have a visible tab are displayed in bold.
|
||||
*/
|
||||
class ProgramListPanel extends JPanel {
|
||||
|
||||
@ -123,7 +126,7 @@ class ProgramListPanel extends JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
programList.setCellRenderer(new MyListCellRenderer<Program>());
|
||||
programList.setCellRenderer(new ProgramListCellRenderer());
|
||||
JScrollPane sp = new JScrollPane();
|
||||
sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
@ -187,7 +190,7 @@ class ProgramListPanel extends JPanel {
|
||||
}
|
||||
|
||||
private void filterList(String filterText) {
|
||||
List<Program> allDataList = new ArrayList<Program>();
|
||||
List<Program> allDataList = new ArrayList<>();
|
||||
allDataList.addAll(hiddenList);
|
||||
allDataList.addAll(shownList);
|
||||
|
||||
@ -227,31 +230,20 @@ class ProgramListPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
private class MyListCellRenderer<T> extends JLabel implements ListCellRenderer<T> {
|
||||
private Font boldFont;
|
||||
private Font font;
|
||||
private class ProgramListCellRenderer extends GListCellRenderer<Program> {
|
||||
|
||||
MyListCellRenderer() {
|
||||
setOpaque(true);
|
||||
@Override
|
||||
protected String getItemText(Program program) {
|
||||
return multiTabPlugin.getStringUsedInList(program);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends T> list, T value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
public Component getListCellRendererComponent(JList<? extends Program> list, Program value,
|
||||
int index, boolean isSelected, boolean hasFocus) {
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, hasFocus);
|
||||
|
||||
if (font == null) {
|
||||
font = list.getFont();
|
||||
font = new Font(font.getName(), Font.PLAIN, font.getSize());
|
||||
boldFont = new Font(font.getName(), Font.BOLD, font.getSize());
|
||||
}
|
||||
|
||||
String text = multiTabPlugin.getStringUsedInList((Program) value);
|
||||
setText(text);
|
||||
if (hiddenList.contains(value)) {
|
||||
setFont(boldFont);
|
||||
}
|
||||
else {
|
||||
setFont(font);
|
||||
setBold();
|
||||
}
|
||||
if (isSelected) {
|
||||
setBackground(list.getSelectionBackground());
|
||||
@ -261,7 +253,7 @@ class ProgramListPanel extends JPanel {
|
||||
setBackground(list.getBackground());
|
||||
setForeground(list.getForeground());
|
||||
}
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 10));
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user