matthiasblaesing commented on code in PR #9767:
URL: https://github.com/apache/netbeans/pull/9767#discussion_r4565112826


##########
ide/editor/src/org/netbeans/modules/editor/WordWrapAction.java:
##########
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.editor;
+
+import java.awt.EventQueue;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import javax.swing.AbstractAction;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import javax.swing.text.JTextComponent;
+import org.netbeans.api.editor.settings.SimpleValueNames;
+import org.netbeans.editor.Utilities;
+import org.netbeans.modules.editor.indent.spi.CodeStylePreferences;
+import org.netbeans.modules.editor.lib2.view.DocumentViewOp;
+import org.netbeans.modules.editor.lib2.view.LineWrapType;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
+import org.openide.awt.Actions;
+import org.openide.awt.DynamicMenuContent;
+import org.openide.util.NbBundle.Messages;
+import org.openide.util.WeakListeners;
+import org.openide.windows.TopComponent;
+import org.openide.windows.WindowManager;
+
+/**
+ * Action that toggles word wrapping for the currently active editor instance.
+ * <p>
+ * This action appears as a checkbox menu item under the <b>View</b> menu. It
+ * allows users to enable or disable line wrapping dynamically for the current
+ * file without changing the global or MIME-type settings configured in
+ * {@code Tools/Options/Editor/Formatting}.
+ * </p>
+ * <p>
+ * Word wrapping behavior relies on the {@link LineWrapType} enumeration, which
+ * defines three values: {@code NONE}, {@code WORD_BOUND}, and
+ * {@code CHARACTER_BOUND}. This action specifically toggles between
+ * {@code NONE} and {@code WORD_BOUND}. If the editor is currently configured 
to
+ * use {@code CHARACTER_BOUND}, it will be treated as {@code NONE} by this
+ * action.
+ * </p>
+ * <p>
+ * The action is automatically disabled when it cannot be applied to the 
current
+ * context. It is bound to the {@code ALT-Z} keyboard shortcut by default, 
which
+ * can be reconfigured via {@code Tools/Options/Keymap}.
+ * </p>
+ *
+ * @author Alejandro L. Belhafi
+ */
+@Messages({"wordWrapAction.displayName=&Word Wrap"})
+@ActionID(category = "View", id = "org.netbeans.modules.editor.WordWrapAction")
+@ActionReferences({
+    @ActionReference(path = "Menu/View", position = 215),
+    @ActionReference(path = "Shortcuts", name = "O-Z")})
+@ActionRegistration(lazy = false, iconInMenu = false, displayName = 
"#wordWrapAction.displayName")
+public class WordWrapAction extends AbstractAction
+        implements PropertyChangeListener, Runnable, DynamicMenuContent {
+
+    /**
+     * Constant representing no line wrapping, mapping to
+     * {@link LineWrapType#NONE}. This is also used as the fallback treatment 
for
+     * {@link LineWrapType#CHARACTER_BOUND}.
+     */
+    private static final String NONE = "none"; //NOI18N
+
+    /**
+     * Constant representing standard word wrapping, mapping to
+     * {@link LineWrapType#WORD_BOUND}.
+     */
+    private static final String WORDS = "words"; //NOI18N

Review Comment:
   This makes sense to me, if we assume that we don't want to introduce new 
dependencies/API. But looking at `LineWrapType`, the values encoded there are 
already API as they are used at multiple places and persitence. So from my POV, 
given that `fromSettingValue` already exists, I suggest to introduce 
`getSettingValue` to return that value. Drop the local definitions and deal 
with `LineWrapType` where possible.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to