3
|
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 */
|
112
|
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;
|
3
|
52
|
112
|
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;
|
3
|
60
|
112
|
61 public ScreenOIA(Screen5250 screen) {
|
|
62 source = screen;
|
|
63 }
|
3
|
64
|
112
|
65 public boolean isInsertMode() {
|
|
66 return insertMode;
|
|
67 }
|
3
|
68
|
112
|
69 protected void setInsertMode(boolean mode) {
|
|
70 level = OIA_LEVEL_INSERT_MODE;
|
|
71 insertMode = mode;
|
|
72 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INSERT_MODE);
|
|
73 }
|
3
|
74
|
112
|
75 public int getCommCheckCode() {
|
|
76 return commCheck;
|
|
77 }
|
3
|
78
|
112
|
79 public int getInputInhibited() {
|
|
80 return inputInhibited;
|
|
81 }
|
3
|
82
|
112
|
83 public int getMachineCheckCode() {
|
|
84 return machineCheck;
|
|
85 }
|
3
|
86
|
112
|
87 public int getOwner() {
|
|
88 return owner;
|
|
89 }
|
3
|
90
|
112
|
91 public int getProgCheckCode() {
|
|
92 return 0;
|
|
93 }
|
3
|
94
|
112
|
95 /**
|
|
96 * Is the keyboard locked or not
|
|
97 *
|
|
98 * @return locked or not
|
|
99 */
|
|
100 public boolean isKeyBoardLocked() {
|
|
101 return locked;
|
|
102 }
|
3
|
103
|
112
|
104 public boolean isKeysBuffered() {
|
|
105 return keysBuffered;
|
|
106 }
|
3
|
107
|
112
|
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 }
|
3
|
116
|
112
|
117 protected void setKeyBoardLocked(boolean lockIt) {
|
|
118 level = OIA_LEVEL_KEYBOARD;
|
|
119 boolean oldLocked = locked;
|
|
120 locked = lockIt;
|
3
|
121
|
112
|
122 if (!lockIt) {
|
|
123 if (isKeysBuffered()) {
|
|
124 source.sendKeys("");
|
|
125 }
|
|
126 }
|
3
|
127
|
112
|
128 if (locked != oldLocked)
|
|
129 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYBOARD_LOCKED);
|
|
130 }
|
|
131
|
|
132 public boolean isMessageWait() {
|
|
133 return messageWait;
|
|
134 }
|
3
|
135
|
112
|
136 protected void setMessageLightOn() {
|
|
137 level = OIA_LEVEL_MESSAGE_LIGHT_ON;
|
|
138 messageWait = true;
|
|
139 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
|
|
140 }
|
3
|
141
|
112
|
142 protected void setMessageLightOff() {
|
|
143 level = OIA_LEVEL_MESSAGE_LIGHT_OFF;
|
|
144 messageWait = false;
|
|
145 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT);
|
|
146 }
|
3
|
147
|
112
|
148 public void setScriptActive(boolean running) {
|
|
149 level = OIA_LEVEL_SCRIPT;
|
|
150 scriptRunning = running;
|
|
151 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_SCRIPT);
|
|
152 }
|
3
|
153
|
112
|
154 public boolean isScriptActive() {
|
|
155 return scriptRunning;
|
|
156 }
|
3
|
157
|
112
|
158 public void setAudibleBell() {
|
|
159 level = OIA_LEVEL_AUDIBLE_BELL;
|
|
160 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_BELL);
|
|
161 }
|
3
|
162
|
112
|
163 protected void clearScreen() {
|
|
164 level = OIA_LEVEL_CLEAR_SCREEN;
|
|
165 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_CLEAR_SCREEN);
|
|
166 }
|
3
|
167
|
112
|
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 }
|
3
|
177
|
112
|
178 listeners.addElement(listener);
|
|
179 }
|
3
|
180
|
112
|
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 }
|
3
|
190
|
112
|
191 listeners.removeElement(listener);
|
|
192 }
|
3
|
193
|
112
|
194 // object methods
|
|
195 public Screen5250 getSource() {
|
|
196 return source;
|
|
197 }
|
3
|
198
|
|
199
|
112
|
200 public void setSource(Screen5250 screen) {
|
|
201 source = screen;
|
|
202 }
|
3
|
203
|
112
|
204 public void setOwner(int newOwner) {
|
|
205 owner = newOwner;
|
|
206 }
|
3
|
207
|
112
|
208 public int getLevel() {
|
|
209 return level;
|
|
210 }
|
3
|
211
|
112
|
212 public String getInhibitedText() {
|
|
213 return inhibitedText;
|
|
214 }
|
3
|
215
|
112
|
216 public void setInputInhibited(int inhibit , int whatCode) {
|
|
217 setInputInhibited(inhibit, whatCode, null);
|
|
218 }
|
3
|
219
|
112
|
220 public void setInputInhibited(int inhibit , int whatCode, String message) {
|
|
221 inputInhibited = inhibit;
|
|
222 level = OIA_LEVEL_INPUT_INHIBITED;
|
|
223 inhibitedText = message;
|
3
|
224
|
|
225 // if (saveInhibit != inhibit || saveInhibitLevel != whatCode) {
|
112
|
226 switch (inhibit) {
|
3
|
227 case INPUTINHIBITED_COMMCHECK :
|
112
|
228 commCheck = whatCode;
|
|
229 break;
|
|
230
|
3
|
231 case INPUTINHIBITED_PROGCHECK :
|
|
232 // progCheck = whatCode; // never used
|
112
|
233 break;
|
|
234
|
3
|
235 case INPUTINHIBITED_MACHINECHECK :
|
112
|
236 machineCheck = whatCode;
|
|
237 break;
|
|
238
|
3
|
239 case INPUTINHIBITED_SYSTEM_WAIT :
|
112
|
240 level = whatCode;
|
|
241 break;
|
|
242
|
3
|
243 case INPUTINHIBITED_NOTINHIBITED :
|
112
|
244 level = whatCode;
|
|
245 break;
|
|
246 }
|
3
|
247
|
112
|
248 fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INPUTINHIBITED);
|
3
|
249 // }
|
112
|
250 }
|
3
|
251
|
112
|
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();
|
3
|
259
|
112
|
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;
|
3
|
281
|
|
282 }
|