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