From 9b93d34988f428579d98e85b2323e87dc1ad2688 Mon Sep 17 00:00:00 2001 From: Radek Davidek Date: Tue, 10 Feb 2026 17:13:39 +0100 Subject: [PATCH] search dialog redesign --- .../kfmanager/service/FileOperations.java | 81 ++-- .../cz/kamma/kfmanager/ui/FileEditor.java | 55 ++- .../cz/kamma/kfmanager/ui/SearchDialog.java | 353 ++++++++++++------ 3 files changed, 323 insertions(+), 166 deletions(-) diff --git a/src/main/java/cz/kamma/kfmanager/service/FileOperations.java b/src/main/java/cz/kamma/kfmanager/service/FileOperations.java index 6c87ba0..5f97c84 100644 --- a/src/main/java/cz/kamma/kfmanager/service/FileOperations.java +++ b/src/main/java/cz/kamma/kfmanager/service/FileOperations.java @@ -11,6 +11,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.regex.Pattern; +import java.util.regex.Matcher; import java.util.zip.*; import net.lingala.zip4j.ZipFile; @@ -656,35 +657,54 @@ public class FileOperations { * Search files by filename pattern and/or content text. * If both are provided, both must match. */ - public static void search(File directory, String filenamePattern, String contentText, boolean recursive, boolean searchArchives, boolean wholeWord, boolean caseSensitive, SearchCallback callback) throws IOException { + public static void search(File directory, String filenamePattern, String contentText, int maxDepth, boolean searchArchives, boolean wholeWord, boolean caseSensitive, boolean filenameIsRegex, boolean contentIsRegex, SearchCallback callback) throws IOException { Pattern filenameRegex = null; String filenameLower = null; if (filenamePattern != null && !filenamePattern.isEmpty()) { - filenameLower = filenamePattern.toLowerCase(); - if (filenamePattern.contains("*") || filenamePattern.contains("?")) { - String regex = filenamePattern - .replace(".", "\\.") - .replace("*", ".*") - .replace("?", "."); - filenameRegex = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); + if (filenameIsRegex) { + try { + filenameRegex = Pattern.compile(filenamePattern, caseSensitive ? 0 : Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); + } catch (Exception e) { + throw new IOException("Invalid filename RegEx: " + e.getMessage()); + } + } else { + filenameLower = caseSensitive ? filenamePattern : filenamePattern.toLowerCase(); + if (filenamePattern.contains("*") || filenamePattern.contains("?")) { + String regex = filenamePattern + .replace(".", "\\.") + .replace("*", ".*") + .replace("?", "."); + filenameRegex = Pattern.compile(regex, caseSensitive ? 0 : Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); + } } } Pattern contentPattern = null; if (contentText != null && !contentText.isEmpty()) { - String quote = Pattern.quote(contentText); - String regex = wholeWord ? "(? findNext()); @@ -135,6 +139,7 @@ public class FileEditor extends JFrame { searchPanel.add(searchField); searchPanel.add(wholeWordCheckBox); searchPanel.add(caseSensitiveCheckBox); + searchPanel.add(regexCheckBox); searchPanel.add(nextBtn); searchPanel.add(prevBtn); searchPanel.add(closeBtn); @@ -147,6 +152,7 @@ public class FileEditor extends JFrame { searchPanel.setVisible(true); wholeWordCheckBox.setSelected(lastWholeWord); caseSensitiveCheckBox.setSelected(lastCaseSensitive); + regexCheckBox.setSelected(lastRegex); String selection = textArea.getSelectedText(); if (selection != null && !selection.isEmpty() && !selection.contains("\n")) { searchField.setText(selection); @@ -194,6 +200,7 @@ public class FileEditor extends JFrame { lastSearchValue = text; lastWholeWord = wholeWordCheckBox.isSelected(); lastCaseSensitive = caseSensitiveCheckBox.isSelected(); + lastRegex = regexCheckBox.isSelected(); updateSearchHistory(text); if (searchField.getText().isEmpty()) searchField.setText(text); @@ -205,23 +212,38 @@ public class FileEditor extends JFrame { if (textArea.getSelectionEnd() > textArea.getSelectionStart()) { String selected = content.substring(textArea.getSelectionStart(), textArea.getSelectionEnd()); boolean match; - if (lastCaseSensitive) { - match = selected.equals(text); + if (lastRegex) { + try { + int flags = (!lastCaseSensitive) ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0; + if (Pattern.compile(text, flags).matcher(selected).matches()) { + start = textArea.getSelectionEnd(); + } + } catch (Exception ignore) {} } else { - match = selected.equalsIgnoreCase(text); - } - if (match) { - start = textArea.getSelectionEnd(); + if (lastCaseSensitive) { + match = selected.equals(text); + } else { + match = selected.equalsIgnoreCase(text); + } + if (match) { + start = textArea.getSelectionEnd(); + } } } - String quote = Pattern.quote(text); - String regex = lastWholeWord ? "(? patternCombo; + private JComboBox searchInCombo; private JComboBox contentPatternCombo; + private JComboBox subDirCombo; private JCheckBox recursiveCheckBox; private JCheckBox contentSearchCheckBox; private JCheckBox archiveSearchCheckBox; private JCheckBox wholeWordCheckBox; private JCheckBox caseSensitiveCheckBox; + private JCheckBox regexCheckBox; + private JCheckBox regexContentCheckBox; + private JCheckBox everythingCheckBox; private JTable resultsTable; private ResultsTableModel tableModel; private JButton searchButton; @@ -69,19 +75,28 @@ public class SearchDialog extends JDialog { Color bg = config.getBackgroundColor(); if (bg == null) return; updateComponentBackground(getContentPane(), bg); + // Ensure some panels are transparent to let the main background show through + if (resultsTable.getTableHeader() != null) { + resultsTable.getTableHeader().setBackground(bg); + resultsTable.getTableHeader().setForeground(isDark(bg) ? Color.WHITE : Color.BLACK); + } } private void updateComponentBackground(Container container, Color bg) { if (container == null) return; - container.setBackground(bg); + if (!(container instanceof JViewport)) { + container.setBackground(bg); + } boolean dark = isDark(bg); Color selColor = config != null ? config.getSelectionColor() : null; for (Component c : container.getComponents()) { - if (c instanceof JPanel || c instanceof JToolBar || c instanceof JScrollPane || c instanceof JViewport || + if (c instanceof JPanel || c instanceof JToolBar || c instanceof JScrollPane || c instanceof JTabbedPane || c instanceof JButton || c instanceof JSplitPane || c instanceof JList || c instanceof JComboBox || c instanceof JTable) { - c.setBackground(bg); + if (!(c instanceof JViewport)) { + c.setBackground(bg); + } if (c instanceof JTable t) { if (t.getTableHeader() != null) { t.getTableHeader().setBackground(bg); @@ -128,98 +143,145 @@ public class SearchDialog extends JDialog { setLayout(new BorderLayout(10, 10)); ((JComponent) getContentPane()).setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - // Panel pro zadání kritérií - JPanel searchPanel = new JPanel(new GridBagLayout()); + // Panel pro zadání kritérií (NORTH panel) + JPanel northPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = new Insets(5, 5, 5, 5); + gbc.insets = new Insets(2, 5, 2, 5); gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.anchor = GridBagConstraints.WEST; + // Row 0: Search for: [patternCombo] gbc.gridx = 0; gbc.gridy = 0; - searchPanel.add(new JLabel("Search for:"), gbc); + gbc.weightx = 0; + northPanel.add(new JLabel("Search for:"), gbc); + + gbc.gridx = 1; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + java.util.List history = config != null ? config.getSearchHistory() : java.util.Collections.emptyList(); + patternCombo = new JComboBox<>(new DefaultComboBoxModel<>(history.toArray(new String[0]))); + patternCombo.setEditable(true); + try { patternCombo.setSelectedItem(""); patternCombo.getEditor().setItem(""); } catch (Exception ignore) {} + northPanel.add(patternCombo, gbc); + + // Row 1: Search in: [searchInCombo] [>>] [Drives] + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 1; + gbc.weightx = 0; + northPanel.add(new JLabel("Search in:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; - // Pattern input is an editable combo box populated from history - java.util.List history = config != null ? config.getSearchHistory() : java.util.Collections.emptyList(); - javax.swing.DefaultComboBoxModel historyModel = new javax.swing.DefaultComboBoxModel<>(); - for (String h : history) historyModel.addElement(h); - patternCombo = new JComboBox<>(historyModel); - patternCombo.setEditable(true); - // start with an empty editor so the field is blank on open - try { - patternCombo.setSelectedItem(""); - patternCombo.getEditor().setItem(""); - } catch (Exception ignore) {} - patternCombo.setToolTipText("Enter filename or pattern (* for any chars, ? for single char)"); - searchPanel.add(patternCombo, gbc); + gbc.gridwidth = 2; // Span across to the end since we removed side buttons + searchInCombo = new JComboBox<>(new String[]{searchDirectory.getAbsolutePath()}); + searchInCombo.setEditable(true); + northPanel.add(searchInCombo, gbc); - gbc.gridx = 0; - gbc.gridy = 1; - gbc.gridwidth = 2; - recursiveCheckBox = new JCheckBox("Include subdirectories", true); - searchPanel.add(recursiveCheckBox, gbc); - - // Row for content text pattern + // Row 2: [ ] RegEx [ ] Everything gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 1; - searchPanel.add(new JLabel("Text:"), gbc); - + gbc.weightx = 0; + regexCheckBox = new JCheckBox("RegEx"); + northPanel.add(regexCheckBox, gbc); + gbc.gridx = 1; - gbc.weightx = 1.0; - java.util.List contentHistory = config != null ? config.getContentSearchHistory() : java.util.Collections.emptyList(); - javax.swing.DefaultComboBoxModel contentHistoryModel = new javax.swing.DefaultComboBoxModel<>(); - for (String h : contentHistory) contentHistoryModel.addElement(h); - contentPatternCombo = new JComboBox<>(contentHistoryModel); - contentPatternCombo.setEditable(true); - try { contentPatternCombo.setSelectedItem(""); contentPatternCombo.getEditor().setItem(""); } catch (Exception ignore) {} - contentPatternCombo.setToolTipText("Text to search inside files"); - searchPanel.add(contentPatternCombo, gbc); + gbc.gridwidth = 2; + everythingCheckBox = new JCheckBox("'Everything'"); + northPanel.add(everythingCheckBox, gbc); - gbc.gridx = 0; + // Row 3: [ ] Search archives ... + gbc.gridx = 1; gbc.gridy = 3; gbc.gridwidth = 2; - contentSearchCheckBox = new JCheckBox("Search inside file contents", false); - searchPanel.add(contentSearchCheckBox, gbc); + archiveSearchCheckBox = new JCheckBox("Search archives (all except for UC2)", false); + northPanel.add(archiveSearchCheckBox, gbc); + // Row 4: Search in subdirectories: [ComboBox] gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 1; - wholeWordCheckBox = new JCheckBox("Whole word only", false); - searchPanel.add(wholeWordCheckBox, gbc); - + northPanel.add(new JLabel("Search in subdirectories:"), gbc); + gbc.gridx = 1; - caseSensitiveCheckBox = new JCheckBox("Case sensitive", false); - searchPanel.add(caseSensitiveCheckBox, gbc); - + gbc.gridwidth = 2; + String[] subDirOptions = {"all (unlimited depth)", "current directory only", "1 level", "2 levels", "3 levels"}; + subDirCombo = new JComboBox<>(subDirOptions); + recursiveCheckBox = new JCheckBox("", true); // keep for logic, but hidden/synced + subDirCombo.addActionListener(e -> { + recursiveCheckBox.setSelected(subDirCombo.getSelectedIndex() == 0); + }); + northPanel.add(subDirCombo, gbc); + + // Separator gbc.gridx = 0; gbc.gridy = 5; - gbc.gridwidth = 2; - archiveSearchCheckBox = new JCheckBox("Search inside archives", false); - archiveSearchCheckBox.setMnemonic(KeyEvent.VK_R); - searchPanel.add(archiveSearchCheckBox, gbc); - + gbc.gridwidth = 3; + northPanel.add(new JSeparator(JSeparator.HORIZONTAL), gbc); + + // Row 6: [x] Find text: [contentPatternCombo] + gbc.gridx = 0; gbc.gridy = 6; - JLabel pathLabel = new JLabel("Directory: " + searchDirectory.getAbsolutePath()); - pathLabel.setFont(pathLabel.getFont().deriveFont(Font.ITALIC)); - searchPanel.add(pathLabel, gbc); + gbc.gridwidth = 1; + contentSearchCheckBox = new JCheckBox("Find text:"); + northPanel.add(contentSearchCheckBox, gbc); - add(searchPanel, BorderLayout.NORTH); + gbc.gridx = 1; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + java.util.List contentHistory = config != null ? config.getContentSearchHistory() : java.util.Collections.emptyList(); + contentPatternCombo = new JComboBox<>(new DefaultComboBoxModel<>(contentHistory.toArray(new String[0]))); + contentPatternCombo.setEditable(true); + try { contentPatternCombo.setSelectedItem(""); contentPatternCombo.getEditor().setItem(""); } catch (Exception ignore) {} + // Enable/disable based on checkbox + contentPatternCombo.setEnabled(contentSearchCheckBox.isSelected()); + contentSearchCheckBox.addActionListener(e -> contentPatternCombo.setEnabled(contentSearchCheckBox.isSelected())); + northPanel.add(contentPatternCombo, gbc); - // Tabulka s výsledky + // Row 7 & 8: Options + JPanel optionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); + + JPanel leftOptions = new JPanel(new GridLayout(0, 1)); + wholeWordCheckBox = new JCheckBox("Whole words only"); + caseSensitiveCheckBox = new JCheckBox("Case sensitive"); + regexContentCheckBox = new JCheckBox("RegEx (2)"); + leftOptions.add(wholeWordCheckBox); + leftOptions.add(caseSensitiveCheckBox); + leftOptions.add(regexContentCheckBox); + + // Sync enabled state + ActionListener contentSync = e -> { + boolean sel = contentSearchCheckBox.isSelected(); + contentPatternCombo.setEnabled(sel); + wholeWordCheckBox.setEnabled(sel); + caseSensitiveCheckBox.setEnabled(sel); + regexContentCheckBox.setEnabled(sel); + }; + contentSearchCheckBox.addActionListener(contentSync); + contentSync.actionPerformed(null); + + optionsPanel.add(leftOptions); + + gbc.gridx = 1; + gbc.gridy = 7; + gbc.gridwidth = 2; + northPanel.add(optionsPanel, gbc); + + add(northPanel, BorderLayout.NORTH); + + // Tabulka s výsledky (CENTER panel) tableModel = new ResultsTableModel(); resultsTable = new JTable(tableModel); resultsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resultsTable.setFont(new Font("Monospaced", Font.PLAIN, 12)); - // let the table columns adjust when the dialog is resized resultsTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); resultsTable.getColumnModel().getColumn(0).setPreferredWidth(400); resultsTable.getColumnModel().getColumn(1).setPreferredWidth(100); resultsTable.getColumnModel().getColumn(2).setPreferredWidth(150); - // Double-click pro otevření umístění resultsTable.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent e) { @@ -229,7 +291,6 @@ public class SearchDialog extends JDialog { } }); - // Enter pro otevření umístění resultsTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "openLocation"); resultsTable.getActionMap().put("openLocation", new AbstractAction() { @Override @@ -238,7 +299,6 @@ public class SearchDialog extends JDialog { } }); - // Enable/disable view/edit buttons depending on selection resultsTable.getSelectionModel().addListSelectionListener(e -> { int sel = resultsTable.getSelectedRow(); boolean ok = false; @@ -255,67 +315,77 @@ public class SearchDialog extends JDialog { editButton.setEnabled(canEdit); }); - JScrollPane scrollPane = new JScrollPane(resultsTable); - scrollPane.setBorder(BorderFactory.createTitledBorder("Results")); - add(scrollPane, BorderLayout.CENTER); + JScrollPane scrollPane = new JScrollPane(resultsTable); + scrollPane.setBorder(BorderFactory.createTitledBorder("Results")); + add(scrollPane, BorderLayout.CENTER); - // Status bar with progress and message - statusLabel = new JLabel("Ready"); - statusProgressBar = new JProgressBar(); - statusProgressBar.setVisible(false); - statusProgressBar.setIndeterminate(false); - JPanel statusPanel = new JPanel(new BorderLayout(6, 6)); - statusPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); - statusPanel.add(statusLabel, BorderLayout.CENTER); - statusPanel.add(statusProgressBar, BorderLayout.EAST); - - // Panel with buttons - JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + // Side Buttons (EAST panel) + JPanel eastPanel = new JPanel(); + eastPanel.setLayout(new BoxLayout(eastPanel, BoxLayout.Y_AXIS)); + eastPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - searchButton = new JButton("Search"); - searchButton.addActionListener(e -> performSearch()); - - stopButton = new JButton("Cancel"); - stopButton.setEnabled(false); - stopButton.addActionListener(e -> { - searching = false; + searchButton = new JButton("Start search"); + searchButton.setMaximumSize(new Dimension(120, 30)); + searchButton.addActionListener(e -> performSearch()); + + stopButton = new JButton("Cancel"); + stopButton.setMaximumSize(new Dimension(120, 30)); stopButton.setEnabled(false); - statusLabel.setText("Cancelling..."); - }); - - viewButton = new JButton("View"); - viewButton.setEnabled(false); - viewButton.addActionListener(e -> viewSelectedFile()); - - editButton = new JButton("Edit"); - editButton.setEnabled(false); - editButton.addActionListener(e -> editSelectedFile()); - - cancelButton = new JButton("Close"); - cancelButton.addActionListener(e -> { - searching = false; - dispose(); - }); - - JButton openButton = new JButton("Open location"); - openButton.addActionListener(e -> openSelectedFile()); - - buttonPanel.add(searchButton); - buttonPanel.add(stopButton); - buttonPanel.add(viewButton); - buttonPanel.add(editButton); - buttonPanel.add(openButton); - buttonPanel.add(cancelButton); + stopButton.addActionListener(e -> { + searching = false; + stopButton.setEnabled(false); + statusLabel.setText("Cancelling..."); + }); - // Compose bottom area: status bar above buttons - JPanel bottomPanel = new JPanel(new BorderLayout()); - bottomPanel.add(statusPanel, BorderLayout.NORTH); - bottomPanel.add(buttonPanel, BorderLayout.SOUTH); - add(bottomPanel, BorderLayout.SOUTH); - - // Set search button as default so Enter starts search - getRootPane().setDefaultButton(searchButton); + eastPanel.add(searchButton); + eastPanel.add(Box.createVerticalStrut(5)); + eastPanel.add(stopButton); + add(eastPanel, BorderLayout.EAST); + + // Status bar with progress and message + statusLabel = new JLabel("Ready"); + statusProgressBar = new JProgressBar(); + statusProgressBar.setVisible(false); + statusProgressBar.setIndeterminate(false); + JPanel statusPanel = new JPanel(new BorderLayout(6, 6)); + statusPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); + statusPanel.add(statusLabel, BorderLayout.CENTER); + statusPanel.add(statusProgressBar, BorderLayout.EAST); + + // Bottom buttons panel + JPanel bottomButtonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + viewButton = new JButton("View"); + viewButton.setEnabled(false); + viewButton.addActionListener(e -> viewSelectedFile()); + + editButton = new JButton("Edit"); + editButton.setEnabled(false); + editButton.addActionListener(e -> editSelectedFile()); + + cancelButton = new JButton("Close"); + cancelButton.addActionListener(e -> { + searching = false; + dispose(); + }); + + JButton openButton = new JButton("Open location"); + openButton.addActionListener(e -> openSelectedFile()); + + bottomButtonPanel.add(viewButton); + bottomButtonPanel.add(editButton); + bottomButtonPanel.add(openButton); + bottomButtonPanel.add(cancelButton); + + JPanel bottomPanel = new JPanel(new BorderLayout()); + bottomPanel.add(statusPanel, BorderLayout.NORTH); + bottomPanel.add(bottomButtonPanel, BorderLayout.SOUTH); + add(bottomPanel, BorderLayout.SOUTH); + + // Set search button as default so Enter starts search + getRootPane().setDefaultButton(searchButton); + // Require explicit Enter to start search when choosing from history. // Bind Enter on the combo editor component so selecting an item from the // popup does not automatically trigger search until user confirms. @@ -490,6 +560,12 @@ public class SearchDialog extends JDialog { namePat = it != null ? it.toString().trim() : ""; } catch (Exception ex) { namePat = ""; } + String searchInDir = ""; + try { + Object sit = searchInCombo.getEditor().getItem(); + searchInDir = sit != null ? sit.toString().trim() : ""; + } catch (Exception ex) { searchInDir = searchDirectory.getAbsolutePath(); } + String contentPat = ""; try { Object cit = contentPatternCombo.getEditor().getItem(); @@ -505,7 +581,17 @@ public class SearchDialog extends JDialog { JOptionPane.WARNING_MESSAGE); return; } - + + File currentSearchDir = new File(searchInDir); + boolean searchEverything = everythingCheckBox != null && everythingCheckBox.isSelected(); + if (!searchEverything && (!currentSearchDir.exists() || !currentSearchDir.isDirectory())) { + JOptionPane.showMessageDialog(this, + "Zadaný adresář neexistuje", + "Chyba", + JOptionPane.WARNING_MESSAGE); + return; + } + if (isContentSearch && contentPat.isEmpty()) { JOptionPane.showMessageDialog(this, "Zadejte hledaný text pro vyhledávání v obsahu", @@ -560,6 +646,18 @@ public class SearchDialog extends JDialog { final boolean searchArchives = archiveSearchCheckBox != null && archiveSearchCheckBox.isSelected(); final boolean wholeWord = wholeWordCheckBox != null && wholeWordCheckBox.isSelected(); final boolean caseSensitive = caseSensitiveCheckBox != null && caseSensitiveCheckBox.isSelected(); + final boolean filenameIsRegex = regexCheckBox != null && regexCheckBox.isSelected(); + final boolean contentIsRegex = regexContentCheckBox != null && regexContentCheckBox.isSelected(); + + int mDepth = -1; + if (subDirCombo != null) { + int idx = subDirCombo.getSelectedIndex(); + if (idx == 1) mDepth = 0; + else if (idx == 2) mDepth = 1; + else if (idx == 3) mDepth = 2; + else if (idx == 4) mDepth = 3; + } + final int maxDepth = mDepth; // Reset and show status foundCount = 0; @@ -573,7 +671,7 @@ public class SearchDialog extends JDialog { @Override protected Void doInBackground() throws Exception { - FileOperations.search(searchDirectory, finalNamePat, finalContentPat, recursiveCheckBox.isSelected(), searchArchives, wholeWord, caseSensitive, new FileOperations.SearchCallback() { + FileOperations.SearchCallback sc = new FileOperations.SearchCallback() { @Override public void onFileFound(File file, String virtualPath) { publish(new Object[]{"file", file, virtualPath}); @@ -588,7 +686,16 @@ public class SearchDialog extends JDialog { public void onProgress(String status) { publish(new Object[]{"progress", status}); } - }); + }; + + if (searchEverything) { + for (File root : File.listRoots()) { + if (!searching) break; + FileOperations.search(root, finalNamePat, finalContentPat, maxDepth, searchArchives, wholeWord, caseSensitive, filenameIsRegex, contentIsRegex, sc); + } + } else { + FileOperations.search(currentSearchDir, finalNamePat, finalContentPat, maxDepth, searchArchives, wholeWord, caseSensitive, filenameIsRegex, contentIsRegex, sc); + } return null; } @@ -720,7 +827,8 @@ public class SearchDialog extends JDialog { if (!contentPat.isEmpty()) { FileEditor.setLastSearchOptions(contentPat, wholeWordCheckBox != null && wholeWordCheckBox.isSelected(), - caseSensitiveCheckBox != null && caseSensitiveCheckBox.isSelected()); + caseSensitiveCheckBox != null && caseSensitiveCheckBox.isSelected(), + regexContentCheckBox != null && regexContentCheckBox.isSelected()); } FileEditor viewer = new FileEditor(owner, item.getFile(), vPath, config, true); @@ -766,7 +874,8 @@ public class SearchDialog extends JDialog { if (!contentPat.isEmpty()) { FileEditor.setLastSearchOptions(contentPat, wholeWordCheckBox != null && wholeWordCheckBox.isSelected(), - caseSensitiveCheckBox != null && caseSensitiveCheckBox.isSelected()); + caseSensitiveCheckBox != null && caseSensitiveCheckBox.isSelected(), + regexContentCheckBox != null && regexContentCheckBox.isSelected()); } FileEditor editor = new FileEditor(owner, item.getFile(), config, false);