comparison src/org/tn5250j/framework/tn5250/ScreenOIA.java @ 3:e8d2a24e85c6 tn5250

adding tn5250 files
author Carl Byington <carl@five-ten-sg.com>
date Thu, 22 May 2014 12:11:10 -0700
parents
children 77ac18bc1b2f
comparison
equal deleted inserted replaced
2:a01665cb683d 3:e8d2a24e85c6
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 {
40 // OIA_LEVEL
41 public static final int OIA_LEVEL_INPUT_INHIBITED = 1;
42 public static final int OIA_LEVEL_NOT_INHIBITED = 2;
43 public static final int OIA_LEVEL_MESSAGE_LIGHT_ON = 3;
44 public static final int OIA_LEVEL_MESSAGE_LIGHT_OFF = 4;
45 public static final int OIA_LEVEL_AUDIBLE_BELL = 5;
46 public static final int OIA_LEVEL_INSERT_MODE = 6;
47 public static final int OIA_LEVEL_KEYBOARD = 7;
48 public static final int OIA_LEVEL_CLEAR_SCREEN = 8;
49 public static final int OIA_LEVEL_SCREEN_SIZE = 9;
50 public static final int OIA_LEVEL_INPUT_ERROR = 10;
51 public static final int OIA_LEVEL_KEYS_BUFFERED = 11;
52 public static final int OIA_LEVEL_SCRIPT = 12;
53
54 // INPUTINHIBITED
55 public static final int INPUTINHIBITED_NOTINHIBITED = 0;
56 public static final int INPUTINHIBITED_SYSTEM_WAIT = 1;
57 public static final int INPUTINHIBITED_COMMCHECK = 2;
58 public static final int INPUTINHIBITED_PROGCHECK = 3;
59 public static final int INPUTINHIBITED_MACHINECHECK = 4;
60 public static final int INPUTINHIBITED_OTHER = 5;
61
62 public ScreenOIA (Screen5250 screen) {
63
64 source = screen;
65
66 }
67
68 public boolean isInsertMode() {
69
70 return insertMode;
71 }
72
73 protected void setInsertMode(boolean mode) {
74
75 level = OIA_LEVEL_INSERT_MODE;
76 insertMode = mode;
77 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INSERT_MODE);
78 }
79
80 public int getCommCheckCode() {
81
82 return commCheck;
83 }
84
85 public int getInputInhibited() {
86
87 return inputInhibited;
88 }
89
90 public int getMachineCheckCode() {
91
92 return machineCheck;
93 }
94
95 public int getOwner() {
96 return owner;
97 }
98
99 public int getProgCheckCode() {
100 return 0;
101 }
102
103 /**
104 * Is the keyboard locked or not
105 *
106 * @return locked or not
107 */
108 public boolean isKeyBoardLocked() {
109 return locked;
110 }
111
112 public boolean isKeysBuffered() {
113 return keysBuffered;
114 }
115
116 public void setKeysBuffered(boolean kb) {
117 level = OIA_LEVEL_KEYS_BUFFERED;
118 boolean oldKB = keysBuffered;
119 keysBuffered = kb;
120 if (keysBuffered != oldKB)
121 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYS_BUFFERED);
122 }
123
124 protected void setKeyBoardLocked(boolean lockIt) {
125 level = OIA_LEVEL_KEYBOARD;
126 boolean oldLocked = locked;
127 locked = lockIt;
128 if (!lockIt) {
129
130 if (isKeysBuffered()) {
131 source.sendKeys("");
132 }
133 }
134
135 if (locked != oldLocked)
136 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYBOARD_LOCKED);
137 }
138
139 public boolean isMessageWait() {
140 return messageWait;
141 }
142
143 protected void setMessageLightOn() {
144 level = OIA_LEVEL_MESSAGE_LIGHT_ON;
145 messageWait = true;
146 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
147 }
148
149 protected void setMessageLightOff() {
150 level = OIA_LEVEL_MESSAGE_LIGHT_OFF;
151 messageWait = false;
152 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
153 }
154
155 public void setScriptActive(boolean running) {
156 level = OIA_LEVEL_SCRIPT;
157 scriptRunning = running;
158 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_SCRIPT);
159 }
160
161 public boolean isScriptActive() {
162 return scriptRunning;
163 }
164
165 public void setAudibleBell() {
166 level = OIA_LEVEL_AUDIBLE_BELL;
167 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_BELL);
168 }
169
170 protected void clearScreen() {
171 level = OIA_LEVEL_CLEAR_SCREEN;
172 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_CLEAR_SCREEN);
173 }
174
175 /**
176 * Add a ScreenOIAListener to the listener list.
177 *
178 * @param listener The ScreenOIAListener to be added
179 */
180 public void addOIAListener(ScreenOIAListener listener) {
181
182 if (listeners == null) {
183 listeners = new java.util.Vector<ScreenOIAListener>(3);
184 }
185 listeners.addElement(listener);
186
187 }
188
189 /**
190 * Remove a iOhioSessionListener from the listener list.
191 *
192 * @param listener The iOhioSessionListener to be removed
193 */
194 public void removeOIAListener(ScreenOIAListener listener) {
195
196 if (listeners == null) {
197 return;
198 }
199 listeners.removeElement(listener);
200 }
201
202 // object methods
203 public Screen5250 getSource() {
204
205 return source;
206 }
207
208
209 public void setSource(Screen5250 screen) {
210
211 source = screen;
212
213 }
214
215 public void setOwner(int newOwner) {
216
217 owner = newOwner;
218
219 }
220
221 public int getLevel() {
222
223 return level;
224 }
225
226 public String getInhibitedText() {
227 return inhibitedText;
228 }
229
230 public void setInputInhibited(int inhibit , int whatCode) {
231 setInputInhibited(inhibit, whatCode, null);
232 }
233
234 public void setInputInhibited(int inhibit , int whatCode, String message) {
235
236 inputInhibited = inhibit;
237 level = OIA_LEVEL_INPUT_INHIBITED;
238 inhibitedText = message;
239
240 // if (saveInhibit != inhibit || saveInhibitLevel != whatCode) {
241 switch(inhibit) {
242
243 case INPUTINHIBITED_COMMCHECK :
244 commCheck = whatCode;
245 break;
246 case INPUTINHIBITED_PROGCHECK :
247 // progCheck = whatCode; // never used
248 break;
249 case INPUTINHIBITED_MACHINECHECK :
250 machineCheck = whatCode;
251 break;
252 case INPUTINHIBITED_SYSTEM_WAIT :
253 level = whatCode;
254 break;
255 case INPUTINHIBITED_NOTINHIBITED :
256 level = whatCode;
257 break;
258 }
259
260 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INPUTINHIBITED);
261 // }
262 }
263
264 /**
265 * Notify all registered listeners of the onOIAChanged event.
266 *
267 */
268 private void fireOIAChanged(int change) {
269
270 if (listeners != null) {
271 int size = listeners.size();
272 for (int i = 0; i < size; i++) {
273 ScreenOIAListener target =
274 listeners.elementAt(i);
275 target.onOIAChanged(this, change);
276 }
277 }
278 }
279
280 private Vector<ScreenOIAListener> listeners = null;
281 private boolean insertMode;
282 private boolean locked;
283 private boolean keysBuffered;
284 private int owner = 0;
285 private int level = 0;
286 private Screen5250 source = null;
287 private int commCheck = 0;
288 private int machineCheck = 0;
289 private boolean messageWait;
290 private boolean scriptRunning;
291 private int inputInhibited = INPUTINHIBITED_NOTINHIBITED;
292 private String inhibitedText;
293
294 }