comparison app/src/main/java/org/tn5250j/framework/tn5250/ScreenOIA.java @ 438:d29cce60f393

migrate from Eclipse to Android Studio
author Carl Byington <carl@five-ten-sg.com>
date Thu, 03 Dec 2015 11:23:55 -0800
parents src/org/tn5250j/framework/tn5250/ScreenOIA.java@77ac18bc1b2f
children
comparison
equal deleted inserted replaced
437:208b31032318 438:d29cce60f393
1 /**
2 * <p>Title: ScreenOIA.java</p>
3 * <p>Description: Main interface to control Operator information area screen</p>
4 * <p>Copyright: Copyright (c) 2000 - 2002</p>
5 * <p>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this software; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 * Boston, MA 02111-1307 USA
20 * </p>
21 * @author Kenneth J. Pouncey
22 * @version 0.5
23 */
24 package org.tn5250j.framework.tn5250;
25
26 import java.util.Vector;
27
28 import org.tn5250j.event.ScreenOIAListener;
29
30 /**
31 * The operator information area of a host session. This area is used to provide
32 * status information regarding the state of the host session and location of
33 * the cursor. A ScreenOIA object can be obtained using the GetOIA() method on
34 * an instance of Screen5250.
35 *
36 *
37 */
38 public class ScreenOIA {
39 // OIA_LEVEL
40 public static final int OIA_LEVEL_INPUT_INHIBITED = 1;
41 public static final int OIA_LEVEL_NOT_INHIBITED = 2;
42 public static final int OIA_LEVEL_MESSAGE_LIGHT_ON = 3;
43 public static final int OIA_LEVEL_MESSAGE_LIGHT_OFF = 4;
44 public static final int OIA_LEVEL_AUDIBLE_BELL = 5;
45 public static final int OIA_LEVEL_INSERT_MODE = 6;
46 public static final int OIA_LEVEL_KEYBOARD = 7;
47 public static final int OIA_LEVEL_CLEAR_SCREEN = 8;
48 public static final int OIA_LEVEL_SCREEN_SIZE = 9;
49 public static final int OIA_LEVEL_INPUT_ERROR = 10;
50 public static final int OIA_LEVEL_KEYS_BUFFERED = 11;
51 public static final int OIA_LEVEL_SCRIPT = 12;
52
53 // INPUTINHIBITED
54 public static final int INPUTINHIBITED_NOTINHIBITED = 0;
55 public static final int INPUTINHIBITED_SYSTEM_WAIT = 1;
56 public static final int INPUTINHIBITED_COMMCHECK = 2;
57 public static final int INPUTINHIBITED_PROGCHECK = 3;
58 public static final int INPUTINHIBITED_MACHINECHECK = 4;
59 public static final int INPUTINHIBITED_OTHER = 5;
60
61 public ScreenOIA(Screen5250 screen) {
62 source = screen;
63 }
64
65 public boolean isInsertMode() {
66 return insertMode;
67 }
68
69 protected void setInsertMode(boolean mode) {
70 level = OIA_LEVEL_INSERT_MODE;
71 insertMode = mode;
72 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INSERT_MODE);
73 }
74
75 public int getCommCheckCode() {
76 return commCheck;
77 }
78
79 public int getInputInhibited() {
80 return inputInhibited;
81 }
82
83 public int getMachineCheckCode() {
84 return machineCheck;
85 }
86
87 public int getOwner() {
88 return owner;
89 }
90
91 public int getProgCheckCode() {
92 return 0;
93 }
94
95 /**
96 * Is the keyboard locked or not
97 *
98 * @return locked or not
99 */
100 public boolean isKeyBoardLocked() {
101 return locked;
102 }
103
104 public boolean isKeysBuffered() {
105 return keysBuffered;
106 }
107
108 public void setKeysBuffered(boolean kb) {
109 level = OIA_LEVEL_KEYS_BUFFERED;
110 boolean oldKB = keysBuffered;
111 keysBuffered = kb;
112
113 if (keysBuffered != oldKB)
114 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYS_BUFFERED);
115 }
116
117 protected void setKeyBoardLocked(boolean lockIt) {
118 level = OIA_LEVEL_KEYBOARD;
119 boolean oldLocked = locked;
120 locked = lockIt;
121
122 if (!lockIt) {
123 if (isKeysBuffered()) {
124 source.sendKeys("");
125 }
126 }
127
128 if (locked != oldLocked)
129 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYBOARD_LOCKED);
130 }
131
132 public boolean isMessageWait() {
133 return messageWait;
134 }
135
136 protected void setMessageLightOn() {
137 level = OIA_LEVEL_MESSAGE_LIGHT_ON;
138 messageWait = true;
139 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
140 }
141
142 protected void setMessageLightOff() {
143 level = OIA_LEVEL_MESSAGE_LIGHT_OFF;
144 messageWait = false;
145 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
146 }
147
148 public void setScriptActive(boolean running) {
149 level = OIA_LEVEL_SCRIPT;
150 scriptRunning = running;
151 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_SCRIPT);
152 }
153
154 public boolean isScriptActive() {
155 return scriptRunning;
156 }
157
158 public void setAudibleBell() {
159 level = OIA_LEVEL_AUDIBLE_BELL;
160 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_BELL);
161 }
162
163 protected void clearScreen() {
164 level = OIA_LEVEL_CLEAR_SCREEN;
165 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_CLEAR_SCREEN);
166 }
167
168 /**
169 * Add a ScreenOIAListener to the listener list.
170 *
171 * @param listener The ScreenOIAListener to be added
172 */
173 public void addOIAListener(ScreenOIAListener listener) {
174 if (listeners == null) {
175 listeners = new java.util.Vector<ScreenOIAListener>(3);
176 }
177
178 listeners.addElement(listener);
179 }
180
181 /**
182 * Remove a iOhioSessionListener from the listener list.
183 *
184 * @param listener The iOhioSessionListener to be removed
185 */
186 public void removeOIAListener(ScreenOIAListener listener) {
187 if (listeners == null) {
188 return;
189 }
190
191 listeners.removeElement(listener);
192 }
193
194 // object methods
195 public Screen5250 getSource() {
196 return source;
197 }
198
199
200 public void setSource(Screen5250 screen) {
201 source = screen;
202 }
203
204 public void setOwner(int newOwner) {
205 owner = newOwner;
206 }
207
208 public int getLevel() {
209 return level;
210 }
211
212 public String getInhibitedText() {
213 return inhibitedText;
214 }
215
216 public void setInputInhibited(int inhibit , int whatCode) {
217 setInputInhibited(inhibit, whatCode, null);
218 }
219
220 public void setInputInhibited(int inhibit , int whatCode, String message) {
221 inputInhibited = inhibit;
222 level = OIA_LEVEL_INPUT_INHIBITED;
223 inhibitedText = message;
224
225 // if (saveInhibit != inhibit || saveInhibitLevel != whatCode) {
226 switch (inhibit) {
227 case INPUTINHIBITED_COMMCHECK :
228 commCheck = whatCode;
229 break;
230
231 case INPUTINHIBITED_PROGCHECK :
232 // progCheck = whatCode; // never used
233 break;
234
235 case INPUTINHIBITED_MACHINECHECK :
236 machineCheck = whatCode;
237 break;
238
239 case INPUTINHIBITED_SYSTEM_WAIT :
240 level = whatCode;
241 break;
242
243 case INPUTINHIBITED_NOTINHIBITED :
244 level = whatCode;
245 break;
246 }
247
248 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INPUTINHIBITED);
249 // }
250 }
251
252 /**
253 * Notify all registered listeners of the onOIAChanged event.
254 *
255 */
256 private void fireOIAChanged(int change) {
257 if (listeners != null) {
258 int size = listeners.size();
259
260 for (int i = 0; i < size; i++) {
261 ScreenOIAListener target =
262 listeners.elementAt(i);
263 target.onOIAChanged(this, change);
264 }
265 }
266 }
267
268 private Vector<ScreenOIAListener> listeners = null;
269 private boolean insertMode;
270 private boolean locked;
271 private boolean keysBuffered;
272 private int owner = 0;
273 private int level = 0;
274 private Screen5250 source = null;
275 private int commCheck = 0;
276 private int machineCheck = 0;
277 private boolean messageWait;
278 private boolean scriptRunning;
279 private int inputInhibited = INPUTINHIBITED_NOTINHIBITED;
280 private String inhibitedText;
281
282 }