From 968e508bb58d479a09b987f4d177a5abc877dc01 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 27 Aug 2021 22:53:04 +0200 Subject: [PATCH] Theme Editor: - change border color of find field to red if noting found/matches - update search match highlighting after reloading file on external change --- .../com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java | 4 +++- .../com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java index 60a2a646..58d8947a 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java @@ -133,7 +133,7 @@ class FlatFindReplaceBar findOrMarkAll( true ); } - private void markAll() { + void markAll() { findOrMarkAll( false ); } @@ -227,6 +227,8 @@ class FlatFindReplaceBar private void updateMatchesLabel( SearchResult result, boolean replace ) { matchesLabel.setText( result.getMarkedCount() + " matches" ); replaceMatchesLabel.setText( replace ? result.getCount() + " matches replaced" : null ); + + findField.setOutline( result.getMarkedCount() > 0 ? null : "error" ); } private void notifyEditorAction( String actionKey ) { diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java index d27a80bd..a1328084 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java @@ -224,6 +224,9 @@ class FlatThemeEditorPane textArea.reload(); textArea.select( selectionStart, selectionEnd ); + + if( findReplaceBar != null && findReplaceBar.isShowing() ) + findReplaceBar.markAll(); } catch( IOException ex ) { JOptionPane.showMessageDialog( this, "Failed to reload '" + textArea.getFileName() + "'\n\nReason: " + ex.getMessage(),