From ed5180ffd621ab89651cb564b0081d0a33d372a4 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 15 Jan 2021 16:15:05 +0100 Subject: [PATCH] Theme Editor: - save/restore selection when reloading file (if changed outside) - select all text in find field when pressing Ctrl+F - use lighter color for operators (e.g. '=') --- .../com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java | 2 ++ .../com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java | 5 +++++ .../main/resources/com/formdev/flatlaf/themeeditor/light.xml | 2 +- 3 files changed, 8 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 f1186801..f906c9fe 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 @@ -93,6 +93,8 @@ class FlatFindReplaceBar String selectedText = textArea.getSelectedText(); if( !StringUtils.isEmpty( selectedText ) && selectedText.indexOf( '\n' ) < 0 ) findField.setText( selectedText ); + else + findField.selectAll(); // if showing bar, highlight matches in editor // (not invoking this from addNotify() because this would break the slide-in animation) 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 47a13b33..d09b4c4f 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 @@ -185,7 +185,12 @@ class FlatThemeEditorPane } try { + int selectionStart = textArea.getSelectionStart(); + int selectionEnd = textArea.getSelectionEnd(); + textArea.reload(); + + textArea.select( selectionStart, selectionEnd ); } catch( IOException ex ) { JOptionPane.showMessageDialog( this, "Failed to reload '" + textArea.getFileName() + "'\n\nReason: " + ex.getMessage(), diff --git a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/light.xml b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/light.xml index 22d780ec..1c548fda 100644 --- a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/light.xml +++ b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/light.xml @@ -62,7 +62,7 @@