2 * Jexer - Java Text User Interface
4 * License: LGPLv3 or later
6 * This module is licensed under the GNU Lesser General Public License
7 * Version 3. Please see the file "COPYING" in this directory for more
8 * information about the GNU Lesser General Public License Version 3.
10 * Copyright (C) 2015 Kevin Lamonte
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 3 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this program; if not, see
24 * http://www.gnu.org/licenses/, or write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
34 * This class encapsulates a user command event. User commands can be
35 * generated by menu actions, keyboard accelerators, and other UI elements.
36 * Commands can operate on both the application and individual widgets.
38 public class TCommand
{
41 * The following types are predefined for the entire system.
43 * TODO: Switch this to int so that TCommand can be subclassed so that
44 * applications can add more.
48 * Immediately abort the application (e.g. remote side closed
64 * Spawn OS shell window.
69 * Cut selected text and copy to the clipboard.
74 * Copy selected text to clipboard.
79 * Paste from clipboard.
84 * Clear selected text without copying it to the clipboard.
104 * Move (move/resize) window.
109 * Zoom (maximize/restore) window.
114 * Next window (like Alt-TAB).
119 * Previous window (like Shift-Alt-TAB).
131 * Type of command, one of EXIT, CASCADE, etc.
136 * Public constructor.
138 * @param type the Type of command, one of EXIT, CASCADE, etc.
140 public TCommand(final Type type
) {
145 * Make human-readable description of this TCommand.
147 * @return displayable String
150 public final String
toString() {
151 return String
.format("%s", type
);
155 * Comparison check. All fields must match to return true.
157 * @param rhs another TCommand instance
158 * @return true if all fields are equal
161 public final boolean equals(final Object rhs
) {
162 if (!(rhs
instanceof TCommand
)) {
166 TCommand that
= (TCommand
) rhs
;
167 return (type
== that
.type
);
170 public static final TCommand cmAbort
= new TCommand(TCommand
.Type
.ABORT
);
171 public static final TCommand cmExit
= new TCommand(TCommand
.Type
.EXIT
);
172 public static final TCommand cmQuit
= new TCommand(TCommand
.Type
.EXIT
);
173 public static final TCommand cmOpen
= new TCommand(TCommand
.Type
.OPEN
);
174 public static final TCommand cmShell
= new TCommand(TCommand
.Type
.SHELL
);
175 public static final TCommand cmCut
= new TCommand(TCommand
.Type
.CUT
);
176 public static final TCommand cmCopy
= new TCommand(TCommand
.Type
.COPY
);
177 public static final TCommand cmPaste
= new TCommand(TCommand
.Type
.PASTE
);
178 public static final TCommand cmClear
= new TCommand(TCommand
.Type
.CLEAR
);
179 public static final TCommand cmTile
= new TCommand(TCommand
.Type
.TILE
);
180 public static final TCommand cmCascade
= new TCommand(TCommand
.Type
.CASCADE
);
181 public static final TCommand cmCloseAll
= new TCommand(TCommand
.Type
.CLOSE_ALL
);
182 public static final TCommand cmWindowMove
= new TCommand(TCommand
.Type
.WINDOW_MOVE
);
183 public static final TCommand cmWindowZoom
= new TCommand(TCommand
.Type
.WINDOW_ZOOM
);
184 public static final TCommand cmWindowNext
= new TCommand(TCommand
.Type
.WINDOW_NEXT
);
185 public static final TCommand cmWindowPrevious
= new TCommand(TCommand
.Type
.WINDOW_PREVIOUS
);
186 public static final TCommand cmWindowClose
= new TCommand(TCommand
.Type
.WINDOW_CLOSE
);