mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 12:00:04 +02:00
GT-2698 refactor UI elements to lock down HTML rendering
This commit is contained in:
parent
a03c96d37b
commit
e0c25b0590
360 changed files with 3895 additions and 4563 deletions
|
@ -98,14 +98,15 @@ public class ActionDialog extends DialogComponentProvider {
|
|||
JPanel innerPanel = new JPanel(new BorderLayout());
|
||||
|
||||
JPanel labelPanel = new JPanel(new GridLayout(0, 1));
|
||||
labelPanel.add(new JLabel("Multiple actions have been mapped to " + keystrokeName));
|
||||
labelPanel.add(new JLabel("Actions that can be enabled at the same"));
|
||||
labelPanel.add(new JLabel("time should be mapped to different keys"));
|
||||
labelPanel.add(DockingUtils.createNonHtmlLabel(
|
||||
"Multiple actions have been mapped to " + keystrokeName));
|
||||
labelPanel.add(DockingUtils.createNonHtmlLabel("Actions that can be enabled at the same"));
|
||||
labelPanel.add(DockingUtils.createNonHtmlLabel("time should be mapped to different keys"));
|
||||
|
||||
innerPanel.setBorder(BorderFactory.createTitledBorder("Actions"));
|
||||
|
||||
ImageIcon image = ResourceManager.loadImage("images/warning.png");
|
||||
JLabel cautionLabel = new JLabel(image);
|
||||
JLabel cautionLabel = DockingUtils.createNonHtmlLabel(image);
|
||||
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
panel.add(cautionLabel);
|
||||
|
|
|
@ -889,7 +889,7 @@ public class DialogComponentProvider
|
|||
|
||||
private JPanel buildStatusPanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
statusLabel = new JLabel(" ");
|
||||
statusLabel = DockingUtils.createHtmlLabel(" ");
|
||||
statusLabel.setName("statusLabel");
|
||||
statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
statusLabel.setForeground(Color.blue);
|
||||
|
|
|
@ -79,7 +79,7 @@ public interface DockingTool {
|
|||
|
||||
/**
|
||||
* Set the status information
|
||||
* @param text string to be displayed in the Status display area
|
||||
* @param text non-html string to be displayed in the Status display area
|
||||
*/
|
||||
public void setStatusInfo(String text);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import javax.swing.text.Document;
|
|||
import javax.swing.text.JTextComponent;
|
||||
import javax.swing.undo.UndoableEdit;
|
||||
|
||||
import docking.widgets.AbstractGCellRenderer;
|
||||
import ghidra.docking.util.DockingWindowsLookAndFeelUtils;
|
||||
import resources.ResourceManager;
|
||||
|
||||
|
@ -68,6 +69,86 @@ public class DockingUtils {
|
|||
return separator;
|
||||
}
|
||||
|
||||
public static JLabel createHtmlLabel() {
|
||||
return createHtmlLabel("");
|
||||
}
|
||||
|
||||
public static JLabel createHtmlLabel(String text) {
|
||||
JLabel label = new JLabel(text);
|
||||
return label;
|
||||
}
|
||||
|
||||
public static JLabel createHtmlLabel(String text, int horizontalAlignment) {
|
||||
JLabel label = new JLabel(text, horizontalAlignment);
|
||||
return label;
|
||||
}
|
||||
|
||||
public static JLabel createHtmlLabel(String text, Icon icon, int horizontalAlignment) {
|
||||
JLabel label = new JLabel(text, icon, horizontalAlignment);
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a JLabel that has HTML rendering disabled.
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public static JLabel createNonHtmlLabel(String text) {
|
||||
JLabel label = new JLabel(text);
|
||||
turnOffHTMLRendering(label);
|
||||
return label;
|
||||
}
|
||||
|
||||
public static JLabel createNonHtmlLabel(Icon icon) {
|
||||
JLabel label = new JLabel(icon);
|
||||
turnOffHTMLRendering(label);
|
||||
return label;
|
||||
}
|
||||
|
||||
public static JLabel createNonHtmlLabel() {
|
||||
return createNonHtmlLabel("");
|
||||
}
|
||||
|
||||
public static JLabel createNonHtmlLabel(String text, int horizontalAlignment) {
|
||||
JLabel label = new JLabel(text, horizontalAlignment);
|
||||
turnOffHTMLRendering(label);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
public static JLabel createNonHtmlLabel(String text, Icon icon, int horizontalAlignment) {
|
||||
JLabel label = new JLabel(text, icon, horizontalAlignment);
|
||||
turnOffHTMLRendering(label);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
public static JLabel createNonHtmlLabel(Icon icon, int horizontalAlignment) {
|
||||
JLabel label = new JLabel(icon, horizontalAlignment);
|
||||
turnOffHTMLRendering(label);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
public static void turnOffHTMLRendering(JComponent comp) {
|
||||
comp.putClientProperty(AbstractGCellRenderer.HTML_DISABLE_STRING, true);
|
||||
}
|
||||
|
||||
public static void turnOffHTMLRendering(JList<?> list) {
|
||||
turnOffHTMLRendering((JComponent) list);
|
||||
if (list.getCellRenderer() instanceof JComponent) {
|
||||
turnOffHTMLRendering((JComponent) list.getCellRenderer());
|
||||
}
|
||||
}
|
||||
|
||||
public static void turnOffHTMLRendering(JComboBox<?> cb) {
|
||||
turnOffHTMLRendering((JComponent) cb);
|
||||
if (cb.getRenderer() instanceof JComponent) {
|
||||
turnOffHTMLRendering((JComponent) cb.getRenderer());
|
||||
}
|
||||
}
|
||||
|
||||
public static Icon scaleIconAsNeeded(Icon icon) {
|
||||
if (icon == null) {
|
||||
return null;
|
||||
|
|
|
@ -1904,7 +1904,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
|
|||
|
||||
/**
|
||||
* Set the status text in the active component window.
|
||||
* @param text status text
|
||||
* @param text non-html status text
|
||||
*/
|
||||
public void setStatusText(String text) {
|
||||
if (root != null) {
|
||||
|
|
|
@ -128,9 +128,9 @@ public class ErrLogDialog extends DialogComponentProvider {
|
|||
|
||||
private void buildMainPanel(String message, String details, boolean isException) {
|
||||
|
||||
messageLabel = new JLabel(HTMLUtilities.toHTML(message));
|
||||
JLabel iconLabel =
|
||||
new JLabel(UIManager.getIcon("OptionPane.errorIcon"), SwingConstants.RIGHT);
|
||||
messageLabel = DockingUtils.createHtmlLabel(HTMLUtilities.toHTML(message));
|
||||
JLabel iconLabel = DockingUtils.createNonHtmlLabel(
|
||||
UIManager.getIcon("OptionPane.errorIcon"), SwingConstants.RIGHT);
|
||||
|
||||
JPanel introPanel = new JPanel(new BorderLayout(10, 10));
|
||||
introPanel.add(iconLabel, BorderLayout.WEST);
|
||||
|
|
|
@ -342,7 +342,7 @@ public class GenericHeader extends JPanel {
|
|||
TitlePanel() {
|
||||
super(new BorderLayout());
|
||||
setFocusable(false);
|
||||
titleLabel = new JLabel();
|
||||
titleLabel = DockingUtils.createNonHtmlLabel();
|
||||
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
|
||||
titleLabel.setForeground(Color.BLACK);
|
||||
titleLabel.setFocusable(false);
|
||||
|
|
|
@ -83,7 +83,7 @@ public class StatusBar extends JPanel {
|
|||
JPanel eastPanel = createEastPanel(statusAreaPanel);
|
||||
add(eastPanel, BorderLayout.EAST);
|
||||
|
||||
statusLabel = new JLabel(" ");
|
||||
statusLabel = DockingUtils.createNonHtmlLabel(" ");
|
||||
statusLabel.setOpaque(true);
|
||||
|
||||
statusLabel.setName("Tool Status");
|
||||
|
|
|
@ -494,7 +494,9 @@ public abstract class DockingAction implements DockingActionIf {
|
|||
}
|
||||
|
||||
protected JMenuItem doCreateMenuItem() {
|
||||
return new DockingMenuItem();
|
||||
DockingMenuItem dmi = new DockingMenuItem();
|
||||
DockingUtils.turnOffHTMLRendering(dmi);
|
||||
return dmi;
|
||||
}
|
||||
|
||||
private void recordInception() {
|
||||
|
|
|
@ -66,7 +66,7 @@ public class KeyEntryDialog extends DialogComponentProvider {
|
|||
defaultPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));
|
||||
|
||||
Icon icon = ResourceManager.loadImage("images/information.png");
|
||||
JLabel imageLabel = new JLabel(icon);
|
||||
JLabel imageLabel = DockingUtils.createNonHtmlLabel(icon);
|
||||
bgColor = imageLabel.getBackground();
|
||||
JTextPane pane = new JTextPane();
|
||||
pane.setBorder(BorderFactory.createEmptyBorder(0, 5, 2, 5));
|
||||
|
@ -75,8 +75,8 @@ public class KeyEntryDialog extends DialogComponentProvider {
|
|||
|
||||
StyledDocument document = pane.getStyledDocument();
|
||||
try {
|
||||
document.insertString(0, "To add or change a key binding, type any key combination.\n"
|
||||
+ "To remove a key binding, press <Enter> or <Backspace>.", null);
|
||||
document.insertString(0, "To add or change a key binding, type any key combination.\n" +
|
||||
"To remove a key binding, press <Enter> or <Backspace>.", null);
|
||||
}
|
||||
catch (BadLocationException e1) {
|
||||
// shouldn't be possible
|
||||
|
@ -204,7 +204,7 @@ public class KeyEntryDialog extends DialogComponentProvider {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
List<DockingActionIf> list = multiAction.getActions();
|
||||
Map<String, DockingActionIf> nameMap = new HashMap<String, DockingActionIf>(list.size());
|
||||
Map<String, DockingActionIf> nameMap = new HashMap<>(list.size());
|
||||
|
||||
// the list may have multiple matches for a single owner, which we do not want (see
|
||||
// DummyKeyBindingsOptionsAction)
|
||||
|
@ -215,7 +215,7 @@ public class KeyEntryDialog extends DialogComponentProvider {
|
|||
}
|
||||
}
|
||||
|
||||
return new ArrayList<DockingActionIf>(nameMap.values());
|
||||
return new ArrayList<>(nameMap.values());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.PluggableServiceRegistry;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
@ -35,20 +36,20 @@ public class ApplicationInformationDisplayFactory {
|
|||
}
|
||||
|
||||
public static String createSplashScreenTitle() {
|
||||
ApplicationInformationDisplayFactory factory =
|
||||
PluggableServiceRegistry.getPluggableService(ApplicationInformationDisplayFactory.class);
|
||||
ApplicationInformationDisplayFactory factory = PluggableServiceRegistry.getPluggableService(
|
||||
ApplicationInformationDisplayFactory.class);
|
||||
return factory.doCreateSplashScreenTitle();
|
||||
}
|
||||
|
||||
public static String createAboutTitle() {
|
||||
ApplicationInformationDisplayFactory factory =
|
||||
PluggableServiceRegistry.getPluggableService(ApplicationInformationDisplayFactory.class);
|
||||
ApplicationInformationDisplayFactory factory = PluggableServiceRegistry.getPluggableService(
|
||||
ApplicationInformationDisplayFactory.class);
|
||||
return factory.doCreateAboutTitle();
|
||||
}
|
||||
|
||||
public static List<Image> getWindowIcons() {
|
||||
ApplicationInformationDisplayFactory factory =
|
||||
PluggableServiceRegistry.getPluggableService(ApplicationInformationDisplayFactory.class);
|
||||
ApplicationInformationDisplayFactory factory = PluggableServiceRegistry.getPluggableService(
|
||||
ApplicationInformationDisplayFactory.class);
|
||||
return factory.doGetWindowIcons();
|
||||
}
|
||||
|
||||
|
@ -69,8 +70,8 @@ public class ApplicationInformationDisplayFactory {
|
|||
}
|
||||
|
||||
public static ImageIcon getHomeIcon() {
|
||||
ApplicationInformationDisplayFactory factory = PluggableServiceRegistry
|
||||
.getPluggableService(ApplicationInformationDisplayFactory.class);
|
||||
ApplicationInformationDisplayFactory factory = PluggableServiceRegistry.getPluggableService(
|
||||
ApplicationInformationDisplayFactory.class);
|
||||
return factory.doGetHomeIcon();
|
||||
}
|
||||
|
||||
|
@ -81,20 +82,20 @@ public class ApplicationInformationDisplayFactory {
|
|||
}
|
||||
|
||||
public static JComponent createSplashScreenComponent() {
|
||||
ApplicationInformationDisplayFactory factory =
|
||||
PluggableServiceRegistry.getPluggableService(ApplicationInformationDisplayFactory.class);
|
||||
ApplicationInformationDisplayFactory factory = PluggableServiceRegistry.getPluggableService(
|
||||
ApplicationInformationDisplayFactory.class);
|
||||
return factory.doCreateSplashScreenComponent();
|
||||
}
|
||||
|
||||
public static JComponent createAboutComponent() {
|
||||
ApplicationInformationDisplayFactory factory =
|
||||
PluggableServiceRegistry.getPluggableService(ApplicationInformationDisplayFactory.class);
|
||||
ApplicationInformationDisplayFactory factory = PluggableServiceRegistry.getPluggableService(
|
||||
ApplicationInformationDisplayFactory.class);
|
||||
return factory.doCreateAboutComponent();
|
||||
}
|
||||
|
||||
public static HelpLocation createHelpLocation() {
|
||||
ApplicationInformationDisplayFactory factory =
|
||||
PluggableServiceRegistry.getPluggableService(ApplicationInformationDisplayFactory.class);
|
||||
ApplicationInformationDisplayFactory factory = PluggableServiceRegistry.getPluggableService(
|
||||
ApplicationInformationDisplayFactory.class);
|
||||
return factory.doCreateHelpLocation();
|
||||
}
|
||||
|
||||
|
@ -117,7 +118,7 @@ public class ApplicationInformationDisplayFactory {
|
|||
|
||||
panel.setBackground(background);
|
||||
|
||||
JLabel nameLabel = new JLabel();
|
||||
JLabel nameLabel = DockingUtils.createNonHtmlLabel();
|
||||
nameLabel.setText(Application.getName());
|
||||
nameLabel.setForeground(new Color(155, 155, 155));
|
||||
Font newFont = new Font("Garamond", Font.BOLD, 35);
|
||||
|
@ -128,7 +129,7 @@ public class ApplicationInformationDisplayFactory {
|
|||
|
||||
final JPanel imagePanel = new JPanel(new BorderLayout());
|
||||
imagePanel.setBackground(background);
|
||||
JLabel imageLabel = new JLabel(icon);
|
||||
JLabel imageLabel = DockingUtils.createNonHtmlLabel(icon);
|
||||
imageLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||
imageLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
imagePanel.add(imageLabel);
|
||||
|
@ -143,7 +144,7 @@ public class ApplicationInformationDisplayFactory {
|
|||
}
|
||||
|
||||
protected List<Image> doGetWindowIcons() {
|
||||
List<Image> list = new ArrayList<Image>();
|
||||
List<Image> list = new ArrayList<>();
|
||||
list.add(ResourceManager.loadImage("images/www_128.png").getImage());
|
||||
list.add(ResourceManager.loadImage("images/www_16.png").getImage());
|
||||
return list;
|
||||
|
|
|
@ -312,8 +312,8 @@ public class SplashScreen extends JWindow {
|
|||
titlePanel.setBackground(backgroundColor);
|
||||
titlePanel.setLayout(new BorderLayout());
|
||||
|
||||
JLabel titleLabel =
|
||||
new JLabel(ApplicationInformationDisplayFactory.createSplashScreenTitle());
|
||||
JLabel titleLabel = DockingUtils.createNonHtmlLabel(
|
||||
ApplicationInformationDisplayFactory.createSplashScreenTitle());
|
||||
Font font = titleLabel.getFont();
|
||||
font = new Font(font.getName(), Font.BOLD, 11);
|
||||
titleLabel.setFont(font);
|
||||
|
@ -328,7 +328,7 @@ public class SplashScreen extends JWindow {
|
|||
|
||||
private Component createStatusComponent() {
|
||||
Font f = new Font("serif", Font.BOLD, 12);
|
||||
statusLabel = new JLabel(" Loading...");
|
||||
statusLabel = DockingUtils.createNonHtmlLabel(" Loading...");
|
||||
statusLabel.setFont(f);
|
||||
|
||||
statusLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 2, 10));
|
||||
|
|
|
@ -415,7 +415,7 @@ public class MultipleActionDockingToolbarButton extends EmptyBorderButton {
|
|||
|
||||
private final int EMTPY_SEPARATOR_HEIGHT = 10;
|
||||
private final int TEXT_SEPARATOR_HEIGHT = 32;
|
||||
private JLabel renderer = new JLabel();
|
||||
private JLabel renderer = DockingUtils.createHtmlLabel();
|
||||
|
||||
private int separatorHeight = EMTPY_SEPARATOR_HEIGHT;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.swing.text.*;
|
|||
|
||||
import com.toedter.calendar.JCalendar;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import ghidra.util.layout.HorizontalLayout;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +35,7 @@ import ghidra.util.layout.HorizontalLayout;
|
|||
*/
|
||||
class Clock extends JPanel implements CaretListener {
|
||||
|
||||
private JLabel dateLabel = new JLabel("Apr 18, 2006");
|
||||
private JLabel dateLabel = DockingUtils.createNonHtmlLabel("Apr 18, 2006");
|
||||
private JTextField hoursField;
|
||||
private JTextField minutesField;
|
||||
private JTextField secondsField;
|
||||
|
@ -132,9 +133,9 @@ class Clock extends JPanel implements CaretListener {
|
|||
|
||||
add(dateLabel);
|
||||
add(hoursField);
|
||||
add(new JLabel(":"));
|
||||
add(DockingUtils.createNonHtmlLabel(":"));
|
||||
add(minutesField);
|
||||
add(new JLabel(":"));
|
||||
add(DockingUtils.createNonHtmlLabel(":"));
|
||||
add(secondsField);
|
||||
|
||||
formatter = new SimpleDateFormat("HH:mm:ss MMM dd, yyyy");
|
||||
|
|
|
@ -24,8 +24,7 @@ import javax.swing.*;
|
|||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.*;
|
||||
|
||||
/**
|
||||
* Color editor that uses the JColorChooser.
|
||||
|
@ -37,7 +36,7 @@ public class ColorEditor extends PropertyEditorSupport {
|
|||
|
||||
private static GhidraColorChooser colorChooser;
|
||||
|
||||
private JLabel previewLabel = new JLabel();
|
||||
private JLabel previewLabel = DockingUtils.createHtmlLabel();
|
||||
private Color color;
|
||||
private Color lastUserSelectedColor;
|
||||
|
||||
|
@ -123,8 +122,8 @@ public class ColorEditor extends PropertyEditorSupport {
|
|||
colorString = DARK_COLOR;
|
||||
}
|
||||
|
||||
previewLabel.setText("<HTML><CENTER><I><FONT SIZE=2 COLOR=" + colorString +
|
||||
">click</FONT></I></CENTER>");
|
||||
previewLabel.setText(
|
||||
"<HTML><CENTER><I><FONT SIZE=2 COLOR=" + colorString + ">click</FONT></I></CENTER>");
|
||||
|
||||
previewLabel.setBackground(color);
|
||||
}
|
||||
|
|
|
@ -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 docking.options.editor;
|
||||
|
||||
import ghidra.framework.options.EditorState;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.MouseAdapter;
|
||||
|
@ -27,61 +22,64 @@ import java.awt.event.MouseEvent;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.ToolTipManager;
|
||||
import ghidra.framework.options.EditorState;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
public class DefaultOptionComponent extends GenericOptionsComponent {
|
||||
private JLabel label;
|
||||
private Component component;
|
||||
private JLabel label;
|
||||
private Component component;
|
||||
|
||||
public DefaultOptionComponent( EditorState editorState ) {
|
||||
super( editorState );
|
||||
setLayout( new PairLayout(0, 6, 40) );
|
||||
this.component = editorState.getEditorComponent();
|
||||
public DefaultOptionComponent(EditorState editorState) {
|
||||
super(editorState);
|
||||
setLayout(new PairLayout(0, 6, 40));
|
||||
this.component = editorState.getEditorComponent();
|
||||
|
||||
label = new JLabel(editorState.getTitle(), SwingConstants.RIGHT);
|
||||
label = DockingUtils.createNonHtmlLabel(editorState.getTitle(), SwingConstants.RIGHT);
|
||||
|
||||
if (component instanceof AbstractButton) {
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent evt) {
|
||||
if (!component.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
AbstractButton button = (AbstractButton) component;
|
||||
button.setSelected(!button.isSelected());
|
||||
}
|
||||
});
|
||||
}
|
||||
setSize(getPreferredSize());
|
||||
|
||||
if (component instanceof AbstractButton) {
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent evt) {
|
||||
if (!component.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
AbstractButton button = (AbstractButton)component;
|
||||
button.setSelected(!button.isSelected());
|
||||
}
|
||||
});
|
||||
}
|
||||
setSize(getPreferredSize());
|
||||
String description = editorState.getDescription();
|
||||
if (description != null) {
|
||||
String htmlDescription = HTMLUtilities.toWrappedHTML(description);
|
||||
ToolTipManager.setToolTipText(label, htmlDescription);
|
||||
if (component instanceof JComponent) {
|
||||
ToolTipManager.setToolTipText((JComponent) component, htmlDescription);
|
||||
}
|
||||
}
|
||||
add(label);
|
||||
add(component);
|
||||
}
|
||||
|
||||
String description = editorState.getDescription();
|
||||
if (description != null) {
|
||||
String htmlDescription = HTMLUtilities.toWrappedHTML( description );
|
||||
ToolTipManager.setToolTipText(label, htmlDescription);
|
||||
if (component instanceof JComponent) {
|
||||
ToolTipManager.setToolTipText((JComponent)component, htmlDescription);
|
||||
}
|
||||
}
|
||||
add(label);
|
||||
add(component);
|
||||
}
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
label.setEnabled(enabled);
|
||||
component.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
label.setEnabled(enabled);
|
||||
component.setEnabled(enabled);
|
||||
}
|
||||
@Override
|
||||
protected void setAlignmentPreferredSize(Dimension dimension) {
|
||||
label.setPreferredSize(dimension);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAlignmentPreferredSize( Dimension dimension ) {
|
||||
label.setPreferredSize( dimension );
|
||||
}
|
||||
|
||||
@Override // overridden to get the size based upon this class's two components
|
||||
protected Dimension getPreferredAlignmentSize() {
|
||||
Dimension dimension = label.getPreferredSize();
|
||||
int maxHeight = Math.max( dimension.height, component.getPreferredSize().height );
|
||||
return new Dimension( dimension.width, maxHeight );
|
||||
}
|
||||
@Override // overridden to get the size based upon this class's two components
|
||||
protected Dimension getPreferredAlignmentSize() {
|
||||
Dimension dimension = label.getPreferredSize();
|
||||
int maxHeight = Math.max(dimension.height, component.getPreferredSize().height);
|
||||
return new Dimension(dimension.width, maxHeight);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ import java.util.List;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.*;
|
||||
|
||||
/**
|
||||
* This Bean FontEditor displays a String with the current selected font name,
|
||||
|
@ -34,7 +33,7 @@ import docking.DockingWindowManager;
|
|||
*/
|
||||
public class FontPropertyEditor extends PropertyEditorSupport {
|
||||
private Font font;
|
||||
// private JLabel previewLabel = new JLabel();
|
||||
// private JLabel previewLabel = DockingUtils.createNonHtmlLabel();
|
||||
private JButton previewButton = new JButton();
|
||||
private final static String SAMPLE_STRING = "ABCabc \u00a9\u00ab\u00a7\u0429\u05d1\u062c\u4eb9";
|
||||
|
||||
|
@ -134,7 +133,7 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||
sizeAndStylePanel.add(BorderLayout.CENTER, stylePanel);
|
||||
topPanel.add(BorderLayout.CENTER, sizeAndStylePanel);
|
||||
|
||||
fontStringLabel = new JLabel(FontPropertyEditor.SAMPLE_STRING);
|
||||
fontStringLabel = DockingUtils.createNonHtmlLabel(FontPropertyEditor.SAMPLE_STRING);
|
||||
fontStringLabel.setPreferredSize(new Dimension(350, 50));
|
||||
fontStringLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
fontStringLabel.setFont(font);
|
||||
|
@ -142,21 +141,18 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||
|
||||
add(BorderLayout.NORTH, topPanel);
|
||||
|
||||
fontLabel = new JLabel();
|
||||
fontLabel.setText("Fonts");
|
||||
fontLabel = DockingUtils.createNonHtmlLabel("Fonts");
|
||||
Font newFont = getFont().deriveFont(1);
|
||||
fontLabel.setFont(newFont);
|
||||
fontLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
fontPanel.add(fontLabel);
|
||||
|
||||
sizeLabel = new JLabel();
|
||||
sizeLabel.setText("Sizes");
|
||||
sizeLabel = DockingUtils.createNonHtmlLabel("Sizes");
|
||||
sizeLabel.setFont(newFont);
|
||||
sizeLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
sizePanel.add(sizeLabel);
|
||||
|
||||
styleLabel = new JLabel();
|
||||
styleLabel.setText("Styles");
|
||||
styleLabel = DockingUtils.createNonHtmlLabel("Styles");
|
||||
styleLabel.setFont(newFont);
|
||||
styleLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
stylePanel.add(styleLabel);
|
||||
|
@ -164,7 +160,7 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||
GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
|
||||
String envfonts[] = gEnv.getAvailableFontFamilyNames();
|
||||
List<FontWrapper> list = new ArrayList<FontWrapper>(envfonts.length);
|
||||
List<FontWrapper> list = new ArrayList<>(envfonts.length);
|
||||
for (String envfont : envfonts) {
|
||||
list.add(new FontWrapper(envfont));
|
||||
}
|
||||
|
@ -175,9 +171,8 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||
fontPanel.add(fonts);
|
||||
fonts.setSelectedItem(fontWrapper);
|
||||
|
||||
sizes =
|
||||
new JComboBox<>(
|
||||
new String[] { "8", "10", "12", "14", "16", "18", "24", "28", "32" });
|
||||
sizes = new JComboBox<>(
|
||||
new String[] { "8", "10", "12", "14", "16", "18", "24", "28", "32" });
|
||||
sizes.setMaximumRowCount(9);
|
||||
sizePanel.add(sizes);
|
||||
sizeChoice = font.getSize();
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.swing.*;
|
|||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.help.Help;
|
||||
import docking.help.HelpService;
|
||||
import docking.widgets.MultiLineLabel;
|
||||
|
@ -34,8 +35,7 @@ import docking.widgets.OptionDialog;
|
|||
import docking.widgets.tree.*;
|
||||
import docking.widgets.tree.internal.DefaultGTreeDataTransformer;
|
||||
import ghidra.framework.options.*;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.bean.opteditor.OptionsVetoException;
|
||||
import ghidra.util.layout.MiddleLayout;
|
||||
import ghidra.util.task.SwingUpdateManager;
|
||||
|
@ -138,7 +138,7 @@ public class OptionsPanel extends JPanel {
|
|||
Options currentOptions = getSelectedOptions();
|
||||
|
||||
int userChoice = OptionDialog.showOptionDialog(viewPanel, "Restore Defaults?",
|
||||
"<html>Restore <b>" + currentOptions.getName() +
|
||||
"<html>Restore <b>" + HTMLUtilities.friendlyEncodeHTML(currentOptions.getName()) +
|
||||
"</b> to default option values <b>and erase current settings?</b>",
|
||||
"Restore Defaults");
|
||||
if (userChoice == OptionDialog.CANCEL_OPTION) {
|
||||
|
@ -243,7 +243,7 @@ public class OptionsPanel extends JPanel {
|
|||
panel.setName("Default");
|
||||
|
||||
Icon icon = ResourceManager.loadImage("images/information.png");
|
||||
JLabel imageLabel = new JLabel(icon);
|
||||
JLabel imageLabel = DockingUtils.createNonHtmlLabel(icon);
|
||||
|
||||
MultiLineLabel label =
|
||||
new MultiLineLabel("To change Options, select a Folder or Option Group from the\n" +
|
||||
|
|
|
@ -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 docking.options.editor;
|
||||
|
||||
import ghidra.util.layout.VerticalLayout;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.Serializable;
|
||||
|
@ -27,6 +24,9 @@ import javax.swing.*;
|
|||
import javax.swing.border.*;
|
||||
import javax.swing.colorchooser.AbstractColorChooserPanel;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import ghidra.util.layout.VerticalLayout;
|
||||
|
||||
public class SettableColorSwatchChooserPanel extends AbstractColorChooserPanel {
|
||||
SwatchPanel swatchPanel;
|
||||
RecentSwatchPanel recentSwatchPanel;
|
||||
|
@ -129,7 +129,7 @@ public class SettableColorSwatchChooserPanel extends AbstractColorChooserPanel {
|
|||
recentSwatchPanel.addMouseListener(recentSwatchListener);
|
||||
recentSwatchPanel.setBorder(border);
|
||||
JPanel recentLabelHolder = new JPanel(new BorderLayout());
|
||||
JLabel l = new JLabel(recentStr);
|
||||
JLabel l = DockingUtils.createHtmlLabel(recentStr);
|
||||
l.setLabelFor(recentSwatchPanel);
|
||||
recentLabelHolder.add(l, BorderLayout.NORTH);
|
||||
gbc.weighty = 0.0;
|
||||
|
@ -144,7 +144,7 @@ public class SettableColorSwatchChooserPanel extends AbstractColorChooserPanel {
|
|||
historySwatchPanel.addMouseListener(historySwatchListener);
|
||||
historySwatchPanel.setBorder(border);
|
||||
JPanel historyLabelHolder = new JPanel(new BorderLayout());
|
||||
JLabel historyLabel = new JLabel("History:");
|
||||
JLabel historyLabel = DockingUtils.createNonHtmlLabel("History:");
|
||||
historyLabel.setLabelFor(historySwatchPanel);
|
||||
historyLabelHolder.add(historyLabel, BorderLayout.NORTH);
|
||||
gbc.weighty = 0.0;
|
||||
|
@ -251,10 +251,10 @@ class SwatchPanel extends JPanel {
|
|||
int y = row * (swatchSize.height + gap.height);
|
||||
g.fillRect(x, y, swatchSize.width, swatchSize.height);
|
||||
g.setColor(Color.black);
|
||||
g.drawLine(x + swatchSize.width - 1, y, x + swatchSize.width - 1, y +
|
||||
swatchSize.height - 1);
|
||||
g.drawLine(x, y + swatchSize.height - 1, x + swatchSize.width - 1, y +
|
||||
swatchSize.height - 1);
|
||||
g.drawLine(x + swatchSize.width - 1, y, x + swatchSize.width - 1,
|
||||
y + swatchSize.height - 1);
|
||||
g.drawLine(x, y + swatchSize.height - 1, x + swatchSize.width - 1,
|
||||
y + swatchSize.height - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -20,18 +19,16 @@ import java.awt.Component;
|
|||
import java.awt.Graphics;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import resources.ResourceManager;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.Timer;
|
||||
|
||||
public class AnimatedIcon implements Icon {
|
||||
|
||||
/** best guess at how many timer invocations may happen before paint gets called*/
|
||||
private static final int MAGIC_TIMER_CALLS_WITHOUT_PAINT_CALL = 5;
|
||||
|
||||
/** best guess at how many timer invocations may happen before paint gets called*/
|
||||
private static final int MAGIC_TIMER_CALLS_WITHOUT_PAINT_CALL = 5;
|
||||
|
||||
private final List<Icon> iconList;
|
||||
private int currentIconIndex = 0;
|
||||
private Component component;
|
||||
|
@ -39,19 +36,20 @@ public class AnimatedIcon implements Icon {
|
|||
private int width;
|
||||
private int skipFrames;
|
||||
private int skipFrameCount = 0;
|
||||
private Timer timer;
|
||||
private int paintCounter = 0;
|
||||
|
||||
private Timer timer;
|
||||
private int paintCounter = 0;
|
||||
|
||||
public AnimatedIcon(List<Icon> icons, int frameDelay, int framesToSkip) {
|
||||
this.iconList = icons;
|
||||
this.skipFrames = framesToSkip;
|
||||
timer = new Timer(frameDelay, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if ( --paintCounter <= 0 ) {
|
||||
timer.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (--paintCounter <= 0) {
|
||||
timer.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (skipFrameCount > 0) {
|
||||
skipFrameCount--;
|
||||
return;
|
||||
|
@ -65,44 +63,33 @@ public class AnimatedIcon implements Icon {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
for ( Icon icon : iconList ) {
|
||||
|
||||
for (Icon icon : iconList) {
|
||||
width = Math.max(width, icon.getIconWidth());
|
||||
height = Math.max(height, icon.getIconHeight());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
private void restartAnimation() {
|
||||
timer.start();
|
||||
paintCounter = MAGIC_TIMER_CALLS_WITHOUT_PAINT_CALL;
|
||||
timer.start();
|
||||
paintCounter = MAGIC_TIMER_CALLS_WITHOUT_PAINT_CALL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
restartAnimation();
|
||||
iconList.get(currentIconIndex).paintIcon( c, g, x, y );
|
||||
restartAnimation();
|
||||
iconList.get(currentIconIndex).paintIcon(c, g, x, y);
|
||||
component = c;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame frame = new JFrame("Test");
|
||||
List<Icon> iconList = new ArrayList<Icon>();
|
||||
iconList.add(ResourceManager.loadImage( "images/weather-clear.png" ));
|
||||
iconList.add(ResourceManager.loadImage( "images/weather-few-clouds-reverse.png" ));
|
||||
iconList.add(ResourceManager.loadImage( "images/weather-overcast.png" ));
|
||||
iconList.add(ResourceManager.loadImage( "images/weather-showers.png" ));
|
||||
iconList.add(ResourceManager.loadImage( "images/weather-few-clouds.png" ));
|
||||
iconList.add(ResourceManager.loadImage( "images/weather-clear.png" ));
|
||||
AnimatedIcon icon = new AnimatedIcon(iconList, 400, 0);
|
||||
JLabel label = new JLabel(icon);
|
||||
frame.getContentPane().add( label );
|
||||
frame.setVisible( true );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public abstract class AbstractGCellRenderer extends JLabel {
|
|||
}
|
||||
|
||||
// taken from BasicHTML.htmlDisable, which is private
|
||||
protected static final String HTML_DISABLE_STRING = "html.disable";
|
||||
public static final String HTML_DISABLE_STRING = "html.disable";
|
||||
|
||||
protected final Border focusBorder;
|
||||
protected final Border noFocusBorder;
|
||||
|
@ -170,15 +170,6 @@ public abstract class AbstractGCellRenderer extends JLabel {
|
|||
return boldFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cell renderer text
|
||||
* @param value Cell object value
|
||||
* @return A string interpretation of value; generated by calling value.toString()
|
||||
*/
|
||||
protected String getText(Object value) {
|
||||
return value == null ? "" : value.toString();
|
||||
}
|
||||
|
||||
protected static Color getBackgroundColorForRow(int row) {
|
||||
|
||||
if ((row & 1) == 1) {
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
*/
|
||||
package docking.widgets;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.ListCellRenderer;
|
||||
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
import ghidra.util.datastruct.CaseInsensitiveDuplicateStringComparator;
|
||||
|
||||
public class DefaultDropDownSelectionDataModel<T> implements DropDownTextFieldDataModel<T> {
|
||||
|
@ -29,19 +29,21 @@ public class DefaultDropDownSelectionDataModel<T> implements DropDownTextFieldDa
|
|||
private ObjectStringComparator comparator;
|
||||
private DataToStringConverter<T> searchConverter;
|
||||
private DataToStringConverter<T> descriptionConverter;
|
||||
private ListCellRenderer<T> renderer = new TDropDownRenderer();
|
||||
private ListCellRenderer<T> renderer =
|
||||
GListCellRenderer.createDefaultCellTextRenderer(value -> searchConverter.getString(value));
|
||||
|
||||
public static DefaultDropDownSelectionDataModel<String> getStringModel(List<String> strings) {
|
||||
return new DefaultDropDownSelectionDataModel<String>(strings,
|
||||
return new DefaultDropDownSelectionDataModel<>(strings,
|
||||
DataToStringConverter.stringDataToStringConverter);
|
||||
}
|
||||
|
||||
public DefaultDropDownSelectionDataModel(List<T> data, DataToStringConverter<T> searchConverter) {
|
||||
public DefaultDropDownSelectionDataModel(List<T> data,
|
||||
DataToStringConverter<T> searchConverter) {
|
||||
this(data, searchConverter, null);
|
||||
}
|
||||
|
||||
public DefaultDropDownSelectionDataModel(List<T> data,
|
||||
DataToStringConverter<T> searchConverter, DataToStringConverter<T> descriptionConverter) {
|
||||
public DefaultDropDownSelectionDataModel(List<T> data, DataToStringConverter<T> searchConverter,
|
||||
DataToStringConverter<T> descriptionConverter) {
|
||||
this.data = data;
|
||||
this.searchConverter = searchConverter;
|
||||
this.descriptionConverter =
|
||||
|
@ -136,23 +138,4 @@ public class DefaultDropDownSelectionDataModel<T> implements DropDownTextFieldDa
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderer for data types. It uses delegation instead of inheritance, due typing issues
|
||||
* (DefaultListCellRenderer is already typed on Object).
|
||||
*/
|
||||
private class TDropDownRenderer implements ListCellRenderer<T> {
|
||||
|
||||
private DefaultListCellRenderer delegate = new DefaultListCellRenderer();
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends T> list, T value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
JLabel label =
|
||||
(JLabel) delegate.getListCellRendererComponent(list, value, index, isSelected,
|
||||
cellHasFocus);
|
||||
label.setText(searchConverter.getString(value));
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import javax.swing.event.*;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import generic.util.WindowUtilities;
|
||||
import ghidra.util.StringUtilities;
|
||||
import ghidra.util.SystemUtilities;
|
||||
|
@ -130,6 +131,7 @@ public class DropDownTextField<T> extends JTextField {
|
|||
}
|
||||
|
||||
private void init(int updateMinDelay) {
|
||||
DockingUtils.turnOffHTMLRendering(list);
|
||||
updateManager = new SwingUpdateManager(updateMinDelay, DEFAULT_MAX_UPDATE_DELAY,
|
||||
"Drop Down Selection Text Field Update Manager", () -> {
|
||||
if (pendingTextUpdate == null) {
|
||||
|
@ -154,7 +156,7 @@ public class DropDownTextField<T> extends JTextField {
|
|||
}
|
||||
|
||||
protected void setPreviewPaneAttributes() {
|
||||
previewLabel = new JLabel();
|
||||
previewLabel = DockingUtils.createNonHtmlLabel();
|
||||
previewLabel.setOpaque(true);
|
||||
previewLabel.setBackground(TOOLTIP_WINDOW_BGCOLOR);
|
||||
previewLabel.setVerticalAlignment(SwingConstants.TOP);
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.swing.event.DocumentEvent;
|
|||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
|
||||
public class FindDialog extends DialogComponentProvider {
|
||||
|
@ -97,7 +98,7 @@ public class FindDialog extends DialogComponentProvider {
|
|||
}
|
||||
});
|
||||
|
||||
JLabel findLabel = new JLabel("Find: ");
|
||||
JLabel findLabel = DockingUtils.createNonHtmlLabel("Find: ");
|
||||
|
||||
// associate this label with a mnemonic key that activates the text field
|
||||
findLabel.setDisplayedMnemonic(KeyEvent.VK_N);
|
||||
|
|
|
@ -22,8 +22,7 @@ import java.util.List;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.*;
|
||||
import docking.options.editor.ButtonPanelFactory;
|
||||
import docking.widgets.table.AbstractGTableModel;
|
||||
import docking.widgets.table.RowObjectTableModel;
|
||||
|
@ -60,7 +59,7 @@ public class ListSelectionDialog<T> extends DialogComponentProvider {
|
|||
this.data = data;
|
||||
this.searchConverter = searchConverter;
|
||||
this.descriptionConverter = descriptionConverter;
|
||||
DefaultDropDownSelectionDataModel<T> model = new DefaultDropDownSelectionDataModel<T>(
|
||||
DefaultDropDownSelectionDataModel<T> model = new DefaultDropDownSelectionDataModel<>(
|
||||
new ArrayList<>(data), searchConverter, descriptionConverter) {
|
||||
|
||||
// overridden to return all data for an empty search; this lets the down-arrow
|
||||
|
@ -112,7 +111,7 @@ public class ListSelectionDialog<T> extends DialogComponentProvider {
|
|||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(40, 40, 30, 40));
|
||||
|
||||
field = new DropDownSelectionTextField<T>(model) {
|
||||
field = new DropDownSelectionTextField<>(model) {
|
||||
|
||||
// overridden to return all data for an empty search; this lets the down-arrow
|
||||
// show the full list
|
||||
|
@ -128,7 +127,7 @@ public class ListSelectionDialog<T> extends DialogComponentProvider {
|
|||
selectionListener = new SelectionListener<>();
|
||||
field.addDropDownSelectionChoiceListener(selectionListener);
|
||||
|
||||
JLabel jLabel = new JLabel(label);
|
||||
JLabel jLabel = DockingUtils.createNonHtmlLabel(label);
|
||||
jLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
|
||||
panel.add(jLabel, BorderLayout.WEST);
|
||||
panel.add(field, BorderLayout.CENTER);
|
||||
|
|
|
@ -29,7 +29,9 @@ import utilities.util.reflection.ReflectionUtilities;
|
|||
*
|
||||
* Class to render a String that has new line characters as a multiline
|
||||
* label. Calculates the resizing and centering characteristics.
|
||||
*
|
||||
* <p>
|
||||
* Not affected by HTML formatting.
|
||||
* <p>
|
||||
*/
|
||||
|
||||
public class MultiLineLabel extends JPanel {
|
||||
|
|
|
@ -22,8 +22,7 @@ import java.util.List;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.*;
|
||||
import docking.widgets.dialogs.*;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.Msg;
|
||||
|
@ -276,11 +275,8 @@ public class OptionDialog extends DialogComponentProvider {
|
|||
|
||||
private JPanel buildMessagePanel(String message, int messageType, Icon icon) {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
JLabel iconLabel = new JLabel();
|
||||
if (icon == null) {
|
||||
icon = getIconForMessageType(messageType);
|
||||
}
|
||||
iconLabel.setIcon(icon);
|
||||
JLabel iconLabel = DockingUtils.createNonHtmlLabel(
|
||||
(icon == null) ? getIconForMessageType(messageType) : icon);
|
||||
JPanel textPanel = createTextPanel(message);
|
||||
textPanel.setMaximumSize(textPanel.getPreferredSize());
|
||||
panel.add(iconLabel, BorderLayout.WEST);
|
||||
|
@ -364,7 +360,7 @@ public class OptionDialog extends DialogComponentProvider {
|
|||
|
||||
this.dialogMessage = message;
|
||||
if (HTMLUtilities.isHTML(dialogMessage)) {
|
||||
JLabel messageLabel = new JLabel(dialogMessage);
|
||||
JLabel messageLabel = DockingUtils.createHtmlLabel(dialogMessage);
|
||||
messageLabel.setName(MESSAGE_COMPONENT_NAME);
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 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,10 +15,6 @@
|
|||
*/
|
||||
package docking.widgets;
|
||||
|
||||
import ghidra.util.MessageType;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.*;
|
||||
import java.util.Arrays;
|
||||
|
@ -27,6 +22,10 @@ import java.util.Arrays;
|
|||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.util.MessageType;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
public class PasswordChangeDialog extends DialogComponentProvider {
|
||||
|
||||
|
@ -45,33 +44,34 @@ public class PasswordChangeDialog extends DialogComponentProvider {
|
|||
wp.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10));
|
||||
|
||||
if (serverName != null) {
|
||||
wp.add(new JLabel(serverType + ":"));
|
||||
wp.add(new JLabel(serverName));
|
||||
wp.add(DockingUtils.createNonHtmlLabel(serverType + ":"));
|
||||
wp.add(DockingUtils.createNonHtmlLabel(serverName));
|
||||
}
|
||||
|
||||
if (userID != null) {
|
||||
wp.add(new JLabel("User ID:"));
|
||||
JLabel nameLabel = new JLabel(userID);
|
||||
wp.add(DockingUtils.createNonHtmlLabel("User ID:"));
|
||||
JLabel nameLabel = DockingUtils.createNonHtmlLabel(userID);
|
||||
nameLabel.setName("NAME-COMPONENT");
|
||||
wp.add(nameLabel);
|
||||
}
|
||||
|
||||
wp.add(new JLabel("New Password:"));
|
||||
wp.add(DockingUtils.createNonHtmlLabel("New Password:"));
|
||||
passwordField1 = new JPasswordField(16);
|
||||
passwordField1.setName("PASSWORD-ENTRY1-COMPONENT");
|
||||
wp.add(passwordField1);
|
||||
|
||||
wp.add(new JLabel("Repeat Password:"));
|
||||
wp.add(DockingUtils.createNonHtmlLabel("Repeat Password:"));
|
||||
passwordField2 = new JPasswordField(16);
|
||||
passwordField2.setName("PASSWORD-ENTRY2-COMPONENT");
|
||||
passwordField2.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
okCallback();
|
||||
}
|
||||
});
|
||||
wp.add(passwordField2);
|
||||
|
||||
wp.add(new JLabel());
|
||||
wp.add(DockingUtils.createNonHtmlLabel());
|
||||
|
||||
KeyListener keyListener = new KeyListener() {
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.awt.event.*;
|
|||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.util.MessageType;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
|
@ -56,7 +57,7 @@ public class PasswordDialog extends DialogComponentProvider {
|
|||
int defaultChoice, boolean includeAnonymousOption) {
|
||||
this(title, serverType, serverName, passPrompt, namePrompt, defaultUserID);
|
||||
if (choicePrompt != null) {
|
||||
workPanel.add(new JLabel(choicePrompt));
|
||||
workPanel.add(DockingUtils.createNonHtmlLabel(choicePrompt));
|
||||
choiceCB = new JComboBox<>(choices);
|
||||
choiceCB.setName("CHOICES-COMPONENT");
|
||||
choiceCB.setSelectedIndex(defaultChoice);
|
||||
|
@ -79,7 +80,7 @@ public class PasswordDialog extends DialogComponentProvider {
|
|||
choiceCB.setEnabled(enableOtherFields);
|
||||
}
|
||||
});
|
||||
workPanel.add(new JLabel(""));
|
||||
workPanel.add(DockingUtils.createNonHtmlLabel(""));
|
||||
workPanel.add(anonymousAccess);
|
||||
}
|
||||
}
|
||||
|
@ -124,24 +125,25 @@ public class PasswordDialog extends DialogComponentProvider {
|
|||
workPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10));
|
||||
|
||||
if (serverName != null) {
|
||||
workPanel.add(new JLabel(serverType + ":"));
|
||||
workPanel.add(new JLabel(serverName));
|
||||
workPanel.add(DockingUtils.createNonHtmlLabel(serverType + ":"));
|
||||
workPanel.add(DockingUtils.createNonHtmlLabel(serverName));
|
||||
}
|
||||
|
||||
if (namePrompt != null) {
|
||||
workPanel.add(new JLabel(namePrompt));
|
||||
workPanel.add(DockingUtils.createNonHtmlLabel(namePrompt));
|
||||
nameField = new JTextField(defaultUserID, 16);
|
||||
nameField.setName("NAME-ENTRY-COMPONENT");
|
||||
workPanel.add(nameField);
|
||||
}
|
||||
else if (defaultUserID != null) {
|
||||
workPanel.add(new JLabel("User ID:"));
|
||||
JLabel nameLabel = new JLabel(defaultUserID);
|
||||
workPanel.add(DockingUtils.createNonHtmlLabel("User ID:"));
|
||||
JLabel nameLabel = DockingUtils.createNonHtmlLabel(defaultUserID);
|
||||
nameLabel.setName("NAME-COMPONENT");
|
||||
workPanel.add(nameLabel);
|
||||
}
|
||||
|
||||
workPanel.add(new JLabel(passPrompt != null ? passPrompt : "Password:"));
|
||||
workPanel.add(
|
||||
DockingUtils.createNonHtmlLabel(passPrompt != null ? passPrompt : "Password:"));
|
||||
passwordField = new JPasswordField(16);
|
||||
passwordField.setName("PASSWORD-ENTRY-COMPONENT");
|
||||
workPanel.add(passwordField);
|
||||
|
|
|
@ -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.
|
||||
|
@ -20,7 +19,8 @@ import java.awt.*;
|
|||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.Scrollable;
|
||||
|
||||
/**
|
||||
* A panel that is scrollable and uses a VariableHeightLayoutManager that
|
||||
|
@ -155,31 +155,6 @@ public class VariableHeightPanel extends JPanel implements Scrollable {
|
|||
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
|
||||
return 20;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
Container c = frame.getContentPane();
|
||||
c.setLayout(new BorderLayout());
|
||||
|
||||
JPanel panel = new VariableHeightPanel(false, 10, 0);
|
||||
|
||||
JButton button = new JButton("Not Lined Up");
|
||||
c.add(panel, BorderLayout.NORTH);
|
||||
JPanel p = new JPanel();
|
||||
p.setBorder(BorderFactory.createLineBorder(Color.RED));
|
||||
p.setBackground(Color.RED);
|
||||
c.add(p, BorderLayout.CENTER);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
JLabel l = new JLabel("label " + i);
|
||||
panel.add(l);
|
||||
}
|
||||
|
||||
c.add(button, BorderLayout.SOUTH);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
@ -239,8 +214,8 @@ class VariableHeightLayoutManager implements LayoutManager {
|
|||
width += d.width;
|
||||
}
|
||||
|
||||
return new Dimension(width + insets.left + insets.right, height + insets.top +
|
||||
insets.bottom);
|
||||
return new Dimension(width + insets.left + insets.right,
|
||||
height + insets.top + insets.bottom);
|
||||
}
|
||||
|
||||
// This preferred size returns Dimension based upon the rows and columns of components that
|
||||
|
@ -334,7 +309,8 @@ class VariableHeightLayoutManager implements LayoutManager {
|
|||
}
|
||||
|
||||
// isolates the preferred size, which varies depending upon the type of layout we are mocking
|
||||
private Dimension getPreferredDimensionForComponent(Component component, Dimension standardSize) {
|
||||
private Dimension getPreferredDimensionForComponent(Component component,
|
||||
Dimension standardSize) {
|
||||
|
||||
Dimension preferredDimension = component.getPreferredSize();
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import javax.swing.*;
|
|||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.Border;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -200,11 +201,12 @@ public class ConditionTestPanel extends JPanel {
|
|||
private Component createSummaryPanel() {
|
||||
JPanel panel = new JPanel(new GridLayout(1, 3, 20, 0));
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
runsLabel = new JLabel("Tests: 0/" + conditionTestModel.getTestCount());
|
||||
runsLabel =
|
||||
DockingUtils.createNonHtmlLabel("Tests: 0/" + conditionTestModel.getTestCount());
|
||||
panel.add(runsLabel);
|
||||
errorsLabel = new JLabel("Errors: 0");
|
||||
errorsLabel = DockingUtils.createNonHtmlLabel("Errors: 0");
|
||||
panel.add(errorsLabel);
|
||||
warningsLabel = new JLabel("Warnings: 0");
|
||||
warningsLabel = DockingUtils.createNonHtmlLabel("Warnings: 0");
|
||||
panel.add(warningsLabel);
|
||||
|
||||
return panel;
|
||||
|
@ -366,7 +368,7 @@ public class ConditionTestPanel extends JPanel {
|
|||
checkbox = new JCheckBox();
|
||||
checkbox.setSelected(true);
|
||||
add(checkbox);
|
||||
label = new JLabel(test.getName());
|
||||
label = DockingUtils.createNonHtmlLabel(test.getName());
|
||||
add(label);
|
||||
label.setToolTipText(test.getDescription());
|
||||
checkbox.addChangeListener(e -> {
|
||||
|
@ -404,7 +406,7 @@ public class ConditionTestPanel extends JPanel {
|
|||
public TestStatusPanel(ConditionTester test) {
|
||||
super(new BorderLayout());
|
||||
this.test = test;
|
||||
label = new JLabel();
|
||||
label = DockingUtils.createNonHtmlLabel();
|
||||
label.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
add(label);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.swing.event.DocumentListener;
|
|||
import javax.swing.text.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
/**
|
||||
|
@ -224,7 +225,7 @@ public class InputDialog extends DialogComponentProvider {
|
|||
textFields[i] = new MyTextField(initialValues[i]);
|
||||
textFields[i].addKeyListener(keyListener);
|
||||
textFields[i].setName("input.dialog.text.field." + i);
|
||||
panel.add(new JLabel(inputLabels[i], SwingConstants.RIGHT));
|
||||
panel.add(DockingUtils.createNonHtmlLabel(inputLabels[i], SwingConstants.RIGHT));
|
||||
panel.add(textFields[i]);
|
||||
}
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.awt.Dimension;
|
|||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
|
||||
/**
|
||||
|
@ -109,8 +110,7 @@ public class InputWithChoicesDialog extends DialogComponentProvider {
|
|||
workPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
// COMBO BOX PANEL
|
||||
JLabel messageLabel = new JLabel();
|
||||
messageLabel.setText(labelText);
|
||||
JLabel messageLabel = DockingUtils.createNonHtmlLabel(labelText);
|
||||
messageLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
|
||||
combo = createComboBox(optionValues, initialValue);
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class InputWithChoicesDialog extends DialogComponentProvider {
|
|||
|
||||
// ICON PANEL (if an icon has been supplied)
|
||||
if (messageIcon != null) {
|
||||
JLabel iconLabel = new JLabel();
|
||||
JLabel iconLabel = DockingUtils.createNonHtmlLabel();
|
||||
iconLabel.setIcon(messageIcon);
|
||||
iconLabel.setVerticalAlignment(SwingConstants.TOP);
|
||||
|
||||
|
|
|
@ -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 docking.widgets.dialogs;
|
||||
|
||||
import ghidra.framework.OperatingSystem;
|
||||
import ghidra.framework.Platform;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
@ -27,11 +23,13 @@ import javax.swing.*;
|
|||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.framework.OperatingSystem;
|
||||
import ghidra.framework.Platform;
|
||||
|
||||
public class MultiLineInputDialog extends DialogComponentProvider {
|
||||
|
||||
private static final KeyStroke SUBMIT_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
|
||||
DockingUtils.CONTROL_KEY_MODIFIER_MASK);
|
||||
private static final KeyStroke SUBMIT_KEYSTROKE =
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
|
||||
|
||||
private boolean isCanceled;
|
||||
private JTextArea inputTextArea;
|
||||
|
@ -71,7 +69,7 @@ public class MultiLineInputDialog extends DialogComponentProvider {
|
|||
}
|
||||
inputTextArea.selectAll();
|
||||
|
||||
JLabel messageLabel = new JLabel();
|
||||
JLabel messageLabel = DockingUtils.createNonHtmlLabel();
|
||||
messageLabel.setText(messageText);
|
||||
messageLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
|
||||
|
||||
|
@ -80,7 +78,7 @@ public class MultiLineInputDialog extends DialogComponentProvider {
|
|||
if (OS == OperatingSystem.MAC_OS_X) {
|
||||
metaKeyText = "Command";
|
||||
}
|
||||
JLabel hintLabel = new JLabel("(" + metaKeyText + "-Enter to accept)");
|
||||
JLabel hintLabel = DockingUtils.createNonHtmlLabel("(" + metaKeyText + "-Enter to accept)");
|
||||
hintLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
Font font = hintLabel.getFont();
|
||||
Font smallerFont = font.deriveFont(12F);
|
||||
|
@ -92,7 +90,7 @@ public class MultiLineInputDialog extends DialogComponentProvider {
|
|||
dataPanel.add(new JScrollPane(inputTextArea), BorderLayout.CENTER);
|
||||
dataPanel.add(hintLabel, BorderLayout.SOUTH);
|
||||
|
||||
JLabel iconLabel = new JLabel();
|
||||
JLabel iconLabel = DockingUtils.createNonHtmlLabel();
|
||||
iconLabel.setIcon(icon);
|
||||
iconLabel.setVerticalAlignment(SwingConstants.TOP);
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class MultiLineMessageDialog extends DialogComponentProvider {
|
|||
workPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
|
||||
if (!StringUtils.isBlank(shortMessage)) {
|
||||
JLabel shortMessageLabel = new JLabel(shortMessage);
|
||||
JLabel shortMessageLabel = DockingUtils.createNonHtmlLabel(shortMessage);
|
||||
shortMessageLabel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 10));
|
||||
workPanel.add(shortMessageLabel, BorderLayout.NORTH);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class MultiLineMessageDialog extends DialogComponentProvider {
|
|||
|
||||
Icon icon = OptionDialog.getIconForMessageType(messageType);
|
||||
if (icon != null) {
|
||||
JLabel iconLabel = new JLabel(icon);
|
||||
JLabel iconLabel = DockingUtils.createNonHtmlLabel(icon);
|
||||
iconLabel.setBorder(BorderFactory.createEmptyBorder(1, 10, 1, 10));
|
||||
workPanel.add(iconLabel, BorderLayout.WEST);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@ import java.math.BigInteger;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.*;
|
||||
import docking.widgets.textfield.IntegerTextField;
|
||||
|
||||
/**
|
||||
|
@ -268,7 +267,7 @@ public class NumberInputDialog extends DialogComponentProvider {
|
|||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
label = new JLabel(prompt);
|
||||
label = DockingUtils.createNonHtmlLabel(prompt);
|
||||
numberInputField = new IntegerTextField(12);
|
||||
numberInputField.addChangeListener(e -> updateOKButtonEnablement());
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ import javax.swing.event.PopupMenuEvent;
|
|||
import javax.swing.event.PopupMenuListener;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.*;
|
||||
import docking.widgets.table.DefaultSortedTableModel;
|
||||
import docking.widgets.table.GTable;
|
||||
import ghidra.docking.settings.*;
|
||||
|
@ -223,8 +222,8 @@ public class SettingsDialog extends DialogComponentProvider {
|
|||
|
||||
}
|
||||
|
||||
private class SettingsEditor extends AbstractCellEditor implements TableCellEditor,
|
||||
PopupMenuListener {
|
||||
private class SettingsEditor extends AbstractCellEditor
|
||||
implements TableCellEditor, PopupMenuListener {
|
||||
|
||||
final static int ENUM = 0;
|
||||
final static int BOOLEAN = 1;
|
||||
|
@ -242,6 +241,7 @@ public class SettingsDialog extends DialogComponentProvider {
|
|||
|
||||
SettingsEditor() {
|
||||
super();
|
||||
DockingUtils.turnOffHTMLRendering(comboBox);
|
||||
comboBox.addPopupMenuListener(this);
|
||||
}
|
||||
|
||||
|
@ -273,8 +273,8 @@ public class SettingsDialog extends DialogComponentProvider {
|
|||
* @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int)
|
||||
*/
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value,
|
||||
boolean isSelected, int row, int column) {
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
|
||||
int row, int column) {
|
||||
if (value instanceof StringChoices) {
|
||||
initComboBox((StringChoices) value);
|
||||
return comboBox;
|
||||
|
@ -283,8 +283,8 @@ public class SettingsDialog extends DialogComponentProvider {
|
|||
initCheckBox((Boolean) value);
|
||||
return checkBox;
|
||||
}
|
||||
throw new AssertException("SettingsEditor: " + value.getClass().getName() +
|
||||
" not supported");
|
||||
throw new AssertException(
|
||||
"SettingsEditor: " + value.getClass().getName() + " not supported");
|
||||
}
|
||||
|
||||
private void initCheckBox(Boolean b) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.event.mouse.GMouseListenerAdapter;
|
||||
import docking.widgets.list.GList;
|
||||
import ghidra.util.exception.AssertException;
|
||||
|
@ -121,7 +122,7 @@ class DirectoryList extends GList<File> implements GhidraFileChooserDirectoryMod
|
|||
updateChooserForSelection();
|
||||
});
|
||||
|
||||
listEditorLabel = new JLabel();
|
||||
listEditorLabel = DockingUtils.createNonHtmlLabel();
|
||||
listEditorLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
package docking.widgets.filechooser;
|
||||
|
||||
import ghidra.util.exception.AssertException;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
@ -24,8 +22,11 @@ import java.util.*;
|
|||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
||||
import docking.widgets.DropDownTextFieldDataModel;
|
||||
import docking.widgets.DropDownSelectionTextField;
|
||||
import docking.widgets.DropDownTextFieldDataModel;
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.exception.AssertException;
|
||||
|
||||
/**
|
||||
* A model that allows the {@link DropDownSelectionTextField} to work with File objects.
|
||||
|
@ -93,7 +94,7 @@ public class FileDropDownSelectionDataModel implements DropDownTextFieldDataMode
|
|||
if (files == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<File> list = new ArrayList<File>();
|
||||
List<File> list = new ArrayList<>();
|
||||
for (File file : files) {
|
||||
list.add(file);
|
||||
}
|
||||
|
@ -126,8 +127,8 @@ public class FileDropDownSelectionDataModel implements DropDownTextFieldDataMode
|
|||
public String getDescription(File file) {
|
||||
boolean isDir = file.isDirectory();
|
||||
return "<html><table>" + "<tr><td>" + (isDir ? "Directory: " : "File: ") + "</td><td>" +
|
||||
"<b>" + file.getName() + "</b>" + "</td></tr>" + "<tr><td>Size:</td><td>" +
|
||||
(isDir ? "0" : file.length()) + " bytes" + "</td></tr>" +
|
||||
"<b>" + HTMLUtilities.friendlyEncodeHTML(file.getName()) + "</b>" + "</td></tr>" +
|
||||
"<tr><td>Size:</td><td>" + (isDir ? "0" : file.length()) + " bytes" + "</td></tr>" +
|
||||
"<tr><td>Last modified:</td><td>" +
|
||||
GhidraFileChooser.format.format(new Date(file.lastModified())) + "</td></tr>" +
|
||||
"</table>";
|
||||
|
@ -155,30 +156,23 @@ public class FileDropDownSelectionDataModel implements DropDownTextFieldDataMode
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderer for data types. It uses delegation instead of inheritance, due typing issues
|
||||
* (DefaultListCellRenderer is already typed on Object).
|
||||
*/
|
||||
private class FileDropDownRenderer implements ListCellRenderer<File> {
|
||||
|
||||
private DefaultListCellRenderer delegate = new DefaultListCellRenderer();
|
||||
private class FileDropDownRenderer extends GListCellRenderer<File> {
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends File> list, File value,
|
||||
protected String getItemText(File file) {
|
||||
return file.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends File> list, File file,
|
||||
int index, boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
JLabel renderer =
|
||||
(JLabel) delegate.getListCellRendererComponent(list, value, index, isSelected,
|
||||
cellHasFocus);
|
||||
super.getListCellRendererComponent(list, file, index, isSelected, cellHasFocus);
|
||||
|
||||
File file = value;
|
||||
renderer.setText(file.getName());
|
||||
setIcon(fileSystemView.getSystemIcon(file));
|
||||
setVerticalAlignment(SwingConstants.TOP);
|
||||
|
||||
renderer.setIcon(fileSystemView.getSystemIcon(file));
|
||||
|
||||
renderer.setVerticalAlignment(SwingConstants.TOP);
|
||||
|
||||
return renderer;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
*/
|
||||
package docking.widgets.filechooser;
|
||||
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.filechooser.GhidraFileChooserModel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
|
@ -26,6 +23,10 @@ import javax.swing.*;
|
|||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.filechooser.GhidraFileChooserModel;
|
||||
|
||||
class FileEditor extends AbstractCellEditor implements TableCellEditor {
|
||||
|
||||
private GhidraFileChooser chooser;
|
||||
|
@ -43,7 +44,7 @@ class FileEditor extends AbstractCellEditor implements TableCellEditor {
|
|||
this.directoryTable = table;
|
||||
this.model = model;
|
||||
|
||||
iconLabel = new JLabel();
|
||||
iconLabel = DockingUtils.createNonHtmlLabel();
|
||||
iconLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
@ -97,8 +98,9 @@ class FileEditor extends AbstractCellEditor implements TableCellEditor {
|
|||
editor.add(nameField, BorderLayout.CENTER);
|
||||
|
||||
// match the spacing of non-editing cells
|
||||
editor.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createEmptyBorder(0, 5, 0, 0), BorderFactory.createLineBorder(Color.GRAY)));
|
||||
editor.setBorder(
|
||||
BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0),
|
||||
BorderFactory.createLineBorder(Color.GRAY)));
|
||||
}
|
||||
|
||||
private void handleDoubleClick(Point p) {
|
||||
|
@ -144,15 +146,14 @@ class FileEditor extends AbstractCellEditor implements TableCellEditor {
|
|||
|
||||
private File getNewFile() {
|
||||
GhidraFileChooserModel fileChooserModel = chooser.getModel();
|
||||
File newFile =
|
||||
new GhidraFile(originalFile.getParentFile(), nameField.getText(),
|
||||
fileChooserModel.getSeparator());
|
||||
File newFile = new GhidraFile(originalFile.getParentFile(), nameField.getText(),
|
||||
fileChooserModel.getSeparator());
|
||||
if (fileChooserModel.renameFile(originalFile, newFile)) {
|
||||
return newFile;
|
||||
}
|
||||
|
||||
Msg.showError(this, chooser.getComponent(), "Rename Failed", "Unable to rename file: " +
|
||||
originalFile);
|
||||
Msg.showError(this, chooser.getComponent(), "Rename Failed",
|
||||
"Unable to rename file: " + originalFile);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,12 @@ package docking.widgets.filechooser;
|
|||
import java.awt.Component;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JList;
|
||||
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
import ghidra.util.filechooser.GhidraFileChooserModel;
|
||||
|
||||
class FileListCellRenderer extends DefaultListCellRenderer {
|
||||
class FileListCellRenderer extends GListCellRenderer<File> {
|
||||
|
||||
private GhidraFileChooser chooser;
|
||||
private GhidraFileChooserModel model;
|
||||
|
@ -33,18 +34,18 @@ class FileListCellRenderer extends DefaultListCellRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
protected String getItemText(File file) {
|
||||
return chooser.getDisplayName(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends File> list, File file, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
File file = (File) value;
|
||||
|
||||
Component c = super.getListCellRendererComponent(list, chooser.getDisplayName(file), index,
|
||||
isSelected, cellHasFocus);
|
||||
if (c instanceof JLabel) {
|
||||
((JLabel) c).setIcon(model.getIcon(file));
|
||||
}
|
||||
return c;
|
||||
super.getListCellRendererComponent(list, file, index, isSelected, cellHasFocus);
|
||||
setIcon(model.getIcon(file));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package docking.widgets.filechooser;
|
|||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import ghidra.framework.preferences.Preferences;
|
||||
import ghidra.util.layout.PairLayout;
|
||||
|
||||
|
@ -50,7 +51,7 @@ class GFileChooserOptionsDialog extends DialogComponentProvider {
|
|||
showDotFilesCheckBox = new JCheckBox();
|
||||
showDotFilesCheckBox.setSelected(true);
|
||||
|
||||
JLabel label = new JLabel("Show '.' files");
|
||||
JLabel label = DockingUtils.createNonHtmlLabel("Show '.' files");
|
||||
label.setToolTipText("When toggled on the file chooser will show files " +
|
||||
"with names that begin with a '.' character");
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import javax.swing.filechooser.FileSystemView;
|
|||
import docking.*;
|
||||
import docking.framework.DockingApplicationConfiguration;
|
||||
import docking.widgets.*;
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
import ghidra.GhidraApplicationLayout;
|
||||
import ghidra.framework.*;
|
||||
import ghidra.framework.preferences.Preferences;
|
||||
|
@ -354,7 +355,7 @@ public class GhidraFileChooser extends DialogComponentProvider
|
|||
}
|
||||
|
||||
private JPanel buildFileNamePanel() {
|
||||
JLabel filenameLabel = new JLabel("File name:");
|
||||
JLabel filenameLabel = DockingUtils.createNonHtmlLabel("File name:");
|
||||
FileDropDownSelectionDataModel model = new FileDropDownSelectionDataModel(this);
|
||||
filenameTextField = new DropDownSelectionTextField<>(model);
|
||||
filenameTextField.setMatchingWindowHeight(200);
|
||||
|
@ -383,28 +384,11 @@ public class GhidraFileChooser extends DialogComponentProvider
|
|||
|
||||
filenameTextField.setName("filenameTextField");
|
||||
|
||||
JLabel filterLabel = new JLabel("Type:");
|
||||
JLabel filterLabel = DockingUtils.createNonHtmlLabel("Type:");
|
||||
filterCombo = new JComboBox<>();
|
||||
filterCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index,
|
||||
isSelected, cellHasFocus);
|
||||
GhidraFileFilter filter = (GhidraFileFilter) value;
|
||||
|
||||
// we can have null filters in the case that the combo box has
|
||||
// no selected item
|
||||
if (filter != null) {
|
||||
label.setText(filter.getDescription());
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
});
|
||||
DockingUtils.turnOffHTMLRendering(filterCombo);
|
||||
filterCombo.setRenderer(GListCellRenderer.createDefaultCellTextRenderer(
|
||||
gff -> gff != null ? gff.getDescription() : ""));
|
||||
filterCombo.addItemListener(e -> rescanCurrentDirectory());
|
||||
|
||||
filterModel = (DefaultComboBoxModel<GhidraFileFilter>) filterCombo.getModel();
|
||||
|
|
|
@ -25,6 +25,7 @@ import javax.swing.*;
|
|||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.dnd.DropTgtAdapter;
|
||||
import docking.dnd.Droppable;
|
||||
import docking.widgets.OptionDialog;
|
||||
|
@ -157,7 +158,7 @@ public class GhidraFileChooserPanel extends JPanel implements Droppable {
|
|||
gbc.gridy = 0;
|
||||
|
||||
if (!createBorder && title != null) {
|
||||
add(new JLabel(title), gbc);
|
||||
add(DockingUtils.createNonHtmlLabel(title), gbc);
|
||||
}
|
||||
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
|
|
|
@ -67,6 +67,14 @@ public class FilterOptions {
|
|||
.sorted()
|
||||
.map(c -> Character.toString(c))
|
||||
.collect(Collectors.joining(""));
|
||||
|
||||
public static final String[] VALID_MULTITERM_DELIMITERS_ARRAY =
|
||||
DELIMITER_NAME_MAP.keySet()
|
||||
.stream()
|
||||
.sorted()
|
||||
.map(c -> Character.toString(c))
|
||||
.collect(Collectors.toList())
|
||||
.toArray(new String[DELIMITER_NAME_MAP.size()]);
|
||||
// @formatter:on
|
||||
|
||||
public static final Character DEFAULT_DELIMITER = ',';
|
||||
|
|
|
@ -24,8 +24,7 @@ import java.util.List;
|
|||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DisabledComponentLayerFactory;
|
||||
import docking.*;
|
||||
import docking.widgets.InlineComponentTitledPanel;
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
@ -210,13 +209,17 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
|
|||
}
|
||||
|
||||
add(containsButton);
|
||||
add(new JLabel(FilterOptions.getIcon(TextFilterStrategy.CONTAINS)));
|
||||
add(DockingUtils.createNonHtmlLabel(
|
||||
FilterOptions.getIcon(TextFilterStrategy.CONTAINS)));
|
||||
add(startsWithButton);
|
||||
add(new JLabel(FilterOptions.getIcon(TextFilterStrategy.STARTS_WITH)));
|
||||
add(DockingUtils.createNonHtmlLabel(
|
||||
FilterOptions.getIcon(TextFilterStrategy.STARTS_WITH)));
|
||||
add(matchesExactlyButton);
|
||||
add(new JLabel(FilterOptions.getIcon(TextFilterStrategy.MATCHES_EXACTLY)));
|
||||
add(DockingUtils.createNonHtmlLabel(
|
||||
FilterOptions.getIcon(TextFilterStrategy.MATCHES_EXACTLY)));
|
||||
add(regularExpressionButton);
|
||||
add(new JLabel(FilterOptions.getIcon(TextFilterStrategy.REGULAR_EXPRESSION)));
|
||||
add(DockingUtils.createNonHtmlLabel(
|
||||
FilterOptions.getIcon(TextFilterStrategy.REGULAR_EXPRESSION)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,22 +406,21 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
|
|||
* Creates the main panel for this dialog.
|
||||
*/
|
||||
private void createPanel() {
|
||||
|
||||
|
||||
getContentPane().setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
|
||||
|
||||
|
||||
JPanel outerPanel = new JPanel();
|
||||
outerPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
|
||||
|
||||
JPanel optionsPanel = new JPanel();
|
||||
optionsPanel.setLayout(new PairLayout());
|
||||
|
||||
|
||||
// Delimiter Row
|
||||
JLabel delimiterCharacterFieldName = new JLabel("Delimiter:");
|
||||
JLabel delimiterCharacterFieldName = DockingUtils.createNonHtmlLabel("Delimiter:");
|
||||
delimiterCharacterFieldName.setToolTipText(
|
||||
"Set the character used to separate filter terms.");
|
||||
|
||||
delimiterCharacterCB =
|
||||
new JComboBox<String>(FilterOptions.VALID_MULTITERM_DELIMITERS.split("(?!^)"));
|
||||
delimiterCharacterCB = new JComboBox<>(FilterOptions.VALID_MULTITERM_DELIMITERS_ARRAY);
|
||||
delimiterCharacterCB.setRenderer(new DelimiterListCellRenderer());
|
||||
|
||||
JPanel fixedSizePanel = new JPanel();
|
||||
|
@ -429,7 +431,7 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
|
|||
optionsPanel.add(fixedSizePanel);
|
||||
|
||||
// Mode Row
|
||||
JLabel label = new JLabel("Evaluation Mode:");
|
||||
JLabel label = DockingUtils.createNonHtmlLabel("Evaluation Mode:");
|
||||
|
||||
JPanel buttonGroupPanel = new JPanel();
|
||||
buttonGroupPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
|
@ -465,19 +467,13 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getText(Object value) {
|
||||
String label = "";
|
||||
|
||||
char char0 = ((String) value).charAt(0);
|
||||
|
||||
label = FilterOptions.DELIMITER_NAME_MAP.get(char0);
|
||||
if (label == null) {
|
||||
label = "<i>Unrecognized</i>";
|
||||
}
|
||||
protected String getItemText(String value) {
|
||||
|
||||
char char0 = value.length() > 0 ? value.charAt(0) : ' ';
|
||||
String delimiterName =
|
||||
FilterOptions.DELIMITER_NAME_MAP.getOrDefault(char0, "<i>Unrecognized</i>");
|
||||
return String.format("<html><font face=monospace>%s</font> <i>%s</i>",
|
||||
char0 == ' ' ? " " : char0, label);
|
||||
|
||||
char0 == ' ' ? " " : char0, delimiterName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -20,11 +19,11 @@ import java.awt.event.KeyEvent;
|
|||
import java.awt.event.KeyListener;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JList;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.table.GTable;
|
||||
|
||||
/**
|
||||
|
@ -81,7 +80,12 @@ public class GList<T> extends JList<T> {
|
|||
}
|
||||
|
||||
private void init() {
|
||||
DockingUtils.turnOffHTMLRendering(this);
|
||||
if (getCellRenderer() instanceof JComponent) {
|
||||
DockingUtils.turnOffHTMLRendering(((JComponent) getCellRenderer()));
|
||||
}
|
||||
addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
// if (e.isActionKey() ||
|
||||
// e.getKeyChar() == KeyEvent.CHAR_UNDEFINED ||
|
||||
|
@ -105,13 +109,16 @@ public class GList<T> extends JList<T> {
|
|||
// e.consume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
ensureIndexIsVisible(getSelectedIndex());
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
package docking.widgets.list;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
@ -28,6 +29,25 @@ import docking.widgets.AbstractGCellRenderer;
|
|||
*/
|
||||
public class GListCellRenderer<E> extends AbstractGCellRenderer implements ListCellRenderer<E> {
|
||||
|
||||
/**
|
||||
* Returns a new ListCellRenderer that maps the list's data instance to a string used in the cell.
|
||||
* <p>
|
||||
* Use this if you only need to provide a way to get the string value from the type being shown
|
||||
* in the list.
|
||||
*
|
||||
* @param cellTextFunc a function that maps a custom type to a string value
|
||||
* @return new GListCellRenderer instance
|
||||
*/
|
||||
public static <E> GListCellRenderer<E> createDefaultCellTextRenderer(
|
||||
Function<E, String> cellTextFunc) {
|
||||
return new GListCellRenderer<>() {
|
||||
@Override
|
||||
protected String getItemText(E value) {
|
||||
return cellTextFunc.apply(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new GListCellRenderer.
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
|
@ -21,8 +20,9 @@ import java.awt.event.*;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import resources.ResourceManager;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
import resources.ResourceManager;
|
||||
|
||||
/**
|
||||
* A widget that can be used to render an icon, title and close button for JTabbedPane. You would
|
||||
|
@ -31,10 +31,10 @@ import docking.widgets.EmptyBorderButton;
|
|||
public class DockingTabRenderer extends JPanel {
|
||||
|
||||
private static final int MAX_TITLE_LENGTH = 25;
|
||||
private Icon EMPTY_ICON = ResourceManager.getScaledIcon(
|
||||
ResourceManager.loadImage("images/close16.gif"), 8, 8);
|
||||
private Icon CLOSE_ICON = ResourceManager.getScaledIcon(
|
||||
ResourceManager.loadImage("images/close16.gif"), 8, 8);
|
||||
private Icon EMPTY_ICON =
|
||||
ResourceManager.getScaledIcon(ResourceManager.loadImage("images/close16.gif"), 8, 8);
|
||||
private Icon CLOSE_ICON =
|
||||
ResourceManager.getScaledIcon(ResourceManager.loadImage("images/close16.gif"), 8, 8);
|
||||
|
||||
private JLabel titleLabel;
|
||||
private JLabel iconLabel;
|
||||
|
@ -50,8 +50,8 @@ public class DockingTabRenderer extends JPanel {
|
|||
final ForwardingMouseListener eventForwardingListener =
|
||||
new ForwardingMouseListener(tabbedPane);
|
||||
|
||||
titleLabel = new JLabel();
|
||||
iconLabel = new JLabel();
|
||||
titleLabel = DockingUtils.createNonHtmlLabel();
|
||||
iconLabel = DockingUtils.createNonHtmlLabel();
|
||||
closeButton = new EmptyBorderButton();
|
||||
|
||||
setTitle(tabTitle, fullTitle);
|
||||
|
@ -105,7 +105,8 @@ public class DockingTabRenderer extends JPanel {
|
|||
@Override
|
||||
public void hierarchyChanged(HierarchyEvent e) {
|
||||
long changeFlags = e.getChangeFlags();
|
||||
if (HierarchyEvent.DISPLAYABILITY_CHANGED == (changeFlags & HierarchyEvent.DISPLAYABILITY_CHANGED)) {
|
||||
if (HierarchyEvent.DISPLAYABILITY_CHANGED == (changeFlags &
|
||||
HierarchyEvent.DISPLAYABILITY_CHANGED)) {
|
||||
|
||||
Container myParent = getParent(); // should be a TabContainer
|
||||
|
||||
|
|
|
@ -66,6 +66,15 @@ public class GTableCellRenderer extends AbstractGCellRenderer implements TableCe
|
|||
setFont(f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cell renderer text
|
||||
* @param value Cell object value
|
||||
* @return A string interpretation of value; generated by calling value.toString()
|
||||
*/
|
||||
protected String getText(Object value) {
|
||||
return value == null ? "" : value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Satisfies the Java {@link javax.swing.table.TableCellRenderer} interface; retrieves
|
||||
* column data via a GTableCellRenderingData object, and defers painting to
|
||||
|
|
|
@ -28,8 +28,7 @@ import javax.swing.table.TableModel;
|
|||
|
||||
import org.jdom.Element;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.*;
|
||||
import docking.help.HelpService;
|
||||
import docking.menu.*;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
|
@ -348,7 +347,7 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
|
|||
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
||||
setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
||||
|
||||
searchLabel = new JLabel(filterLabel);
|
||||
searchLabel = DockingUtils.createNonHtmlLabel(filterLabel);
|
||||
searchLabel.setToolTipText("Include only table elements that match the given search text");
|
||||
|
||||
filterField = new FilterTextField(table);
|
||||
|
@ -401,7 +400,7 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
|
|||
|
||||
RowObjectFilterModel<ROW_OBJECT> tableModel =
|
||||
(RowObjectFilterModel<ROW_OBJECT>) table.getModel();
|
||||
columnFilterAction = new NonToolbarMultiStateAction<ColumnBasedTableFilter<ROW_OBJECT>>(
|
||||
columnFilterAction = new NonToolbarMultiStateAction<>(
|
||||
"Column Filter", "GTableFilterPanel") {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,7 @@ import javax.swing.*;
|
|||
import javax.swing.border.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import resources.*;
|
||||
import resources.icons.EmptyIcon;
|
||||
import resources.icons.TranslateIcon;
|
||||
|
@ -51,8 +52,8 @@ public class GTableHeaderRenderer extends JPanel implements TableCellRenderer {
|
|||
private static final Icon FILTER_ICON =
|
||||
ResourceManager.getScaledIcon(ResourceManager.loadImage("images/filter_off.png"), 12, 12);
|
||||
|
||||
private JLabel textLabel = new JLabel();
|
||||
private JLabel iconLabel = new JLabel();
|
||||
private JLabel textLabel = DockingUtils.createNonHtmlLabel();
|
||||
private JLabel iconLabel = DockingUtils.createNonHtmlLabel();
|
||||
private Icon helpIcon = null;
|
||||
private CustomPaddingBorder customBorder;
|
||||
protected boolean isPaintingPrimarySortColumn;
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.swing.*;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.table.columnfilter.ColumnBasedTableFilter;
|
||||
import docking.widgets.table.columnfilter.ColumnFilterSaveManager;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
|
@ -152,7 +153,7 @@ public class ColumnFilterArchiveDialog<R> extends DialogComponentProvider {
|
|||
panel.setBorder(BorderFactory.createTitledBorder(
|
||||
BorderFactory.createEmptyBorder(19, 0, 26, 5), "Preview"));
|
||||
|
||||
previewLabel = new JLabel();
|
||||
previewLabel = DockingUtils.createHtmlLabel();
|
||||
previewLabel.setVerticalAlignment(SwingConstants.TOP);
|
||||
panel.add(new JScrollPane(previewLabel));
|
||||
return panel;
|
||||
|
|
|
@ -360,7 +360,7 @@ public class ColumnFilterDialog<R> extends DialogComponentProvider
|
|||
}
|
||||
|
||||
private Component createLogicalOperationLabel(LogicOperation op) {
|
||||
JLabel jLabel = new JLabel("<" + op + ">", SwingConstants.CENTER);
|
||||
JLabel jLabel = DockingUtils.createNonHtmlLabel("<" + op + ">", SwingConstants.CENTER);
|
||||
jLabel.setForeground(Color.GRAY);
|
||||
return jLabel;
|
||||
}
|
||||
|
@ -368,9 +368,9 @@ public class ColumnFilterDialog<R> extends DialogComponentProvider
|
|||
private JComponent buildHeaderPanel() {
|
||||
JPanel headerPanel = new JPanel(new FilterPanelLayout(200, 0));
|
||||
|
||||
headerPanel.add(new JLabel("Table Column", SwingConstants.CENTER));
|
||||
headerPanel.add(new JLabel("Filter", SwingConstants.CENTER));
|
||||
headerPanel.add(new JLabel("Filter Value", SwingConstants.CENTER));
|
||||
headerPanel.add(DockingUtils.createNonHtmlLabel("Table Column", SwingConstants.CENTER));
|
||||
headerPanel.add(DockingUtils.createNonHtmlLabel("Filter", SwingConstants.CENTER));
|
||||
headerPanel.add(DockingUtils.createNonHtmlLabel("Filter Value", SwingConstants.CENTER));
|
||||
|
||||
headerPanel.setBorder(new CompoundBorder(
|
||||
BorderFactory.createMatteBorder(0, 0, 1, 0, Color.DARK_GRAY.brighter().brighter()),
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Vector;
|
|||
import javax.swing.*;
|
||||
import javax.swing.border.BevelBorder;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
import docking.widgets.combobox.GhidraComboBox;
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
|
@ -114,7 +115,7 @@ class ColumnFilterPanel extends JPanel {
|
|||
}
|
||||
|
||||
private Component createOrLabel() {
|
||||
JLabel jLabel = new JLabel("<OR>", SwingConstants.CENTER);
|
||||
JLabel jLabel = DockingUtils.createNonHtmlLabel("<OR>", SwingConstants.CENTER);
|
||||
jLabel.setForeground(Color.GRAY);
|
||||
return jLabel;
|
||||
}
|
||||
|
|
|
@ -121,15 +121,8 @@ public class ConstraintFilterPanel extends JPanel {
|
|||
private class ConstraintComboBoxCellRenderer extends GListCellRenderer<ColumnConstraint<?>> {
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends ColumnConstraint<?>> list,
|
||||
ColumnConstraint<?> value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index,
|
||||
isSelected, cellHasFocus);
|
||||
|
||||
label.setText(value.getName());
|
||||
|
||||
return label;
|
||||
protected String getItemText(ColumnConstraint<?> value) {
|
||||
return value.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import docking.widgets.DropDownTextField;
|
||||
import docking.widgets.DropDownTextFieldDataModel;
|
||||
import docking.widgets.list.GListCellRenderer;
|
||||
import docking.widgets.table.constraint.*;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
|
||||
|
@ -200,14 +201,13 @@ public class AutocompletingStringConstraintEditor extends DataLoadingConstraintE
|
|||
* Cell renderer for suggestion nominees. Substrings that match the models' query
|
||||
* are highlighted for ease-of-use.
|
||||
*/
|
||||
private class AutocompleteListCellRenderer implements ListCellRenderer<String> {
|
||||
|
||||
private DefaultListCellRenderer delegate = new DefaultListCellRenderer();
|
||||
private class AutocompleteListCellRenderer extends GListCellRenderer<String> {
|
||||
|
||||
private final AutocompleteDataModel model;
|
||||
|
||||
public AutocompleteListCellRenderer(AutocompleteDataModel autocompleteDataModel) {
|
||||
this.model = autocompleteDataModel;
|
||||
this.setHTMLRenderingEnabled(true);
|
||||
}
|
||||
|
||||
private String formatListValue(String value, boolean isSelected) {
|
||||
|
@ -216,7 +216,7 @@ public class AutocompletingStringConstraintEditor extends DataLoadingConstraintE
|
|||
|
||||
Color color = isSelected ? Color.YELLOW : Color.MAGENTA;
|
||||
|
||||
StringBuffer sb = new StringBuffer("<html>");
|
||||
StringBuilder sb = new StringBuilder("<html>");
|
||||
// find and highlight all instances of the user-defined pattern
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group(1);
|
||||
|
@ -226,19 +226,17 @@ public class AutocompletingStringConstraintEditor extends DataLoadingConstraintE
|
|||
matcher.appendTail(sb);
|
||||
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends String> list, String value,
|
||||
int index, boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) delegate.getListCellRendererComponent(list, value, index,
|
||||
isSelected, cellHasFocus);
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
String valueString = formatListValue(value, isSelected);
|
||||
|
||||
label.setText(valueString);
|
||||
return label;
|
||||
setText(valueString);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.swing.*;
|
||||
|
||||
import docking.DisabledComponentLayerFactory;
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import docking.widgets.table.constraint.ColumnData;
|
||||
|
@ -90,7 +91,7 @@ public abstract class DataLoadingConstraintEditor<T> extends AbstractColumnConst
|
|||
@Override
|
||||
protected Component buildInlineEditorComponent() {
|
||||
JPanel editorPanel = new JPanel(new BorderLayout());
|
||||
statusLabel = new JLabel();
|
||||
statusLabel = DockingUtils.createHtmlLabel();
|
||||
statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
taskMonitorComponent = new TaskMonitorComponent();
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Calendar;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import docking.widgets.table.constraint.RangeColumnConstraint;
|
||||
import docking.widgets.table.constraint.provider.DateColumnConstraintProvider;
|
||||
|
@ -107,7 +108,7 @@ public class DateRangeConstraintEditor extends AbstractColumnConstraintEditor<Lo
|
|||
|
||||
panel.add(controlPanel);
|
||||
|
||||
infoLabel = new JLabel();
|
||||
infoLabel = DockingUtils.createHtmlLabel();
|
||||
infoLabel.setForeground(Color.GRAY);
|
||||
infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel.add(infoLabel);
|
||||
|
@ -115,32 +116,6 @@ public class DateRangeConstraintEditor extends AbstractColumnConstraintEditor<Lo
|
|||
return panel;
|
||||
}
|
||||
|
||||
private void rangeChanged() {
|
||||
if (!hasEditorComponents()) {
|
||||
return;
|
||||
}
|
||||
String statusMsg = "";
|
||||
|
||||
if (checkEditorValueValidity()) {
|
||||
|
||||
LocalDate start = lowerSpinnerModel.getDate();
|
||||
LocalDate end = upperSpinnerModel.getDate();
|
||||
|
||||
// add one because the date range is inclusive.
|
||||
long days = ChronoUnit.DAYS.between(start, end) + 1;
|
||||
// add one because the date range is inclusive.
|
||||
|
||||
statusMsg += formatStatus(String.format("Range Size: %,d days", days), false);
|
||||
}
|
||||
else {
|
||||
statusMsg += formatStatus(getErrorMessage(), true);
|
||||
}
|
||||
|
||||
infoLabel.setText(statusMsg);
|
||||
|
||||
valueChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateInfoMessage(boolean isValid) {
|
||||
if (isValid) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import javax.swing.JSpinner.NumberEditor;
|
|||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.numberformat.BoundedRangeDecimalFormatterFactory;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import docking.widgets.table.constraint.RangeColumnConstraint;
|
||||
|
@ -75,7 +76,7 @@ public class DoubleRangeConstraintEditor extends AbstractColumnConstraintEditor<
|
|||
|
||||
infoLabelNumberFormat = new DecimalFormat(DISPLAY_FORMAT);
|
||||
|
||||
infoLabel = new JLabel();
|
||||
infoLabel = DockingUtils.createHtmlLabel();
|
||||
infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel.add(infoLabel);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.swing.JLabel;
|
|||
import javax.swing.JPanel;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
|
||||
|
@ -48,7 +49,7 @@ public final class DummyConstraintEditor<T> implements ColumnConstraintEditor<T>
|
|||
public Component getInlineComponent() {
|
||||
JPanel panel = new JPanel();
|
||||
|
||||
JLabel errorLabel = new JLabel(
|
||||
JLabel errorLabel = DockingUtils.createHtmlLabel(
|
||||
"<html>" + HTMLUtilities.bold(HTMLUtilities.colorString(Color.RED, message)));
|
||||
|
||||
panel.add(errorLabel);
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.*;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import docking.widgets.table.constraint.EnumColumnConstraint;
|
||||
|
||||
|
@ -76,7 +77,7 @@ public class EnumConstraintEditor<T extends Enum<T>> extends AbstractColumnConst
|
|||
JPanel outerPanel = new JPanel(new BorderLayout());
|
||||
outerPanel.add(panel, BorderLayout.CENTER);
|
||||
|
||||
infoLabel = new JLabel("");
|
||||
infoLabel = DockingUtils.createHtmlLabel("");
|
||||
infoLabel.setForeground(Color.GRAY);
|
||||
infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
outerPanel.add(infoLabel, BorderLayout.SOUTH);
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.swing.*;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.spinner.IntegerSpinner;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import docking.widgets.table.constraint.SingleValueColumnConstraint;
|
||||
|
@ -70,7 +71,7 @@ public class IntegerConstraintEditor<T extends Number> extends AbstractColumnCon
|
|||
spinnerModel.addChangeListener(e -> valueChanged());
|
||||
|
||||
panel.add(spinner.getSpinner(), BorderLayout.CENTER);
|
||||
statusLabel = new JLabel();
|
||||
statusLabel = DockingUtils.createHtmlLabel();
|
||||
panel.add(statusLabel, BorderLayout.SOUTH);
|
||||
statusLabel.setForeground(Color.RED);
|
||||
statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.math.BigInteger;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.spinner.IntegerSpinner;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import docking.widgets.table.constraint.RangeColumnConstraint;
|
||||
|
@ -103,7 +104,7 @@ public class IntegerRangeConstraintEditor<T extends Number>
|
|||
|
||||
panel.add(rangeControlPanel);
|
||||
|
||||
infoLabel = new JLabel();
|
||||
infoLabel = DockingUtils.createHtmlLabel();
|
||||
infoLabel.setForeground(Color.GRAY);
|
||||
infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel.add(infoLabel);
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.awt.*;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import docking.widgets.table.constraint.StringColumnConstraint;
|
||||
|
||||
|
@ -51,7 +52,7 @@ public class StringConstraintEditor extends AbstractColumnConstraintEditor<Strin
|
|||
|
||||
panel.add(textField, BorderLayout.CENTER);
|
||||
|
||||
infoLabel = new JLabel("abc"); // temporary text in the label so that it sizes properly
|
||||
infoLabel = DockingUtils.createHtmlLabel("abc"); // temporary text in the label so that it sizes properly
|
||||
infoLabel.setForeground(Color.RED);
|
||||
infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel.add(infoLabel, BorderLayout.SOUTH);
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.math.BigInteger;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import docking.widgets.table.constraint.SingleValueColumnConstraint;
|
||||
import docking.widgets.textfield.IntegerTextField;
|
||||
|
@ -57,7 +58,7 @@ public class UnsignedLongConstraintEditor extends AbstractColumnConstraintEditor
|
|||
field.addChangeListener(e -> valueChanged());
|
||||
|
||||
panel.add(field.getComponent(), BorderLayout.CENTER);
|
||||
statusLabel = new JLabel();
|
||||
statusLabel = DockingUtils.createHtmlLabel();
|
||||
panel.add(statusLabel, BorderLayout.SOUTH);
|
||||
statusLabel.setForeground(Color.RED);
|
||||
statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.math.BigInteger;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.table.constraint.ColumnConstraint;
|
||||
import docking.widgets.table.constraint.RangeColumnConstraint;
|
||||
import docking.widgets.textfield.IntegerTextField;
|
||||
|
@ -68,7 +69,7 @@ public class UnsignedLongRangeConstraintEditor extends AbstractColumnConstraintE
|
|||
|
||||
panel.add(rangeControlPanel);
|
||||
|
||||
infoLabel = new JLabel();
|
||||
infoLabel = DockingUtils.createHtmlLabel();
|
||||
infoLabel.setForeground(Color.GRAY);
|
||||
infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel.add(infoLabel);
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.awt.FlowLayout;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
import docking.widgets.table.GTable;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -150,13 +151,14 @@ public class GThreadedTablePanel<T> extends JPanel {
|
|||
}
|
||||
|
||||
private void buildPending() {
|
||||
JLabel label = new JLabel("Update pending...", SwingConstants.CENTER);
|
||||
refreshButton = new EmptyBorderButton(Icons.REFRESH_ICON);
|
||||
refreshButton.addActionListener(e -> threadedModel.reload());
|
||||
refreshButton.setToolTipText("Force Refresh Now");
|
||||
pendingPanel = new JPanel(new FlowLayout());
|
||||
pendingPanel.setName("Pending Panel");
|
||||
pendingPanel.add(label, BorderLayout.CENTER);
|
||||
pendingPanel.add(
|
||||
DockingUtils.createNonHtmlLabel("Update pending...", SwingConstants.CENTER),
|
||||
BorderLayout.CENTER);
|
||||
pendingPanel.add(refreshButton, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ import javax.swing.text.Caret;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import docking.DockingUtils;
|
||||
|
||||
/**
|
||||
* A class that links text fields into a "formatted text field", separated by expressions.
|
||||
*
|
||||
|
@ -54,7 +56,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
*
|
||||
* JTextField second = new JTextField();
|
||||
* hbox.add(second);
|
||||
* hbox.add(new JLabel("-"));
|
||||
* hbox.add(DockingUtils.createNonHtmlLabel("-"));
|
||||
* linker.linkField(second, "-", "-");
|
||||
*
|
||||
* JTextField third = new JTextField();
|
||||
|
@ -881,7 +883,7 @@ public class TextFieldLinker {
|
|||
|
||||
JTextField second = new JTextField();
|
||||
hbox.add(second);
|
||||
hbox.add(new JLabel("-"));
|
||||
hbox.add(DockingUtils.createNonHtmlLabel("-"));
|
||||
linker.linkField(second, "-", "-");
|
||||
|
||||
JTextField third = new JTextField();
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.swing.border.BevelBorder;
|
|||
|
||||
import org.jdom.Element;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.help.HelpService;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
|
@ -120,7 +121,7 @@ public class DefaultGTreeFilterProvider implements GTreeFilterProvider {
|
|||
private JPanel createFilterPanel() {
|
||||
JPanel newFilterPanel = new JPanel(new BorderLayout());
|
||||
newFilterPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
||||
JLabel filterLabel = new JLabel(" Filter: ");
|
||||
JLabel filterLabel = DockingUtils.createNonHtmlLabel(" Filter: ");
|
||||
newFilterPanel.add(filterLabel, BorderLayout.WEST);
|
||||
|
||||
filterField = new FilterTextField(gTree.getJTree());
|
||||
|
|
|
@ -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.
|
||||
|
@ -22,54 +21,59 @@ import javax.swing.Icon;
|
|||
import javax.swing.JTree;
|
||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.widgets.tree.GTree;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
|
||||
public class GTreeRenderer extends DefaultTreeCellRenderer {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Color VALID_DROP_TARGET_COLOR = new Color( 200, 200, 255 );
|
||||
private static final Color VALID_DROP_TARGET_COLOR = new Color(200, 200, 255);
|
||||
private static final int DEFAULT_MIN_ICON_WIDTH = 22;
|
||||
|
||||
|
||||
private Object dropTarget;
|
||||
private boolean paintDropTarget;
|
||||
|
||||
|
||||
private Font cachedDefaultFont;
|
||||
private Font cachedBoldFont;
|
||||
private int minIconWidth = DEFAULT_MIN_ICON_WIDTH;
|
||||
|
||||
|
||||
public GTreeRenderer() {
|
||||
DockingUtils.turnOffHTMLRendering(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see javax.swing.tree.DefaultTreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Component getTreeCellRendererComponent(JTree tree, Object value,
|
||||
boolean selected1, boolean expanded, boolean leaf, int row, boolean hasFocus1) {
|
||||
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected1,
|
||||
boolean expanded, boolean leaf, int row, boolean hasFocus1) {
|
||||
|
||||
super.getTreeCellRendererComponent(tree, value, selected1, expanded, leaf, row, hasFocus1);
|
||||
GTreeNode node = (GTreeNode)value;
|
||||
super.getTreeCellRendererComponent(tree, value, selected1, expanded, leaf, row, hasFocus1);
|
||||
GTreeNode node = (GTreeNode) value;
|
||||
|
||||
String text = node.getName();
|
||||
setText(text);
|
||||
setToolTipText(node.getToolTip());
|
||||
|
||||
Icon icon = node.getIcon(expanded);
|
||||
if ( icon == null ) {
|
||||
if (icon == null) {
|
||||
icon = getIcon();
|
||||
}
|
||||
else {
|
||||
setIcon( icon );
|
||||
setIcon(icon);
|
||||
}
|
||||
|
||||
|
||||
updateIconTextGap(icon, minIconWidth);
|
||||
|
||||
paintDropTarget = (value==dropTarget);
|
||||
|
||||
|
||||
paintDropTarget = (value == dropTarget);
|
||||
|
||||
GTree gtree = node.getTree();
|
||||
|
||||
|
||||
GTreeFilter filter = gtree == null ? null : gtree.getFilter();
|
||||
boolean isBold = (filter != null) && filter.showFilterMatches() && filter.acceptsNode(node);
|
||||
setFont( getFont( isBold ) );
|
||||
return this;
|
||||
setFont(getFont(isBold));
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void updateIconTextGap(Icon icon, int minWidth) {
|
||||
|
@ -77,15 +81,15 @@ public class GTreeRenderer extends DefaultTreeCellRenderer {
|
|||
if (icon != null) {
|
||||
iconWidth = icon.getIconWidth();
|
||||
}
|
||||
setIconTextGap(Math.max(minWidth-iconWidth, 2));
|
||||
setIconTextGap(Math.max(minWidth - iconWidth, 2));
|
||||
}
|
||||
|
||||
@Override // overridden to recalculate icon text gaps
|
||||
public void setIcon( Icon icon ) {
|
||||
super.setIcon( icon );
|
||||
updateIconTextGap( icon, minIconWidth );
|
||||
public void setIcon(Icon icon) {
|
||||
super.setIcon(icon);
|
||||
updateIconTextGap(icon, minIconWidth);
|
||||
}
|
||||
|
||||
|
||||
public int getMinIconWidth() {
|
||||
return minIconWidth;
|
||||
}
|
||||
|
@ -98,29 +102,29 @@ public class GTreeRenderer extends DefaultTreeCellRenderer {
|
|||
private Font getFont(boolean bold) {
|
||||
Font font = getFont();
|
||||
// check if someone set a new font on the renderer
|
||||
if ( font != cachedDefaultFont && font != cachedBoldFont ) {
|
||||
if (font != cachedDefaultFont && font != cachedBoldFont) {
|
||||
cachedDefaultFont = font;
|
||||
|
||||
|
||||
// Bug Alert!:
|
||||
// We must create a new font here and not use deriveFont(). Using derive font has
|
||||
// bugs when calculating the string width for a bold derived font.
|
||||
cachedBoldFont = new Font( font.getFamily(), Font.BOLD, font.getSize() );
|
||||
cachedBoldFont = new Font(font.getFamily(), Font.BOLD, font.getSize());
|
||||
}
|
||||
return bold ? cachedBoldFont : cachedDefaultFont;
|
||||
}
|
||||
|
||||
|
||||
// our parent makes this call in the paint() method so we cannot just call setBackground() in
|
||||
// getTreeCellRendererComponent(), but we must instead make sure that the paint() method gets
|
||||
// the correct color
|
||||
@Override
|
||||
public Color getBackgroundNonSelectionColor() {
|
||||
if ( paintDropTarget ) {
|
||||
if (paintDropTarget) {
|
||||
return VALID_DROP_TARGET_COLOR;
|
||||
}
|
||||
return super.getBackgroundNonSelectionColor();
|
||||
}
|
||||
|
||||
public void setRendererDropTarget( Object target ) {
|
||||
|
||||
public void setRendererDropTarget(Object target) {
|
||||
this.dropTarget = target;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ import java.io.IOException;
|
|||
import javax.swing.*;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.*;
|
||||
import docking.help.Help;
|
||||
import docking.help.HelpService;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
|
@ -215,8 +214,8 @@ public class WizardManager extends DialogComponentProvider implements WizardPane
|
|||
}
|
||||
});
|
||||
|
||||
titleLabel = (wizardIcon == null ? new JLabel(INIT_TITLE)
|
||||
: new JLabel(INIT_TITLE, wizardIcon, SwingConstants.TRAILING));
|
||||
titleLabel = (wizardIcon == null ? DockingUtils.createNonHtmlLabel(INIT_TITLE)
|
||||
: DockingUtils.createNonHtmlLabel(INIT_TITLE, wizardIcon, SwingConstants.TRAILING));
|
||||
|
||||
EmptyBorderButton helpButton =
|
||||
new EmptyBorderButton(ResourceManager.loadImage("images/information.png"));
|
||||
|
|
|
@ -22,8 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.*;
|
||||
import docking.util.AnimatedIcon;
|
||||
import docking.widgets.OptionDialog;
|
||||
import ghidra.util.*;
|
||||
|
@ -181,7 +180,7 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
|
|||
AnimatedIcon icon = new AnimatedIcon(iconList, 200, 0);
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setSize(new Dimension(200, 100));
|
||||
panel.add(new JLabel(icon));
|
||||
panel.add(DockingUtils.createNonHtmlLabel(icon));
|
||||
mainPanel.add(panel, BorderLayout.CENTER);
|
||||
|
||||
repack();
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.DockingUtils;
|
||||
import docking.ToolTipManager;
|
||||
import docking.util.AnimatedIcon;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
|
@ -485,7 +486,7 @@ public class TaskMonitorComponent extends JPanel implements TaskMonitor {
|
|||
iconList.add(ResourceManager.loadImage("images/hourglass24_10.png"));
|
||||
iconList.add(ResourceManager.loadImage("images/hourglass24_11.png"));
|
||||
AnimatedIcon progressIcon = new AnimatedIcon(iconList, 150, 0);
|
||||
imageLabel = new JLabel(progressIcon);
|
||||
imageLabel = DockingUtils.createNonHtmlLabel(progressIcon);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,8 +107,8 @@ public class StatusBarTest extends AbstractDockingTest {
|
|||
}
|
||||
|
||||
private void addAndRemoveStatusItems() {
|
||||
final JLabel label1 = new JLabel("Test Label 1");
|
||||
final JLabel label2 = new JLabel("Test Label 2");
|
||||
final JLabel label1 = DockingUtils.createNonHtmlLabel("Test Label 1");
|
||||
final JLabel label2 = DockingUtils.createNonHtmlLabel("Test Label 2");
|
||||
|
||||
// normal add/remove operations
|
||||
runSwing(new Runnable() {
|
||||
|
@ -165,7 +165,7 @@ public class StatusBarTest extends AbstractDockingTest {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
statusBar.removeStatusItem(new JLabel("Test Label 3"));
|
||||
statusBar.removeStatusItem(DockingUtils.createNonHtmlLabel("Test Label 3"));
|
||||
|
||||
Assert.fail("Did not receive an expected NullPointerException.");
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public class PlaceholderSetTest extends AbstractGenericTest {
|
|||
}
|
||||
|
||||
private class TestProvider extends ComponentProvider {
|
||||
JLabel label = new JLabel();
|
||||
JLabel label = DockingUtils.createNonHtmlLabel();
|
||||
|
||||
public TestProvider() {
|
||||
super(null, null, null);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue