This is an automated email from the ASF dual-hosted git repository.

ebakke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f5ae6f  [NETBEANS-5726] Fix incorrect checkbox state shown by 'Show 
Editor Toolbar' and other boolean preference actions.
5f5ae6f is described below

commit 5f5ae6f574c59b6f3541e1a7b434064c00de131d
Author: Eirik Bakke <eba...@ultorg.com>
AuthorDate: Fri May 28 12:21:29 2021 -0400

    [NETBEANS-5726] Fix incorrect checkbox state shown by 'Show Editor Toolbar' 
and other boolean preference actions.
---
 .../modules/editor/actions/ToggleAction.java       | 59 +++++++++++++---------
 1 file changed, 36 insertions(+), 23 deletions(-)

diff --git 
a/ide/editor.actions/src/org/netbeans/modules/editor/actions/ToggleAction.java 
b/ide/editor.actions/src/org/netbeans/modules/editor/actions/ToggleAction.java
index 3666dfe..1f5eb7e 100644
--- 
a/ide/editor.actions/src/org/netbeans/modules/editor/actions/ToggleAction.java
+++ 
b/ide/editor.actions/src/org/netbeans/modules/editor/actions/ToggleAction.java
@@ -20,6 +20,7 @@
 package org.netbeans.modules.editor.actions;
 
 import java.awt.event.ActionEvent;
+import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.text.JTextComponent;
@@ -34,35 +35,47 @@ import org.netbeans.api.editor.EditorActionNames;
  *
  * @author Miloslav Metelka
  */
-@EditorActionRegistrations({
-    @EditorActionRegistration(
-        name = EditorActionNames.toggleToolbar,
-        menuPath = "View",
-        menuPosition = 800,
-        menuText = "#" + EditorActionNames.toggleToolbar + "_menu_text",
-        preferencesKey = SimpleValueNames.TOOLBAR_VISIBLE_PROP
-    ),
-    @EditorActionRegistration(
-        name = EditorActionNames.toggleLineNumbers,
-        menuPath = "View",
-        menuPosition = 850,
-        menuText = "#" + EditorActionNames.toggleLineNumbers + "_menu_text",
-        preferencesKey = SimpleValueNames.LINE_NUMBER_VISIBLE
-    ),
-    @EditorActionRegistration(
-        name = EditorActionNames.toggleNonPrintableCharacters,
-        menuPath = "View",
-        menuPosition = 870,
-        menuText = "#" + EditorActionNames.toggleNonPrintableCharacters + 
"_menu_text",
-        preferencesKey = SimpleValueNames.NON_PRINTABLE_CHARACTERS_VISIBLE
-    )
-})
 public final class ToggleAction extends AbstractEditorAction {
+    /* Use eager initialization for these actions. Otherwise the selection 
("checked") state of menu
+    items will not properly track the respective Preferences value 
(NETBEANS-5726). */
+    @EditorActionRegistrations({
+        @EditorActionRegistration(
+            name = EditorActionNames.toggleToolbar,
+            menuPath = "View",
+            menuPosition = 800,
+            menuText = "#" + EditorActionNames.toggleToolbar + "_menu_text",
+            preferencesKey = SimpleValueNames.TOOLBAR_VISIBLE_PROP
+        ),
+        @EditorActionRegistration(
+            name = EditorActionNames.toggleLineNumbers,
+            menuPath = "View",
+            menuPosition = 850,
+            menuText = "#" + EditorActionNames.toggleLineNumbers + 
"_menu_text",
+            preferencesKey = SimpleValueNames.LINE_NUMBER_VISIBLE
+        ),
+        @EditorActionRegistration(
+            name = EditorActionNames.toggleNonPrintableCharacters,
+            menuPath = "View",
+            menuPosition = 870,
+            menuText = "#" + EditorActionNames.toggleNonPrintableCharacters + 
"_menu_text",
+            preferencesKey = SimpleValueNames.NON_PRINTABLE_CHARACTERS_VISIBLE
+        )
+    })
+    public static ToggleAction create(Map<String,?> attrs) {
+        return new ToggleAction(attrs);
+    }
 
     private static final Logger LOG = 
Logger.getLogger(ToggleAction.class.getName());
 
     private static final long serialVersionUID = 1L;
 
+    public ToggleAction() {
+    }
+
+    private ToggleAction(Map<String,?> attrs) {
+        super(attrs);
+    }
+
     @Override
     public void actionPerformed(ActionEvent evt, JTextComponent component) {
         // Leave empty - AlwaysEnabledAction toggles state in preferences by 
default

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to