replace text menu item (functioonality not implemented, yet)

This commit is contained in:
honfika@gmail.com
2014-12-21 18:52:49 +01:00
parent 3cf464a78f
commit 8cf907e3b8
15 changed files with 218 additions and 24 deletions

View File

@@ -48,13 +48,14 @@ public class SearchDialog extends AppDialog implements ActionListener {
private static final String ACTION_CANCEL = "CANCEL";
public JTextField searchField = new MyTextField();
public JTextField replaceField = new MyTextField();
public JCheckBox ignoreCaseCheckBox = new JCheckBox(translate("checkbox.ignorecase"));
public JCheckBox regexpCheckBox = new JCheckBox(translate("checkbox.regexp"));
public JRadioButton searchInASRadioButton = new JRadioButton(translate("checkbox.searchAS"));
public JRadioButton searchInTextsRadioButton = new JRadioButton(translate("checkbox.searchText"));
public boolean result = false;
public SearchDialog(Window owner) {
public SearchDialog(Window owner, boolean replace) {
super(owner);
setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
ignoreCaseCheckBox.setSelected(true);
@@ -75,34 +76,44 @@ public class SearchDialog extends AppDialog implements ActionListener {
panField.add(new JLabel(translate("label.searchtext")));
panField.add(searchField);
cnt.add(panField);
if (replace) {
panField = new JPanel(new FlowLayout());
replaceField.setPreferredSize(new Dimension(250, replaceField.getPreferredSize().height));
panField.add(new JLabel(translate("label.replacementtext")));
panField.add(replaceField);
cnt.add(panField);
}
JPanel checkPanel = new JPanel(new FlowLayout());
checkPanel.add(ignoreCaseCheckBox);
checkPanel.add(regexpCheckBox);
cnt.add(checkPanel);
ButtonGroup group = new ButtonGroup();
group.add(searchInASRadioButton);
group.add(searchInTextsRadioButton);
if (!replace) {
ButtonGroup group = new ButtonGroup();
group.add(searchInASRadioButton);
group.add(searchInTextsRadioButton);
JPanel rbPanel = new JPanel(new FlowLayout());
searchInASRadioButton.setSelected(true);
searchInTextsRadioButton.setSelected(false);
rbPanel.add(searchInASRadioButton);
rbPanel.add(searchInTextsRadioButton);
cnt.add(rbPanel);
JPanel rbPanel = new JPanel(new FlowLayout());
searchInASRadioButton.setSelected(true);
searchInTextsRadioButton.setSelected(false);
rbPanel.add(searchInASRadioButton);
rbPanel.add(searchInTextsRadioButton);
cnt.add(rbPanel);
}
cnt.add(panButtons);
getRootPane().setDefaultButton(okButton);
View.centerScreen(this);
//View.setWindowIcon(this);
setIconImage(View.loadImage("search16"));
setTitle(translate("dialog.title"));
setIconImage(View.loadImage(replace ? "replace16" : "search16"));
setTitle(replace ? translate("dialog.title.replace") : translate("dialog.title"));
setModalityType(ModalityType.APPLICATION_MODAL);
pack();
List<Image> images = new ArrayList<>();
images.add(View.loadImage("search16"));
images.add(View.loadImage("search32"));
images.add(View.loadImage(replace ? "replace16" : "search16"));
images.add(View.loadImage(replace ? "replace32" : "search32"));
setIconImages(images);
}
@@ -117,7 +128,7 @@ public class SearchDialog extends AppDialog implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == ACTION_OK) {
if (e.getActionCommand().equals(ACTION_OK)) {
if (regexpCheckBox.isSelected()) {
try {
Pattern pat = Pattern.compile(searchField.getText());