searchdialog, file view improved
This commit is contained in:
parent
4f15bac6ff
commit
8d012dd14f
@ -123,7 +123,7 @@ public class FileEditor extends JDialog {
|
||||
searchPanel.setVisible(false);
|
||||
}
|
||||
|
||||
private void showSearchPanel() {
|
||||
private void showSearchPanel(boolean focusField) {
|
||||
searchPanel.setVisible(true);
|
||||
String selection = textArea.getSelectedText();
|
||||
if (selection != null && !selection.isEmpty() && !selection.contains("\n")) {
|
||||
@ -139,6 +139,7 @@ public class FileEditor extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
if (focusField) {
|
||||
searchField.requestFocusInWindow();
|
||||
searchField.selectAll();
|
||||
|
||||
@ -146,6 +147,9 @@ public class FileEditor extends JDialog {
|
||||
searchField.requestFocusInWindow();
|
||||
searchField.selectAll();
|
||||
});
|
||||
} else {
|
||||
textArea.requestFocusInWindow();
|
||||
}
|
||||
|
||||
if (northPanel != null) {
|
||||
northPanel.revalidate();
|
||||
@ -483,7 +487,7 @@ public class FileEditor extends JDialog {
|
||||
|
||||
JMenuItem findItem = new JMenuItem("Hledat...");
|
||||
findItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK));
|
||||
findItem.addActionListener(e -> showSearchPanel());
|
||||
findItem.addActionListener(e -> showSearchPanel(true));
|
||||
editMenu.add(findItem);
|
||||
|
||||
JMenuItem findNextItem = new JMenuItem("Hledat další");
|
||||
@ -559,14 +563,8 @@ public class FileEditor extends JDialog {
|
||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
|
||||
// ESC - Zavřít nebo skrýt hledání
|
||||
rootPane.registerKeyboardAction(e -> {
|
||||
if (searchPanel != null && searchPanel.isVisible()) {
|
||||
hideSearchPanel();
|
||||
} else {
|
||||
closeEditor();
|
||||
}
|
||||
},
|
||||
// ESC - Zavřít view
|
||||
rootPane.registerKeyboardAction(e -> closeEditor(),
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
|
||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
@ -577,9 +575,10 @@ public class FileEditor extends JDialog {
|
||||
return;
|
||||
}
|
||||
if (!searchPanel.isVisible()) {
|
||||
showSearchPanel();
|
||||
showSearchPanel(false);
|
||||
}
|
||||
findNext();
|
||||
textArea.requestFocusInWindow();
|
||||
},
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0),
|
||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
@ -647,12 +646,15 @@ public class FileEditor extends JDialog {
|
||||
|
||||
// Hledání
|
||||
rootPane.registerKeyboardAction(e -> {
|
||||
if (!isImageFile(file)) showSearchPanel();
|
||||
if (!isImageFile(file)) showSearchPanel(true);
|
||||
},
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK),
|
||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
rootPane.registerKeyboardAction(e -> findPrevious(),
|
||||
rootPane.registerKeyboardAction(e -> {
|
||||
findPrevious();
|
||||
textArea.requestFocusInWindow();
|
||||
},
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_DOWN_MASK),
|
||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
}
|
||||
|
||||
@ -290,13 +290,14 @@ public class SearchDialog extends JDialog {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||
try {
|
||||
// If the popup is visible, treat Enter as "confirm selection" and proceed to search
|
||||
// If the popup is visible, treat Enter as "confirm selection": fill editor and close popup
|
||||
if (patternCombo.isPopupVisible()) {
|
||||
Object sel = patternCombo.getSelectedItem();
|
||||
if (sel != null) {
|
||||
patternCombo.getEditor().setItem(sel.toString());
|
||||
}
|
||||
patternCombo.hidePopup();
|
||||
return; // Do not start search yet
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
// Actual confirm to start search
|
||||
@ -319,6 +320,7 @@ public class SearchDialog extends JDialog {
|
||||
Object sel = contentPatternCombo.getSelectedItem();
|
||||
if (sel != null) contentPatternCombo.getEditor().setItem(sel.toString());
|
||||
contentPatternCombo.hidePopup();
|
||||
return; // Do not start search yet
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
performSearch();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user