Scoped script text search and search across multiple SWFs

This commit is contained in:
Jindra Petřík
2021-02-24 19:55:59 +01:00
parent d9513d4902
commit 9cac6ddb49
14 changed files with 343 additions and 68 deletions
@@ -22,6 +22,7 @@ import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@@ -30,6 +31,7 @@ import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
@@ -59,9 +61,25 @@ public class SearchDialog extends AppDialog {
public JRadioButton searchInTextsRadioButton = new JRadioButton(translate("checkbox.searchText"));
private JComboBox<String> scopeComboBox;
private int result = ERROR_OPTION;
public SearchDialog(Window owner, boolean replace) {
public static final int SCOPE_SELECTION = 0;
public static final int SCOPE_CURRENT_FILE = 1;
public static final int SCOPE_ALL_FILES = 2;
public int getCurrentScope() {
int index = scopeComboBox.getSelectedIndex();
if (scopeComboBox.getModel().getSize() == 3) {
return index;
} else {
return 1 + index;
}
}
public SearchDialog(Window owner, boolean replace, String selection) {
super(owner);
setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
ignoreCaseCheckBox.setSelected(true);
@@ -89,6 +107,19 @@ public class SearchDialog extends AppDialog {
cnt.add(panField);
}
panField = new JPanel(new FlowLayout());
List<String> scopeItems = new ArrayList<>();
if (selection != null) {
scopeItems.add(translate("scope.selection").replace("%selection%", selection));
}
scopeItems.add(translate("scope.currentFile"));
scopeItems.add(translate("scope.allFiles"));
panField.add(new JLabel(translate("label.scope")));
scopeComboBox = new JComboBox<>(scopeItems.toArray(new String[scopeItems.size()]));
panField.add(scopeComboBox);
cnt.add(panField);
JPanel checkPanel = new JPanel(new FlowLayout());
checkPanel.add(ignoreCaseCheckBox);
checkPanel.add(regexpCheckBox);
@@ -112,6 +143,10 @@ public class SearchDialog extends AppDialog {
rbPanel.add(searchInPCodeRadioButton);
rbPanel.add(searchInTextsRadioButton);
cnt.add(rbPanel);
searchInASRadioButton.addActionListener(this::searchTypeActionPerformed);
searchInPCodeRadioButton.addActionListener(this::searchTypeActionPerformed);
searchInTextsRadioButton.addActionListener(this::searchTypeActionPerformed);
}
cnt.add(panButtons);
@@ -127,6 +162,19 @@ public class SearchDialog extends AppDialog {
setIconImages(images);
}
private void searchTypeActionPerformed(ActionEvent e) {
if (searchInTextsRadioButton.isSelected()) {
if (scopeComboBox.getModel().getSize() == 3) {
scopeComboBox.setSelectedIndex(1);
} else {
scopeComboBox.setSelectedIndex(0);
}
scopeComboBox.setEnabled(false);
} else {
scopeComboBox.setEnabled(true);
}
}
@Override
public void setVisible(boolean b) {
if (b) {