fix: disable HTML rendering in labels if not needed
This commit is contained in:
@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
|
||||
import jadx.gui.settings.JadxSettings;
|
||||
import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.utils.UiUtils;
|
||||
import jadx.gui.utils.ui.NodeLabel;
|
||||
|
||||
public class QuarkDialog extends JDialog {
|
||||
private static final long serialVersionUID = 4855753773520368215L;
|
||||
@@ -59,7 +60,7 @@ public class QuarkDialog extends JDialog {
|
||||
description.setAlignmentX(0.5f);
|
||||
|
||||
fileSelectCombo = new JComboBox<>(files.toArray(new Path[0]));
|
||||
fileSelectCombo.setRenderer((list, value, index, isSelected, cellHasFocus) -> new JLabel(value.getFileName().toString()));
|
||||
fileSelectCombo.setRenderer((list, value, index, isSelected, cellHasFocus) -> new NodeLabel(value.getFileName().toString()));
|
||||
|
||||
JPanel textPane = new JPanel();
|
||||
textPane.add(description);
|
||||
|
||||
@@ -44,6 +44,7 @@ import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.ui.TabbedPane;
|
||||
import jadx.gui.ui.panel.ContentPanel;
|
||||
import jadx.gui.utils.JNodeCache;
|
||||
import jadx.gui.utils.ui.NodeLabel;
|
||||
|
||||
public class QuarkReportPanel extends ContentPanel {
|
||||
private static final long serialVersionUID = -242266836695889206L;
|
||||
@@ -211,7 +212,7 @@ public class QuarkReportPanel extends ContentPanel {
|
||||
|
||||
@Override
|
||||
public Component render() {
|
||||
JLabel label = new JLabel(((String) getUserObject()));
|
||||
JLabel label = new NodeLabel(((String) getUserObject()));
|
||||
label.setFont(bold ? boldFont : font);
|
||||
label.setIcon(null);
|
||||
label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
@@ -320,7 +321,7 @@ public class QuarkReportPanel extends ContentPanel {
|
||||
|
||||
@Override
|
||||
public Component render() {
|
||||
JLabel label = new JLabel(mth.toString());
|
||||
JLabel label = new NodeLabel(mth.toString());
|
||||
label.setFont(font);
|
||||
label.setIcon(jnode.getIcon());
|
||||
label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
|
||||
@@ -71,6 +71,11 @@ public class CodeNode extends JNode {
|
||||
return jNode.makeLongStringHtml();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableHtml() {
|
||||
return jNode.disableHtml();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntaxName() {
|
||||
return jNode.getSyntaxName();
|
||||
|
||||
@@ -97,6 +97,11 @@ public class JField extends JNode {
|
||||
return UiUtils.typeStr(field.getType()) + " " + field.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableHtml() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDescString() {
|
||||
return false;
|
||||
|
||||
@@ -155,6 +155,11 @@ public class JMethod extends JNode {
|
||||
return UiUtils.typeFormatHtml(name, getReturnType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableHtml() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String makeDescString() {
|
||||
return UiUtils.typeStr(getReturnType()) + " " + makeBaseString();
|
||||
|
||||
@@ -81,6 +81,10 @@ public abstract class JNode extends DefaultMutableTreeNode implements Comparable
|
||||
return makeLongString();
|
||||
}
|
||||
|
||||
public boolean disableHtml() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getPos() {
|
||||
JavaNode javaNode = getJavaNode();
|
||||
if (javaNode == null) {
|
||||
|
||||
@@ -142,6 +142,7 @@ import jadx.gui.utils.UiUtils;
|
||||
import jadx.gui.utils.fileswatcher.LiveReloadWorker;
|
||||
import jadx.gui.utils.logs.LogCollector;
|
||||
import jadx.gui.utils.ui.ActionHandler;
|
||||
import jadx.gui.utils.ui.NodeLabel;
|
||||
|
||||
import static io.reactivex.internal.functions.Functions.EMPTY_RUNNABLE;
|
||||
import static javax.swing.KeyStroke.getKeyStroke;
|
||||
@@ -1281,6 +1282,7 @@ public class MainWindow extends JFrame {
|
||||
Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused);
|
||||
if (value instanceof JNode) {
|
||||
JNode jNode = (JNode) value;
|
||||
NodeLabel.disableHtml(this, jNode.disableHtml());
|
||||
setText(jNode.makeStringHtml());
|
||||
setIcon(jNode.getIcon());
|
||||
setToolTipText(jNode.getTooltip());
|
||||
|
||||
@@ -23,6 +23,7 @@ import jadx.gui.ui.panel.ContentPanel;
|
||||
import jadx.gui.utils.Icons;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.UiUtils;
|
||||
import jadx.gui.utils.ui.NodeLabel;
|
||||
|
||||
public class TabComponent extends JPanel {
|
||||
private static final long serialVersionUID = -8147035487543610321L;
|
||||
@@ -58,7 +59,7 @@ public class TabComponent extends JPanel {
|
||||
} else {
|
||||
tabTitle = node.makeLongStringHtml();
|
||||
}
|
||||
label = new JLabel(tabTitle);
|
||||
label = new NodeLabel(tabTitle, node.disableHtml());
|
||||
label.setFont(getLabelFont());
|
||||
String toolTip = contentPanel.getTabTooltip();
|
||||
if (toolTip != null) {
|
||||
|
||||
@@ -55,6 +55,7 @@ import jadx.gui.utils.JNodeCache;
|
||||
import jadx.gui.utils.JumpPosition;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.UiUtils;
|
||||
import jadx.gui.utils.ui.NodeLabel;
|
||||
|
||||
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||
@@ -402,9 +403,9 @@ public abstract class CommonSearchDialog extends JFrame {
|
||||
}
|
||||
|
||||
protected final class ResultsTableCellRenderer implements TableCellRenderer {
|
||||
private final JLabel label;
|
||||
private final NodeLabel label;
|
||||
private final RSyntaxTextArea codeArea;
|
||||
private final JLabel emptyLabel;
|
||||
private final NodeLabel emptyLabel;
|
||||
private final Color codeSelectedColor;
|
||||
private final Color codeBackground;
|
||||
|
||||
@@ -414,11 +415,11 @@ public abstract class CommonSearchDialog extends JFrame {
|
||||
codeArea.setRows(1);
|
||||
codeBackground = codeArea.getBackground();
|
||||
codeSelectedColor = codeArea.getSelectionColor();
|
||||
label = new JLabel();
|
||||
label = new NodeLabel();
|
||||
label.setOpaque(true);
|
||||
label.setFont(codeArea.getFont());
|
||||
label.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
emptyLabel = new JLabel();
|
||||
emptyLabel = new NodeLabel();
|
||||
emptyLabel.setOpaque(true);
|
||||
}
|
||||
|
||||
@@ -454,8 +455,9 @@ public abstract class CommonSearchDialog extends JFrame {
|
||||
private Component makeCell(JNode node, int column) {
|
||||
if (column == 0) {
|
||||
label.setText(node.makeLongStringHtml());
|
||||
label.setToolTipText(label.getText());
|
||||
label.setToolTipText(node.getTooltip());
|
||||
label.setIcon(node.getIcon());
|
||||
label.disableHtml(node.disableHtml());
|
||||
return label;
|
||||
}
|
||||
if (!node.hasDescString()) {
|
||||
|
||||
@@ -22,7 +22,6 @@ import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -60,6 +59,7 @@ import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.TextStandardActions;
|
||||
import jadx.gui.utils.UiUtils;
|
||||
import jadx.gui.utils.ui.DocumentUpdateListener;
|
||||
import jadx.gui.utils.ui.NodeLabel;
|
||||
|
||||
public class RenameDialog extends JDialog {
|
||||
private static final long serialVersionUID = -3269715644416902410L;
|
||||
@@ -313,7 +313,7 @@ public class RenameDialog extends JDialog {
|
||||
|
||||
private void initUI() {
|
||||
JLabel lbl = new JLabel(NLS.str("popup.rename"));
|
||||
JLabel nodeLabel = new JLabel(this.node.makeLongStringHtml(), this.node.getIcon(), SwingConstants.LEFT);
|
||||
JLabel nodeLabel = NodeLabel.longName(node);
|
||||
lbl.setLabelFor(nodeLabel);
|
||||
|
||||
renameField = new JTextField(40);
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.util.Map;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import jadx.api.ICodeInfo;
|
||||
@@ -31,6 +30,7 @@ import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.utils.JNodeCache;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.UiUtils;
|
||||
import jadx.gui.utils.ui.NodeLabel;
|
||||
|
||||
public class UsageDialog extends CommonSearchDialog {
|
||||
private static final long serialVersionUID = -5105405789969134105L;
|
||||
@@ -147,7 +147,7 @@ public class UsageDialog extends CommonSearchDialog {
|
||||
Font codeFont = settings.getFont();
|
||||
JLabel lbl = new JLabel(NLS.str("usage_dialog.label"));
|
||||
lbl.setFont(codeFont);
|
||||
JLabel nodeLabel = new JLabel(this.node.makeLongStringHtml(), this.node.getIcon(), SwingConstants.LEFT);
|
||||
JLabel nodeLabel = NodeLabel.longName(node);
|
||||
nodeLabel.setFont(codeFont);
|
||||
lbl.setLabelFor(nodeLabel);
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import jadx.gui.device.protocol.ADB;
|
||||
import jadx.gui.device.protocol.ADBDevice;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.UiUtils;
|
||||
import jadx.gui.utils.ui.NodeLabel;
|
||||
|
||||
public class LogcatPanel extends JPanel {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LogcatPanel.class);
|
||||
@@ -301,7 +302,7 @@ public class LogcatPanel extends JPanel {
|
||||
}
|
||||
|
||||
public JPanel getContent() {
|
||||
JLabel label = new JLabel(this.label + ": ");
|
||||
JLabel label = NodeLabel.noHtml(this.label + ": ");
|
||||
CheckComboStore[] stores = new CheckComboStore[ids.length];
|
||||
for (int j = 0; j < ids.length; j++) {
|
||||
stores[j] = new CheckComboStore(index[j], ids[j], Boolean.TRUE);
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package jadx.gui.utils.ui;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import jadx.gui.treemodel.JNode;
|
||||
|
||||
public class NodeLabel extends JLabel {
|
||||
|
||||
public static NodeLabel longName(JNode node) {
|
||||
NodeLabel label = new NodeLabel(node.makeLongStringHtml(), node.disableHtml());
|
||||
label.setIcon(node.getIcon());
|
||||
label.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
return label;
|
||||
}
|
||||
|
||||
public static NodeLabel noHtml(String label) {
|
||||
return new NodeLabel(label, true);
|
||||
}
|
||||
|
||||
public static void disableHtml(JLabel label, boolean disable) {
|
||||
label.putClientProperty("html.disable", disable);
|
||||
}
|
||||
|
||||
private boolean htmlDisabled = false;
|
||||
|
||||
public NodeLabel() {
|
||||
disableHtml(true);
|
||||
}
|
||||
|
||||
public NodeLabel(String label) {
|
||||
disableHtml(true);
|
||||
setText(label);
|
||||
}
|
||||
|
||||
public NodeLabel(String label, boolean disableHtml) {
|
||||
disableHtml(disableHtml);
|
||||
setText(label);
|
||||
}
|
||||
|
||||
public void disableHtml(boolean disable) {
|
||||
if (htmlDisabled != disable) {
|
||||
htmlDisabled = disable;
|
||||
disableHtml(this, disable);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user