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 * Immediately abort the application (e.g. remote side closed
44 public static final int ABORT
= 1;
49 public static final int OPEN
= 2;
54 public static final int EXIT
= 3;
57 * Spawn OS shell window.
59 public static final int SHELL
= 4;
62 * Cut selected text and copy to the clipboard.
64 public static final int CUT
= 5;
67 * Copy selected text to clipboard.
69 public static final int COPY
= 6;
72 * Paste from clipboard.
74 public static final int PASTE
= 7;
77 * Clear selected text without copying it to the clipboard.
79 public static final int CLEAR
= 8;
84 public static final int TILE
= 9;
89 public static final int CASCADE
= 10;
94 public static final int CLOSE_ALL
= 11;
97 * Move (move/resize) window.
99 public static final int WINDOW_MOVE
= 12;
102 * Zoom (maximize/restore) window.
104 public static final int WINDOW_ZOOM
= 13;
107 * Next window (like Alt-TAB).
109 public static final int WINDOW_NEXT
= 14;
112 * Previous window (like Shift-Alt-TAB).
114 public static final int WINDOW_PREVIOUS
= 15;
119 public static final int WINDOW_CLOSE
= 16;
122 * Type of command, one of EXIT, CASCADE, etc.
127 * Protected constructor. Subclasses can be used to define new commands.
129 * @param type the Type of command, one of EXIT, CASCADE, etc.
131 protected TCommand(final int type
) {
136 * Make human-readable description of this TCommand.
138 * @return displayable String
141 public final String
toString() {
142 return String
.format("%s", type
);
146 * Comparison check. All fields must match to return true.
148 * @param rhs another TCommand instance
149 * @return true if all fields are equal
152 public final boolean equals(final Object rhs
) {
153 if (!(rhs
instanceof TCommand
)) {
157 TCommand that
= (TCommand
) rhs
;
158 return (type
== that
.type
);
161 public static final TCommand cmAbort
= new TCommand(ABORT
);
162 public static final TCommand cmExit
= new TCommand(EXIT
);
163 public static final TCommand cmQuit
= new TCommand(EXIT
);
164 public static final TCommand cmOpen
= new TCommand(OPEN
);
165 public static final TCommand cmShell
= new TCommand(SHELL
);
166 public static final TCommand cmCut
= new TCommand(CUT
);
167 public static final TCommand cmCopy
= new TCommand(COPY
);
168 public static final TCommand cmPaste
= new TCommand(PASTE
);
169 public static final TCommand cmClear
= new TCommand(CLEAR
);
170 public static final TCommand cmTile
= new TCommand(TILE
);
171 public static final TCommand cmCascade
= new TCommand(CASCADE
);
172 public static final TCommand cmCloseAll
= new TCommand(CLOSE_ALL
);
173 public static final TCommand cmWindowMove
= new TCommand(WINDOW_MOVE
);
174 public static final TCommand cmWindowZoom
= new TCommand(WINDOW_ZOOM
);
175 public static final TCommand cmWindowNext
= new TCommand(WINDOW_NEXT
);
176 public static final TCommand cmWindowPrevious
= new TCommand(WINDOW_PREVIOUS
);
177 public static final TCommand cmWindowClose
= new TCommand(WINDOW_CLOSE
);