checkstyle'd
[nikiroo-utils.git] / src / jexer / TCommand.java
index ce19e2a06233f0e9097aded7b11fdc4ada0b9303..c51e570e783191b989607a2151e335b8172c040d 100644 (file)
@@ -1,16 +1,11 @@
 /**
  * Jexer - Java Text User Interface
  *
- * Version: $Id$
- *
- * Author: Kevin Lamonte, <a href="mailto:kevin.lamonte@gmail.com">kevin.lamonte@gmail.com</a>
- *
  * License: LGPLv3 or later
  *
- * Copyright: This module is licensed under the GNU Lesser General
- * Public License Version 3.  Please see the file "COPYING" in this
- * directory for more information about the GNU Lesser General Public
- * License Version 3.
+ * This module is licensed under the GNU Lesser General Public License
+ * Version 3.  Please see the file "COPYING" in this directory for more
+ * information about the GNU Lesser General Public License Version 3.
  *
  *     Copyright (C) 2015  Kevin Lamonte
  *
  * http://www.gnu.org/licenses/, or write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA
+ *
+ * @author Kevin Lamonte [kevin.lamonte@gmail.com]
+ * @version 1
  */
 package jexer;
 
 /**
- * This class encapsulates several kinds of user commands.  A user command
- * can be generated by a menu action or keyboard accelerator.
+ * This class encapsulates a user command event.  User commands can be
+ * generated by menu actions, keyboard accelerators, and other UI elements.
+ * Commands can operate on both the application and individual widgets.
  */
 public class TCommand {
 
+    /**
+     * The following types are predefined for the entire system.
+     *
+     * TODO: Switch this to int so that TCommand can be subclassed so that
+     * applications can add more.
+     */
     public enum Type {
-       /**
-        * Immediately abort the application (e.g. remote side closed
-        * connection)
-        */
-       ABORT,
-
-       /**
-        * File open dialog
-        */
-       OPEN,
-
-       /**
-        * Exit application
-        */
-       EXIT,
-
-       /**
-        * Spawn OS shell window
-        */
-       SHELL,
-
-       /**
-        * Cut selected text and copy to the clipboard
-        */
-       CUT,
-
-       /**
-        * Copy selected text to clipboard
-        */
-       COPY,
-
-       /**
-        * Paste from clipboard
-        */
-       PASTE,
-
-       /**
-        * Clear selected text without copying it to the clipboard
-        */
-       CLEAR,
-
-       /**
-        * Tile windows
-        */
-       TILE,
-
-       /**
-        * Cascade windows
-        */
-       CASCADE,
-
-       /**
-        * Close all windows
-        */
-       CLOSE_ALL,
-
-       /**
-        * Move (move/resize) window
-        */
-       WINDOW_MOVE,
-
-       /**
-        * Zoom (maximize/restore) window
-        */
-       WINDOW_ZOOM,
-
-       /**
-        * Next window (like Alt-TAB)
-        */
-       WINDOW_NEXT,
-
-       /**
-        * Previous window (like Shift-Alt-TAB)
-        */
-       WINDOW_PREVIOUS,
-
-       /**
-        * Close window
-        */
-       WINDOW_CLOSE,
+        /**
+         * Immediately abort the application (e.g. remote side closed
+         * connection).
+         */
+        ABORT,
+
+        /**
+         * File open dialog.
+         */
+        OPEN,
+
+        /**
+         * Exit application.
+         */
+        EXIT,
+
+        /**
+         * Spawn OS shell window.
+         */
+        SHELL,
+
+        /**
+         * Cut selected text and copy to the clipboard.
+         */
+        CUT,
+
+        /**
+         * Copy selected text to clipboard.
+         */
+        COPY,
+
+        /**
+         * Paste from clipboard.
+         */
+        PASTE,
+
+        /**
+         * Clear selected text without copying it to the clipboard.
+         */
+        CLEAR,
+
+        /**
+         * Tile windows.
+         */
+        TILE,
+
+        /**
+         * Cascade windows.
+         */
+        CASCADE,
+
+        /**
+         * Close all windows.
+         */
+        CLOSE_ALL,
+
+        /**
+         * Move (move/resize) window.
+         */
+        WINDOW_MOVE,
+
+        /**
+         * Zoom (maximize/restore) window.
+         */
+        WINDOW_ZOOM,
+
+        /**
+         * Next window (like Alt-TAB).
+         */
+        WINDOW_NEXT,
+
+        /**
+         * Previous window (like Shift-Alt-TAB).
+         */
+        WINDOW_PREVIOUS,
+
+        /**
+         * Close window.
+         */
+        WINDOW_CLOSE,
 
     }
 
     /**
      * Type of command, one of EXIT, CASCADE, etc.
      */
-    public Type type;
+    private Type type;
 
     /**
-     * Public contructor
+     * Public constructor.
      *
      * @param type the Type of command, one of EXIT, CASCADE, etc.
      */
-    public TCommand(Type type) {
-       this.type = type;
+    public TCommand(final Type type) {
+        this.type = type;
     }
 
     /**
-     * Make human-readable description of this event
+     * Make human-readable description of this TCommand.
+     *
+     * @return displayable String
      */
     @Override
-    public String toString() {
-       return String.format("%s", type);
+    public final String toString() {
+        return String.format("%s", type);
     }
 
     /**
-     * Comparison.  All fields must match to return true.
+     * Comparison check.  All fields must match to return true.
+     *
+     * @param rhs another TCommand instance
+     * @return true if all fields are equal
      */
     @Override
-    public boolean equals(Object rhs) {
-       if (!(rhs instanceof TCommand)) {
-           return false;
-       }
+    public final boolean equals(final Object rhs) {
+        if (!(rhs instanceof TCommand)) {
+            return false;
+        }
 
-       TCommand that = (TCommand)rhs;
-       return (type == that.type);
+        TCommand that = (TCommand) rhs;
+        return (type == that.type);
     }
 
-    static public final TCommand cmAbort      = new TCommand(TCommand.Type.ABORT);
-    static public final TCommand cmExit       = new TCommand(TCommand.Type.EXIT);
-    static public final TCommand cmQuit       = new TCommand(TCommand.Type.EXIT);
-    static public final TCommand cmOpen       = new TCommand(TCommand.Type.OPEN);
-    static public final TCommand cmShell      = new TCommand(TCommand.Type.SHELL);
-    static public final TCommand cmCut        = new TCommand(TCommand.Type.CUT);
-    static public final TCommand cmCopy       = new TCommand(TCommand.Type.COPY);
-    static public final TCommand cmPaste      = new TCommand(TCommand.Type.PASTE);
-    static public final TCommand cmClear      = new TCommand(TCommand.Type.CLEAR);
-    static public final TCommand cmTile       = new TCommand(TCommand.Type.TILE);
-    static public final TCommand cmCascade    = new TCommand(TCommand.Type.CASCADE);
-    static public final TCommand cmCloseAll   = new TCommand(TCommand.Type.CLOSE_ALL);
-    static public final TCommand cmWindowMove = new TCommand(TCommand.Type.WINDOW_MOVE);
-    static public final TCommand cmWindowZoom = new TCommand(TCommand.Type.WINDOW_ZOOM);
-    static public final TCommand cmWindowNext = new TCommand(TCommand.Type.WINDOW_NEXT);
-    static public final TCommand cmWindowPrevious = new TCommand(TCommand.Type.WINDOW_PREVIOUS);
-    static public final TCommand cmWindowClose = new TCommand(TCommand.Type.WINDOW_CLOSE);
+    public static final TCommand cmAbort      = new TCommand(TCommand.Type.ABORT);
+    public static final TCommand cmExit       = new TCommand(TCommand.Type.EXIT);
+    public static final TCommand cmQuit       = new TCommand(TCommand.Type.EXIT);
+    public static final TCommand cmOpen       = new TCommand(TCommand.Type.OPEN);
+    public static final TCommand cmShell      = new TCommand(TCommand.Type.SHELL);
+    public static final TCommand cmCut        = new TCommand(TCommand.Type.CUT);
+    public static final TCommand cmCopy       = new TCommand(TCommand.Type.COPY);
+    public static final TCommand cmPaste      = new TCommand(TCommand.Type.PASTE);
+    public static final TCommand cmClear      = new TCommand(TCommand.Type.CLEAR);
+    public static final TCommand cmTile       = new TCommand(TCommand.Type.TILE);
+    public static final TCommand cmCascade    = new TCommand(TCommand.Type.CASCADE);
+    public static final TCommand cmCloseAll   = new TCommand(TCommand.Type.CLOSE_ALL);
+    public static final TCommand cmWindowMove = new TCommand(TCommand.Type.WINDOW_MOVE);
+    public static final TCommand cmWindowZoom = new TCommand(TCommand.Type.WINDOW_ZOOM);
+    public static final TCommand cmWindowNext = new TCommand(TCommand.Type.WINDOW_NEXT);
+    public static final TCommand cmWindowPrevious = new TCommand(TCommand.Type.WINDOW_PREVIOUS);
+    public static final TCommand cmWindowClose = new TCommand(TCommand.Type.WINDOW_CLOSE);
 
 }