mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch
'origin/GT-3292_dragonmacher_PR-784_00rsiere_decompiler-multi-highlight' (closes #784) Conflicts: Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileOptions.java
This commit is contained in:
commit
59e88c6ca9
40 changed files with 2821 additions and 490 deletions
|
@ -15,14 +15,13 @@
|
|||
*/
|
||||
package docking.options.editor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.*;
|
||||
import javax.swing.colorchooser.AbstractColorChooserPanel;
|
||||
|
||||
public class GhidraColorChooser extends JColorChooser {
|
||||
|
@ -31,6 +30,7 @@ public class GhidraColorChooser extends JColorChooser {
|
|||
|
||||
private String title = DEFAULT_TITLE;
|
||||
private RecentColorCache recentColorCache = new RecentColorCache();
|
||||
private String activeTabName;
|
||||
|
||||
public GhidraColorChooser() {
|
||||
super();
|
||||
|
@ -54,12 +54,24 @@ public class GhidraColorChooser extends JColorChooser {
|
|||
return recentColorCache.getMRUColorList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the active tab of this chooser to be the given tab name, if it exists (the color chooser
|
||||
* UI may be different, depending upon the current Look and Feel)
|
||||
*
|
||||
* @param tabName the tab name
|
||||
*/
|
||||
public void setActiveTab(String tabName) {
|
||||
activeTabName = tabName;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Color showDialog(Component centerOverComponent) {
|
||||
maybeInstallSettableColorSwatchChooserPanel();
|
||||
|
||||
OKListener okListener = new OKListener();
|
||||
JDialog dialog = createDialog(centerOverComponent, title, true, this, okListener, null);
|
||||
doSetActiveTab(dialog);
|
||||
|
||||
dialog.show(); // blocks until user brings dialog down...
|
||||
Color color = okListener.getColor();
|
||||
if (color != null) {
|
||||
|
@ -68,6 +80,48 @@ public class GhidraColorChooser extends JColorChooser {
|
|||
return color; // null if the user cancels
|
||||
}
|
||||
|
||||
private void doSetActiveTab(JDialog dialog) {
|
||||
if (activeTabName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
JTabbedPane pane = findTabbedPane(dialog);
|
||||
if (pane == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int n = pane.getTabCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
String tabTitle = pane.getTitleAt(i);
|
||||
if (activeTabName.equals(tabTitle)) {
|
||||
pane.setSelectedIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JTabbedPane findTabbedPane(Component component) {
|
||||
if (!(component instanceof Container)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Container parent = (Container) component;
|
||||
if (parent instanceof JTabbedPane) {
|
||||
return (JTabbedPane) parent;
|
||||
}
|
||||
|
||||
int n = parent.getComponentCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
Component child = parent.getComponent(i);
|
||||
JTabbedPane pane = findTabbedPane(child);
|
||||
if (pane != null) {
|
||||
return pane;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void maybeInstallSettableColorSwatchChooserPanel() {
|
||||
if (recentColorCache.size() == 0) {
|
||||
return;
|
||||
|
@ -87,7 +141,13 @@ public class GhidraColorChooser extends JColorChooser {
|
|||
SettableColorSwatchChooserPanel newSwatchPanel =
|
||||
new SettableColorSwatchChooserPanel(mruColorList);
|
||||
AbstractColorChooserPanel[] newChooserPanels =
|
||||
new AbstractColorChooserPanel[] { newSwatchPanel, chooserPanels[1], chooserPanels[2] };
|
||||
new AbstractColorChooserPanel[chooserPanels.length];
|
||||
newChooserPanels[0] = newSwatchPanel;
|
||||
for (int i = 1; i < chooserPanels.length; i++) {
|
||||
AbstractColorChooserPanel panel = chooserPanels[i];
|
||||
newChooserPanels[i] = panel;
|
||||
}
|
||||
|
||||
setChooserPanels(newChooserPanels);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,21 +56,6 @@ public class InputDialog extends DialogComponentProvider {
|
|||
this(dialogTitle, new String[] { label }, new String[] { DEFAULT_VALUE }, true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a generic input dialog with the specified title, a text field,
|
||||
* labeled by the specified label. The user should check the value of
|
||||
* "isCanceled()" to know whether or not the user canceled the operation.
|
||||
* Otherwise, use the "getValue()" or "getValues()" to get the value(s)
|
||||
* entered by the user. Use the tool's "showDialog()" to display the dialog.
|
||||
* <P>
|
||||
* @param dialogTitle used as the name of the dialog's title bar
|
||||
* @param label value to use for the label of the text field
|
||||
* @param listener listener that is called when the OK button is hit
|
||||
*/
|
||||
public InputDialog(String dialogTitle, String label, InputDialogListener listener) {
|
||||
this(dialogTitle, new String[] { label }, new String[] { DEFAULT_VALUE }, true, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a generic input dialog with the specified title, a text field,
|
||||
* labeled by the specified label. The user should check the value of
|
||||
|
@ -96,27 +81,13 @@ public class InputDialog extends DialogComponentProvider {
|
|||
* @param dialogTitle used as the name of the dialog's title bar
|
||||
* @param label value to use for the label of the text field
|
||||
* @param initialValue initial value to use for the text field
|
||||
* @param listener the dialog listener (may be null)
|
||||
*/
|
||||
public InputDialog(String dialogTitle, String label, String initialValue,
|
||||
InputDialogListener listener) {
|
||||
this(dialogTitle, new String[] { label }, new String[] { initialValue }, true, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a generic input dialog with the specified title, a text field,
|
||||
* labeled by the specified label. The user should check the value of
|
||||
* "isCanceled()" to know whether or not the user canceled the operation.
|
||||
* Otherwise, use the "getValue()" or "getValues()" to get the value(s)
|
||||
* entered by the user. Use the tool's "showDialog()" to display the dialog.
|
||||
* <P>
|
||||
* @param dialogTitle used as the name of the dialog's title bar
|
||||
* @param label values to use for the label of the text field
|
||||
* @param isModal whether or not the dialog is to be modal
|
||||
*/
|
||||
public InputDialog(String dialogTitle, String label, boolean isModal) {
|
||||
this(dialogTitle, new String[] { label }, new String[] { DEFAULT_VALUE }, isModal, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a generic input dialog with the specified title, a text field,
|
||||
* labeled by the specified label. The user should check the value of
|
||||
|
@ -163,8 +134,8 @@ public class InputDialog extends DialogComponentProvider {
|
|||
*/
|
||||
public InputDialog(String dialogTitle, String[] labels, String[] initialValues, boolean isModal,
|
||||
InputDialogListener listener) {
|
||||
super(dialogTitle, isModal, (listener != null), // status area needed?
|
||||
true, false); // do need button panel
|
||||
super(dialogTitle, isModal, (listener != null) /* status */, true /* buttons */,
|
||||
false /* no tasks */);
|
||||
this.listener = listener;
|
||||
|
||||
// create the key listener all the text fields will use
|
||||
|
@ -253,40 +224,36 @@ public class InputDialog extends DialogComponentProvider {
|
|||
close();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
//* API methods
|
||||
//**************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns if this dialog is cancelled.
|
||||
* Returns if this dialog is cancelled
|
||||
* @return true if cancelled
|
||||
*/
|
||||
public boolean isCanceled() {
|
||||
return isCanceled;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the value of the first (and maybe only) text field
|
||||
* Return the value of the first (and maybe only) text field
|
||||
* @return the text field value
|
||||
*/
|
||||
public String getValue() {
|
||||
return inputValues[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* return the values for all the text field(s)
|
||||
* Sets the text of the primary text field
|
||||
* @param text the text
|
||||
*/
|
||||
public String[] getValues() {
|
||||
return inputValues;
|
||||
public void setValue(String text) {
|
||||
textFields[0].setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* reset all the text fields to their initial values
|
||||
* Return the values for all the text field(s)
|
||||
* @return the text field values
|
||||
*/
|
||||
public void resetValues() {
|
||||
for (int v = 0; v < inputValues.length; v++) {
|
||||
String value = initialValues[v];
|
||||
inputValues[v] = value;
|
||||
textFields[v].setText(value);
|
||||
}
|
||||
public String[] getValues() {
|
||||
return inputValues;
|
||||
}
|
||||
|
||||
private class MyTextField extends JTextField {
|
||||
|
|
|
@ -1633,8 +1633,8 @@ public class FieldPanel extends JPanel
|
|||
if (e.getButton() != MouseEvent.BUTTON1) {
|
||||
return;
|
||||
}
|
||||
cursorHandler.setCursorPos(e.getX(), e.getY(), null);
|
||||
cursorHandler.notifyCursorChanged(EventTrigger.GUI_ACTION);
|
||||
|
||||
cursorHandler.setCursorPos(e.getX(), e.getY(), EventTrigger.GUI_ACTION);
|
||||
if (!selectionHandler.isInProgress() && !didDrag) {
|
||||
selectionHandler.clearSelection();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue