Commit 1d3e6ecb authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

chore: use lambda (PR #544)

parent a5a951cf
......@@ -34,24 +34,21 @@ public class IndexJob extends BackgroundJob {
cache.setTextIndex(index);
cache.setUsageInfo(usageInfo);
for (final JavaClass cls : wrapper.getIncludedClasses()) {
addTask(new Runnable() {
@Override
public void run() {
try {
index.indexNames(cls);
addTask(() -> {
try {
index.indexNames(cls);
CodeLinesInfo linesInfo = new CodeLinesInfo(cls);
List<StringRef> lines = splitLines(cls);
CodeLinesInfo linesInfo = new CodeLinesInfo(cls);
List<StringRef> lines = splitLines(cls);
usageInfo.processClass(cls, linesInfo, lines);
if (Utils.isFreeMemoryAvailable()) {
index.indexCode(cls, linesInfo, lines);
} else {
index.classCodeIndexSkipped(cls);
}
} catch (Exception e) {
LOG.error("Index error in class: {}", cls.getFullName(), e);
usageInfo.processClass(cls, linesInfo, lines);
if (Utils.isFreeMemoryAvailable()) {
index.indexCode(cls, linesInfo, lines);
} else {
index.classCodeIndexSkipped(cls);
}
} catch (Exception e) {
LOG.error("Index error in class: {}", cls.getFullName(), e);
}
});
}
......
......@@ -185,12 +185,9 @@ public class MainWindow extends JFrame {
JadxUpdate.check(new IUpdateCallback() {
@Override
public void onUpdate(final Release r) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
updateLink.setText(NLS.str("menu.update_label", r.getName()));
updateLink.setVisible(true);
}
SwingUtilities.invokeLater(() -> {
updateLink.setText(NLS.str("menu.update_label", r.getName()));
updateLink.setVisible(true);
});
}
});
......
......@@ -2,8 +2,6 @@ package jadx.gui.ui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
......@@ -38,12 +36,7 @@ public class ProgressPanel extends JPanel implements PropertyChangeListener {
cancelButton.setBorderPainted(false);
cancelButton.setFocusPainted(false);
cancelButton.setContentAreaFilled(false);
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mainWindow.cancelBackgroundJobs();
}
});
cancelButton.addActionListener(e -> mainWindow.cancelBackgroundJobs());
add(cancelButton);
}
}
......
package jadx.gui.ui.codearea;
import javax.swing.*;
import javax.swing.event.PopupMenuListener;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JPopupMenu;
import javax.swing.JViewport;
import javax.swing.SwingUtilities;
import javax.swing.text.BadLocationException;
import javax.swing.text.Caret;
import javax.swing.text.DefaultCaret;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
......@@ -91,12 +95,12 @@ public final class CodeArea extends RSyntaxTextArea {
}
private void addMenuItems(JClass jCls) {
Action findUsage = new FindUsageAction(contentPanel, this, jCls);
FindUsageAction findUsage = new FindUsageAction(contentPanel, this, jCls);
JPopupMenu popup = getPopupMenu();
popup.addSeparator();
popup.add(findUsage);
popup.addPopupMenuListener((PopupMenuListener) findUsage);
popup.addPopupMenuListener(findUsage);
}
public void loadSettings() {
......
......@@ -3,7 +3,6 @@ package jadx.gui.ui.codearea;
import javax.swing.*;
import javax.swing.text.BadLocationException;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
......@@ -40,6 +39,7 @@ class SearchBar extends JToolBar {
private final JCheckBox wholeWordCB;
private final JCheckBox matchCaseCB;
private ActionListener forwardListener = e -> search(0);
public SearchBar(RSyntaxTextArea textArea) {
rTextArea = textArea;
......@@ -64,55 +64,41 @@ class SearchBar extends JToolBar {
}
}
});
searchField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
search(1);
}
});
searchField.addActionListener(e -> search(1));
new TextStandardActions(searchField);
add(searchField);
JButton prevButton = new JButton(NLS.str("search.previous"));
prevButton.setIcon(ICON_UP);
prevButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
search(-1);
}
});
prevButton.addActionListener(e -> search(-1));
prevButton.setBorderPainted(false);
add(prevButton);
JButton nextButton = new JButton(NLS.str("search.next"));
nextButton.setIcon(ICON_DOWN);
nextButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
search(1);
}
});
nextButton.addActionListener(e -> search(1));
nextButton.setBorderPainted(false);
add(nextButton);
markAllCB = new JCheckBox(NLS.str("search.mark_all"));
markAllCB.addActionListener(new ForwardListener());
markAllCB.addActionListener(forwardListener);
add(markAllCB);
regexCB = new JCheckBox(NLS.str("search.regex"));
regexCB.addActionListener(new ForwardListener());
regexCB.addActionListener(forwardListener);
add(regexCB);
matchCaseCB = new JCheckBox(NLS.str("search.match_case"));
matchCaseCB.addActionListener(new ForwardListener());
matchCaseCB.addActionListener(forwardListener);
add(matchCaseCB);
wholeWordCB = new JCheckBox(NLS.str("search.whole_word"));
wholeWordCB.addActionListener(new ForwardListener());
wholeWordCB.addActionListener(forwardListener);
add(wholeWordCB);
JButton closeButton = new JButton();
closeButton.setIcon(ICON_CLOSE);
closeButton.addActionListener(l -> toggle());
closeButton.addActionListener(e -> toggle());
closeButton.setBorderPainted(false);
add(closeButton);
......@@ -181,11 +167,4 @@ class SearchBar extends JToolBar {
searchField.setBackground(COLOR_BG_NORMAL);
}
}
private class ForwardListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
search(0);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment