gui: fix some sonar warnings
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package jadx.gui.jobs;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
@@ -39,13 +38,10 @@ public abstract class BackgroundJob {
|
||||
|
||||
private class ShutdownTask extends FutureTask<Boolean> {
|
||||
public ShutdownTask() {
|
||||
super(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
runJob();
|
||||
executor.shutdown();
|
||||
return executor.awaitTermination(5, TimeUnit.MINUTES);
|
||||
}
|
||||
super(() -> {
|
||||
runJob();
|
||||
executor.shutdown();
|
||||
return executor.awaitTermination(1, TimeUnit.HOURS);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
@@ -143,7 +145,7 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
protected JPanel initResultsTable() {
|
||||
ResultsTableCellRenderer renderer = new ResultsTableCellRenderer();
|
||||
resultsModel = new ResultsModel(renderer);
|
||||
resultsModel.addTableModelListener((e) -> updateProgressLabel());
|
||||
resultsModel.addTableModelListener(e -> updateProgressLabel());
|
||||
resultsTable = new ResultsTable(resultsModel);
|
||||
resultsTable.setShowHorizontalLines(false);
|
||||
resultsTable.setDragEnabled(false);
|
||||
@@ -183,24 +185,24 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED));
|
||||
|
||||
JPanel paginationPanel = new JPanel();
|
||||
paginationPanel.setAlignmentX( Component.LEFT_ALIGNMENT );
|
||||
paginationPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
paginationPanel.setLayout(new BoxLayout(paginationPanel, BoxLayout.X_AXIS));
|
||||
resultsInfoLabel = new JLabel("");
|
||||
|
||||
JButton nextPageButton = new JButton("->");
|
||||
nextPageButton.setToolTipText(NLS.str("search_dialog.next_page"));
|
||||
nextPageButton.addActionListener((e) -> {
|
||||
nextPageButton.addActionListener(e -> {
|
||||
resultsModel.nextPage();
|
||||
resultsTable.updateTable();
|
||||
resultsTable.scrollRectToVisible(new Rectangle(0,0,1,1));
|
||||
resultsTable.scrollRectToVisible(new Rectangle(0, 0, 1, 1));
|
||||
});
|
||||
|
||||
JButton prevPageButton = new JButton("<-");
|
||||
prevPageButton.setToolTipText(NLS.str("search_dialog.prev_page"));
|
||||
prevPageButton.addActionListener((e) -> {
|
||||
prevPageButton.addActionListener(e -> {
|
||||
resultsModel.prevPage();
|
||||
resultsTable.updateTable();
|
||||
resultsTable.scrollRectToVisible(new Rectangle(0,0,1,1));
|
||||
resultsTable.scrollRectToVisible(new Rectangle(0, 0, 1, 1));
|
||||
});
|
||||
|
||||
paginationPanel.add(prevPageButton);
|
||||
@@ -309,8 +311,9 @@ public abstract class CommonSearchDialog extends JDialog {
|
||||
}
|
||||
|
||||
public int getDisplayedResultsStart() {
|
||||
if (rows.size() == 0)
|
||||
if (rows.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return start + 1;
|
||||
}
|
||||
|
||||
@@ -373,7 +376,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) {
|
||||
|
||||
@@ -27,8 +27,6 @@ import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -501,12 +499,7 @@ public class MainWindow extends JFrame {
|
||||
|
||||
flatPkgButton = new JToggleButton(ICON_FLAT_PKG);
|
||||
flatPkgButton.setSelected(isFlattenPackage);
|
||||
ActionListener flatPkgAction = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
toggleFlattenPackage();
|
||||
}
|
||||
};
|
||||
ActionListener flatPkgAction = e -> toggleFlattenPackage();
|
||||
flatPkgMenuItem.addActionListener(flatPkgAction);
|
||||
flatPkgButton.addActionListener(flatPkgAction);
|
||||
flatPkgButton.setToolTipText(NLS.str("menu.flatten"));
|
||||
@@ -568,8 +561,8 @@ public class MainWindow extends JFrame {
|
||||
tree.setCellRenderer(new DefaultTreeCellRenderer() {
|
||||
@Override
|
||||
public Component getTreeCellRendererComponent(JTree tree,
|
||||
Object value, boolean selected, boolean expanded,
|
||||
boolean isLeaf, int row, boolean focused) {
|
||||
Object value, boolean selected, boolean expanded,
|
||||
boolean isLeaf, int row, boolean focused) {
|
||||
Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused);
|
||||
if (value instanceof JNode) {
|
||||
setIcon(((JNode) value).getIcon());
|
||||
@@ -660,7 +653,7 @@ public class MainWindow extends JFrame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void menuSelected(MenuEvent e) {
|
||||
public void menuSelected(MenuEvent menuEvent) {
|
||||
recentFiles.removeAll();
|
||||
File openFile = wrapper.getOpenFile();
|
||||
String currentFile = openFile == null ? "" : openFile.getAbsolutePath();
|
||||
@@ -670,12 +663,7 @@ public class MainWindow extends JFrame {
|
||||
}
|
||||
JMenuItem menuItem = new JMenuItem(file);
|
||||
recentFiles.add(menuItem);
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
openFile(new File(file));
|
||||
}
|
||||
});
|
||||
menuItem.addActionListener(e -> openFile(new File(file)));
|
||||
}
|
||||
if (recentFiles.getItemCount() == 0) {
|
||||
recentFiles.add(new JMenuItem(NLS.str("menu.no_recent_files")));
|
||||
|
||||
@@ -6,11 +6,8 @@ import javax.swing.event.DocumentListener;
|
||||
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.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import jadx.gui.utils.NLS;
|
||||
@@ -28,7 +25,7 @@ public class SearchDialog extends CommonSearchDialog {
|
||||
CODE
|
||||
}
|
||||
|
||||
private Set<SearchOptions> options = EnumSet.allOf(SearchOptions.class);
|
||||
private Set<SearchOptions> options;
|
||||
|
||||
private JTextField searchField;
|
||||
private JCheckBox caseChBox;
|
||||
@@ -87,7 +84,6 @@ public class SearchDialog extends CommonSearchDialog {
|
||||
}
|
||||
|
||||
private class SearchFieldListener implements DocumentListener, ActionListener {
|
||||
|
||||
private Timer timer;
|
||||
|
||||
private synchronized void change() {
|
||||
@@ -126,11 +122,7 @@ public class SearchDialog extends CommonSearchDialog {
|
||||
new TextStandardActions(searchField);
|
||||
|
||||
caseChBox = new JCheckBox(NLS.str("search_dialog.ignorecase"));
|
||||
caseChBox.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
performSearch();
|
||||
}
|
||||
});
|
||||
caseChBox.addItemListener(e -> performSearch());
|
||||
|
||||
JCheckBox clsChBox = makeOptionsCheckBox(NLS.str("search_dialog.class"), SearchOptions.CLASS);
|
||||
JCheckBox mthChBox = makeOptionsCheckBox(NLS.str("search_dialog.method"), SearchOptions.METHOD);
|
||||
@@ -196,15 +188,13 @@ public class SearchDialog extends CommonSearchDialog {
|
||||
final JCheckBox chBox = new JCheckBox(name);
|
||||
chBox.setAlignmentX(LEFT_ALIGNMENT);
|
||||
chBox.setSelected(options.contains(opt));
|
||||
chBox.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (chBox.isSelected()) {
|
||||
options.add(opt);
|
||||
} else {
|
||||
options.remove(opt);
|
||||
}
|
||||
performSearch();
|
||||
chBox.addItemListener(e -> {
|
||||
if (chBox.isSelected()) {
|
||||
options.add(opt);
|
||||
} else {
|
||||
options.remove(opt);
|
||||
}
|
||||
performSearch();
|
||||
});
|
||||
return chBox;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
public class CodeIndex<T> implements SearchIndex<T> {
|
||||
|
||||
private final List<StringRef> keys = new ArrayList<>();
|
||||
private final List<T> values = new ArrayList<T>();
|
||||
private final List<T> values = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void put(String str, T value) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
public class SimpleIndex<T> implements SearchIndex<T> {
|
||||
|
||||
private final List<String> keys = new ArrayList<>();
|
||||
private final List<T> values = new ArrayList<T>();
|
||||
private final List<T> values = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void put(String str, T value) {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package jadx.gui.utils.search;
|
||||
|
||||
import static jadx.gui.utils.Utils.caseChar;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static jadx.gui.utils.Utils.caseChar;
|
||||
|
||||
public class StringRef implements CharSequence {
|
||||
|
||||
private final String refStr;
|
||||
@@ -82,8 +83,8 @@ public class StringRef implements CharSequence {
|
||||
}
|
||||
|
||||
private static int indexOf(String source, int sourceOffset, int sourceCount,
|
||||
String target, int targetOffset, int targetCount,
|
||||
int fromIndex, boolean caseInsensitive) {
|
||||
String target, int targetOffset, int targetCount,
|
||||
int fromIndex, boolean caseInsensitive) {
|
||||
if (fromIndex >= sourceCount) {
|
||||
return (targetCount == 0 ? sourceCount : -1);
|
||||
}
|
||||
@@ -187,5 +188,4 @@ public class StringRef implements CharSequence {
|
||||
int offset = this.offset;
|
||||
return refStr.substring(offset, offset + len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user