reformat code and fix sonar warnings
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
package jadx.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.gui.settings.JadxSettings;
|
||||
import jadx.gui.settings.JadxSettingsAdapter;
|
||||
import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.utils.LogCollector;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class JadxGUI {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JadxGUI.class);
|
||||
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package jadx.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.IJadxArgs;
|
||||
import jadx.api.JadxDecompiler;
|
||||
import jadx.api.JavaClass;
|
||||
@@ -8,14 +16,6 @@ import jadx.api.ResourceFile;
|
||||
import jadx.core.utils.exceptions.DecodeException;
|
||||
import jadx.core.utils.exceptions.JadxException;
|
||||
|
||||
import javax.swing.ProgressMonitor;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class JadxWrapper {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JadxWrapper.class);
|
||||
|
||||
@@ -55,6 +55,7 @@ public class JadxWrapper {
|
||||
LOG.info("done");
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Save interrupted", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package jadx.gui.jobs;
|
||||
|
||||
import jadx.gui.JadxWrapper;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -13,8 +11,10 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.gui.JadxWrapper;
|
||||
|
||||
public abstract class BackgroundJob {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DecompileJob.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BackgroundJob.class);
|
||||
|
||||
protected final JadxWrapper wrapper;
|
||||
private final ThreadPoolExecutor executor;
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package jadx.gui.jobs;
|
||||
|
||||
import jadx.gui.ui.ProgressPanel;
|
||||
import jadx.gui.utils.CacheObject;
|
||||
import jadx.gui.utils.search.TextSearchIndex;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.*;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.gui.ui.ProgressPanel;
|
||||
import jadx.gui.utils.CacheObject;
|
||||
import jadx.gui.utils.Utils;
|
||||
import jadx.gui.utils.search.TextSearchIndex;
|
||||
|
||||
public class BackgroundWorker extends SwingWorker<Void, Void> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BackgroundWorker.class);
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package jadx.gui.jobs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.core.codegen.CodeWriter;
|
||||
import jadx.gui.JadxWrapper;
|
||||
@@ -11,12 +17,6 @@ import jadx.gui.utils.Utils;
|
||||
import jadx.gui.utils.search.StringRef;
|
||||
import jadx.gui.utils.search.TextSearchIndex;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class IndexJob extends BackgroundJob {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(IndexJob.class);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package jadx.gui.settings;
|
||||
|
||||
import jadx.cli.JadxCLIArgs;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Window;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -14,6 +11,8 @@ import java.util.Set;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
|
||||
import jadx.cli.JadxCLIArgs;
|
||||
|
||||
public class JadxSettings extends JadxCLIArgs {
|
||||
|
||||
private static final String USER_HOME = System.getProperty("user.home");
|
||||
@@ -21,7 +20,7 @@ public class JadxSettings extends JadxCLIArgs {
|
||||
|
||||
private static final Font DEFAULT_FONT = new RSyntaxTextArea().getFont();
|
||||
|
||||
static final Set<String> SKIP_FIELDS = new HashSet<String>(Arrays.asList(
|
||||
static final Set<String> SKIP_FIELDS = new HashSet<>(Arrays.asList(
|
||||
"files", "input", "outputDir", "verbose", "printHelp"
|
||||
));
|
||||
|
||||
@@ -29,11 +28,11 @@ public class JadxSettings extends JadxCLIArgs {
|
||||
private String lastSaveFilePath = USER_HOME;
|
||||
private boolean flattenPackage = false;
|
||||
private boolean checkForUpdates = false;
|
||||
private List<String> recentFiles = new ArrayList<String>();
|
||||
private List<String> recentFiles = new ArrayList<>();
|
||||
private String fontStr = "";
|
||||
private boolean autoStartJobs = false;
|
||||
|
||||
private Map<String, WindowLocation> windowPos = new HashMap<String, WindowLocation>();
|
||||
private Map<String, WindowLocation> windowPos = new HashMap<>();
|
||||
|
||||
public JadxSettings() {
|
||||
setSkipResources(true);
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package jadx.gui.settings;
|
||||
|
||||
import jadx.gui.JadxGUI;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.InstanceCreator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.gui.JadxGUI;
|
||||
|
||||
public class JadxSettingsAdapter {
|
||||
|
||||
|
||||
@@ -1,31 +1,9 @@
|
||||
package jadx.gui.settings;
|
||||
|
||||
import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.utils.NLS;
|
||||
import say.swing.JFontChooser;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.WindowConstants;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
@@ -35,17 +13,21 @@ import java.awt.event.MouseEvent;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import say.swing.JFontChooser;
|
||||
|
||||
import jadx.gui.ui.MainWindow;
|
||||
import jadx.gui.utils.NLS;
|
||||
|
||||
public class JadxSettingsWindow extends JDialog {
|
||||
private static final long serialVersionUID = -1804570470377354148L;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JadxSettingsWindow.class);
|
||||
|
||||
private final MainWindow mainWindow;
|
||||
private final JadxSettings settings;
|
||||
private final String startSettings;
|
||||
private final transient MainWindow mainWindow;
|
||||
private final transient JadxSettings settings;
|
||||
private final transient String startSettings;
|
||||
|
||||
private boolean needReload = false;
|
||||
private transient boolean needReload = false;
|
||||
|
||||
public JadxSettingsWindow(MainWindow mainWindow, JadxSettings settings) {
|
||||
this.mainWindow = mainWindow;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import jadx.api.JavaNode;
|
||||
import jadx.gui.utils.search.StringRef;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
public class CodeNode extends JNode {
|
||||
|
||||
private static final long serialVersionUID = 1658650786734966545L;
|
||||
|
||||
private final JNode jNode;
|
||||
private final JClass jParent;
|
||||
private final StringRef line;
|
||||
private final transient JNode jNode;
|
||||
private final transient JClass jParent;
|
||||
private final transient StringRef line;
|
||||
private final int lineNum;
|
||||
|
||||
public CodeNode(JNode jNode, int lineNum, StringRef line) {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.JavaField;
|
||||
import jadx.api.JavaMethod;
|
||||
@@ -8,11 +12,6 @@ import jadx.core.dex.info.AccessInfo;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
|
||||
public class JClass extends JNode {
|
||||
private static final long serialVersionUID = -1239986875244097177L;
|
||||
|
||||
@@ -24,9 +23,9 @@ public class JClass extends JNode {
|
||||
private static final ImageIcon ICON_ENUM = Utils.openIcon("enum_obj");
|
||||
private static final ImageIcon ICON_ANNOTATION = Utils.openIcon("annotation_obj");
|
||||
|
||||
private final JavaClass cls;
|
||||
private final JClass jParent;
|
||||
private boolean loaded;
|
||||
private final transient JavaClass cls;
|
||||
private final transient JClass jParent;
|
||||
private transient boolean loaded;
|
||||
|
||||
public JClass(JavaClass cls) {
|
||||
this.cls = cls;
|
||||
@@ -71,6 +70,7 @@ public class JClass extends JNode {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContent() {
|
||||
return cls.getCode();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import jadx.api.JavaField;
|
||||
import jadx.api.JavaNode;
|
||||
import jadx.core.dex.info.AccessInfo;
|
||||
import jadx.gui.utils.OverlayIcon;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public class JField extends JNode {
|
||||
private static final long serialVersionUID = 1712572192106793359L;
|
||||
|
||||
@@ -20,8 +19,8 @@ public class JField extends JNode {
|
||||
private static final ImageIcon ICON_TRANSIENT = Utils.openIcon("transient_co");
|
||||
private static final ImageIcon ICON_VOLATILE = Utils.openIcon("volatile_co");
|
||||
|
||||
private final JavaField field;
|
||||
private final JClass jParent;
|
||||
private final transient JavaField field;
|
||||
private final transient JClass jParent;
|
||||
|
||||
public JField(JavaField javaField, JClass jClass) {
|
||||
this.field = javaField;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Iterator;
|
||||
|
||||
import jadx.api.JavaMethod;
|
||||
import jadx.api.JavaNode;
|
||||
import jadx.core.dex.info.AccessInfo;
|
||||
@@ -7,10 +10,6 @@ import jadx.core.dex.instructions.args.ArgType;
|
||||
import jadx.gui.utils.OverlayIcon;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class JMethod extends JNode {
|
||||
private static final long serialVersionUID = 3834526867464663751L;
|
||||
|
||||
@@ -22,8 +21,8 @@ public class JMethod extends JNode {
|
||||
private static final ImageIcon ICON_CONSTRUCTOR = Utils.openIcon("constr_ovr");
|
||||
private static final ImageIcon ICON_SYNC = Utils.openIcon("synch_co");
|
||||
|
||||
private final JavaMethod mth;
|
||||
private final JClass jParent;
|
||||
private final transient JavaMethod mth;
|
||||
private final transient JClass jParent;
|
||||
|
||||
public JMethod(JavaMethod javaMethod, JClass jClass) {
|
||||
this.mth = javaMethod;
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import jadx.api.JavaNode;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
|
||||
import jadx.api.JavaNode;
|
||||
|
||||
public abstract class JNode extends DefaultMutableTreeNode {
|
||||
|
||||
private static final long serialVersionUID = -5154479091781041008L;
|
||||
|
||||
public abstract JClass getJParent();
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.JavaPackage;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.JavaPackage;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
public class JPackage extends JNode implements Comparable<JPackage> {
|
||||
private static final long serialVersionUID = -4120718634156839804L;
|
||||
|
||||
@@ -18,12 +17,12 @@ public class JPackage extends JNode implements Comparable<JPackage> {
|
||||
|
||||
private String name;
|
||||
private final List<JClass> classes;
|
||||
private final List<JPackage> innerPackages = new ArrayList<JPackage>(1);
|
||||
private final List<JPackage> innerPackages = new ArrayList<>(1);
|
||||
|
||||
public JPackage(JavaPackage pkg) {
|
||||
this.name = pkg.getName();
|
||||
List<JavaClass> javaClasses = pkg.getClasses();
|
||||
this.classes = new ArrayList<JClass>(javaClasses.size());
|
||||
this.classes = new ArrayList<>(javaClasses.size());
|
||||
for (JavaClass javaClass : javaClasses) {
|
||||
classes.add(new JClass(javaClass));
|
||||
}
|
||||
@@ -32,7 +31,7 @@ public class JPackage extends JNode implements Comparable<JPackage> {
|
||||
|
||||
public JPackage(String name) {
|
||||
this.name = name;
|
||||
this.classes = new ArrayList<JClass>(1);
|
||||
this.classes = new ArrayList<>(1);
|
||||
}
|
||||
|
||||
public final void update() {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
|
||||
import jadx.api.ResourceFile;
|
||||
import jadx.api.ResourceFileContent;
|
||||
import jadx.api.ResourceType;
|
||||
@@ -8,14 +15,6 @@ import jadx.core.xmlgen.ResContainer;
|
||||
import jadx.gui.utils.OverlayIcon;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
|
||||
public class JResource extends JNode implements Comparable<JResource> {
|
||||
private static final long serialVersionUID = -201018424302612434L;
|
||||
|
||||
@@ -32,15 +31,15 @@ public class JResource extends JNode implements Comparable<JResource> {
|
||||
FILE
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final String shortName;
|
||||
private final List<JResource> files = new ArrayList<JResource>(1);
|
||||
private final JResType type;
|
||||
private final ResourceFile resFile;
|
||||
private final transient String name;
|
||||
private final transient String shortName;
|
||||
private final transient List<JResource> files = new ArrayList<>(1);
|
||||
private final transient JResType type;
|
||||
private final transient ResourceFile resFile;
|
||||
|
||||
private boolean loaded;
|
||||
private String content;
|
||||
private Map<Integer, Integer> lineMapping;
|
||||
private transient boolean loaded;
|
||||
private transient String content;
|
||||
private transient Map<Integer, Integer> lineMapping;
|
||||
|
||||
public JResource(ResourceFile resFile, String name, JResType type) {
|
||||
this(resFile, name, name, type);
|
||||
@@ -62,13 +61,14 @@ public class JResource extends JNode implements Comparable<JResource> {
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadContent() {
|
||||
private void loadContent() {
|
||||
getContent();
|
||||
for (JResource res : files) {
|
||||
res.loadContent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -77,6 +77,7 @@ public class JResource extends JNode implements Comparable<JResource> {
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContent() {
|
||||
if (!loaded && resFile != null && type == JResType.FILE) {
|
||||
loaded = true;
|
||||
@@ -90,18 +91,18 @@ public class JResource extends JNode implements Comparable<JResource> {
|
||||
return content;
|
||||
}
|
||||
|
||||
protected void addSubFiles(ResContainer rc, JResource root, int depth) {
|
||||
private void addSubFiles(ResContainer rc, JResource root, int depth) {
|
||||
CodeWriter cw = rc.getContent();
|
||||
if (cw != null) {
|
||||
if (depth == 0) {
|
||||
root.lineMapping = cw.getLineMapping();
|
||||
root.content = cw.toString();
|
||||
} else {
|
||||
String name = rc.getName();
|
||||
String[] path = name.split("/");
|
||||
String shortName = path.length == 0 ? name : path[path.length - 1];
|
||||
ResourceFileContent fileContent = new ResourceFileContent(shortName, ResourceType.XML, cw);
|
||||
addPath(path, root, new JResource(fileContent, name, shortName, JResType.FILE));
|
||||
String resName = rc.getName();
|
||||
String[] path = resName.split("/");
|
||||
String resShortName = path.length == 0 ? resName : path[path.length - 1];
|
||||
ResourceFileContent fileContent = new ResourceFileContent(resShortName, ResourceType.XML, cw);
|
||||
addPath(path, root, new JResource(fileContent, resName, resShortName, JResType.FILE));
|
||||
}
|
||||
}
|
||||
List<ResContainer> subFiles = rc.getSubFiles();
|
||||
@@ -117,13 +118,14 @@ public class JResource extends JNode implements Comparable<JResource> {
|
||||
root.getFiles().add(jResource);
|
||||
return;
|
||||
}
|
||||
JResource currentRoot = root;
|
||||
int last = path.length - 1;
|
||||
for (int i = 0; i <= last; i++) {
|
||||
String f = path[i];
|
||||
if (i == last) {
|
||||
root.getFiles().add(jResource);
|
||||
currentRoot.getFiles().add(jResource);
|
||||
} else {
|
||||
root = getResDir(root, f);
|
||||
currentRoot = getResDir(currentRoot, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,12 +161,14 @@ public class JResource extends JNode implements Comparable<JResource> {
|
||||
case MANIFEST:
|
||||
case XML:
|
||||
return SyntaxConstants.SYNTAX_STYLE_XML;
|
||||
|
||||
default:
|
||||
String syntax = getSyntaxByExtension(resFile.getName());
|
||||
if (syntax != null) {
|
||||
return syntax;
|
||||
}
|
||||
return super.getSyntaxName();
|
||||
}
|
||||
String syntax = getSyntaxByExtension(resFile.getName());
|
||||
if (syntax != null) {
|
||||
return syntax;
|
||||
}
|
||||
return super.getSyntaxName();
|
||||
}
|
||||
|
||||
private String getSyntaxByExtension(String name) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
@@ -11,6 +12,11 @@ import javax.swing.ImageIcon;
|
||||
|
||||
import jadx.api.ResourceFile;
|
||||
import jadx.gui.JadxWrapper;
|
||||
import jadx.api.ResourceFile;
|
||||
import jadx.gui.JadxWrapper;
|
||||
import jadx.gui.treemodel.JResource.JResType;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import jadx.gui.treemodel.JResource.JResType;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
@@ -19,9 +25,9 @@ public class JRoot extends JNode {
|
||||
|
||||
private static final ImageIcon ROOT_ICON = Utils.openIcon("java_model_obj");
|
||||
|
||||
private final JadxWrapper wrapper;
|
||||
private final transient JadxWrapper wrapper;
|
||||
|
||||
private boolean flatPackages = false;
|
||||
private transient boolean flatPackages = false;
|
||||
|
||||
public JRoot(JadxWrapper wrapper) {
|
||||
this.wrapper = wrapper;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import jadx.api.JavaPackage;
|
||||
import jadx.gui.JadxWrapper;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -15,13 +10,17 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import jadx.api.JavaPackage;
|
||||
import jadx.gui.JadxWrapper;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
public class JSources extends JNode {
|
||||
private static final long serialVersionUID = 8962924556824862801L;
|
||||
|
||||
private static final ImageIcon ROOT_ICON = Utils.openIcon("packagefolder_obj");
|
||||
|
||||
private final JadxWrapper wrapper;
|
||||
private final boolean flatPackages;
|
||||
private final transient JadxWrapper wrapper;
|
||||
private final transient boolean flatPackages;
|
||||
|
||||
public JSources(JRoot jRoot, JadxWrapper wrapper) {
|
||||
this.flatPackages = jRoot.isFlatPackages();
|
||||
@@ -52,7 +51,7 @@ public class JSources extends JNode {
|
||||
* @return root packages
|
||||
*/
|
||||
List<JPackage> getHierarchyPackages(List<JavaPackage> packages) {
|
||||
Map<String, JPackage> pkgMap = new HashMap<String, JPackage>();
|
||||
Map<String, JPackage> pkgMap = new HashMap<>();
|
||||
for (JavaPackage pkg : packages) {
|
||||
addPackage(pkgMap, new JPackage(pkg));
|
||||
}
|
||||
@@ -90,7 +89,7 @@ public class JSources extends JNode {
|
||||
innerPackages.addAll(pkg.getInnerPackages());
|
||||
}
|
||||
// find root packages
|
||||
List<JPackage> rootPkgs = new ArrayList<JPackage>();
|
||||
List<JPackage> rootPkgs = new ArrayList<>();
|
||||
for (JPackage pkg : pkgMap.values()) {
|
||||
if (!innerPackages.contains(pkg)) {
|
||||
rootPkgs.add(pkg);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package jadx.gui.treemodel;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.*;
|
||||
|
||||
public class TextNode extends JNode {
|
||||
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import jadx.api.JadxDecompiler;
|
||||
import jadx.gui.utils.NLS;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
class AboutDialog extends JDialog {
|
||||
private static final long serialVersionUID = 5763493590584039096L;
|
||||
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import jadx.api.CodePosition;
|
||||
import jadx.api.JavaNode;
|
||||
import jadx.gui.settings.JadxSettings;
|
||||
import jadx.gui.treemodel.JClass;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.utils.Position;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
@@ -19,10 +8,7 @@ import javax.swing.event.PopupMenuListener;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Caret;
|
||||
import javax.swing.text.DefaultCaret;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.LinkGenerator;
|
||||
@@ -34,12 +20,19 @@ import org.fife.ui.rsyntaxtextarea.TokenTypes;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.CodePosition;
|
||||
import jadx.api.JavaNode;
|
||||
import jadx.gui.settings.JadxSettings;
|
||||
import jadx.gui.treemodel.JClass;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.utils.Position;
|
||||
|
||||
class CodeArea extends RSyntaxTextArea {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CodeArea.class);
|
||||
|
||||
private static final long serialVersionUID = 6312736869579635796L;
|
||||
|
||||
public static final Color BACKGROUND = new Color(0xFAFAFA);
|
||||
public static final Color CODE_BACKGROUND = new Color(0xFAFAFA);
|
||||
public static final Color JUMP_TOKEN_FGD = new Color(0x491BA1);
|
||||
|
||||
private final CodePanel contentPanel;
|
||||
@@ -50,7 +43,7 @@ class CodeArea extends RSyntaxTextArea {
|
||||
this.node = panel.getNode();
|
||||
|
||||
setMarkOccurrences(true);
|
||||
setBackground(BACKGROUND);
|
||||
setBackground(CODE_BACKGROUND);
|
||||
setAntiAliasingEnabled(true);
|
||||
setEditable(false);
|
||||
loadSettings();
|
||||
@@ -78,8 +71,6 @@ class CodeArea extends RSyntaxTextArea {
|
||||
|
||||
private void addMenuItems(CodeArea codeArea, JClass jCls) {
|
||||
Action findUsage = new FindUsageAction(codeArea, jCls);
|
||||
// TODO: hotkey works only when popup menu is shown
|
||||
// findUsage.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_F7, KeyEvent.ALT_DOWN_MASK));
|
||||
|
||||
JPopupMenu popup = getPopupMenu();
|
||||
popup.addSeparator();
|
||||
@@ -197,10 +188,10 @@ class CodeArea extends RSyntaxTextArea {
|
||||
private class FindUsageAction extends AbstractAction implements PopupMenuListener {
|
||||
private static final long serialVersionUID = 4692546569977976384L;
|
||||
|
||||
private final CodeArea codeArea;
|
||||
private final JClass jCls;
|
||||
private final transient CodeArea codeArea;
|
||||
private final transient JClass jCls;
|
||||
|
||||
private JavaNode node;
|
||||
private transient JavaNode node;
|
||||
|
||||
public FindUsageAction(CodeArea codeArea, JClass jCls) {
|
||||
super("Find Usage");
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.KeyStroke;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
class CodePanel extends ContentPanel {
|
||||
|
||||
private static final long serialVersionUID = 5310536092010045565L;
|
||||
@@ -50,10 +48,12 @@ class CodePanel extends ContentPanel {
|
||||
codeArea.loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
TabbedPane getTabbedPane() {
|
||||
return tabbedPane;
|
||||
}
|
||||
|
||||
@Override
|
||||
JNode getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -1,47 +1,19 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import jadx.gui.jobs.BackgroundJob;
|
||||
import jadx.gui.jobs.BackgroundWorker;
|
||||
import jadx.gui.jobs.DecompileJob;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.treemodel.TextNode;
|
||||
import jadx.gui.utils.CacheObject;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.Position;
|
||||
import jadx.gui.utils.search.TextSearchIndex;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
@@ -56,6 +28,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.gui.jobs.BackgroundJob;
|
||||
import jadx.gui.jobs.BackgroundWorker;
|
||||
import jadx.gui.jobs.DecompileJob;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.treemodel.TextNode;
|
||||
import jadx.gui.utils.CacheObject;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.Position;
|
||||
import jadx.gui.utils.search.TextSearchIndex;
|
||||
|
||||
public abstract class CommonSearchDialog extends JDialog {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CommonSearchDialog.class);
|
||||
@@ -63,10 +45,10 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
|
||||
public static final int MAX_RESULTS_COUNT = 100;
|
||||
|
||||
protected final TabbedPane tabbedPane;
|
||||
protected final CacheObject cache;
|
||||
protected final MainWindow mainWindow;
|
||||
protected final Font codeFont;
|
||||
protected final transient TabbedPane tabbedPane;
|
||||
protected final transient CacheObject cache;
|
||||
protected final transient MainWindow mainWindow;
|
||||
protected final transient Font codeFont;
|
||||
|
||||
protected ResultsModel resultsModel;
|
||||
protected ResultsTable resultsTable;
|
||||
@@ -83,6 +65,12 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
this.codeFont = mainWindow.getSettings().getFont();
|
||||
}
|
||||
|
||||
protected abstract void openInit();
|
||||
|
||||
protected abstract void loadFinished();
|
||||
|
||||
protected abstract void loadStart();
|
||||
|
||||
public void loadWindowPos() {
|
||||
mainWindow.getSettings().loadWindowPos(this);
|
||||
}
|
||||
@@ -98,6 +86,20 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
task.execute();
|
||||
}
|
||||
|
||||
protected void registerInitOnOpen() {
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
openInit();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void openSelectedItem() {
|
||||
int selectedId = resultsTable.getSelectedRow();
|
||||
if (selectedId == -1) {
|
||||
@@ -162,7 +164,7 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
resultsTable.setShowHorizontalLines(false);
|
||||
resultsTable.setDragEnabled(false);
|
||||
resultsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
resultsTable.setBackground(CodeArea.BACKGROUND);
|
||||
resultsTable.setBackground(CodeArea.CODE_BACKGROUND);
|
||||
resultsTable.setColumnSelectionAllowed(false);
|
||||
resultsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||
resultsTable.setAutoscrolls(false);
|
||||
@@ -174,6 +176,7 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
}
|
||||
|
||||
resultsTable.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent evt) {
|
||||
if (evt.getClickCount() == 2) {
|
||||
openSelectedItem();
|
||||
@@ -255,9 +258,9 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
private static final long serialVersionUID = -7821286846923903208L;
|
||||
private static final String[] COLUMN_NAMES = {"Node", "Code"};
|
||||
|
||||
private final List<JNode> rows = new ArrayList<JNode>();
|
||||
private final ResultsTableCellRenderer renderer;
|
||||
private boolean addDescColumn;
|
||||
private final transient List<JNode> rows = new ArrayList<>();
|
||||
private final transient ResultsTableCellRenderer renderer;
|
||||
private transient boolean addDescColumn;
|
||||
|
||||
public ResultsModel(ResultsTableCellRenderer renderer) {
|
||||
this.renderer = renderer;
|
||||
@@ -321,7 +324,7 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
|
||||
private final JLabel emptyLabel = new JLabel();
|
||||
|
||||
private Map<Integer, Component> componentCache = new HashMap<Integer, Component>();
|
||||
private Map<Integer, Component> componentCache = new HashMap<>();
|
||||
|
||||
public ResultsTableCellRenderer() {
|
||||
UIDefaults defaults = UIManager.getDefaults();
|
||||
@@ -332,7 +335,7 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected,
|
||||
boolean hasFocus, int row, int column) {
|
||||
boolean hasFocus, int row, int column) {
|
||||
int id = row << 2 | column;
|
||||
Component comp = componentCache.get(id);
|
||||
if (comp == null) {
|
||||
@@ -352,7 +355,7 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
comp.setBackground(selectedBackground);
|
||||
comp.setForeground(selectedForeground);
|
||||
} else {
|
||||
comp.setBackground(CodeArea.BACKGROUND);
|
||||
comp.setBackground(CodeArea.CODE_BACKGROUND);
|
||||
comp.setForeground(foreground);
|
||||
}
|
||||
}
|
||||
@@ -442,9 +445,4 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
warnLabel.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void loadFinished();
|
||||
|
||||
protected abstract void loadStart();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import jadx.gui.treemodel.JNode;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
abstract class ContentPanel extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 3237031760631677822L;
|
||||
|
||||
protected final TabbedPane tabbedPane;
|
||||
protected final JNode node;
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import hu.kazocsaba.imageviewer.ImageViewer;
|
||||
|
||||
import jadx.api.ResourceFile;
|
||||
import jadx.gui.treemodel.JResource;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class ImagePanel extends ContentPanel {
|
||||
|
||||
private static final long serialVersionUID = 4071356367073142688L;
|
||||
|
||||
ImagePanel(TabbedPane panel, JResource res) {
|
||||
super(panel, res);
|
||||
|
||||
@@ -23,5 +26,6 @@ public class ImagePanel extends ContentPanel {
|
||||
|
||||
@Override
|
||||
public void loadSettings() {
|
||||
// no op
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
@@ -12,14 +12,7 @@ import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Element;
|
||||
import javax.swing.text.StyleConstants;
|
||||
import javax.swing.text.Utilities;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.HashMap;
|
||||
@@ -30,9 +23,9 @@ public class LineNumbers extends JPanel implements CaretListener {
|
||||
|
||||
private static final Border OUTER = new MatteBorder(0, 0, 0, 1, Color.LIGHT_GRAY);
|
||||
|
||||
private static final int HEIGHT = Integer.MAX_VALUE - 1000000;
|
||||
private static final Color FOREGROUND = Color.GRAY;
|
||||
private static final Color BACKGROUND = CodeArea.BACKGROUND;
|
||||
private static final int NUM_HEIGHT = Integer.MAX_VALUE - 1000000;
|
||||
private static final Color NUM_FOREGROUND = Color.GRAY;
|
||||
private static final Color NUM_BACKGROUND = CodeArea.CODE_BACKGROUND;
|
||||
private static final Color CURRENT_LINE_FOREGROUND = new Color(227, 0, 0);
|
||||
|
||||
private CodeArea codeArea;
|
||||
@@ -45,8 +38,8 @@ public class LineNumbers extends JPanel implements CaretListener {
|
||||
public LineNumbers(CodeArea component) {
|
||||
this.codeArea = component;
|
||||
setFont(component.getFont());
|
||||
setBackground(BACKGROUND);
|
||||
setForeground(FOREGROUND);
|
||||
setBackground(NUM_BACKGROUND);
|
||||
setForeground(NUM_FOREGROUND);
|
||||
|
||||
setBorderGap(5);
|
||||
setPreferredWidth();
|
||||
@@ -82,7 +75,7 @@ public class LineNumbers extends JPanel implements CaretListener {
|
||||
|
||||
Dimension d = getPreferredSize();
|
||||
if (d != null) {
|
||||
d.setSize(preferredWidth, HEIGHT);
|
||||
d.setSize(preferredWidth, NUM_HEIGHT);
|
||||
setPreferredSize(d);
|
||||
setSize(d);
|
||||
}
|
||||
@@ -104,7 +97,7 @@ public class LineNumbers extends JPanel implements CaretListener {
|
||||
if (isCurrentLine(rowStartOffset)) {
|
||||
g.setColor(CURRENT_LINE_FOREGROUND);
|
||||
} else {
|
||||
g.setColor(FOREGROUND);
|
||||
g.setColor(NUM_FOREGROUND);
|
||||
}
|
||||
String lineNumber = getTextLineNumber(rowStartOffset);
|
||||
int stringWidth = fontMetrics.stringWidth(lineNumber);
|
||||
@@ -154,7 +147,7 @@ public class LineNumbers extends JPanel implements CaretListener {
|
||||
descent = fontMetrics.getDescent();
|
||||
} else {
|
||||
if (fonts == null) {
|
||||
fonts = new HashMap<String, FontMetrics>();
|
||||
fonts = new HashMap<>();
|
||||
}
|
||||
Element root = codeArea.getDocument().getDefaultRootElement();
|
||||
int index = root.getElementIndex(rowStartOffset);
|
||||
|
||||
@@ -1,32 +1,25 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import jadx.gui.settings.JadxSettings;
|
||||
import jadx.gui.utils.LogCollector;
|
||||
import jadx.gui.utils.NLS;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
|
||||
import jadx.gui.settings.JadxSettings;
|
||||
import jadx.gui.utils.LogCollector;
|
||||
import jadx.gui.utils.NLS;
|
||||
|
||||
class LogViewer extends JDialog {
|
||||
private static final long serialVersionUID = -2188700277429054641L;
|
||||
private static final Level[] LEVEL_ITEMS = {Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR};
|
||||
|
||||
private static Level level = Level.WARN;
|
||||
private final JadxSettings settings;
|
||||
private RSyntaxTextArea textPane;
|
||||
|
||||
private final transient JadxSettings settings;
|
||||
private transient RSyntaxTextArea textPane;
|
||||
|
||||
public LogViewer(JadxSettings settings) {
|
||||
this.settings = settings;
|
||||
@@ -41,8 +34,7 @@ class LogViewer extends JDialog {
|
||||
|
||||
JPanel controlPane = new JPanel();
|
||||
controlPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
@SuppressWarnings("unchecked")
|
||||
final JComboBox cb = new JComboBox(LEVEL_ITEMS);
|
||||
final JComboBox<Level> cb = new JComboBox<>(LEVEL_ITEMS);
|
||||
cb.setSelectedItem(level);
|
||||
cb.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,36 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.MenuEvent;
|
||||
import javax.swing.event.MenuListener;
|
||||
import javax.swing.event.TreeExpansionEvent;
|
||||
import javax.swing.event.TreeWillExpandListener;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.ExpandVetoException;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.awt.*;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.ResourceFile;
|
||||
import jadx.gui.JadxWrapper;
|
||||
import jadx.gui.jobs.BackgroundWorker;
|
||||
@@ -21,60 +52,6 @@ import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.Position;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.ProgressMonitor;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
import javax.swing.event.MenuEvent;
|
||||
import javax.swing.event.MenuListener;
|
||||
import javax.swing.event.TreeExpansionEvent;
|
||||
import javax.swing.event.TreeWillExpandListener;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.ExpandVetoException;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.Font;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static javax.swing.KeyStroke.getKeyStroke;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@@ -101,9 +78,9 @@ public class MainWindow extends JFrame {
|
||||
private static final ImageIcon ICON_DEOBF = Utils.openIcon("lock_edit");
|
||||
private static final ImageIcon ICON_LOG = Utils.openIcon("report");
|
||||
|
||||
private final JadxWrapper wrapper;
|
||||
private final JadxSettings settings;
|
||||
private final CacheObject cacheObject;
|
||||
private final transient JadxWrapper wrapper;
|
||||
private final transient JadxSettings settings;
|
||||
private final transient CacheObject cacheObject;
|
||||
|
||||
private JPanel mainPanel;
|
||||
|
||||
@@ -119,11 +96,9 @@ public class MainWindow extends JFrame {
|
||||
private JToggleButton deobfToggleBtn;
|
||||
private JCheckBoxMenuItem deobfMenuItem;
|
||||
|
||||
private Link updateLink;
|
||||
private ProgressPanel progressPane;
|
||||
private BackgroundWorker backgroundWorker;
|
||||
|
||||
private DropTarget dropTarget;
|
||||
private transient Link updateLink;
|
||||
private transient ProgressPanel progressPane;
|
||||
private transient BackgroundWorker backgroundWorker;
|
||||
|
||||
public MainWindow(JadxSettings settings) {
|
||||
this.wrapper = new JadxWrapper(settings);
|
||||
@@ -179,7 +154,7 @@ public class MainWindow extends JFrame {
|
||||
if (!currentDirectory.isEmpty()) {
|
||||
fileChooser.setCurrentDirectory(new File(currentDirectory));
|
||||
}
|
||||
int ret = fileChooser.showDialog(mainPanel, NLS.str("file.open"));
|
||||
int ret = fileChooser.showDialog(mainPanel, NLS.str("file.open_title"));
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
settings.setLastOpenFilePath(fileChooser.getCurrentDirectory().getPath());
|
||||
openFile(fileChooser.getSelectedFile());
|
||||
@@ -346,7 +321,7 @@ public class MainWindow extends JFrame {
|
||||
}
|
||||
|
||||
private void initMenuAndToolbar() {
|
||||
Action openAction = new AbstractAction(NLS.str("file.open"), ICON_OPEN) {
|
||||
Action openAction = new AbstractAction(NLS.str("file.open_action"), ICON_OPEN) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
openFile();
|
||||
@@ -569,8 +544,8 @@ public class MainWindow extends JFrame {
|
||||
splitPane.setResizeWeight(SPLIT_PANE_RESIZE_WEIGHT);
|
||||
mainPanel.add(splitPane);
|
||||
|
||||
DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode(NLS.str("msg.open_file"));
|
||||
treeModel = new DefaultTreeModel(treeRoot);
|
||||
DefaultMutableTreeNode treeRootNode = new DefaultMutableTreeNode(NLS.str("msg.open_file"));
|
||||
treeModel = new DefaultTreeModel(treeRootNode);
|
||||
tree = new JTree(treeModel);
|
||||
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
||||
tree.addMouseListener(new MouseAdapter() {
|
||||
@@ -625,7 +600,7 @@ public class MainWindow extends JFrame {
|
||||
tabbedPane = new TabbedPane(this);
|
||||
splitPane.setRightComponent(tabbedPane);
|
||||
|
||||
dropTarget = new DropTarget(this, DnDConstants.ACTION_COPY, new MainDropTarget(this));
|
||||
new DropTarget(this, DnDConstants.ACTION_COPY, new MainDropTarget(this));
|
||||
|
||||
setContentPane(mainPanel);
|
||||
setTitle(DEFAULT_TITLE);
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.SwingWorker;
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
public class ProgressPanel extends JPanel implements PropertyChangeListener {
|
||||
|
||||
private static final long serialVersionUID = -3238438119672015733L;
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import jadx.gui.utils.TextStandardActions;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import java.awt.Color;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
@@ -24,6 +15,10 @@ import org.fife.ui.rtextarea.SearchResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.TextStandardActions;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
class SearchBar extends JToolBar {
|
||||
private static final long serialVersionUID = 1836871286618633003L;
|
||||
|
||||
|
||||
@@ -1,45 +1,26 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.TextStandardActions;
|
||||
import jadx.gui.utils.search.TextSearchIndex;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.WindowConstants;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.TextStandardActions;
|
||||
import jadx.gui.utils.search.TextSearchIndex;
|
||||
|
||||
public class SearchDialog extends CommonSearchDialog {
|
||||
|
||||
private static final long serialVersionUID = -5105405456969134105L;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SearchDialog.class);
|
||||
|
||||
enum SearchOptions {
|
||||
CLASS,
|
||||
METHOD,
|
||||
@@ -56,20 +37,11 @@ public class SearchDialog extends CommonSearchDialog {
|
||||
this.options = options;
|
||||
|
||||
initUI();
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
openInit();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
registerInitOnOpen();
|
||||
loadWindowPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void openInit() {
|
||||
prepare();
|
||||
String lastSearch = cache.getLastSearch();
|
||||
|
||||
@@ -1,27 +1,9 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import jadx.api.ResourceFile;
|
||||
import jadx.api.ResourceType;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.treemodel.JResource;
|
||||
import jadx.gui.utils.JumpManager;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.Position;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicButtonUI;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
@@ -37,6 +19,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.ResourceFile;
|
||||
import jadx.api.ResourceType;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.treemodel.JResource;
|
||||
import jadx.gui.utils.JumpManager;
|
||||
import jadx.gui.utils.NLS;
|
||||
import jadx.gui.utils.Position;
|
||||
import jadx.gui.utils.Utils;
|
||||
|
||||
class TabbedPane extends JTabbedPane {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TabbedPane.class);
|
||||
@@ -45,9 +36,9 @@ class TabbedPane extends JTabbedPane {
|
||||
private static final ImageIcon ICON_CLOSE = Utils.openIcon("cross");
|
||||
private static final ImageIcon ICON_CLOSE_INACTIVE = Utils.openIcon("cross_grayed");
|
||||
|
||||
private final MainWindow mainWindow;
|
||||
private final Map<JNode, ContentPanel> openTabs = new LinkedHashMap<JNode, ContentPanel>();
|
||||
private JumpManager jumps = new JumpManager();
|
||||
private final transient MainWindow mainWindow;
|
||||
private final transient Map<JNode, ContentPanel> openTabs = new LinkedHashMap<>();
|
||||
private transient JumpManager jumps = new JumpManager();
|
||||
|
||||
TabbedPane(MainWindow window) {
|
||||
mainWindow = window;
|
||||
@@ -255,7 +246,7 @@ class TabbedPane extends JTabbedPane {
|
||||
closeOther.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<ContentPanel> contentPanels = new ArrayList<ContentPanel>(openTabs.values());
|
||||
List<ContentPanel> contentPanels = new ArrayList<>(openTabs.values());
|
||||
for (ContentPanel panel : contentPanels) {
|
||||
if (panel != contentPanel) {
|
||||
closeCodePanel(panel);
|
||||
@@ -298,7 +289,7 @@ class TabbedPane extends JTabbedPane {
|
||||
}
|
||||
|
||||
public void closeAllTabs() {
|
||||
List<ContentPanel> contentPanels = new ArrayList<ContentPanel>(openTabs.values());
|
||||
List<ContentPanel> contentPanels = new ArrayList<>(openTabs.values());
|
||||
for (ContentPanel panel : contentPanels) {
|
||||
closeCodePanel(panel);
|
||||
}
|
||||
|
||||
@@ -1,51 +1,28 @@
|
||||
package jadx.gui.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.utils.CodeUsageInfo;
|
||||
import jadx.gui.utils.NLS;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class UsageDialog extends CommonSearchDialog {
|
||||
|
||||
private static final long serialVersionUID = -5105405789969134105L;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UsageDialog.class);
|
||||
|
||||
private final JNode node;
|
||||
private final transient JNode node;
|
||||
|
||||
public UsageDialog(MainWindow mainWindow, JNode node) {
|
||||
super(mainWindow);
|
||||
this.node = node;
|
||||
|
||||
initUI();
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
openInit();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
registerInitOnOpen();
|
||||
loadWindowPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void openInit() {
|
||||
prepare();
|
||||
}
|
||||
@@ -57,6 +34,7 @@ public class UsageDialog extends CommonSearchDialog {
|
||||
|
||||
@Override
|
||||
protected void loadStart() {
|
||||
// no op
|
||||
}
|
||||
|
||||
private synchronized void performSearch() {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package jadx.gui.update;
|
||||
|
||||
import jadx.api.JadxDecompiler;
|
||||
import jadx.gui.update.data.Release;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
@@ -14,11 +11,13 @@ import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import jadx.api.JadxDecompiler;
|
||||
import jadx.gui.update.data.Release;
|
||||
|
||||
public class JadxUpdate {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JadxUpdate.class);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package jadx.gui.utils;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import jadx.gui.jobs.DecompileJob;
|
||||
import jadx.gui.jobs.IndexJob;
|
||||
import jadx.gui.utils.search.TextSearchIndex;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CacheObject {
|
||||
|
||||
private DecompileJob decompileJob;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package jadx.gui.utils;
|
||||
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.JavaMethod;
|
||||
import jadx.api.JavaNode;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.JavaMethod;
|
||||
import jadx.api.JavaNode;
|
||||
|
||||
public class CodeLinesInfo {
|
||||
private NavigableMap<Integer, JavaNode> map = new TreeMap<Integer, JavaNode>();
|
||||
private NavigableMap<Integer, JavaNode> map = new TreeMap<>();
|
||||
|
||||
public CodeLinesInfo(JavaClass cls) {
|
||||
addClass(cls);
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package jadx.gui.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jadx.api.CodePosition;
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.JavaNode;
|
||||
@@ -7,16 +13,10 @@ import jadx.gui.treemodel.CodeNode;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
import jadx.gui.utils.search.StringRef;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CodeUsageInfo {
|
||||
|
||||
public static class UsageInfo {
|
||||
private final List<CodeNode> usageList = new ArrayList<CodeNode>();
|
||||
private final List<CodeNode> usageList = new ArrayList<>();
|
||||
|
||||
public List<CodeNode> getUsageList() {
|
||||
return usageList;
|
||||
@@ -29,7 +29,7 @@ public class CodeUsageInfo {
|
||||
this.nodeCache = nodeCache;
|
||||
}
|
||||
|
||||
private final Map<JNode, UsageInfo> usageMap = new HashMap<JNode, UsageInfo>();
|
||||
private final Map<JNode, UsageInfo> usageMap = new HashMap<>();
|
||||
|
||||
public void processClass(JavaClass javaClass, CodeLinesInfo linesInfo, List<StringRef> lines) {
|
||||
Map<CodePosition, JavaNode> usage = javaClass.getUsageMap();
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package jadx.gui.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.JavaField;
|
||||
import jadx.api.JavaMethod;
|
||||
@@ -10,12 +13,9 @@ import jadx.gui.treemodel.JField;
|
||||
import jadx.gui.treemodel.JMethod;
|
||||
import jadx.gui.treemodel.JNode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JNodeCache {
|
||||
|
||||
private final Map<JavaNode, JNode> cache = new HashMap<JavaNode, JNode>();
|
||||
private final Map<JavaNode, JNode> cache = new HashMap<>();
|
||||
|
||||
public JNode makeFrom(JavaNode javaNode) {
|
||||
if (javaNode == null) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
public class JumpManager {
|
||||
|
||||
private List<Position> list = new ArrayList<Position>();
|
||||
private List<Position> list = new ArrayList<>();
|
||||
private int currentPos = 0;
|
||||
|
||||
public void addPosition(Position pos) {
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
package jadx.gui.utils;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextArea;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Desktop;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -64,9 +58,7 @@ public class Link extends JLabel implements MouseListener {
|
||||
try {
|
||||
desktop.browse(new java.net.URI(url));
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
LOG.debug("Open url error", e);
|
||||
} catch (URISyntaxException e) {
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Open url error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import ch.qos.logback.classic.PatternLayout;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.Layout;
|
||||
import ch.qos.logback.core.read.CyclicBufferAppender;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package jadx.gui.utils;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -10,7 +9,7 @@ import java.util.List;
|
||||
public class OverlayIcon implements Icon {
|
||||
|
||||
private final Icon icon;
|
||||
private final List<Icon> icons = new ArrayList<Icon>(4);
|
||||
private final List<Icon> icons = new ArrayList<>(4);
|
||||
|
||||
private static final double A = 0.8;
|
||||
private static final double B = 0.2;
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package jadx.gui.utils;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.UndoableEditEvent;
|
||||
import javax.swing.event.UndoableEditListener;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import javax.swing.undo.UndoManager;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
package jadx.gui.utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.net.URL;
|
||||
|
||||
import jadx.core.dex.info.AccessInfo;
|
||||
import jadx.core.dex.instructions.args.ArgType;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.KeyStroke;
|
||||
import java.net.URL;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private static final ImageIcon ICON_STATIC = Utils.openIcon("static_co");
|
||||
|
||||
@@ -4,10 +4,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CodeIndex<T> extends SearchIndex<T> {
|
||||
public class CodeIndex<T> implements SearchIndex<T> {
|
||||
|
||||
private final List<StringRef> keys = new ArrayList<StringRef>();
|
||||
private final List<T> values = new ArrayList<T>();
|
||||
private final List<StringRef> keys = new ArrayList<>();
|
||||
private final List<T> values = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void put(String str, T value) {
|
||||
@@ -34,7 +34,7 @@ public class CodeIndex<T> extends SearchIndex<T> {
|
||||
if (size == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<T> results = new ArrayList<T>();
|
||||
List<T> results = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
StringRef key = keys.get(i);
|
||||
if (key.indexOf(str) != -1) {
|
||||
|
||||
@@ -2,19 +2,15 @@ package jadx.gui.utils.search;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class SearchIndex<V> {
|
||||
public interface SearchIndex<V> {
|
||||
|
||||
public abstract void put(String str, V value);
|
||||
void put(String str, V value);
|
||||
|
||||
public void put(StringRef str, V value) {
|
||||
throw new UnsupportedOperationException("StringRef put not supported");
|
||||
}
|
||||
void put(StringRef str, V value);
|
||||
|
||||
public boolean isStringRefSupported() {
|
||||
return false;
|
||||
}
|
||||
boolean isStringRefSupported();
|
||||
|
||||
public abstract List<V> getValuesForKeysContaining(String str);
|
||||
List<V> getValuesForKeysContaining(String str);
|
||||
|
||||
public abstract int size();
|
||||
int size();
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SimpleIndex<T> extends SearchIndex<T> {
|
||||
public class SimpleIndex<T> implements SearchIndex<T> {
|
||||
|
||||
private final List<String> keys = new ArrayList<String>();
|
||||
private final List<T> values = new ArrayList<T>();
|
||||
private final List<String> keys = new ArrayList<>();
|
||||
private final List<T> values = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void put(String str, T value) {
|
||||
@@ -15,13 +15,23 @@ public class SimpleIndex<T> extends SearchIndex<T> {
|
||||
values.add(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(StringRef str, T value) {
|
||||
throw new UnsupportedOperationException("StringRef not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStringRefSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> getValuesForKeysContaining(String str) {
|
||||
int size = size();
|
||||
if (size == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<T> results = new ArrayList<T>();
|
||||
List<T> results = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
String key = keys.get(i);
|
||||
if (key.contains(str)) {
|
||||
|
||||
@@ -114,7 +114,7 @@ public class StringRef implements CharSequence {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int pos = -targetLen;
|
||||
List<StringRef> list = new ArrayList<StringRef>();
|
||||
List<StringRef> list = new ArrayList<>();
|
||||
while (true) {
|
||||
int start = pos + targetLen;
|
||||
pos = indexOf(str, 0, len, splitBy, 0, targetLen, start);
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package jadx.gui.utils.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.JavaField;
|
||||
import jadx.api.JavaMethod;
|
||||
@@ -11,12 +17,6 @@ import jadx.gui.ui.CommonSearchDialog;
|
||||
import jadx.gui.utils.CodeLinesInfo;
|
||||
import jadx.gui.utils.JNodeCache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TextSearchIndex {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TextSearchIndex.class);
|
||||
@@ -28,14 +28,14 @@ public class TextSearchIndex {
|
||||
private SearchIndex<JNode> fldNamesIndex;
|
||||
private SearchIndex<CodeNode> codeIndex;
|
||||
|
||||
private List<JavaClass> skippedClasses = new ArrayList<JavaClass>();
|
||||
private List<JavaClass> skippedClasses = new ArrayList<>();
|
||||
|
||||
public TextSearchIndex(JNodeCache nodeCache) {
|
||||
this.nodeCache = nodeCache;
|
||||
this.clsNamesIndex = new SimpleIndex<JNode>();
|
||||
this.mthNamesIndex = new SimpleIndex<JNode>();
|
||||
this.fldNamesIndex = new SimpleIndex<JNode>();
|
||||
this.codeIndex = new CodeIndex<CodeNode>();
|
||||
this.clsNamesIndex = new SimpleIndex<>();
|
||||
this.mthNamesIndex = new SimpleIndex<>();
|
||||
this.fldNamesIndex = new SimpleIndex<>();
|
||||
this.codeIndex = new CodeIndex<>();
|
||||
}
|
||||
|
||||
public void indexNames(JavaClass cls) {
|
||||
@@ -93,7 +93,7 @@ public class TextSearchIndex {
|
||||
return items;
|
||||
}
|
||||
} else {
|
||||
items = new ArrayList<CodeNode>();
|
||||
items = new ArrayList<>();
|
||||
}
|
||||
addSkippedClasses(items, text);
|
||||
return items;
|
||||
|
||||
Reference in New Issue
Block a user