Initial commit
3
META-INF/MANIFEST.MF
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: net.infordata.em.Main
|
||||||
|
|
||||||
19
README
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
xtn5250mg is a fork of vproietti's xtn5250 (https://sourceforge.net/projects/xtn5250/)
|
||||||
|
|
||||||
|
It implements an emulator for 5250 streams to connect to AS400/iSeries.
|
||||||
|
|
||||||
|
Difference between xtn5250mg and original xtn5250 will follow :
|
||||||
|
|
||||||
|
*** version 0.2 ***
|
||||||
|
Re-ordering window title. Host comes before software name.
|
||||||
|
Visual representation of connection status at window title :
|
||||||
|
- prefix * or ~ if connected
|
||||||
|
- prefix ! if disconnected
|
||||||
|
Adds french localization
|
||||||
|
|
||||||
|
*** version 0.1 ***
|
||||||
|
1) xtn5250mg can connect to an AS400 which port is different than the default 23.
|
||||||
|
For such servers, simply append ":" and the port number to the server's address.
|
||||||
|
2) KEEPALIVE. If you experience a recurrent session drop with xtn5250 after a
|
||||||
|
rather small period of inactivity, this fork xtn5250 addresses that issue. However,
|
||||||
|
the value of /proc/sys/net/ipv4/tcp_keepalive_time may also need to be adjusted.
|
||||||
21
build.sh
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Let's go to the folder containing the build.sh file
|
||||||
|
# We don't want to remove all .class files on the system should
|
||||||
|
# the script run on /
|
||||||
|
VERSION="0.1-1.19i"
|
||||||
|
BASEDIR=$(dirname $0)
|
||||||
|
echo $BASEDIR
|
||||||
|
cd $BASEDIR
|
||||||
|
|
||||||
|
# xtn5250mg is a very tiny project. This build is very simple:
|
||||||
|
# it deletes all .class object to rebuild them all.
|
||||||
|
find . -name "*.class" | xargs rm -rf
|
||||||
|
|
||||||
|
find . -name "*.java" > .javasources.txt
|
||||||
|
javac -target 7 -source 7 -encoding "ISO8859-1" @.javasources.txt
|
||||||
|
#rm -f .javasources.txt
|
||||||
|
|
||||||
|
JARFILE="xtn5250mg-${VERSION}.jar"
|
||||||
|
rm -f $JARFILE
|
||||||
|
jar cvmf META-INF/MANIFEST.MF $JARFILE build.sh net README logging.properties -C res res
|
||||||
61
logging.properties
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
############################################################
|
||||||
|
# Default Logging Configuration File
|
||||||
|
#
|
||||||
|
# You can use a different file by specifying a filename
|
||||||
|
# with the java.util.logging.config.file system property.
|
||||||
|
# For example java -Djava.util.logging.config.file=myfile
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Global properties
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
# "handlers" specifies a comma separated list of log Handler
|
||||||
|
# classes. These handlers will be installed during VM startup.
|
||||||
|
# Note that these classes must be on the system classpath.
|
||||||
|
# By default we only configure a ConsoleHandler, which will only
|
||||||
|
# show messages at the INFO and above levels.
|
||||||
|
handlers= java.util.logging.ConsoleHandler
|
||||||
|
|
||||||
|
# To also add the FileHandler, use the following line instead.
|
||||||
|
#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
|
||||||
|
|
||||||
|
# Default global logging level.
|
||||||
|
# This specifies which kinds of events are logged across
|
||||||
|
# all loggers. For any given facility this global level
|
||||||
|
# can be overriden by a facility specific level
|
||||||
|
# Note that the ConsoleHandler also has a separate level
|
||||||
|
# setting to limit messages printed to the console.
|
||||||
|
.level= INFO
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Handler specific properties.
|
||||||
|
# Describes specific configuration info for Handlers.
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
# default file output is in user's home directory.
|
||||||
|
#java.util.logging.FileHandler.pattern = %h/java%u.log
|
||||||
|
java.util.logging.FileHandler.pattern = xtn5250.log
|
||||||
|
java.util.logging.FileHandler.limit = 50000
|
||||||
|
java.util.logging.FileHandler.count = 1
|
||||||
|
#java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
|
||||||
|
java.util.logging.FileHandler.level = ALL
|
||||||
|
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
|
||||||
|
|
||||||
|
# Limit the message that are printed on the console to INFO and above.
|
||||||
|
java.util.logging.ConsoleHandler.level = ALL
|
||||||
|
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Facility specific properties.
|
||||||
|
# Provides extra control for each logger.
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
# For example, set the com.xyz.foo logger to only log SEVERE
|
||||||
|
# messages:
|
||||||
|
#net.infordata.em.tnprot.level = FINEST
|
||||||
|
#net.infordata.em.tn5250.XI5250OrdList.level = FINER
|
||||||
|
#net.infordata.em.tn5250.XI5250Emulator.level = FINER
|
||||||
|
#net.infordata.em.tn5250.XI5250CmdList.level = FINEST
|
||||||
|
|
||||||
347
net/infordata/em/Main.java
Normal file
|
|
@ -0,0 +1,347 @@
|
||||||
|
package net.infordata.em;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.FontFormatException;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XI5250Field;
|
||||||
|
import net.infordata.em.crt5250.XIEbcdicTranslator;
|
||||||
|
import net.infordata.em.tn5250.XI5250Emulator;
|
||||||
|
import net.infordata.em.tn5250.XI5250Frame;
|
||||||
|
import net.infordata.em.tn5250ext.PSHBTNCHCHandler;
|
||||||
|
import net.infordata.em.tn5250ext.XI5250EmulatorExt;
|
||||||
|
import net.infordata.em.tn5250ext.XI5250PanelHandler;
|
||||||
|
import net.infordata.em.tn5250ext.XI5250PanelsDispatcher;
|
||||||
|
import net.infordata.em.tn5250.XIImagesBdl;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command line startup utility.
|
||||||
|
* @author valentino.proietti
|
||||||
|
*/
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
// images
|
||||||
|
private static XIImagesBdl cvImagesBdl =
|
||||||
|
net.infordata.em.tn5250.XIImagesBdl.getImagesBdl();
|
||||||
|
|
||||||
|
private Main() {}
|
||||||
|
|
||||||
|
private static void usageError(String msg) {
|
||||||
|
System.err.println(msg);
|
||||||
|
System.err.println("Usage: [-3dFX] [-PSHBTNCHC] [-STRPCCMD] [-altFKeyRemap]" +
|
||||||
|
" [-maximized] [-cp codepage] [-devName name]" +
|
||||||
|
" [-autoLogon <fieldsCount>;<usrFieldLabel>;<pwdFieldLabel>;<user>;<passwd>]" +
|
||||||
|
" host-name");
|
||||||
|
System.err.println("Supported code pages:");
|
||||||
|
for (String cp : XIEbcdicTranslator.getRegisteredTranslators().keySet()) {
|
||||||
|
System.err.println(" " + cp +
|
||||||
|
(XI5250Emulator.DEFAULT_CODE_PAGE.equalsIgnoreCase(cp)? " default" : ""));
|
||||||
|
}
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Font loadFontFromResource(Class theClass, String fontFileName, float fontSize) {
|
||||||
|
float fntSize = 12f;
|
||||||
|
if (fontSize >= 1f) {
|
||||||
|
fntSize = fontSize;
|
||||||
|
}
|
||||||
|
InputStream is = null;
|
||||||
|
try {
|
||||||
|
is = new FileInputStream("/tmp/Inconsolata.otf");
|
||||||
|
} catch (FileNotFoundException ex) {
|
||||||
|
System.err.println("file not found font : " + ex);
|
||||||
|
}
|
||||||
|
Font font = null;
|
||||||
|
try {
|
||||||
|
System.err.println(" createFont Testing res/" + fontFileName + " ... ");
|
||||||
|
font = Font.createFont(Font.TRUETYPE_FONT, is);
|
||||||
|
System.err.println(" createFont OK ");
|
||||||
|
font = font.deriveFont(fntSize);
|
||||||
|
} catch (FontFormatException | IOException ex) {
|
||||||
|
System.err.println(" Font err : " + ex.getMessage());
|
||||||
|
} finally {
|
||||||
|
if (is != null) {
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
System.err.println("Close error : " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
boolean pUse3dFX = false;
|
||||||
|
boolean pAltFKeyRemap = false;
|
||||||
|
boolean pPSHBTNCHC = false;
|
||||||
|
boolean pSTRPCCMD = false;
|
||||||
|
boolean pMaximized = false;
|
||||||
|
|
||||||
|
String arg;
|
||||||
|
String pHost = null;
|
||||||
|
boolean expectCP = false;
|
||||||
|
boolean expectDevName = false;
|
||||||
|
boolean expectLogonInfo = false;
|
||||||
|
String cp = null;
|
||||||
|
String devName = null;
|
||||||
|
LogonInfo logonInfo = null;
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
arg = args[i];
|
||||||
|
if (arg.startsWith("-")) {
|
||||||
|
if ("-3dfx".equalsIgnoreCase(arg))
|
||||||
|
pUse3dFX = true;
|
||||||
|
else if ("-PSHBTNCHC".equalsIgnoreCase(arg))
|
||||||
|
pPSHBTNCHC = true;
|
||||||
|
else if ("-STRPCCMD".equalsIgnoreCase(arg))
|
||||||
|
pSTRPCCMD = true;
|
||||||
|
else if ("-maximized".equalsIgnoreCase(arg))
|
||||||
|
pMaximized = true;
|
||||||
|
else if ("-altFKeyRemap".equalsIgnoreCase(arg))
|
||||||
|
pAltFKeyRemap = true;
|
||||||
|
else if ("-cp".equalsIgnoreCase(arg))
|
||||||
|
expectCP = true;
|
||||||
|
else if ("-devName".equalsIgnoreCase(arg))
|
||||||
|
expectDevName = true;
|
||||||
|
else if ("-autoLogon".equalsIgnoreCase(arg))
|
||||||
|
expectLogonInfo = true;
|
||||||
|
else
|
||||||
|
usageError("Wrong option: " + arg);
|
||||||
|
}
|
||||||
|
else if (expectCP) {
|
||||||
|
expectCP = false;
|
||||||
|
if (XIEbcdicTranslator.getTranslator(arg) == null)
|
||||||
|
usageError("Unknown codepage: " + arg);
|
||||||
|
cp = arg;
|
||||||
|
}
|
||||||
|
else if (expectDevName) {
|
||||||
|
expectDevName = false;
|
||||||
|
devName = arg;
|
||||||
|
}
|
||||||
|
else if (expectLogonInfo) {
|
||||||
|
expectLogonInfo = false;
|
||||||
|
try {
|
||||||
|
logonInfo = new LogonInfo(arg);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex) {
|
||||||
|
usageError(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (pHost == null)
|
||||||
|
pHost = arg;
|
||||||
|
else
|
||||||
|
usageError("Too many host names.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (expectCP)
|
||||||
|
usageError("A code page is expected");
|
||||||
|
|
||||||
|
final boolean altFKeyRemap = pAltFKeyRemap;
|
||||||
|
final boolean use3dFX = pUse3dFX;
|
||||||
|
final boolean enablePSHBTNCHC = pPSHBTNCHC;
|
||||||
|
final boolean enableSTRPCCMD = pSTRPCCMD;
|
||||||
|
final boolean maximized = pMaximized;
|
||||||
|
final String host = pHost;
|
||||||
|
final String codePage = cp;
|
||||||
|
final String deviceName = devName;
|
||||||
|
final LogonInfo autoLogonInfo = logonInfo;
|
||||||
|
try {
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
XI5250Emulator em;
|
||||||
|
if (enablePSHBTNCHC) {
|
||||||
|
XI5250EmulatorExt emext = new XI5250EmulatorExt();
|
||||||
|
PanelsDispatcher disp = new PanelsDispatcher();
|
||||||
|
disp.setEmulator(emext);
|
||||||
|
new PSHBTNCHCHandler(disp);
|
||||||
|
if (autoLogonInfo != null)
|
||||||
|
new AutoLogonHandler(disp, autoLogonInfo);
|
||||||
|
em = emext;
|
||||||
|
}
|
||||||
|
else if (autoLogonInfo != null) {
|
||||||
|
XI5250EmulatorExt emext = new XI5250EmulatorExt();
|
||||||
|
PanelsDispatcher disp = new PanelsDispatcher();
|
||||||
|
disp.setEmulator(emext);
|
||||||
|
new AutoLogonHandler(disp, autoLogonInfo);
|
||||||
|
em = emext;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
em = new XI5250Emulator();
|
||||||
|
}
|
||||||
|
em.setTerminalType("IBM-3477-FC");
|
||||||
|
em.setKeyboardQueue(true);
|
||||||
|
|
||||||
|
em.setStrPcCmdEnabled(enableSTRPCCMD);
|
||||||
|
em.setAltFKeyRemap(altFKeyRemap);
|
||||||
|
em.setCodePage(codePage);
|
||||||
|
|
||||||
|
if (deviceName != null)
|
||||||
|
em.setTelnetEnv("\u0003DEVNAME\u0001" + deviceName);
|
||||||
|
|
||||||
|
if (host != null) {
|
||||||
|
em.setHost(host);
|
||||||
|
em.setActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Font mahefaFont = loadFontFromResource(Main.class, "MonoSpaced", 1);
|
||||||
|
em.setFont(mahefaFont);
|
||||||
|
XI5250Frame frm = new XI5250Frame("xtn5250mg" + " " +
|
||||||
|
XI5250Emulator.VERSION, em);
|
||||||
|
frm.setFont(mahefaFont);
|
||||||
|
frm.setIconImage(cvImagesBdl.getImage("Logo"));
|
||||||
|
|
||||||
|
frm.addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//3D FX
|
||||||
|
if (use3dFX) {
|
||||||
|
em.setDefFieldsBorderStyle(XI5250Field.LOWERED_BORDER);
|
||||||
|
em.setDefBackground(UIManager.getColor("control"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//frm.setBounds(0, 0, 570, 510);
|
||||||
|
frm.centerOnScreen(70);
|
||||||
|
if (maximized) {
|
||||||
|
frm.doNotPackOnStartup();
|
||||||
|
frm.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||||
|
}
|
||||||
|
frm.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (InterruptedException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
catch (InvocationTargetException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////
|
||||||
|
|
||||||
|
private static class PanelsDispatcher extends XI5250PanelsDispatcher {
|
||||||
|
|
||||||
|
private AutoLogonHandler ivAutoLogonHandler;
|
||||||
|
private XI5250PanelHandler ivHandler;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void addPanelHandler(XI5250PanelHandler panel) {
|
||||||
|
if (panel instanceof AutoLogonHandler) {
|
||||||
|
if (ivAutoLogonHandler != null)
|
||||||
|
throw new IllegalArgumentException("Handler already setted");
|
||||||
|
ivAutoLogonHandler = (AutoLogonHandler)panel;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ivHandler != null)
|
||||||
|
throw new IllegalArgumentException("Handler already setted");
|
||||||
|
ivHandler = panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected synchronized XI5250PanelHandler getCurrentPanelHandler() {
|
||||||
|
return (ivAutoLogonHandler != null && ivAutoLogonHandler.detailedTest()) ? ivAutoLogonHandler : ivHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void removePanelHandler(XI5250PanelHandler panel) {
|
||||||
|
if (ivHandler != panel)
|
||||||
|
throw new IllegalArgumentException("Not the registered handler " + panel);
|
||||||
|
ivHandler = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////
|
||||||
|
|
||||||
|
private static class LogonInfo {
|
||||||
|
|
||||||
|
final int fieldsCount;
|
||||||
|
final String userLabel;
|
||||||
|
final String passwdLabel;
|
||||||
|
final String user;
|
||||||
|
final String passwd;
|
||||||
|
|
||||||
|
LogonInfo(String info) {
|
||||||
|
String[] ss = info.split(";", 5);
|
||||||
|
if (ss.length < 5)
|
||||||
|
throw new IllegalArgumentException("Invalid autoLogon argument");
|
||||||
|
try {
|
||||||
|
fieldsCount = Integer.parseInt(ss[0]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex) {
|
||||||
|
throw new IllegalArgumentException("Invalid autoLogon argument: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
userLabel = ss[1];
|
||||||
|
passwdLabel = ss[2];
|
||||||
|
user = ss[3];
|
||||||
|
passwd = ss[4];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////
|
||||||
|
|
||||||
|
private static class AutoLogonHandler extends XI5250PanelHandler {
|
||||||
|
|
||||||
|
private final LogonInfo ivLogonInfo;
|
||||||
|
private boolean ivLoggedOn;
|
||||||
|
|
||||||
|
public AutoLogonHandler(XI5250PanelsDispatcher aPanelDisp, LogonInfo info) {
|
||||||
|
super(aPanelDisp);
|
||||||
|
ivLogonInfo = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean detailedTest() {
|
||||||
|
if (ivLoggedOn)
|
||||||
|
return false;
|
||||||
|
// I'm expecting xx fields in the logon panel
|
||||||
|
if (getFields().size() != ivLogonInfo.fieldsCount)
|
||||||
|
return false;
|
||||||
|
// Is there the user id field ?
|
||||||
|
if (!checkField(getFieldNextTo(ivLogonInfo.userLabel), 10))
|
||||||
|
return false;
|
||||||
|
// Is there the password field ?
|
||||||
|
if (!checkField(getFieldNextTo(ivLogonInfo.passwdLabel), 10))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void start() {
|
||||||
|
ivLoggedOn = true;
|
||||||
|
// Start logon panel processing
|
||||||
|
XI5250Field userField = getFieldNextTo(ivLogonInfo.userLabel);
|
||||||
|
XI5250Field passwdField = getFieldNextTo(ivLogonInfo.passwdLabel);
|
||||||
|
userField.setString(ivLogonInfo.user); // Your user id
|
||||||
|
passwdField.setString(ivLogonInfo.passwd); // Your password
|
||||||
|
// Simulate the user ENTER key pressed
|
||||||
|
getEmulator().processRawKeyEvent(
|
||||||
|
new KeyEvent(getEmulator(), KeyEvent.KEY_PRESSED,
|
||||||
|
0, 0, KeyEvent.VK_ENTER, KeyEvent.CHAR_UNDEFINED));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void stop() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1249
net/infordata/em/crt/XICrt.java
Normal file
84
net/infordata/em/crt/XICrtBeanInfo.java
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.infordata.em.crt;
|
||||||
|
|
||||||
|
import java.beans.BeanInfo;
|
||||||
|
import java.beans.IntrospectionException;
|
||||||
|
import java.beans.Introspector;
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.beans.SimpleBeanInfo;
|
||||||
|
|
||||||
|
public class XICrtBeanInfo extends SimpleBeanInfo {
|
||||||
|
Class<XICrt> beanClass = XICrt.class;
|
||||||
|
String iconColor16x16Filename;
|
||||||
|
String iconColor32x32Filename;
|
||||||
|
String iconMono16x16Filename;
|
||||||
|
String iconMono32x32Filename;
|
||||||
|
|
||||||
|
|
||||||
|
public XICrtBeanInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDescriptor[] getPropertyDescriptors() {
|
||||||
|
try {
|
||||||
|
PropertyDescriptor _cursorVisible = new PropertyDescriptor("cursorVisible", beanClass, "isCursorVisible", "setCursorVisible");
|
||||||
|
|
||||||
|
PropertyDescriptor _font = new PropertyDescriptor("font", beanClass, "getFont", "setFont");
|
||||||
|
|
||||||
|
PropertyDescriptor[] pds = new PropertyDescriptor[] {
|
||||||
|
_cursorVisible,
|
||||||
|
_font,
|
||||||
|
};
|
||||||
|
return pds;
|
||||||
|
}
|
||||||
|
catch (IntrospectionException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.awt.Image getIcon(int iconKind) {
|
||||||
|
switch (iconKind) {
|
||||||
|
case BeanInfo.ICON_COLOR_16x16:
|
||||||
|
return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null;
|
||||||
|
case BeanInfo.ICON_COLOR_32x32:
|
||||||
|
return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null;
|
||||||
|
case BeanInfo.ICON_MONO_16x16:
|
||||||
|
return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null;
|
||||||
|
case BeanInfo.ICON_MONO_32x32:
|
||||||
|
return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BeanInfo[] getAdditionalBeanInfo() {
|
||||||
|
Class<?> superclass = beanClass.getSuperclass();
|
||||||
|
try {
|
||||||
|
BeanInfo superBeanInfo = Introspector.getBeanInfo(superclass);
|
||||||
|
return new BeanInfo[] { superBeanInfo };
|
||||||
|
}
|
||||||
|
catch (IntrospectionException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
599
net/infordata/em/crt/XICrtBuffer.java
Normal file
|
|
@ -0,0 +1,599 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 26/03/97 rel. 0.90 - start of revisions history.
|
||||||
|
26/03/97 rel. 0.90 - changed to speed up drawing.
|
||||||
|
10/04/97 rel. 0.93 - chars less than space are not drawed but are stored in ivCharBuffer.
|
||||||
|
28/04/97 rel. _.__ - ivCharBuffer, ivAttrBuffer array from [cols][rows] to [rows][cols].
|
||||||
|
14/05/97 rel. 1.00 - first release.
|
||||||
|
30/07/97 rel. 1.03b- bugs.
|
||||||
|
13/01/98 rel. 1.05d- NT painting bug.
|
||||||
|
14/01/98 rel. 1.06 - asynchronous paint on off-screen image.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
29/07/99 rel. 1.14 - Rework on 3d look&feel.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements an off-screen image buffer.
|
||||||
|
* To be used by XICrt.
|
||||||
|
*
|
||||||
|
* @see XICrt
|
||||||
|
*
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XICrtBuffer implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private int ivNCols;
|
||||||
|
private int ivNRows;
|
||||||
|
|
||||||
|
transient private Graphics ivGr;
|
||||||
|
transient private int ivCharW;
|
||||||
|
transient private int ivCharH;
|
||||||
|
transient private int ivCharD;
|
||||||
|
transient private int ivGrW;
|
||||||
|
transient private int ivGrH;
|
||||||
|
|
||||||
|
private int ivDefAttr; // default char attribute
|
||||||
|
|
||||||
|
// [rows][cols]
|
||||||
|
private char[][] ivCharBuffer;
|
||||||
|
private int[][] ivAttrBuffer;
|
||||||
|
|
||||||
|
//!!1.06
|
||||||
|
transient private List<Rectangle> ivDirtyAreas = new ArrayList<Rectangle>(20);
|
||||||
|
|
||||||
|
//!!1.14
|
||||||
|
transient private XICrt ivCrt;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a XICrtBuffer with the given dimensions expressed in number of
|
||||||
|
* chars.
|
||||||
|
*/
|
||||||
|
public XICrtBuffer(int nCols, int nRows) {
|
||||||
|
ivNCols = nCols;
|
||||||
|
ivNRows = nRows;
|
||||||
|
ivCharBuffer = new char[ivNRows][ivNCols];
|
||||||
|
ivAttrBuffer = new int[ivNRows][ivNCols];
|
||||||
|
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a XICrtBuffer filling it with a portion of another one.
|
||||||
|
*/
|
||||||
|
public XICrtBuffer(XICrtBuffer from, int aC, int aR, int aW, int aH) {
|
||||||
|
this(aW, aH);
|
||||||
|
copyFrom(0, 0, from, aC, aR, aW, aH);
|
||||||
|
setDefAttr(from.getDefAttr());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a cloned XICrtBuffer (the new one needs initGraphics() to be
|
||||||
|
* displayed).
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
XICrtBuffer aClone = new XICrtBuffer(this, 0, 0, ivNCols, ivNRows);
|
||||||
|
/* !!1.04
|
||||||
|
XICrtBuffer aClone = new XICrtBuffer(ivNCols, ivNRows);
|
||||||
|
aClone.copyFrom(this);
|
||||||
|
*/
|
||||||
|
return aClone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
final void setCrt(XICrt crt) {
|
||||||
|
ivCrt = crt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XICrt getCrt() {
|
||||||
|
return ivCrt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the graphics area.
|
||||||
|
*/
|
||||||
|
public synchronized void setGraphics(Graphics gr) {
|
||||||
|
ivGr = gr;
|
||||||
|
if (ivGr != null) {
|
||||||
|
FontMetrics fontMetrics = ivGr.getFontMetrics();
|
||||||
|
ivCharW = fontMetrics.charWidth('W');
|
||||||
|
ivCharH = fontMetrics.getHeight();
|
||||||
|
ivCharD = fontMetrics.getDescent();
|
||||||
|
ivGrW = ivNCols * ivCharW;
|
||||||
|
ivGrH = ivNRows * ivCharH;
|
||||||
|
|
||||||
|
copyFrom(this); // refresh !!1.06 required
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//!!1.03b
|
||||||
|
ivCharW = 1; // to avoid possible division by 0 in pending events
|
||||||
|
ivCharH = 1;
|
||||||
|
ivCharD = 1;
|
||||||
|
ivGrW = ivNCols * ivCharW;
|
||||||
|
ivGrH = ivNRows * ivCharH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the buffer on System.out stream.
|
||||||
|
* Useful for debugging.
|
||||||
|
*/
|
||||||
|
public void dumpBuffer(PrintStream out) {
|
||||||
|
out.println("BUFFER DUMP");
|
||||||
|
for (int r = 0; r < ivNRows; r++) {
|
||||||
|
for (int c = 0; c < ivNCols; c++)
|
||||||
|
out.print(ivCharBuffer[r][c]);
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
for (int r = 0; r < ivNRows; r++) {
|
||||||
|
for (int c = 0; c < ivNCols; c++)
|
||||||
|
out.print(Integer.toHexString(ivAttrBuffer[r][c]) + " ");
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
out.println("END BUFFER DUMP");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy contents from another XICrtBuffer (can be itself).
|
||||||
|
*/
|
||||||
|
public void copyFrom(XICrtBuffer from) {
|
||||||
|
copyFrom(0, 0, from, 0, 0, from.ivNCols, from.ivNRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy contents from another XICrtBuffer (can be itself).
|
||||||
|
* @param col the destination column pos.
|
||||||
|
* @param row the destination row pos.
|
||||||
|
* @param from the source XICrtBuffer.
|
||||||
|
* @param aC the source column pos.
|
||||||
|
* @param aR the source row pos.
|
||||||
|
* @param aW the source dimension.
|
||||||
|
* @param aH the source dimension.
|
||||||
|
*/
|
||||||
|
public synchronized void copyFrom(int col, int row,
|
||||||
|
XICrtBuffer from,
|
||||||
|
int aC, int aR, int aW, int aH) {
|
||||||
|
aW = Math.min(aW, from.ivNCols - aC);
|
||||||
|
aH = Math.min(aH, from.ivNRows - aR);
|
||||||
|
int nCols = Math.min(ivNCols - col, aW);
|
||||||
|
int nRows = Math.min(ivNRows - row, aH);
|
||||||
|
int lastAttr;
|
||||||
|
int lastCol;
|
||||||
|
int lastRow;
|
||||||
|
StringBuilder str;
|
||||||
|
|
||||||
|
for (int r = 0; r < nRows; r++) {
|
||||||
|
for (int c = 0; c < nCols; ) {
|
||||||
|
lastCol = col + c;
|
||||||
|
lastRow = row + r;
|
||||||
|
lastAttr = from.getAttrInternal(aC + c, aR + r);
|
||||||
|
str = new StringBuilder();
|
||||||
|
|
||||||
|
// group chars with the same attribute
|
||||||
|
for ( ; c < nCols && lastAttr == from.getAttrInternal(aC + c, aR + r); c++)
|
||||||
|
str.append(from.getChar(aC + c, aR + r));
|
||||||
|
|
||||||
|
drawString(new String(str), lastCol, lastRow, lastAttr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void invalidateAll() {
|
||||||
|
addDirtyArea(new Rectangle(0, 0, ivNCols, ivNRows));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the screen buffer.
|
||||||
|
*/
|
||||||
|
public synchronized void clear() {
|
||||||
|
for (int c = 0; c < ivNCols; c++)
|
||||||
|
for (int r = 0; r < ivNRows; r++) {
|
||||||
|
ivCharBuffer[r][c] = '\u0000';
|
||||||
|
ivAttrBuffer[r][c] = ivDefAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ivDirtyAreas.clear();
|
||||||
|
|
||||||
|
if (ivGr != null) {
|
||||||
|
Graphics gr = ivGr.create(); //!!1.05d
|
||||||
|
try {
|
||||||
|
gr.setColor(getBackground(ivDefAttr));
|
||||||
|
gr.fillRect(0, 0, ivGrW, ivGrH);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
gr.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public synchronized void scrollDown(int r1, int r2, int nRows) {
|
||||||
|
if ((r1 >= r2) || (nRows == 0))
|
||||||
|
throw new IllegalArgumentException("ScrollDown()");
|
||||||
|
|
||||||
|
sync();
|
||||||
|
|
||||||
|
nRows = Math.max(nRows, r2 - r1);
|
||||||
|
|
||||||
|
for (int r = r2; r > (r1 + nRows); r--)
|
||||||
|
for (int c = 0; c < ivNCols; c++) {
|
||||||
|
ivCharBuffer[r][c] = ivCharBuffer[r - nRows][c];
|
||||||
|
ivAttrBuffer[r][c] = ivAttrBuffer[r - nRows][c];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int r = r1; r <= (r1 + nRows); r++)
|
||||||
|
for (int c = 0; c < ivNCols; c++) {
|
||||||
|
ivCharBuffer[r][c] = '\u0000';
|
||||||
|
ivAttrBuffer[r][c] = ivDefAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ivGr != null) {
|
||||||
|
Graphics gr = ivGr.create(); //!!1.05d
|
||||||
|
try {
|
||||||
|
gr.copyArea(0, r1 * ivCharH, ivNCols * ivCharW, (r2 - r1) * ivCharH,
|
||||||
|
0, ivCharH * nRows);
|
||||||
|
gr.setColor(getBackground(ivDefAttr));
|
||||||
|
gr.fillRect(0, r1 * ivCharH, ivNCols * ivCharW, ivCharH * nRows);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
gr.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public synchronized void scrollUp(int r1, int r2, int nRows) {
|
||||||
|
if ((r1 >= r2) || (nRows == 0))
|
||||||
|
throw new IllegalArgumentException("ScrollUp()");
|
||||||
|
|
||||||
|
sync();
|
||||||
|
|
||||||
|
nRows = Math.max(nRows, r2 - r1);
|
||||||
|
|
||||||
|
for (int r = r1; r < (r2 - nRows); r++)
|
||||||
|
for (int c = 0; c < ivNCols; c++) {
|
||||||
|
ivCharBuffer[r][c] = ivCharBuffer[r + nRows][c];
|
||||||
|
ivAttrBuffer[r][c] = ivAttrBuffer[r + nRows][c];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int r = r2; r >= (r2 - nRows); r--)
|
||||||
|
for (int c = 0; c < ivNCols; c++) {
|
||||||
|
ivCharBuffer[r][c] = '\u0000';
|
||||||
|
ivAttrBuffer[r][c] = ivDefAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ivGr != null) {
|
||||||
|
Graphics gr = ivGr.create(); //!!1.05d
|
||||||
|
try {
|
||||||
|
gr.copyArea(0, (r1 + 1) * ivCharH, ivNCols * ivCharW, (r2 - r1) * ivCharH,
|
||||||
|
0, -ivCharH * nRows);
|
||||||
|
gr.setColor(getBackground(ivDefAttr));
|
||||||
|
gr.fillRect(0, (r2 - nRows + 1) * ivCharH, ivNCols * ivCharW, ivCharH * nRows);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
gr.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the dimensions in chars.
|
||||||
|
*/
|
||||||
|
public Dimension getCrtSize() {
|
||||||
|
return new Dimension(ivNCols, ivNRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the dimensions in pixels.
|
||||||
|
*/
|
||||||
|
public Dimension getSize() {
|
||||||
|
return new Dimension(ivGrW, ivGrH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public Dimension getCharSize() {
|
||||||
|
return new Dimension(ivCharW, ivCharH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts characters coordinates in pixels coordinates.
|
||||||
|
*/
|
||||||
|
public Point toPoint(int col, int row) {
|
||||||
|
return new Point(col * ivCharW, (row + 1) * ivCharH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the default attribute.
|
||||||
|
*/
|
||||||
|
public void drawString(String str, int col, int row) {
|
||||||
|
drawString(str, col, row, ivDefAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the given attribute.
|
||||||
|
*/
|
||||||
|
public synchronized void drawString(String aStr, int col, int row,
|
||||||
|
int aAttr) {
|
||||||
|
col = Math.max(0, Math.min(ivNCols - 1, col));
|
||||||
|
row = Math.max(0, Math.min(ivNRows - 1, row));
|
||||||
|
int len = Math.min(aStr.length(), ivNCols - col);
|
||||||
|
|
||||||
|
if (len <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
ivCharBuffer[row][col + i] = aStr.charAt(i);
|
||||||
|
ivAttrBuffer[row][col + i] = aAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
addDirtyArea(new Rectangle(col, row, len, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private void addDirtyArea(Rectangle newRt) {
|
||||||
|
Rectangle rt;
|
||||||
|
Rectangle rtG;
|
||||||
|
Rectangle res = new Rectangle(newRt); //!!V 03/03/98
|
||||||
|
int count = 0;
|
||||||
|
for (Iterator<Rectangle> e = ivDirtyAreas.iterator(); e.hasNext(); ) {
|
||||||
|
rt = (Rectangle)e.next();
|
||||||
|
// used to see if rectangles are adiacent (x coord)
|
||||||
|
rtG = new Rectangle(rt);
|
||||||
|
rtG.grow(1, 0);
|
||||||
|
if (rtG.intersects(newRt)) {
|
||||||
|
e.remove();
|
||||||
|
res = res.union(rt);
|
||||||
|
// no more than two rects can be joined (x coord)
|
||||||
|
if (++count >= 2)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ivDirtyAreas.add(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be called just before painting the offscreen image.
|
||||||
|
*/
|
||||||
|
public synchronized void sync() {
|
||||||
|
if (ivGr == null || ivDirtyAreas.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Graphics gr = ivGr.create(); //!!1.05d
|
||||||
|
try {
|
||||||
|
Rectangle rt;
|
||||||
|
for (Iterator<Rectangle> e = ivDirtyAreas.iterator(); e.hasNext(); ) {
|
||||||
|
rt = (Rectangle)e.next();
|
||||||
|
|
||||||
|
int lastAttr;
|
||||||
|
int lastCol;
|
||||||
|
int lastRow;
|
||||||
|
StringBuilder str;
|
||||||
|
|
||||||
|
for (int r = 0; r < rt.height; r++) {
|
||||||
|
for (int c = 0; c < rt.width; ) {
|
||||||
|
lastCol = rt.x + c;
|
||||||
|
lastRow = rt.y + r;
|
||||||
|
lastAttr = getAttr(rt.x + c, rt.y + r);
|
||||||
|
str = new StringBuilder();
|
||||||
|
|
||||||
|
// group char with the same attribute to speed up drawing
|
||||||
|
for ( ; c < rt.width && lastAttr == getAttr(rt.x + c, rt.y + r); c++)
|
||||||
|
str.append(getChar(rt.x + c, rt.y + r));
|
||||||
|
|
||||||
|
_drawString(gr, new String(str), lastCol, lastRow, lastAttr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (XICrt.DEBUG >= 2) {
|
||||||
|
gr.setColor(Color.yellow);
|
||||||
|
gr.drawRect(rt.x * ivCharW + 1, rt.y * ivCharH + 1,
|
||||||
|
rt.width * ivCharW - 3, rt.height * ivCharH - 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ivDirtyAreas.clear();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
gr.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws the given string on the graphics context (called by sync()).
|
||||||
|
*/
|
||||||
|
protected void _drawString(Graphics gr, String aStr, int col, int row,
|
||||||
|
int aAttr) { //!!1.06
|
||||||
|
int len = aStr.length();
|
||||||
|
|
||||||
|
gr.setColor(getBackground(aAttr));
|
||||||
|
gr.fillRect(col * ivCharW, row * ivCharH, ivCharW * len, ivCharH);
|
||||||
|
|
||||||
|
// do not draw char less than space
|
||||||
|
StringBuilder strBuf = new StringBuilder(aStr);
|
||||||
|
for (int i = 0; i < strBuf.length(); i++) {
|
||||||
|
if (strBuf.charAt(i) < ' ')
|
||||||
|
strBuf.setCharAt(i, ' ');
|
||||||
|
}
|
||||||
|
String str = new String(strBuf);
|
||||||
|
|
||||||
|
gr.setColor(getForeground(aAttr));
|
||||||
|
gr.drawString(str.substring(0, len), col * ivCharW,
|
||||||
|
(row + 1) * ivCharH - ivCharD);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public String getString(int col, int row, int nChars) {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
for (int i = 0; i < nChars; i++) {
|
||||||
|
str.append(getChar(col + i, row));
|
||||||
|
}
|
||||||
|
return new String(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public String getString() {
|
||||||
|
char[] buf = new char[ivNRows * ivNCols];
|
||||||
|
|
||||||
|
for (int i = 0; i < ivNRows; i++)
|
||||||
|
System.arraycopy(ivCharBuffer[i], 0, buf, i * ivNCols, ivNCols);
|
||||||
|
|
||||||
|
return new String(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Background attribute to color mapping.
|
||||||
|
*/
|
||||||
|
protected Color getBackground(int aAttribute){
|
||||||
|
return Color.red;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Foreground attribute to color mapping.
|
||||||
|
*/
|
||||||
|
protected Color getForeground(int aAttribute) {
|
||||||
|
return Color.blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final int getAttrInternal(int col, int row) {
|
||||||
|
col = Math.max(0, Math.min(ivNCols - 1, col));
|
||||||
|
row = Math.max(0, Math.min(ivNRows - 1, row));
|
||||||
|
|
||||||
|
return ivAttrBuffer[row][col];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public int getAttr(int col, int row) {
|
||||||
|
return getAttrInternal(col, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final char getChar(int col, int row) {
|
||||||
|
col = Math.max(0, Math.min(ivNCols - 1, col));
|
||||||
|
row = Math.max(0, Math.min(ivNRows - 1, row));
|
||||||
|
|
||||||
|
return ivCharBuffer[row][col];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the default attribute.
|
||||||
|
*/
|
||||||
|
public void setDefAttr(int aAttr) {
|
||||||
|
ivDefAttr = aAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default attribute.
|
||||||
|
*/
|
||||||
|
public final int getDefAttr() {
|
||||||
|
return ivDefAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public Point toPoints(int aCol, int aRow) {
|
||||||
|
return new Point(aCol * ivCharW, aRow * ivCharH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public Rectangle toPoints(int aCol, int aRow, int aNCols, int aNRows) {
|
||||||
|
return new Rectangle(aCol * ivCharW, aRow * ivCharH,
|
||||||
|
aNCols * ivCharW, aNRows * ivCharH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
void writeObject(ObjectOutputStream oos) throws IOException {
|
||||||
|
oos.defaultWriteObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||||
|
ois.defaultReadObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
45
net/infordata/em/crt5250/XI5250BaseField.java
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common base interface for XI5250FieldsList and XI5250Field.
|
||||||
|
* Only for possible future implementations.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public interface XI5250BaseField {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void init();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void saveTo(XI5250FieldSaver aSaver) throws IOException;
|
||||||
|
}
|
||||||
1780
net/infordata/em/crt5250/XI5250Crt.java
Normal file
75
net/infordata/em/crt5250/XI5250CrtAdapter.java
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XI5250CrtListener adapter.
|
||||||
|
* @see XI5250CrtListener
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250CrtAdapter implements XI5250CrtListener {
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#FIELD_ACTIVATED
|
||||||
|
*/
|
||||||
|
public void fieldActivated(XI5250CrtEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#FIELD_DEACTIVATED
|
||||||
|
*/
|
||||||
|
public void fieldDeactivated(XI5250CrtEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#SIZE_CHANGED
|
||||||
|
*/
|
||||||
|
public void sizeChanged(XI5250CrtEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#KEY_EVENT
|
||||||
|
*/
|
||||||
|
public void keyEvent(XI5250CrtEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#MOUSE_ENTERS_FIELD
|
||||||
|
*/
|
||||||
|
public void mouseEntersField(XI5250CrtEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#MOUSE_EXITS_FIELD
|
||||||
|
*/
|
||||||
|
public void mouseExitsField(XI5250CrtEvent e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
97
net/infordata/em/crt5250/XI5250CrtBeanInfo.java
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
import java.beans.BeanInfo;
|
||||||
|
import java.beans.IntrospectionException;
|
||||||
|
import java.beans.Introspector;
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.beans.SimpleBeanInfo;
|
||||||
|
|
||||||
|
public class XI5250CrtBeanInfo extends SimpleBeanInfo {
|
||||||
|
Class<XI5250Crt> beanClass = XI5250Crt.class;
|
||||||
|
String iconColor16x16Filename;
|
||||||
|
String iconColor32x32Filename;
|
||||||
|
String iconMono16x16Filename;
|
||||||
|
String iconMono32x32Filename;
|
||||||
|
|
||||||
|
|
||||||
|
public XI5250CrtBeanInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDescriptor[] getPropertyDescriptors() {
|
||||||
|
try {
|
||||||
|
PropertyDescriptor _defBackground = new PropertyDescriptor("defBackground", beanClass, "getDefBackground", "setDefBackground");
|
||||||
|
|
||||||
|
PropertyDescriptor _defFieldsBorderStyle = new PropertyDescriptor("defFieldsBorderStyle", beanClass, "getDefFieldsBorderStyle", "setDefFieldsBorderStyle");
|
||||||
|
|
||||||
|
PropertyDescriptor _font = new PropertyDescriptor("font", beanClass, null, "setFont");
|
||||||
|
|
||||||
|
PropertyDescriptor _insertState = new PropertyDescriptor("insertState", beanClass, "isInsertState", "setInsertState");
|
||||||
|
|
||||||
|
PropertyDescriptor _referenceCursor = new PropertyDescriptor("referenceCursor", beanClass, "isReferenceCursor", "setReferenceCursor");
|
||||||
|
|
||||||
|
PropertyDescriptor _codePage = new PropertyDescriptor("codePage", beanClass, "getCodePage", "setCodePage");
|
||||||
|
|
||||||
|
PropertyDescriptor[] pds = new PropertyDescriptor[] {
|
||||||
|
_defBackground,
|
||||||
|
_defFieldsBorderStyle,
|
||||||
|
_font,
|
||||||
|
_insertState,
|
||||||
|
_referenceCursor,
|
||||||
|
_codePage,
|
||||||
|
};
|
||||||
|
return pds;
|
||||||
|
}
|
||||||
|
catch (IntrospectionException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.awt.Image getIcon(int iconKind) {
|
||||||
|
switch (iconKind) {
|
||||||
|
case BeanInfo.ICON_COLOR_16x16:
|
||||||
|
return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null;
|
||||||
|
case BeanInfo.ICON_COLOR_32x32:
|
||||||
|
return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null;
|
||||||
|
case BeanInfo.ICON_MONO_16x16:
|
||||||
|
return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null;
|
||||||
|
case BeanInfo.ICON_MONO_32x32:
|
||||||
|
return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BeanInfo[] getAdditionalBeanInfo() {
|
||||||
|
Class<?> superclass = beanClass.getSuperclass();
|
||||||
|
try {
|
||||||
|
BeanInfo superBeanInfo = Introspector.getBeanInfo(superclass);
|
||||||
|
return new BeanInfo[] { superBeanInfo };
|
||||||
|
}
|
||||||
|
catch (IntrospectionException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
676
net/infordata/em/crt5250/XI5250CrtBuffer.java
Normal file
|
|
@ -0,0 +1,676 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 26/03/97 rel. 0.90 - start of revisions history.
|
||||||
|
26/03/97 rel. 0.90 - changed to speed up drawing.
|
||||||
|
10/04/97 rel. 0.93 - some fixes to add SignedNumeric fields handling.
|
||||||
|
27/05/97 rel. 1.00 - first release.
|
||||||
|
13/01/98 rel. 1.05d- NT painting bug.
|
||||||
|
14/01/98 rel. 1.06 - asynchronous paint on off-screen image.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
29/07/99 rel. 1.14 - Rework on 3d look&feel.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import net.infordata.em.crt.XICrtBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds capabilities required by 5250 emulation to XICrtBuffer.
|
||||||
|
* To be used by XI5250Crt.
|
||||||
|
*
|
||||||
|
* @see XI5250Crt
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250CrtBuffer extends XICrtBuffer implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//!!0.95c
|
||||||
|
public static final int GRAY_INTENSITY = colorAsIntensity(Color.gray);
|
||||||
|
|
||||||
|
//!!0.95b
|
||||||
|
private ColorWrapper ivBackColor = new ColorWrapper(Color.black);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* to be used with dark background
|
||||||
|
*/
|
||||||
|
private static final Color blue = new Color(128, 128, 255);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The character foreground color map used with dark background colors
|
||||||
|
*/
|
||||||
|
private final Color[][] DK_FORE_COLORS_MAP = {
|
||||||
|
{
|
||||||
|
// normal reverse
|
||||||
|
Color.green, ivBackColor,
|
||||||
|
Color.white, ivBackColor,
|
||||||
|
Color.green, ivBackColor, // underscore
|
||||||
|
Color.white, // underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
Color.red, ivBackColor,
|
||||||
|
Color.red.brighter(), ivBackColor, // blink
|
||||||
|
Color.red, ivBackColor, // underscore
|
||||||
|
Color.red.brighter(), // blink, underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
Color.cyan, ivBackColor, // column separator
|
||||||
|
Color.yellow, ivBackColor, // column separator
|
||||||
|
Color.cyan, ivBackColor, // column separator, underscore
|
||||||
|
Color.yellow, // column separator, underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
Color.pink, ivBackColor,
|
||||||
|
blue, ivBackColor,
|
||||||
|
Color.pink, ivBackColor, // underscore
|
||||||
|
blue, // underscore
|
||||||
|
ivBackColor // invisible
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The character background color map used with dark background colors
|
||||||
|
*/
|
||||||
|
private final Color[][] DK_BACK_COLORS_MAP = {
|
||||||
|
{
|
||||||
|
// normal reverse
|
||||||
|
ivBackColor, Color.green,
|
||||||
|
ivBackColor, Color.white,
|
||||||
|
ivBackColor, Color.green, // underscore
|
||||||
|
ivBackColor, // underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
ivBackColor, Color.red,
|
||||||
|
ivBackColor, Color.red.brighter(), // blink
|
||||||
|
ivBackColor, Color.red, // underscore
|
||||||
|
ivBackColor, // blink, underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
ivBackColor, Color.cyan, // column separator
|
||||||
|
ivBackColor, Color.yellow,// column separator
|
||||||
|
ivBackColor, Color.cyan, // column separator, underscore
|
||||||
|
ivBackColor, // column separator, underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
ivBackColor, Color.pink,
|
||||||
|
ivBackColor, blue,
|
||||||
|
ivBackColor, Color.pink, // underscore
|
||||||
|
ivBackColor, // underscore
|
||||||
|
ivBackColor // invisible
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The character foreground color map used with bright background colors
|
||||||
|
*/
|
||||||
|
private final Color[][] LT_FORE_COLORS_MAP = {
|
||||||
|
{
|
||||||
|
// normal reverse
|
||||||
|
Color.green.darker().darker(), ivBackColor,
|
||||||
|
Color.darkGray, ivBackColor,
|
||||||
|
Color.green.darker().darker(), ivBackColor, // underscore
|
||||||
|
Color.darkGray, // underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
Color.red, ivBackColor,
|
||||||
|
Color.red.brighter(), ivBackColor, // blink
|
||||||
|
Color.red, ivBackColor, // underscore
|
||||||
|
Color.red.brighter(), // blink, underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
Color.blue, ivBackColor, // column separator
|
||||||
|
Color.yellow.darker(), ivBackColor, // column separator
|
||||||
|
Color.blue, ivBackColor, // column separator, underscore
|
||||||
|
Color.yellow.darker(), // column separator, underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
Color.pink.darker(), ivBackColor,
|
||||||
|
blue.darker(), ivBackColor,
|
||||||
|
Color.pink.darker(), ivBackColor, // underscore
|
||||||
|
blue.darker(), // underscore
|
||||||
|
ivBackColor // invisible
|
||||||
|
},
|
||||||
|
{ //** input fields color map
|
||||||
|
// normal reverse
|
||||||
|
Color.green.darker().darker(), Color.white,
|
||||||
|
Color.darkGray, Color.white,
|
||||||
|
Color.green.darker().darker(), Color.white, // underscore
|
||||||
|
Color.darkGray, // underscore
|
||||||
|
Color.white, // invisible
|
||||||
|
Color.red, Color.white,
|
||||||
|
Color.red.brighter(), Color.white, // blink
|
||||||
|
Color.red, Color.white, // underscore
|
||||||
|
Color.red.brighter(), // blink, underscore
|
||||||
|
Color.white, // invisible
|
||||||
|
Color.blue, Color.white, // column separator
|
||||||
|
Color.yellow.darker(), Color.white, // column separator
|
||||||
|
Color.blue, Color.white, // column separator, underscore
|
||||||
|
Color.yellow.darker(), // column separator, underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
Color.pink.darker(), Color.white,
|
||||||
|
blue.darker(), Color.white,
|
||||||
|
Color.pink.darker(), Color.white, // underscore
|
||||||
|
blue.darker(), // underscore
|
||||||
|
ivBackColor // invisible
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The character background color map used with bright background colors
|
||||||
|
*/
|
||||||
|
private final Color[][] LT_BACK_COLORS_MAP = {
|
||||||
|
{
|
||||||
|
// normal reverse
|
||||||
|
ivBackColor, Color.green.darker().darker(),
|
||||||
|
ivBackColor, Color.darkGray,
|
||||||
|
ivBackColor, Color.green.darker().darker(), // underscore
|
||||||
|
ivBackColor, // underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
ivBackColor, Color.red,
|
||||||
|
ivBackColor, Color.red.brighter(), // blink
|
||||||
|
ivBackColor, Color.red, // underscore
|
||||||
|
ivBackColor, // blink, underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
ivBackColor, Color.blue, // column separator
|
||||||
|
ivBackColor, Color.yellow.darker(),// column separator
|
||||||
|
ivBackColor, Color.blue, // column separator, underscore
|
||||||
|
ivBackColor, // column separator, underscore
|
||||||
|
ivBackColor, // invisible
|
||||||
|
ivBackColor, Color.pink.darker(),
|
||||||
|
ivBackColor, blue.darker(),
|
||||||
|
ivBackColor, Color.pink.darker(), // underscore
|
||||||
|
ivBackColor, // underscore
|
||||||
|
ivBackColor // invisible
|
||||||
|
},
|
||||||
|
{ //** input fields color map
|
||||||
|
// normal reverse
|
||||||
|
Color.white, Color.green.darker().darker(),
|
||||||
|
Color.white, Color.darkGray,
|
||||||
|
Color.white, Color.green.darker().darker(), // underscore
|
||||||
|
Color.white, // underscore
|
||||||
|
Color.white, // invisible
|
||||||
|
Color.white, Color.red,
|
||||||
|
Color.white, Color.red.brighter(), // blink
|
||||||
|
Color.white, Color.red, // underscore
|
||||||
|
Color.white, // blink, underscore
|
||||||
|
Color.white, // invisible
|
||||||
|
Color.white, Color.blue, // column separator
|
||||||
|
Color.white, Color.yellow.darker(),// column separator
|
||||||
|
Color.white, Color.blue, // column separator, underscore
|
||||||
|
Color.white, // column separator, underscore
|
||||||
|
Color.white, // invisible
|
||||||
|
Color.white, Color.pink.darker(),
|
||||||
|
Color.white, blue.darker(),
|
||||||
|
Color.white, Color.pink.darker(), // underscore
|
||||||
|
Color.white, // underscore
|
||||||
|
Color.white // invisible
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private Color[][] ivForegroundColorsMap = DK_FORE_COLORS_MAP;
|
||||||
|
private Color[][] ivBackgroundColorsMap = DK_BACK_COLORS_MAP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Extra char attribute
|
||||||
|
*/
|
||||||
|
static final int UNDERSCORE = 0x01;
|
||||||
|
/**
|
||||||
|
* 5250 Extra char attribute
|
||||||
|
*/
|
||||||
|
static final int COLUMN_SEPARATOR = 0x02;
|
||||||
|
|
||||||
|
static final int[] EXTRA_ATTR_MAP = {
|
||||||
|
// normal reverse
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
UNDERSCORE,
|
||||||
|
UNDERSCORE,
|
||||||
|
UNDERSCORE,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
UNDERSCORE,
|
||||||
|
UNDERSCORE,
|
||||||
|
UNDERSCORE,
|
||||||
|
0x00,
|
||||||
|
COLUMN_SEPARATOR,
|
||||||
|
COLUMN_SEPARATOR,
|
||||||
|
COLUMN_SEPARATOR,
|
||||||
|
COLUMN_SEPARATOR,
|
||||||
|
COLUMN_SEPARATOR | UNDERSCORE,
|
||||||
|
COLUMN_SEPARATOR | UNDERSCORE,
|
||||||
|
COLUMN_SEPARATOR | UNDERSCORE,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
UNDERSCORE,
|
||||||
|
UNDERSCORE,
|
||||||
|
UNDERSCORE,
|
||||||
|
0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contructs a XI5250CrtBuffer with the given dimensions expressed in number of chars.
|
||||||
|
*/
|
||||||
|
public XI5250CrtBuffer(int nCols, int nRows) {
|
||||||
|
super(nCols, nRows);
|
||||||
|
setDefAttr(0x20);
|
||||||
|
clear(); // sets new attribute
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a XI5250CrtBuffer from a portion of another one.
|
||||||
|
*/
|
||||||
|
public XI5250CrtBuffer(XI5250CrtBuffer from, int aC, int aR, int aW, int aH) {
|
||||||
|
super(from, aC, aR, aW, aH);
|
||||||
|
setDefBackground(from.getDefBackground());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a cloned XICrtBuffer (the new one needs initGraphics() to be
|
||||||
|
* displayed).
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
XI5250CrtBuffer aClone = new XI5250CrtBuffer(this, 0, 0,
|
||||||
|
getCrtSize().width, getCrtSize().height);
|
||||||
|
/* !!1.04
|
||||||
|
XI5250CrtBuffer aClone = new XI5250CrtBuffer(getCrtSize().width, getCrtSize().height);
|
||||||
|
aClone.setDefBackground(getDefBackground()); //!!0.95b
|
||||||
|
aClone.copyFrom(this);
|
||||||
|
*/
|
||||||
|
return aClone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles lines wrap.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public synchronized void drawString(String aStr, int col, int row,
|
||||||
|
int aAttr) {
|
||||||
|
int lPos = toLinearPos(col, row);
|
||||||
|
col = toColPos(lPos);
|
||||||
|
row = toRowPos(lPos);
|
||||||
|
|
||||||
|
// if attribute == USE_PRESENT_ATTRIBUTE then get previous attribute
|
||||||
|
if (aAttr == XI5250Crt.USE_PRESENT_ATTRIBUTE)
|
||||||
|
aAttr = getAttr(col, row);
|
||||||
|
|
||||||
|
// split line to handle wrap
|
||||||
|
int len = aStr.length();
|
||||||
|
int x = col;
|
||||||
|
int y = row;
|
||||||
|
int dx;
|
||||||
|
int i = 0;
|
||||||
|
int maxW = getCrtSize().width;
|
||||||
|
|
||||||
|
while (len > 0) {
|
||||||
|
dx = Math.min(maxW - x, len);
|
||||||
|
|
||||||
|
super.drawString(aStr.substring(i, i + dx), x, y, aAttr);
|
||||||
|
|
||||||
|
i += dx;
|
||||||
|
len -= dx;
|
||||||
|
x = 0;
|
||||||
|
++y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws attribute place-holder char.
|
||||||
|
*/
|
||||||
|
protected void _drawAttributePlaceHolder(Graphics gr, int col, int row,
|
||||||
|
int aAttr) {
|
||||||
|
int lPos = toLinearPos(col, row);
|
||||||
|
col = toColPos(lPos);
|
||||||
|
row = toRowPos(lPos);
|
||||||
|
|
||||||
|
int charW = getCharSize().width;
|
||||||
|
int charH = getCharSize().height;
|
||||||
|
|
||||||
|
gr.setColor(getBackground(0x20));
|
||||||
|
gr.fillRect(col * charW, row * charH, charW, charH);
|
||||||
|
|
||||||
|
if (XI5250Crt.DEBUG >= 2) { // to see them
|
||||||
|
gr.setColor(getForeground(0x20));
|
||||||
|
gr.drawString("#", col * charW, (row + 1) * charH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws 5250 extra attribute (UNDERLINE and COLUMN_SEPARATOR).
|
||||||
|
*/
|
||||||
|
protected void _drawExtraAttribute(Graphics gr, int col, int row, int len,
|
||||||
|
int aAttr) {
|
||||||
|
int extra = getExtraCharAttribute(aAttr);
|
||||||
|
int dy = 2; //!!0.95b
|
||||||
|
|
||||||
|
int charW = getCharSize().width;
|
||||||
|
int charH = getCharSize().height;
|
||||||
|
|
||||||
|
gr.setColor(getForeground(aAttr));
|
||||||
|
|
||||||
|
if ((extra & UNDERSCORE) != 0) {
|
||||||
|
gr.drawLine(col * charW, (row + 1) * charH - dy - 1,
|
||||||
|
(col + len) * charW - 1, (row + 1) * charH - dy - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((extra & COLUMN_SEPARATOR) != 0) {
|
||||||
|
gr.setColor(getForeground(0x22));
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
gr.drawLine((col + i) * charW, (row + 1) * charH - dy,
|
||||||
|
(col + i) * charW, (row + 1) * charH - dy);
|
||||||
|
|
||||||
|
gr.drawLine((col + i + 1) * charW - 1, (row + 1) * charH - dy,
|
||||||
|
(col + i + 1) * charW - 1, (row + 1) * charH - dy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splits string to detect attribute place-holder presence.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void _drawString(Graphics gr, String aStr, int col, int row,
|
||||||
|
int aAttr) {
|
||||||
|
if (aStr.length() <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int pos = -1;
|
||||||
|
for (int i = 0; i < aStr.length(); i++) {
|
||||||
|
if (aStr.charAt(i) == XI5250Crt.ATTRIBUTE_PLACE_HOLDER) {
|
||||||
|
pos = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos == -1) {
|
||||||
|
super._drawString(gr, aStr, col, row, aAttr);
|
||||||
|
_drawExtraAttribute(gr, col, row, aStr.length(), aAttr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// draw string portion before attribute place-holder
|
||||||
|
if (pos > 0) {
|
||||||
|
super._drawString(gr, aStr, col, row, aAttr);
|
||||||
|
_drawExtraAttribute(gr, col, row, aStr.length(), aAttr);
|
||||||
|
}
|
||||||
|
// draw attribute place-holder
|
||||||
|
_drawAttributePlaceHolder(gr, col + pos, row, aAttr);
|
||||||
|
// draw string portion after attribute place-holder
|
||||||
|
if (pos < (aStr.length() - 1))
|
||||||
|
_drawString(gr, aStr.substring(pos + 1), col + pos + 1, row, aAttr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be used to verify the presence of a string in the buffer.
|
||||||
|
* Redefined to implement lines wrap.
|
||||||
|
* @see String#indexOf
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getString(int col, int row, int nChars) {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
for (int i = 0; i < nChars; i++) {
|
||||||
|
int j = toLinearPos(col + i, row);
|
||||||
|
str.append(getChar(toColPos(j), toRowPos(j)));
|
||||||
|
}
|
||||||
|
return new String(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute to color mapping.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Color getBackground(int aAttribute) {
|
||||||
|
// see SA21-9247-6 pg 2-143
|
||||||
|
int mapIdx = Math.min(ivBackgroundColorsMap.length - 1,
|
||||||
|
getColorMapIdx(aAttribute));
|
||||||
|
return ivBackgroundColorsMap[mapIdx]
|
||||||
|
[getColorAttributeIdx(aAttribute) - 0x20];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute to color mapping.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Color getForeground(int aAttribute) {
|
||||||
|
// see SA21-9247-6 pg 2-143
|
||||||
|
int mapIdx = Math.min(ivForegroundColorsMap.length - 1,
|
||||||
|
getColorMapIdx(aAttribute));
|
||||||
|
return ivForegroundColorsMap[mapIdx]
|
||||||
|
[getColorAttributeIdx(aAttribute) - 0x20];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute to extra char attribute mapping.
|
||||||
|
*/
|
||||||
|
protected int getExtraCharAttribute(int aAttribute) {
|
||||||
|
return EXTRA_ATTR_MAP[getColorAttributeIdx(aAttribute) - 0x20];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected final byte getColorMapIdx(int aAttribute) {
|
||||||
|
return (byte)((aAttribute >> 24) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected final int getColorAttributeIdx(int aAttribute) {
|
||||||
|
return aAttribute & 0x00FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getAttr(int col, int row) {
|
||||||
|
int attr = super.getAttr(col, row);
|
||||||
|
XI5250Crt crt = (XI5250Crt)getCrt();
|
||||||
|
if (crt != null) {
|
||||||
|
//!!1.14 change color table
|
||||||
|
XI5250Field field = crt.getFieldFromPos(col, row);
|
||||||
|
if (field != null && !field.isOrgBypassField())
|
||||||
|
attr |= (1 << 24);
|
||||||
|
}
|
||||||
|
return attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts x-y coord to buffer linear position.
|
||||||
|
*/
|
||||||
|
public final int toLinearPos(int aCol, int aRow) {
|
||||||
|
return (aRow * getCrtSize().width) + aCol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts buffer linear position to x-y coord.
|
||||||
|
*/
|
||||||
|
public final int toColPos(int aPos) {
|
||||||
|
return aPos % getCrtSize().width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts buffer linear position to x-y coord.
|
||||||
|
*/
|
||||||
|
public final int toRowPos(int aPos) {
|
||||||
|
return aPos / getCrtSize().width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts color to an intensity value (0 to 1000)
|
||||||
|
* @see #setDefBackground
|
||||||
|
*/
|
||||||
|
public static final int colorAsIntensity(Color aColor) {
|
||||||
|
float[] hsb = Color.RGBtoHSB(aColor.getRed(), aColor.getGreen(),
|
||||||
|
aColor.getBlue(), null);
|
||||||
|
return (int)(hsb[2] * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the default background color.
|
||||||
|
* The new color intensity is used to choose which colors table must be used.
|
||||||
|
*/
|
||||||
|
public void setDefBackground(Color aColor) {
|
||||||
|
if (ivBackColor.equals(aColor))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// check if background color intensity (referred to GRAY_INTENSITY)
|
||||||
|
// has changed
|
||||||
|
if ((colorAsIntensity(ivBackColor) >= GRAY_INTENSITY) !=
|
||||||
|
(colorAsIntensity(aColor) >= GRAY_INTENSITY)) {
|
||||||
|
boolean dark = (colorAsIntensity(aColor) < GRAY_INTENSITY);
|
||||||
|
|
||||||
|
ivBackgroundColorsMap = (dark) ? DK_BACK_COLORS_MAP : LT_BACK_COLORS_MAP;
|
||||||
|
ivForegroundColorsMap = (dark) ? DK_FORE_COLORS_MAP : LT_FORE_COLORS_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
ivBackColor.setColor(aColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public Color getDefBackground() {
|
||||||
|
return ivBackColor.getColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// */
|
||||||
|
// void writeObject(ObjectOutputStream oos) throws IOException {
|
||||||
|
// oos.defaultWriteObject();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||||
|
// ois.defaultReadObject();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simply routes all method calls to the contained color methods
|
||||||
|
*/
|
||||||
|
private static class ColorWrapper extends Color implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Color ivColor;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public ColorWrapper(Color aColor) {
|
||||||
|
super(0);
|
||||||
|
ivColor = aColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setColor(Color aColor) {
|
||||||
|
ivColor = aColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public Color getColor() {
|
||||||
|
return ivColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getRed() {
|
||||||
|
return ivColor.getRed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGreen() {
|
||||||
|
return ivColor.getGreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBlue() {
|
||||||
|
return ivColor.getBlue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRGB() {
|
||||||
|
return ivColor.getRGB();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color brighter() {
|
||||||
|
return ivColor.brighter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color darker() {
|
||||||
|
return ivColor.darker();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return ivColor.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return ivColor.equals(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return ivColor.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
275
net/infordata/em/crt5250/XI5250CrtCtrl.java
Normal file
|
|
@ -0,0 +1,275 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
!!V 15/06/99 rel. 1.13 - creation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.SystemColor;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.print.PageFormat;
|
||||||
|
import java.awt.print.Printable;
|
||||||
|
import java.awt.print.PrinterException;
|
||||||
|
import java.awt.print.PrinterJob;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
import net.infordata.em.util.XICommand;
|
||||||
|
import net.infordata.em.util.XICommandMgr;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles common commands.
|
||||||
|
*/
|
||||||
|
public class XI5250CrtCtrl {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(XI5250CrtCtrl.class.getName());
|
||||||
|
|
||||||
|
private XI5250Crt ivCrt;
|
||||||
|
|
||||||
|
private XICommandMgr ivCommandMgr = new XICommandMgr();
|
||||||
|
|
||||||
|
|
||||||
|
public static final String SWITCH_3DFX_CMD = "SWITCH_3DFX_CMD";
|
||||||
|
public static final String REFERENCE_CURSOR_CMD = "REFERENCE_CURSOR_CMD";
|
||||||
|
|
||||||
|
public static final String COPY_CMD = "COPY_CMD";
|
||||||
|
public static final String PASTE_CMD = "PASTE_CMD";
|
||||||
|
|
||||||
|
public static final String PRINT_CMD = "PRINT_CMD";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250CrtCtrl(XI5250Crt aCrt) {
|
||||||
|
if (aCrt == null)
|
||||||
|
throw new IllegalArgumentException("An XI5250Crt instance is required.");
|
||||||
|
|
||||||
|
ivCrt = aCrt;
|
||||||
|
|
||||||
|
ivCrt.addPropertyChangeListener(new PropertyListener());
|
||||||
|
|
||||||
|
// Copy command
|
||||||
|
getCommandMgr().enableCommand(
|
||||||
|
COPY_CMD, ivCrt.getSelectedArea() != null);
|
||||||
|
getCommandMgr().setCommand(COPY_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processCopyCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Paste command
|
||||||
|
getCommandMgr().setCommand(PASTE_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processPasteCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3Dfx command
|
||||||
|
getCommandMgr().setCommandState(SWITCH_3DFX_CMD, is3DFX());
|
||||||
|
getCommandMgr().setCommand(SWITCH_3DFX_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processSwitch3dFxCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reference cursor command
|
||||||
|
getCommandMgr().setCommandState(
|
||||||
|
REFERENCE_CURSOR_CMD, ivCrt.isReferenceCursor());
|
||||||
|
getCommandMgr().setCommand(REFERENCE_CURSOR_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processReferenceCursorCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Print command
|
||||||
|
getCommandMgr().setCommand(PRINT_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processPrintCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XI5250Crt getCrt() {
|
||||||
|
return ivCrt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XICommandMgr getCommandMgr() {
|
||||||
|
return ivCommandMgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final boolean is3DFX() {
|
||||||
|
return
|
||||||
|
(getCrt().getDefFieldsBorderStyle() == XI5250Field.LOWERED_BORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processCopyCmd() {
|
||||||
|
getCrt().processRawKeyEvent(
|
||||||
|
new KeyEvent(getCrt(), KeyEvent.KEY_PRESSED,
|
||||||
|
0, KeyEvent.CTRL_MASK, KeyEvent.VK_INSERT, (char)KeyEvent.VK_INSERT));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processPasteCmd() {
|
||||||
|
getCrt().processRawKeyEvent(
|
||||||
|
new KeyEvent(getCrt(), KeyEvent.KEY_PRESSED,
|
||||||
|
0, KeyEvent.SHIFT_MASK, KeyEvent.VK_INSERT, (char)KeyEvent.VK_INSERT));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processSwitch3dFxCmd() {
|
||||||
|
boolean flag = getCommandMgr().getCommandState(SWITCH_3DFX_CMD);
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
getCrt().setDefFieldsBorderStyle(XI5250Field.LOWERED_BORDER);
|
||||||
|
getCrt().setDefBackground(UIManager.getColor("control"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
getCrt().setDefFieldsBorderStyle(XI5250Field.NO_BORDER);
|
||||||
|
getCrt().setDefBackground(SystemColor.black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processReferenceCursorCmd() {
|
||||||
|
boolean flag = getCommandMgr().getCommandState(REFERENCE_CURSOR_CMD);
|
||||||
|
|
||||||
|
getCrt().setReferenceCursor(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void emulatorPropertyChanged(PropertyChangeEvent e) {
|
||||||
|
String propertyName = e.getPropertyName();
|
||||||
|
|
||||||
|
if (propertyName == XI5250Crt.SELECTED_AREA) {
|
||||||
|
getCommandMgr().enableCommand(
|
||||||
|
COPY_CMD, getCrt().getSelectedArea() != null);
|
||||||
|
}
|
||||||
|
else if (propertyName == XI5250Crt.DEF_FIELDS_BORDER_STYLE) {
|
||||||
|
getCommandMgr().setCommandState(SWITCH_3DFX_CMD, is3DFX());
|
||||||
|
}
|
||||||
|
else if (propertyName == XI5250Crt.REFERENCE_CURSOR) {
|
||||||
|
getCommandMgr().setCommandState(
|
||||||
|
REFERENCE_CURSOR_CMD, getCrt().isReferenceCursor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processPrintCmd() {
|
||||||
|
PrinterJob job = PrinterJob.getPrinterJob();
|
||||||
|
job.setPrintable(new Printable() {
|
||||||
|
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
|
||||||
|
throws PrinterException {
|
||||||
|
if (pageIndex > 0) {
|
||||||
|
return NO_SUCH_PAGE;
|
||||||
|
}
|
||||||
|
final int imgWidth = (int)pageFormat.getImageableWidth();
|
||||||
|
final int imgHeight = (int)pageFormat.getImageableHeight();
|
||||||
|
final XI5250Crt crt = getCrt();
|
||||||
|
Graphics2D g2d = (Graphics2D)graphics;
|
||||||
|
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
|
||||||
|
double scale;
|
||||||
|
{
|
||||||
|
int w = crt.getSize().width;
|
||||||
|
int h = crt.getSize().height;
|
||||||
|
scale = Math.min(((double)imgWidth) / w, ((double)imgHeight) / h);
|
||||||
|
g2d.scale(scale, scale);
|
||||||
|
}
|
||||||
|
synchronized (crt.getTreeLock()) {
|
||||||
|
synchronized (crt) {
|
||||||
|
Color oldBG = crt.getDefBackground();
|
||||||
|
//int oldBS = crt.getDefFieldsBorderStyle();
|
||||||
|
try {
|
||||||
|
//crt.setDefFieldsBorderStyle(XI5250Field.NO_BORDER);
|
||||||
|
crt.setDefBackground(SystemColor.white);
|
||||||
|
crt.printAll(g2d);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
//crt.setDefFieldsBorderStyle(oldBS);
|
||||||
|
crt.setDefBackground(oldBG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PAGE_EXISTS; }
|
||||||
|
});
|
||||||
|
boolean doPrint = job.printDialog();
|
||||||
|
if (doPrint) {
|
||||||
|
try {
|
||||||
|
job.print();
|
||||||
|
}
|
||||||
|
catch (final PrinterException ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, "catchedException()", ex);
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
JOptionPane.showMessageDialog(getCrt(),
|
||||||
|
ex.getMessage() + "\nSee the log for details ",
|
||||||
|
"ERROR", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Usata per sincronizzare i comandi con le property dell' emulatore.
|
||||||
|
*/
|
||||||
|
class PropertyListener implements PropertyChangeListener {
|
||||||
|
|
||||||
|
public void propertyChange(PropertyChangeEvent e) {
|
||||||
|
emulatorPropertyChanged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
128
net/infordata/em/crt5250/XI5250CrtEvent.java
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class XI5250CrtEvent extends EventObject {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A field has been activated.
|
||||||
|
*/
|
||||||
|
public static final int FIELD_ACTIVATED = 0;
|
||||||
|
/**
|
||||||
|
* A field has been deactivated.
|
||||||
|
*/
|
||||||
|
public static final int FIELD_DEACTIVATED = FIELD_ACTIVATED + 1;
|
||||||
|
/**
|
||||||
|
* The crt real-size is changed (ie. the font size is changed) (this event is posted).
|
||||||
|
*/
|
||||||
|
public static final int SIZE_CHANGED = FIELD_ACTIVATED + 2;
|
||||||
|
/**
|
||||||
|
* A key has been pressed.
|
||||||
|
* !!! Use this event instead of AWT KeyEvent !!!.
|
||||||
|
*/
|
||||||
|
public static final int KEY_EVENT = FIELD_ACTIVATED + 3;
|
||||||
|
/**
|
||||||
|
* Mouse enters the field area.
|
||||||
|
*/
|
||||||
|
public static final int MOUSE_ENTERS_FIELD = FIELD_ACTIVATED + 4;
|
||||||
|
/**
|
||||||
|
* Mouse exits from a field area.
|
||||||
|
*/
|
||||||
|
public static final int MOUSE_EXITS_FIELD = FIELD_ACTIVATED + 5;
|
||||||
|
|
||||||
|
|
||||||
|
private static final String[] cvIdDescr = {"FIELD_ACTIVATED",
|
||||||
|
"FIELD_DEACTIVATED",
|
||||||
|
"SIZE_CHANGED",
|
||||||
|
"KEY_EVENT",
|
||||||
|
"MOUSE_ENTERS_FIELD",
|
||||||
|
"MOUSE_EXITS_FIELD"};
|
||||||
|
|
||||||
|
private int ivId;
|
||||||
|
private XI5250Field ivField;
|
||||||
|
private KeyEvent ivKeyEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected XI5250CrtEvent(int aId, XI5250Crt aCrt, XI5250Field aField,
|
||||||
|
KeyEvent aKeyEvent) {
|
||||||
|
super(aCrt);
|
||||||
|
ivId = aId;
|
||||||
|
ivField = aField;
|
||||||
|
ivKeyEvent = aKeyEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250CrtEvent(int aId, XI5250Crt aCrt, XI5250Field aField) {
|
||||||
|
this(aId, aCrt, aField, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final int getID() {
|
||||||
|
return ivId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XI5250Crt getCrt() {
|
||||||
|
return (XI5250Crt)getSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XI5250Field getField() {
|
||||||
|
return ivField;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final KeyEvent getKeyEvent() {
|
||||||
|
return ivKeyEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + "[" + cvIdDescr[getID()] + "," + ivField + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
371
net/infordata/em/crt5250/XI5250CrtFrame.java
Normal file
|
|
@ -0,0 +1,371 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
!!V 15/06/99 rel. 1.13 - creation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.AWTEvent;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import javax.swing.AbstractButton;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.JToolBar;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import net.infordata.em.tn5250.XI5250EmulatorCtrl;
|
||||||
|
import net.infordata.em.util.XICommand;
|
||||||
|
import net.infordata.em.util.XICommandMgr;
|
||||||
|
import net.infordata.em.util.XIUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class XI5250CrtFrame extends JFrame {
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// images
|
||||||
|
private static XIImagesBdl cvImagesBdl = XIImagesBdl.getImagesBdl();
|
||||||
|
|
||||||
|
private static ResourceBundle cvRes =
|
||||||
|
ResourceBundle.getBundle("net.infordata.em.crt5250.resources.Res");
|
||||||
|
|
||||||
|
private boolean ivPending;
|
||||||
|
private boolean ivOpened;
|
||||||
|
|
||||||
|
private boolean ivFirstTime = true; //!!1.11
|
||||||
|
private boolean ivSizeControlledFrame = false; //!!1.11
|
||||||
|
|
||||||
|
private XI5250CrtCtrl ivCrtCtrl;
|
||||||
|
|
||||||
|
public static final String EXIT_CMD = "EXIT_CMD";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250CrtFrame(String aTitle, XI5250Crt aCrt) {
|
||||||
|
this(aTitle, aCrt, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250CrtFrame(String aTitle, XI5250Crt aCrt,
|
||||||
|
boolean sizeControlledFrame) {
|
||||||
|
super(aTitle);
|
||||||
|
|
||||||
|
ivSizeControlledFrame = sizeControlledFrame;
|
||||||
|
|
||||||
|
if (aCrt == null)
|
||||||
|
throw new IllegalArgumentException("An XI5250Crt instance is required.");
|
||||||
|
|
||||||
|
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||||
|
|
||||||
|
ivCrtCtrl = createController(aCrt);
|
||||||
|
|
||||||
|
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
|
||||||
|
|
||||||
|
JPanel panel = new XI5250Crt.SupportPanel(getCrt());
|
||||||
|
panel.setBackground(getCrt().getBackground());
|
||||||
|
getContentPane().add(panel, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
getCrt().addPropertyChangeListener(new PropertyChangeListener() {
|
||||||
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
|
emulatorPropertyChanged(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
JToolBar toolBar = createToolBar();
|
||||||
|
JMenuBar menuBar = createMenuBar();
|
||||||
|
|
||||||
|
setJMenuBar(menuBar);
|
||||||
|
getContentPane().add(toolBar, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
// Exit command
|
||||||
|
getCommandMgr().setCommand(EXIT_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processExitCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void doNotPackOnStartup() {
|
||||||
|
ivFirstTime = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processExitCmd() {
|
||||||
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected XI5250CrtCtrl createController(XI5250Crt crt) {
|
||||||
|
return new XI5250CrtCtrl(crt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected final XI5250CrtCtrl getCrtCtrl() {
|
||||||
|
return ivCrtCtrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XI5250Crt getCrt() {
|
||||||
|
return ivCrtCtrl.getCrt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private void emulatorPropertyChanged(PropertyChangeEvent evt) {
|
||||||
|
String propertyName = evt.getPropertyName();
|
||||||
|
if ("background".equals(propertyName))
|
||||||
|
getCrt().getParent().setBackground(getCrt().getBackground());
|
||||||
|
else if ("font".equals(propertyName) ||
|
||||||
|
XI5250Crt.CRT_SIZE.equals(propertyName)) {
|
||||||
|
getCrt().revalidate();
|
||||||
|
sizeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XICommandMgr getCommandMgr() {
|
||||||
|
return ivCrtCtrl.getCommandMgr();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void invalidate() {
|
||||||
|
super.invalidate();
|
||||||
|
sizeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void sizeChanged() {
|
||||||
|
if (ivOpened && !ivPending) {
|
||||||
|
ivPending = true;
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
if (ivFirstTime || ivSizeControlledFrame) {
|
||||||
|
ivFirstTime = false;
|
||||||
|
pack(); //!!1.03b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
ivPending = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void centerOnScreen() {
|
||||||
|
Dimension ss = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
Dimension dim = getSize();
|
||||||
|
|
||||||
|
setBounds((ss.width - dim.width) / 2, (ss.height - dim.height) / 2 ,
|
||||||
|
dim.width, dim.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void centerOnScreen(int perc) {
|
||||||
|
Dimension ss = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
Dimension dim = getSize();
|
||||||
|
dim.width = (ss.width * perc) / 100;
|
||||||
|
dim.height = (ss.height * perc) / 100;
|
||||||
|
|
||||||
|
setBounds((ss.width - dim.width) / 2, (ss.height - dim.height) / 2 ,
|
||||||
|
dim.width, dim.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void processWindowEvent(WindowEvent e) {
|
||||||
|
switch(e.getID()) {
|
||||||
|
case WindowEvent.WINDOW_OPENED:
|
||||||
|
getCrt().requestFocus();
|
||||||
|
ivOpened = true;
|
||||||
|
sizeChanged();
|
||||||
|
break;
|
||||||
|
case WindowEvent.WINDOW_CLOSING:
|
||||||
|
getCommandMgr().dispatchCommand(EXIT_CMD);
|
||||||
|
break;
|
||||||
|
case WindowEvent.WINDOW_CLOSED:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
super.processWindowEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected JMenuBar createMenuBar() {
|
||||||
|
String str;
|
||||||
|
|
||||||
|
str = cvRes.getString("TXT_Edit");
|
||||||
|
JMenu editMenu = new JMenu(XIUtil.removeMnemonics(str));
|
||||||
|
editMenu.setMnemonic(XIUtil.getMnemonic(str));
|
||||||
|
{
|
||||||
|
JMenuItem copyItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Copy"));
|
||||||
|
JMenuItem pasteItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Paste"));
|
||||||
|
JMenuItem printItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Print"));
|
||||||
|
|
||||||
|
editMenu.add(copyItem);
|
||||||
|
editMenu.add(pasteItem);
|
||||||
|
editMenu.addSeparator();
|
||||||
|
editMenu.add(printItem);
|
||||||
|
|
||||||
|
getCommandMgr().handleCommand(copyItem,
|
||||||
|
XI5250CrtCtrl.COPY_CMD);
|
||||||
|
getCommandMgr().handleCommand(pasteItem,
|
||||||
|
XI5250CrtCtrl.PASTE_CMD);
|
||||||
|
getCommandMgr().handleCommand(printItem,
|
||||||
|
XI5250EmulatorCtrl.PRINT_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
str = cvRes.getString("TXT_Options");
|
||||||
|
JMenu optionsMenu = new JMenu(XIUtil.removeMnemonics(str));
|
||||||
|
optionsMenu.setMnemonic(XIUtil.getMnemonic(str));
|
||||||
|
{
|
||||||
|
JCheckBoxMenuItem switch3DfxItem =
|
||||||
|
new JCheckBoxMenuItem(cvRes.getString("TXT_3dFx"));
|
||||||
|
JCheckBoxMenuItem referenceCursorItem =
|
||||||
|
new JCheckBoxMenuItem(cvRes.getString("TXT_RefCursor"));
|
||||||
|
|
||||||
|
optionsMenu.add(switch3DfxItem);
|
||||||
|
optionsMenu.add(referenceCursorItem);
|
||||||
|
|
||||||
|
getCommandMgr().handleCommand(switch3DfxItem,
|
||||||
|
XI5250CrtCtrl.SWITCH_3DFX_CMD);
|
||||||
|
getCommandMgr().handleCommand(referenceCursorItem,
|
||||||
|
XI5250CrtCtrl.REFERENCE_CURSOR_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
JMenuBar menuBar = new JMenuBar();
|
||||||
|
menuBar.add(editMenu);
|
||||||
|
menuBar.add(optionsMenu);
|
||||||
|
return menuBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserisce nella tool-bar i bottoni di default.
|
||||||
|
*/
|
||||||
|
protected JToolBar createToolBar() {
|
||||||
|
// bottoni della tool-bar
|
||||||
|
AbstractButton[] buttons = new AbstractButton[] {
|
||||||
|
new JButton(cvImagesBdl.getIcon("Copy")),
|
||||||
|
new JButton(cvImagesBdl.getIcon("Paste")),
|
||||||
|
null,
|
||||||
|
new JButton(cvImagesBdl.getIcon("Print")),
|
||||||
|
null,
|
||||||
|
new JToggleButton(cvImagesBdl.getIcon("3dFx")),
|
||||||
|
new JToggleButton(cvImagesBdl.getIcon("RefCursor")),
|
||||||
|
};
|
||||||
|
// action commands associati con i bottoni della tool-bar.
|
||||||
|
String[] buttonsActCmd = new String[] {
|
||||||
|
XI5250CrtCtrl.COPY_CMD,
|
||||||
|
XI5250CrtCtrl.PASTE_CMD,
|
||||||
|
null,
|
||||||
|
XI5250EmulatorCtrl.PRINT_CMD,
|
||||||
|
null,
|
||||||
|
XI5250CrtCtrl.SWITCH_3DFX_CMD,
|
||||||
|
XI5250CrtCtrl.REFERENCE_CURSOR_CMD,
|
||||||
|
};
|
||||||
|
// Hint associati ad i vari bottoni.
|
||||||
|
String[] buttonHints = new String[] {
|
||||||
|
cvRes.getString("TXT_Copy"),
|
||||||
|
cvRes.getString("TXT_Paste"),
|
||||||
|
null,
|
||||||
|
cvRes.getString("TXT_Print"),
|
||||||
|
null,
|
||||||
|
cvRes.getString("TXT_3dFx"),
|
||||||
|
cvRes.getString("TXT_RefCursor"),
|
||||||
|
};
|
||||||
|
|
||||||
|
JToolBar toolBar = new JToolBar();
|
||||||
|
toolBar.setFloatable(false);
|
||||||
|
|
||||||
|
Dimension size = new Dimension(26, 26);
|
||||||
|
|
||||||
|
for (int i = 0; i < buttons.length; i++) {
|
||||||
|
if (buttons[i] != null) {
|
||||||
|
AbstractButton button = (AbstractButton)buttons[i];
|
||||||
|
toolBar.add(button);
|
||||||
|
button.setToolTipText(buttonHints[i]);
|
||||||
|
button.setMinimumSize(size);
|
||||||
|
button.setPreferredSize(size);
|
||||||
|
button.setMaximumSize(size);
|
||||||
|
button.setRequestFocusEnabled(false);
|
||||||
|
getCommandMgr().handleCommand(button, buttonsActCmd[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
toolBar.addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
return toolBar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
72
net/infordata/em/crt5250/XI5250CrtListener.java
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
!!V 03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.EventListener;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XI5250CrtEvent listener
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public interface XI5250CrtListener extends EventListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#FIELD_ACTIVATED
|
||||||
|
*/
|
||||||
|
public void fieldActivated(XI5250CrtEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#FIELD_DEACTIVATED
|
||||||
|
*/
|
||||||
|
public void fieldDeactivated(XI5250CrtEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#SIZE_CHANGED
|
||||||
|
*/
|
||||||
|
public void sizeChanged(XI5250CrtEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#KEY_EVENT
|
||||||
|
*/
|
||||||
|
public void keyEvent(XI5250CrtEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#MOUSE_ENTERS_FIELD
|
||||||
|
*/
|
||||||
|
public void mouseEntersField(XI5250CrtEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250CrtEvent#MOUSE_EXITS_FIELD
|
||||||
|
*/
|
||||||
|
public void mouseExitsField(XI5250CrtEvent e);
|
||||||
|
}
|
||||||
1419
net/infordata/em/crt5250/XI5250Field.java
Normal file
67
net/infordata/em/crt5250/XI5250FieldAdapter.java
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 14/05/97 rel. 0.96d- removed SIZE_CHANGED.
|
||||||
|
27/05/97 rel. 1.00 - first release.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XI5250FieldListener adapter.
|
||||||
|
* @see XI5250FieldListener
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250FieldAdapter implements XI5250FieldListener {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void activated(XI5250FieldEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void deactivated(XI5250FieldEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void valueChanged(XI5250FieldEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void enabledStateChanged(XI5250FieldEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void keyEvent(XI5250FieldEvent e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
118
net/infordata/em/crt5250/XI5250FieldEvent.java
Normal file
|
|
@ -0,0 +1,118 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 14/05/97 rel. 0.96d- removed SIZE_CHANGED.
|
||||||
|
27/05/97 rel. 1.00 - first release.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XI5250Field notification event.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250FieldEvent extends EventObject {
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The field has been activated (ie. the cursor enters the field area)
|
||||||
|
*/
|
||||||
|
public static final int ACTIVATED = 0;
|
||||||
|
/**
|
||||||
|
* The field has been deactivated (ie. the cursor exits the field area)
|
||||||
|
*/
|
||||||
|
public static final int DEACTIVATED = 1;
|
||||||
|
/**
|
||||||
|
* The field value has been changed.
|
||||||
|
*/
|
||||||
|
public static final int VALUE_CHANGED = 2;
|
||||||
|
/**
|
||||||
|
* The field enabled state has changed.
|
||||||
|
*/
|
||||||
|
public static final int ENABLED_STATE_CHANGED = 3;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public static final int KEY_EVENT = 4;
|
||||||
|
|
||||||
|
|
||||||
|
private static final String[] cvIdDescr = {"ACTIVATED",
|
||||||
|
"DEACTIVATED",
|
||||||
|
"VALUE_CHANGED",
|
||||||
|
"ENABLED_STATE_CHANGED",
|
||||||
|
"KEY_EVENT"};
|
||||||
|
|
||||||
|
private int ivId;
|
||||||
|
private KeyEvent ivKeyEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250FieldEvent(int aId, XI5250Field aField) {
|
||||||
|
super(aField);
|
||||||
|
ivId = aId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250FieldEvent(int aId, XI5250Field aField, KeyEvent ke) {
|
||||||
|
this(aId, aField);
|
||||||
|
ivKeyEvent = ke;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final int getID() {
|
||||||
|
return ivId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XI5250Field getField() {
|
||||||
|
return (XI5250Field)getSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final KeyEvent getKeyEvent() {
|
||||||
|
return ivKeyEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + "[" + cvIdDescr[ivId] + "," + getSource() + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
68
net/infordata/em/crt5250/XI5250FieldListener.java
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 14/05/97 rel. 0.96d- removed SIZE_CHANGED.
|
||||||
|
27/05/97 rel. 1.00 - first release.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.EventListener;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for XI5250FieldEvent.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public interface XI5250FieldListener extends EventListener {
|
||||||
|
/**
|
||||||
|
* Input cursor enters in the field area
|
||||||
|
*/
|
||||||
|
public void activated(XI5250FieldEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input cursor exits from the input area
|
||||||
|
*/
|
||||||
|
public void deactivated(XI5250FieldEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field value is changed
|
||||||
|
*/
|
||||||
|
public void valueChanged(XI5250FieldEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field enabled state is changed using setEnabled method
|
||||||
|
* @see XI5250Field#setEnabled
|
||||||
|
* @see XI5250Field#isEnabled
|
||||||
|
*/
|
||||||
|
public void enabledStateChanged(XI5250FieldEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void keyEvent(XI5250FieldEvent e);
|
||||||
|
}
|
||||||
45
net/infordata/em/crt5250/XI5250FieldPaintAdapter.java
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 27/05/97 rel. 1.00 - first release.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XI5250FieldPaintListener adapter.
|
||||||
|
* @see XI5250FieldPaintListener
|
||||||
|
*/
|
||||||
|
public class XI5250FieldPaintAdapter implements XI5250FieldPaintListener {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void fieldPaint(XI5250FieldPaintEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void rowPaint(XI5250FieldPaintEvent e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
95
net/infordata/em/crt5250/XI5250FieldPaintEvent.java
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 27/05/97 rel. 1.00 - first release.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XI5250Field painting event.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250FieldPaintEvent extends EventObject {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paint at field level can be added.
|
||||||
|
*/
|
||||||
|
public static final int FIELD_PAINT = 0;
|
||||||
|
/**
|
||||||
|
* Paint at field singol row level can be added.
|
||||||
|
*/
|
||||||
|
public static final int ROW_PAINT = 1;
|
||||||
|
|
||||||
|
private static final String[] cvIdDescr = {"FIELD_PAINT",
|
||||||
|
"ROW_PAINT"};
|
||||||
|
|
||||||
|
private int ivId;
|
||||||
|
private Graphics ivGr;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250FieldPaintEvent(int aId, XI5250Field aField, Graphics aGr) {
|
||||||
|
super(aField);
|
||||||
|
ivId = aId;
|
||||||
|
ivGr = aGr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public int getID() {
|
||||||
|
return ivId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Graphics that can be used to paint.
|
||||||
|
*/
|
||||||
|
public Graphics getGraphics() {
|
||||||
|
return ivGr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250Field getField() {
|
||||||
|
return (XI5250Field)getSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + "[" + cvIdDescr[ivId] + "," + getSource() + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
55
net/infordata/em/crt5250/XI5250FieldPaintListener.java
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 27/05/97 rel. 1.00 - first release.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.EventListener;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Usefull to add some paint over a field.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public interface XI5250FieldPaintListener extends EventListener {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One event for paint, the bounding rectangle is setted as the clip region.
|
||||||
|
* Coordinate are relative to the field bounding rectangle
|
||||||
|
* @see XI5250Field#getBoundingRect
|
||||||
|
*/
|
||||||
|
public void fieldPaint(XI5250FieldPaintEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One event for each row that makes up the field
|
||||||
|
* (a field can be splitted over multiple rows)
|
||||||
|
* Coordinate are relative to the field bounding rectangle
|
||||||
|
* @see XI5250Field#getRowsRects
|
||||||
|
*/
|
||||||
|
public void rowPaint(XI5250FieldPaintEvent e);
|
||||||
|
}
|
||||||
44
net/infordata/em/crt5250/XI5250FieldSaver.java
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface that must be implemented to save XI5250 field status.
|
||||||
|
*
|
||||||
|
* @see XI5250Field#saveTo
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public interface XI5250FieldSaver {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void write(XI5250Field aField, String aStr) throws IOException;
|
||||||
|
}
|
||||||
310
net/infordata/em/crt5250/XI5250FieldsList.java
Normal file
|
|
@ -0,0 +1,310 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 27/05/97 rel. 1.00 - first release.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It is used by XI5250Crt to handle the XI5250Field collection.
|
||||||
|
*
|
||||||
|
* @see XI5250Crt
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250FieldsList implements XI5250BaseField, Cloneable {
|
||||||
|
private XI5250Crt ivCrt;
|
||||||
|
private ArrayList<XI5250Field> ivFields = new ArrayList<XI5250Field>(40);
|
||||||
|
private List<XI5250Field> ivROFields = Collections.unmodifiableList(ivFields);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250FieldsList(XI5250Crt aCrt) {
|
||||||
|
ivCrt = aCrt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a cloned XI5250FieldList
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Object clone() {
|
||||||
|
try {
|
||||||
|
XI5250FieldsList aClone = (XI5250FieldsList)super.clone();
|
||||||
|
// non clono singoli campi perchè vengono sempre ricreati da 0 e mai modificati
|
||||||
|
aClone.ivFields = (ArrayList<XI5250Field>)ivFields.clone();
|
||||||
|
aClone.ivROFields = Collections.unmodifiableList(aClone.ivFields);
|
||||||
|
return aClone;
|
||||||
|
}
|
||||||
|
catch (CloneNotSupportedException e) {
|
||||||
|
throw new InternalError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls init for each field it owns.
|
||||||
|
* @see XI5250Field#init
|
||||||
|
*/
|
||||||
|
public void init() {
|
||||||
|
for (int i = 0; i < ivFields.size(); i++)
|
||||||
|
ivFields.get(i).init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls removeNotify for each field it owns.
|
||||||
|
*/
|
||||||
|
public void removeNotify() {
|
||||||
|
for (int i = 0; i < ivFields.size(); i++)
|
||||||
|
ivFields.get(i).removeNotify();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls saveTo for each field it owns.
|
||||||
|
* @see XI5250Field#saveTo
|
||||||
|
*/
|
||||||
|
public void saveTo(XI5250FieldSaver aSaver) throws IOException {
|
||||||
|
for (int i = 0; i < ivFields.size(); i++)
|
||||||
|
ivFields.get(i).saveTo(aSaver);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls resized for each field it owns.
|
||||||
|
* @see XI5250Field#resized
|
||||||
|
*/
|
||||||
|
public void resized() {
|
||||||
|
for (int i = 0; i < ivFields.size(); i++)
|
||||||
|
ivFields.get(i).resized();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lets fields paint themselves.
|
||||||
|
*/
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
XI5250Field field = null;
|
||||||
|
Rectangle clip = g.getClipBounds();
|
||||||
|
|
||||||
|
for (int i = 0; i < ivFields.size(); i++) {
|
||||||
|
field = ivFields.get(i);
|
||||||
|
Rectangle fr = field.getBoundingRect();
|
||||||
|
|
||||||
|
if (clip.intersects(fr)) {
|
||||||
|
Graphics fg = g.create(fr.x, fr.y, fr.width, fr.height);
|
||||||
|
try {
|
||||||
|
field.paint(fg);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
fg.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ricerca campo che inizia da tale posizione, se non lo trova
|
||||||
|
* ritorna un numero negativo che trasformandolo con la formula
|
||||||
|
* idx = (-idx) - 1 indica la posizione nel vettore dove dovrebbe
|
||||||
|
* essere inserito
|
||||||
|
*/
|
||||||
|
private int searchField(int aCol, int aRow) {
|
||||||
|
int kk = ivCrt.toLinearPos(aCol, aRow);
|
||||||
|
int min = 0;
|
||||||
|
int max = ivFields.size();
|
||||||
|
int med = (max + min) / 2;
|
||||||
|
XI5250Field field;
|
||||||
|
// ricerca binaria
|
||||||
|
while ((med < ivFields.size()) && (min <= max)) {
|
||||||
|
field = ivFields.get(med);
|
||||||
|
if (field.getSortKey() == kk)
|
||||||
|
return med;
|
||||||
|
else if (field.getSortKey() > kk)
|
||||||
|
max = med - 1;
|
||||||
|
else
|
||||||
|
min = med + 1;
|
||||||
|
|
||||||
|
med = (max + min) / 2;
|
||||||
|
}
|
||||||
|
// non esiste quindi
|
||||||
|
return -(min + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a field to the fields collection.
|
||||||
|
*/
|
||||||
|
public void addField(XI5250Field aField) {
|
||||||
|
/*
|
||||||
|
// !!V già presente in quella posizione, oppure overlapping,
|
||||||
|
// sollevare una eccezione invece di return ??
|
||||||
|
if (fieldFromPos(aField.ivCol, aField.ivRow) != null)
|
||||||
|
return;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// !!V già presente in quella posizione, oppure overlapping,
|
||||||
|
// viene sostituito il campo
|
||||||
|
XI5250Field field = fieldFromPos(aField.getCol(), aField.getRow());
|
||||||
|
if (field != null) {
|
||||||
|
ivFields.set(fromFieldToIdx(field), aField);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int idx = searchField(aField.getCol(), aField.getRow());
|
||||||
|
idx = (-idx) - 1;
|
||||||
|
ivFields.add(idx, aField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Campo presente in tale posizione oppure precedente
|
||||||
|
*/
|
||||||
|
private XI5250Field prevFieldFromPosInternal(int aCol, int aRow) {
|
||||||
|
int idx = searchField(aCol, aRow);
|
||||||
|
if (idx >= 0)
|
||||||
|
return ivFields.get(idx);
|
||||||
|
|
||||||
|
idx = (-idx) - 1;
|
||||||
|
|
||||||
|
if (idx == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// accedo al precedente
|
||||||
|
return ivFields.get(idx - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ritorna indice del campo
|
||||||
|
*/
|
||||||
|
protected int fromFieldToIdx(XI5250Field aField) {
|
||||||
|
XI5250Field field;
|
||||||
|
int i = 0;
|
||||||
|
for (Iterator<XI5250Field> e = ivFields.iterator(); e.hasNext(); i++) {
|
||||||
|
field = e.next();
|
||||||
|
if (field == aField)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the field present in the given position, null if none.
|
||||||
|
*/
|
||||||
|
public XI5250Field fieldFromPos(int aCol, int aRow) {
|
||||||
|
// accedo al precedente
|
||||||
|
XI5250Field field = prevFieldFromPosInternal(aCol, aRow);
|
||||||
|
if (field == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
int kk = ivCrt.toLinearPos(aCol, aRow);
|
||||||
|
int fk = field.getSortKey();
|
||||||
|
// verifico che posizione sia sul campo
|
||||||
|
if ((kk >= fk) && (kk < (fk + field.getLength())))
|
||||||
|
return field;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250Field nextFieldFromPos(int aCol, int aRow) {
|
||||||
|
if (ivFields.isEmpty())
|
||||||
|
return null;
|
||||||
|
// accedo al precedente
|
||||||
|
XI5250Field field = prevFieldFromPosInternal(aCol, aRow);
|
||||||
|
if (field == null || field == ivFields.get(ivFields.size() - 1))
|
||||||
|
return ((!ivFields.isEmpty()) ? ivFields.get(0) :
|
||||||
|
null);
|
||||||
|
|
||||||
|
int idx = fromFieldToIdx(field);
|
||||||
|
return ivFields.get(idx + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250Field prevFieldFromPos(int aCol, int aRow) {
|
||||||
|
if (ivFields.isEmpty())
|
||||||
|
return null;
|
||||||
|
XI5250Field field = fieldFromPos(aCol, aRow);
|
||||||
|
// caso cursore sul campo
|
||||||
|
if (field != null) {
|
||||||
|
if (field == ivFields.get(0))
|
||||||
|
return ivFields.get(ivFields.size() - 1);
|
||||||
|
|
||||||
|
int idx = fromFieldToIdx(field);
|
||||||
|
idx = (idx == 0) ? (ivFields.size() - 1) : idx - 1;
|
||||||
|
return ivFields.get(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
// caso cursore non sul campo
|
||||||
|
// accedo al precedente
|
||||||
|
field = prevFieldFromPosInternal(aCol, aRow);
|
||||||
|
if (field == null)
|
||||||
|
return ((!ivFields.isEmpty()) ? ivFields.get(ivFields.size() - 1) : null);
|
||||||
|
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public List<XI5250Field> getFields() {
|
||||||
|
return ivROFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the field at the given index (null if none).
|
||||||
|
* Fields enumeration is based on their linear buffer position.
|
||||||
|
*/
|
||||||
|
public XI5250Field getField(int idx) {
|
||||||
|
try {
|
||||||
|
return (XI5250Field)ivFields.get(idx);
|
||||||
|
}
|
||||||
|
catch (ArrayIndexOutOfBoundsException ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1070
net/infordata/em/crt5250/XIEbcdicNTranslator.java
Normal file
273
net/infordata/em/crt5250/XIEbcdicTranslator.java
Normal file
|
|
@ -0,0 +1,273 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 10/04/97 rel. 0.93 - moved to crt5250 package.
|
||||||
|
16/04/97 rel. 0.94 - toPacked method added.
|
||||||
|
28/04/97 rel. 0.94c- corrected problem with underscore.
|
||||||
|
27/05/97 rel. 1.00 - first release.
|
||||||
|
25/07/97 rel. 1.03a- '|' char mapping.
|
||||||
|
03/03/98 rel. _.___- SWING and reorganization.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public abstract class XIEbcdicTranslator {
|
||||||
|
|
||||||
|
|
||||||
|
private static final Map<String,XIEbcdicTranslator> cvRegistry =
|
||||||
|
Collections.synchronizedMap(new LinkedHashMap<String,XIEbcdicTranslator>());
|
||||||
|
private static final Map<String,XIEbcdicTranslator> cvRORegistry =
|
||||||
|
Collections.unmodifiableMap(cvRegistry);
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
registerTranslator("CP37", XIEbcdicNTranslator.TRANSLATOR_CP37);
|
||||||
|
registerTranslator("CP273", XIEbcdicNTranslator.TRANSLATOR_CP273);
|
||||||
|
registerTranslator("CP277", XIEbcdicNTranslator.TRANSLATOR_CP277);
|
||||||
|
registerTranslator("CP278", XIEbcdicNTranslator.TRANSLATOR_CP278);
|
||||||
|
registerTranslator("CP280", XIEbcdicNTranslator.TRANSLATOR_CP280);
|
||||||
|
registerTranslator("CP284", XIEbcdicNTranslator.TRANSLATOR_CP284);
|
||||||
|
registerTranslator("CP285", XIEbcdicNTranslator.TRANSLATOR_CP285);
|
||||||
|
registerTranslator("CP297", XIEbcdicNTranslator.TRANSLATOR_CP297);
|
||||||
|
registerTranslator("CP424", XIEbcdicNTranslator.TRANSLATOR_CP424);
|
||||||
|
registerTranslator("CP500", XIEbcdicNTranslator.TRANSLATOR_CP500);
|
||||||
|
registerTranslator("CP850", XIEbcdicNTranslator.TRANSLATOR_CP850);
|
||||||
|
registerTranslator("CP870", XIEbcdicNTranslator.TRANSLATOR_CP870);
|
||||||
|
registerTranslator("CP838", XIEbcdicNTranslator.TRANSLATOR_CP838);
|
||||||
|
registerTranslator("CP1140", XIEbcdicNTranslator.TRANSLATOR_CP1140);
|
||||||
|
registerTranslator("CP1141", XIEbcdicNTranslator.TRANSLATOR_CP1141);
|
||||||
|
registerTranslator("CP1144", XIEbcdicNTranslator.TRANSLATOR_CP1144);
|
||||||
|
registerTranslator("CP1147", XIEbcdicNTranslator.TRANSLATOR_CP1147);
|
||||||
|
registerTranslator("CP1153", XIEbcdicNTranslator.TRANSLATOR_CP1153);
|
||||||
|
registerTranslator("CP1160", XIEbcdicNTranslator.TRANSLATOR_CP1160);
|
||||||
|
//
|
||||||
|
registerTranslator("CP1025", XIEbcdicNTranslator.TRANSLATOR_CP1025);
|
||||||
|
registerTranslator("CP1026", XIEbcdicNTranslator.TRANSLATOR_CP1026);
|
||||||
|
|
||||||
|
registerTranslator("CP1112", XIEbcdicNTranslator.TRANSLATOR_CP1112);
|
||||||
|
registerTranslator("CP1122", XIEbcdicNTranslator.TRANSLATOR_CP1122);
|
||||||
|
registerTranslator("CP1123", XIEbcdicNTranslator.TRANSLATOR_CP1123);
|
||||||
|
registerTranslator("CP1125", XIEbcdicNTranslator.TRANSLATOR_CP1125);
|
||||||
|
|
||||||
|
registerTranslator("CP1130", XIEbcdicNTranslator.TRANSLATOR_CP1130);
|
||||||
|
registerTranslator("CP1132", XIEbcdicNTranslator.TRANSLATOR_CP1132);
|
||||||
|
registerTranslator("CP1137", XIEbcdicNTranslator.TRANSLATOR_CP1137);
|
||||||
|
|
||||||
|
registerTranslator("CP1142", XIEbcdicNTranslator.TRANSLATOR_CP1142);
|
||||||
|
registerTranslator("CP1145", XIEbcdicNTranslator.TRANSLATOR_CP1145);
|
||||||
|
registerTranslator("CP1146", XIEbcdicNTranslator.TRANSLATOR_CP1146);
|
||||||
|
registerTranslator("CP1148", XIEbcdicNTranslator.TRANSLATOR_CP1148);
|
||||||
|
registerTranslator("CP1149", XIEbcdicNTranslator.TRANSLATOR_CP1149);
|
||||||
|
|
||||||
|
registerTranslator("CP1154", XIEbcdicNTranslator.TRANSLATOR_CP1154);
|
||||||
|
registerTranslator("CP1155", XIEbcdicNTranslator.TRANSLATOR_CP1155);
|
||||||
|
registerTranslator("CP1156", XIEbcdicNTranslator.TRANSLATOR_CP1156);
|
||||||
|
registerTranslator("CP1157", XIEbcdicNTranslator.TRANSLATOR_CP1157);
|
||||||
|
registerTranslator("CP1158", XIEbcdicNTranslator.TRANSLATOR_CP1158);
|
||||||
|
|
||||||
|
registerTranslator("CP1164", XIEbcdicNTranslator.TRANSLATOR_CP1164);
|
||||||
|
|
||||||
|
registerTranslator("CP420", XIEbcdicNTranslator.TRANSLATOR_CP420);
|
||||||
|
registerTranslator("CP871", XIEbcdicNTranslator.TRANSLATOR_CP871);
|
||||||
|
registerTranslator("CP875", XIEbcdicNTranslator.TRANSLATOR_CP875);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected XIEbcdicTranslator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public static synchronized void registerTranslator(String id,
|
||||||
|
XIEbcdicTranslator tr) {
|
||||||
|
if (id == null)
|
||||||
|
throw new NullPointerException("id is null");
|
||||||
|
if (tr == null)
|
||||||
|
throw new NullPointerException("tr is null");
|
||||||
|
if (cvRegistry.containsKey(id.toLowerCase()))
|
||||||
|
throw new IllegalArgumentException("Translator " + id.toLowerCase() + " already registered");
|
||||||
|
cvRegistry.put(id.toLowerCase(), tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a read-only map of registered translators
|
||||||
|
*/
|
||||||
|
public static Map<String,XIEbcdicTranslator> getRegisteredTranslators() {
|
||||||
|
return cvRORegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the XIEbcdicTranslator.
|
||||||
|
*/
|
||||||
|
public static XIEbcdicTranslator getTranslator(String id) {
|
||||||
|
return cvRegistry.get(id.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts byte to int without sign.
|
||||||
|
*/
|
||||||
|
public static final int toInt(byte bb) {
|
||||||
|
return ((int)bb & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts byte to hex rapresentation
|
||||||
|
*/
|
||||||
|
public static final String toHex(byte bb) {
|
||||||
|
String hex = Integer.toString(toInt(bb), 16);
|
||||||
|
return "00".substring(hex.length()) + hex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From ebcdic code to char
|
||||||
|
*/
|
||||||
|
public abstract char toChar(byte aEbcdicChar);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From char to ebcdic code
|
||||||
|
*/
|
||||||
|
public abstract byte toEBCDIC(char aChar);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From String to ebcdic string
|
||||||
|
*/
|
||||||
|
public byte[] toText(String aString, int aLen) {
|
||||||
|
byte[] bb = new byte[aLen];
|
||||||
|
int i;
|
||||||
|
int len = Math.min(aLen, aString.length());
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
bb[i] = toEBCDIC(aString.charAt(i));
|
||||||
|
// fill with space
|
||||||
|
for (i = len; i < aLen; i++)
|
||||||
|
bb[i] = toEBCDIC(' ');
|
||||||
|
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From int to ebcdic numeric not packed
|
||||||
|
*/
|
||||||
|
public byte[] toNumeric(int aNum, int aLen) {
|
||||||
|
byte[] bb = new byte[aLen];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = aLen - 1; i >= 0; i--) {
|
||||||
|
bb[i] = toEBCDIC((char)(((int)'0') + (aNum % 10)));
|
||||||
|
aNum /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From int to packed
|
||||||
|
*/
|
||||||
|
public byte[] toPacked(int aNum, int aLen) {
|
||||||
|
byte[] res = new byte[(aLen + 1) / 2];
|
||||||
|
int x;
|
||||||
|
|
||||||
|
for (int i = res.length - 1; i >= 0; i--) {
|
||||||
|
if (i == res.length - 1 && aNum < 0) {
|
||||||
|
res[i] = (byte)0x0D;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x = aNum % 10;
|
||||||
|
aNum /= 10;
|
||||||
|
res[i] = (byte)x;
|
||||||
|
}
|
||||||
|
|
||||||
|
x = aNum % 10;
|
||||||
|
aNum /= 10;
|
||||||
|
res[i] |= (byte)(x << 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From ebcdic string to String
|
||||||
|
*/
|
||||||
|
public String toString(byte[] aBuf, int aOfs, int aLen) {
|
||||||
|
String str = "";
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = aOfs; i < (aOfs + aLen); i++)
|
||||||
|
str += toChar(aBuf[i]);
|
||||||
|
|
||||||
|
// strip trailing blanks
|
||||||
|
for (i = str.length() - 1; (i >= 0) && (str.charAt(i) == ' '); i--)
|
||||||
|
;
|
||||||
|
|
||||||
|
return str.substring(0, Math.max(0, Math.min(str.length(), i + 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From ebcdic numeric not packed to int
|
||||||
|
*/
|
||||||
|
public int toInt(byte[] aBuf, int aOfs, int aLen) {
|
||||||
|
String str = toString(aBuf, aOfs, aLen);
|
||||||
|
return Integer.parseInt(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From ebcdic packed to int
|
||||||
|
*/
|
||||||
|
public int toIntFromPacked(byte[] aBuf, int aOfs, int aLen) {
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
for (int i = aOfs; i < (aOfs + aLen); i++) {
|
||||||
|
res = (res * 100) + ((aBuf[i] >> 4 & 0x0F) * 10);
|
||||||
|
|
||||||
|
if ((aBuf[i] & 0x0F) == 0x0D)
|
||||||
|
res /= -10;
|
||||||
|
else if ((aBuf[i] & 0x0F) == 0x0F)
|
||||||
|
res /= 10;
|
||||||
|
else
|
||||||
|
res += (aBuf[i] & 0x0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
124
net/infordata/em/crt5250/XIImagesBdl.java
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
!!V 15/06/99 rel. 1.13 - creation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.crt5250;
|
||||||
|
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.ListResourceBundle;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.Icon;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
import net.infordata.em.util.XIUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The image bundle.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIImagesBdl extends ListResourceBundle {
|
||||||
|
|
||||||
|
private static XIImagesBdl cvImagesBdl;
|
||||||
|
|
||||||
|
private static Object[][] cvContents = null;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
cvContents = new Object[][] {
|
||||||
|
{"ShiftDown",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/ShiftDown.gif")},
|
||||||
|
{"CapsLock",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/CapsLock.gif")},
|
||||||
|
//
|
||||||
|
{"3dFx",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/3dFx.gif")},
|
||||||
|
{"Copy",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/Copy.gif")},
|
||||||
|
{"Paste",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/Paste.gif")},
|
||||||
|
{"RefCursor",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/RefCursor.gif")},
|
||||||
|
{"Print",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/Print.gif")},
|
||||||
|
//
|
||||||
|
{"Logo",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/Logo.gif")},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (RuntimeException ex) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private XIImagesBdl() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static XIImagesBdl getImagesBdl() {
|
||||||
|
if (cvImagesBdl == null) {
|
||||||
|
cvImagesBdl = new XIImagesBdl();
|
||||||
|
}
|
||||||
|
|
||||||
|
return cvImagesBdl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[][] getContents() {
|
||||||
|
return cvContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final Image getImage(String anImageName) {
|
||||||
|
return ((ImageIcon)getIcon(anImageName)).getImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Map<String, Icon> ivIcons = new HashMap<String, Icon>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public synchronized final Icon getIcon(String anImageName) {
|
||||||
|
Icon icon = (Icon)ivIcons.get(anImageName);
|
||||||
|
if (icon == null) {
|
||||||
|
icon = new ImageIcon((Image)getObject(anImageName));
|
||||||
|
ivIcons.put(anImageName, icon);
|
||||||
|
}
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
net/infordata/em/crt5250/resources/3dFx.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
net/infordata/em/crt5250/resources/CapsLock.gif
Normal file
|
After Width: | Height: | Size: 903 B |
BIN
net/infordata/em/crt5250/resources/Copy.gif
Normal file
|
After Width: | Height: | Size: 153 B |
BIN
net/infordata/em/crt5250/resources/Logo.gif
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
net/infordata/em/crt5250/resources/Paste.gif
Normal file
|
After Width: | Height: | Size: 173 B |
BIN
net/infordata/em/crt5250/resources/Print.gif
Normal file
|
After Width: | Height: | Size: 155 B |
BIN
net/infordata/em/crt5250/resources/RefCursor.gif
Normal file
|
After Width: | Height: | Size: 941 B |
13
net/infordata/em/crt5250/resources/Res.properties
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# crt5250
|
||||||
|
|
||||||
|
TXT_Copy = Copy
|
||||||
|
TXT_Options = &Options
|
||||||
|
TXT_RefCursor = Ref. cursor
|
||||||
|
TXT_Exit = Exit
|
||||||
|
TXT_Paste = Paste
|
||||||
|
TXT_Edit = &Edit
|
||||||
|
TXT_3dFx = 3dFx
|
||||||
|
|
||||||
|
TXT_Print = Print
|
||||||
|
|
||||||
|
|
||||||
12
net/infordata/em/crt5250/resources/Res_it.properties
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# crt5250
|
||||||
|
|
||||||
|
TXT_Copy = Copia
|
||||||
|
TXT_Options = &Opzioni
|
||||||
|
TXT_RefCursor = Cursore di riferimento
|
||||||
|
TXT_Exit = Chiudi
|
||||||
|
TXT_Paste = Incolla
|
||||||
|
TXT_Edit = &Modifica
|
||||||
|
TXT_3dFx = 3dFx
|
||||||
|
|
||||||
|
TXT_Print = Stampa pannello
|
||||||
|
|
||||||
BIN
net/infordata/em/crt5250/resources/ShiftDown.gif
Normal file
|
After Width: | Height: | Size: 220 B |
126
net/infordata/em/tn5250/Test.java
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XI5250Field;
|
||||||
|
import net.infordata.em.crt5250.XIEbcdicTranslator;
|
||||||
|
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
private Test() { }
|
||||||
|
|
||||||
|
private static void usageError(String msg) {
|
||||||
|
System.err.println(msg);
|
||||||
|
System.err.println("Usage: [-3dFX] [-altFKeyRemap] [-cp codepage] host-name");
|
||||||
|
System.err.println("Supported code pages:");
|
||||||
|
for (String cp : XIEbcdicTranslator.getRegisteredTranslators().keySet()) {
|
||||||
|
System.err.println(" " + cp +
|
||||||
|
(XI5250Emulator.DEFAULT_CODE_PAGE.equalsIgnoreCase(cp)? " default" : ""));
|
||||||
|
}
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used only for test purposes.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
/*!!1.12
|
||||||
|
if (System.getProperty("java.version").compareTo("1.1.1") < 0 ||
|
||||||
|
System.getProperty("java.version").compareTo("1.1_Final") == 0) {
|
||||||
|
System.err.println("!!! Use JDK 1.1.1 or newer !!!");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
// checkJDK();
|
||||||
|
|
||||||
|
boolean pUse3dFX = false;
|
||||||
|
boolean pAltFKeyRemap = false;
|
||||||
|
|
||||||
|
String arg;
|
||||||
|
String pHost = null;
|
||||||
|
boolean expectCP = false;
|
||||||
|
String cp = null;
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
arg = args[i];
|
||||||
|
if (arg.startsWith("-")) {
|
||||||
|
if ("-3dfx".equalsIgnoreCase(arg))
|
||||||
|
pUse3dFX = true;
|
||||||
|
else if ("-altFKeyRemap".equalsIgnoreCase(arg))
|
||||||
|
pAltFKeyRemap = true;
|
||||||
|
else if ("-cp".equalsIgnoreCase(arg))
|
||||||
|
expectCP = true;
|
||||||
|
else
|
||||||
|
usageError("Wrong option: " + arg);
|
||||||
|
}
|
||||||
|
else if (expectCP) {
|
||||||
|
expectCP = false;
|
||||||
|
if (XIEbcdicTranslator.getTranslator(arg) == null)
|
||||||
|
usageError("Unknown codepage: " + arg);
|
||||||
|
cp = arg;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (pHost == null)
|
||||||
|
pHost = arg;
|
||||||
|
else
|
||||||
|
usageError("Too many host names.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (expectCP)
|
||||||
|
usageError("A code page is expected");
|
||||||
|
|
||||||
|
final boolean altFKeyRemap = pAltFKeyRemap;
|
||||||
|
final boolean use3dFX = pUse3dFX;
|
||||||
|
final String host = pHost;
|
||||||
|
final String codePage = cp;
|
||||||
|
try {
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
XI5250Emulator em = new XI5250Emulator();
|
||||||
|
em.setTerminalType("IBM-3477-FC");
|
||||||
|
em.setKeyboardQueue(true);
|
||||||
|
|
||||||
|
em.setAltFKeyRemap(altFKeyRemap);
|
||||||
|
em.setCodePage(codePage);
|
||||||
|
|
||||||
|
if (host != null) {
|
||||||
|
em.setHost(host);
|
||||||
|
em.setActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
XI5250Frame frm = new XI5250Frame("xtn5250mg" + " " +
|
||||||
|
XI5250Emulator.VERSION, em);
|
||||||
|
frm.addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//3D FX
|
||||||
|
if (use3dFX) {
|
||||||
|
em.setDefFieldsBorderStyle(XI5250Field.LOWERED_BORDER);
|
||||||
|
em.setDefBackground(UIManager.getColor("control"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//frm.setBounds(0, 0, 570, 510);
|
||||||
|
frm.centerOnScreen(70);
|
||||||
|
frm.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (InterruptedException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
catch (InvocationTargetException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
544
net/infordata/em/tn5250/XI5250Applet.java
Normal file
|
|
@ -0,0 +1,544 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
!!V 09/07/98 rel. 1.10 - creation.
|
||||||
|
05/02/99 rel. 1.11 - Swing 1.1 bug work-around.
|
||||||
|
08/06/99 rel. 1.11a- The emulator is centered.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import javax.swing.AbstractButton;
|
||||||
|
import javax.swing.JApplet;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.JToolBar;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XI5250Crt;
|
||||||
|
import net.infordata.em.crt5250.XI5250Field;
|
||||||
|
import net.infordata.em.util.XICommand;
|
||||||
|
import net.infordata.em.util.XICommandMgr;
|
||||||
|
import net.infordata.em.util.XIUtil;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class XI5250Applet extends JApplet {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private static final int DEBUG = 0;
|
||||||
|
|
||||||
|
// if true the emulation frame survives to the applet dead,
|
||||||
|
// !!VERIFY: a stopped applet causes event dispatching problems
|
||||||
|
private static final boolean UNDEAD_FRAME = false;
|
||||||
|
|
||||||
|
// images
|
||||||
|
private static XIImagesBdl cvImagesBdl = XIImagesBdl.getImagesBdl();
|
||||||
|
|
||||||
|
private static ResourceBundle cvRes =
|
||||||
|
ResourceBundle.getBundle("net.infordata.em.tn5250.resources.Res");
|
||||||
|
|
||||||
|
private XI5250EmulatorCtrl ivEmulatorCtrl;
|
||||||
|
private EmulatorFrame ivFrame;
|
||||||
|
private boolean ivFirstTime = true;
|
||||||
|
|
||||||
|
private boolean ivDestroyed = false;
|
||||||
|
|
||||||
|
private PropertyChangeListener ivPropertyChangeListener =
|
||||||
|
new PropertyChangeListener() {
|
||||||
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
|
emulatorPropertyChanged(evt);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final String INFRAME_CMD = "INFRAME_CMD";
|
||||||
|
|
||||||
|
protected XI5250Emulator createEmulator() {
|
||||||
|
return new XI5250Emulator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
if (DEBUG >= 1)
|
||||||
|
System.out.println("init()");
|
||||||
|
|
||||||
|
/*!!1.12
|
||||||
|
if (System.getProperty("java.version").compareTo("1.1.1") < 0 ||
|
||||||
|
System.getProperty("java.version").compareTo("1.1_Final") == 0) {
|
||||||
|
System.err.println("!!! Use JDK 1.1.1 or newer !!!");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
// XI5250Emulator.checkJDK();
|
||||||
|
|
||||||
|
String host = null;
|
||||||
|
host = getParameter("host");
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (host == null) {
|
||||||
|
System.err.println("Host name or ip address is required.");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean inplace = true;
|
||||||
|
{
|
||||||
|
String ss = getParameter("inplace");
|
||||||
|
if (ss != null && "false".equals(ss.toLowerCase()))
|
||||||
|
inplace = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean p3dFX = "true".equalsIgnoreCase(getParameter("3dFX"));
|
||||||
|
final boolean altFKeyRemap = "true".equalsIgnoreCase(getParameter("altFKeyRemap"));
|
||||||
|
final String codePage = getParameter("codePage");
|
||||||
|
final boolean requestFocus = !"false".equalsIgnoreCase(getParameter("requestFocus"));
|
||||||
|
final boolean pSTRPCCMD = "true".equalsIgnoreCase(getParameter("STRPCCMD"));
|
||||||
|
final String deviceName = getParameter("devName");
|
||||||
|
|
||||||
|
ivEmulatorCtrl = new XI5250EmulatorCtrl(createEmulator());
|
||||||
|
getEmulator().setTerminalType("IBM-3477-FC");
|
||||||
|
getEmulator().setHost(host);
|
||||||
|
//3D FX
|
||||||
|
if (p3dFX) {
|
||||||
|
getEmulator().setDefFieldsBorderStyle(XI5250Field.LOWERED_BORDER);
|
||||||
|
getEmulator().setDefBackground(UIManager.getColor("control"));
|
||||||
|
}
|
||||||
|
getEmulator().setAltFKeyRemap(altFKeyRemap);
|
||||||
|
getEmulator().setCodePage(codePage);
|
||||||
|
getEmulator().setStrPcCmdEnabled(pSTRPCCMD);
|
||||||
|
if (deviceName != null)
|
||||||
|
getEmulator().setTelnetEnv("\u0003DEVNAME\u0001" + deviceName);
|
||||||
|
|
||||||
|
//!! 1.11a execution moved to the EventQueueThread
|
||||||
|
if (inplace)
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
emulatorInPlace();
|
||||||
|
if (requestFocus)
|
||||||
|
getEmulator().requestFocusInWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
else
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
emulatorInFrame();
|
||||||
|
if (requestFocus)
|
||||||
|
getEmulator().requestFocusInWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// InFrame command
|
||||||
|
getCommandMgr().enableCommand(
|
||||||
|
INFRAME_CMD, ivFrame == null);
|
||||||
|
getCommandMgr().setCommand(INFRAME_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processInFrameCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
if (DEBUG >= 1)
|
||||||
|
System.out.println("start()");
|
||||||
|
|
||||||
|
if (getEmulator().getHost() != null) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
getEmulator().setActive(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
if (DEBUG >= 1)
|
||||||
|
System.out.println("stop()");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
if (DEBUG >= 1)
|
||||||
|
System.out.println("destroy()");
|
||||||
|
|
||||||
|
ivDestroyed = true;
|
||||||
|
if (!UNDEAD_FRAME || ivFrame == null) {
|
||||||
|
emulatorInPlace();
|
||||||
|
getEmulator().setActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XI5250Emulator getEmulator() {
|
||||||
|
return ivEmulatorCtrl.getEmulator();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XICommandMgr getCommandMgr() {
|
||||||
|
return ivEmulatorCtrl.getCommandMgr();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processInFrameCmd() {
|
||||||
|
emulatorInFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void emulatorInPlace() {
|
||||||
|
if (!ivFirstTime && ivFrame == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ivFirstTime = false;
|
||||||
|
|
||||||
|
if (DEBUG >= 1)
|
||||||
|
System.out.println("inplace");
|
||||||
|
|
||||||
|
if (ivFrame != null) {
|
||||||
|
ivFrame.setJMenuBar(null); // work around for a Swing 1.1 bug
|
||||||
|
|
||||||
|
ivFrame.dispose();
|
||||||
|
ivFrame = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
getCommandMgr().enableCommand(INFRAME_CMD, true);
|
||||||
|
|
||||||
|
JToolBar toolBar = createToolBar();
|
||||||
|
JMenuBar menuBar = createMenuBar();
|
||||||
|
|
||||||
|
setJMenuBar(menuBar);
|
||||||
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
getContentPane().add(toolBar, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
JPanel panel = new XI5250Emulator.SupportPanel(getEmulator());
|
||||||
|
panel.setBackground(getEmulator().getBackground());
|
||||||
|
getContentPane().add(panel, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
getEmulator().addPropertyChangeListener(ivPropertyChangeListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void emulatorInFrame() {
|
||||||
|
if (ivFrame != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (DEBUG >= 1)
|
||||||
|
System.out.println("inframe");
|
||||||
|
|
||||||
|
getCommandMgr().enableCommand(INFRAME_CMD, false);
|
||||||
|
|
||||||
|
getEmulator().removePropertyChangeListener(ivPropertyChangeListener);
|
||||||
|
setJMenuBar(null);
|
||||||
|
getContentPane().removeAll();
|
||||||
|
validate();
|
||||||
|
repaint();
|
||||||
|
|
||||||
|
ivFrame = new EmulatorFrame("xtn5250mg" + " " +
|
||||||
|
XI5250Emulator.VERSION,
|
||||||
|
getEmulator());
|
||||||
|
ivFrame.setBounds(0, 0, 648, 506);
|
||||||
|
ivFrame.centerOnScreen();
|
||||||
|
ivFrame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private void frameClosed() {
|
||||||
|
if (DEBUG >= 1)
|
||||||
|
System.out.println("frameClosed()");
|
||||||
|
|
||||||
|
if (UNDEAD_FRAME && ivDestroyed)
|
||||||
|
getEmulator().setActive(false);
|
||||||
|
else {
|
||||||
|
emulatorInPlace();
|
||||||
|
invalidate();
|
||||||
|
validate();
|
||||||
|
getEmulator().requestFocusInWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private void emulatorPropertyChanged(PropertyChangeEvent evt) {
|
||||||
|
String propertyName = evt.getPropertyName();
|
||||||
|
if ("background".equals(propertyName))
|
||||||
|
getEmulator().getParent().setBackground(getEmulator().getBackground());
|
||||||
|
else if ("font".equals(propertyName) ||
|
||||||
|
XI5250Crt.CRT_SIZE.equals(propertyName))
|
||||||
|
getEmulator().revalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private JMenuBar createMenuBar() {
|
||||||
|
String str;
|
||||||
|
|
||||||
|
str = cvRes.getString("TXT_Communications");
|
||||||
|
JMenu commMenu = new JMenu(XIUtil.removeMnemonics(str));
|
||||||
|
commMenu.setMnemonic(XIUtil.getMnemonic(str));
|
||||||
|
{
|
||||||
|
JMenuItem connItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Connect"));
|
||||||
|
JMenuItem disconnItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Disconnect"));
|
||||||
|
JMenuItem aboutItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_About"));
|
||||||
|
|
||||||
|
commMenu.add(connItem);
|
||||||
|
commMenu.add(disconnItem);
|
||||||
|
commMenu.addSeparator();
|
||||||
|
commMenu.add(aboutItem);
|
||||||
|
|
||||||
|
getCommandMgr().handleCommand(connItem,
|
||||||
|
XI5250EmulatorCtrl.CONNECT_CMD);
|
||||||
|
getCommandMgr().handleCommand(disconnItem,
|
||||||
|
XI5250EmulatorCtrl.DISCONNECT_CMD);
|
||||||
|
getCommandMgr().handleCommand(aboutItem,
|
||||||
|
XI5250EmulatorCtrl.ABOUT_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
str = cvRes.getString("TXT_Edit");
|
||||||
|
JMenu editMenu = new JMenu(XIUtil.removeMnemonics(str));
|
||||||
|
editMenu.setMnemonic(XIUtil.getMnemonic(str));
|
||||||
|
{
|
||||||
|
JMenuItem copyItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Copy"));
|
||||||
|
JMenuItem pasteItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Paste"));
|
||||||
|
JMenuItem snapShotItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_SnapShot"));
|
||||||
|
JMenuItem printItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Print"));
|
||||||
|
|
||||||
|
editMenu.add(copyItem);
|
||||||
|
editMenu.add(pasteItem);
|
||||||
|
editMenu.addSeparator();
|
||||||
|
editMenu.add(snapShotItem);
|
||||||
|
editMenu.addSeparator();
|
||||||
|
editMenu.add(printItem);
|
||||||
|
|
||||||
|
getCommandMgr().handleCommand(copyItem,
|
||||||
|
XI5250EmulatorCtrl.COPY_CMD);
|
||||||
|
getCommandMgr().handleCommand(pasteItem,
|
||||||
|
XI5250EmulatorCtrl.PASTE_CMD);
|
||||||
|
getCommandMgr().handleCommand(snapShotItem,
|
||||||
|
XI5250EmulatorCtrl.SNAPSHOT_CMD);
|
||||||
|
getCommandMgr().handleCommand(printItem,
|
||||||
|
XI5250EmulatorCtrl.PRINT_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
str = cvRes.getString("TXT_Options");
|
||||||
|
JMenu optionsMenu = new JMenu(XIUtil.removeMnemonics(str));
|
||||||
|
optionsMenu.setMnemonic(XIUtil.getMnemonic(str));
|
||||||
|
{
|
||||||
|
JMenuItem inFrameItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_InFrame"));
|
||||||
|
JCheckBoxMenuItem switch3DfxItem =
|
||||||
|
new JCheckBoxMenuItem(cvRes.getString("TXT_3dFx"));
|
||||||
|
JCheckBoxMenuItem referenceCursorItem =
|
||||||
|
new JCheckBoxMenuItem(cvRes.getString("TXT_RefCursor"));
|
||||||
|
|
||||||
|
optionsMenu.add(inFrameItem);
|
||||||
|
optionsMenu.addSeparator();
|
||||||
|
optionsMenu.add(switch3DfxItem);
|
||||||
|
optionsMenu.add(referenceCursorItem);
|
||||||
|
|
||||||
|
getCommandMgr().handleCommand(inFrameItem,
|
||||||
|
INFRAME_CMD);
|
||||||
|
getCommandMgr().handleCommand(switch3DfxItem,
|
||||||
|
XI5250EmulatorCtrl.SWITCH_3DFX_CMD);
|
||||||
|
getCommandMgr().handleCommand(referenceCursorItem,
|
||||||
|
XI5250EmulatorCtrl.REFERENCE_CURSOR_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
JMenuBar menuBar = new JMenuBar();
|
||||||
|
menuBar.add(commMenu);
|
||||||
|
menuBar.add(editMenu);
|
||||||
|
menuBar.add(optionsMenu);
|
||||||
|
return menuBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserisce nella tool-bar i bottoni di default.
|
||||||
|
*/
|
||||||
|
private JToolBar createToolBar() {
|
||||||
|
// bottoni della tool-bar
|
||||||
|
AbstractButton[] buttons = new AbstractButton[] {
|
||||||
|
new JButton(cvImagesBdl.getIcon("Connect")),
|
||||||
|
new JButton(cvImagesBdl.getIcon("Disconnect")),
|
||||||
|
null,
|
||||||
|
new JButton(cvImagesBdl.getIcon("Copy")),
|
||||||
|
new JButton(cvImagesBdl.getIcon("Paste")),
|
||||||
|
null,
|
||||||
|
new JButton(cvImagesBdl.getIcon("SnapShot")),
|
||||||
|
new JButton(cvImagesBdl.getIcon("Print")),
|
||||||
|
null,
|
||||||
|
new JButton(cvImagesBdl.getIcon("InFrame")),
|
||||||
|
null,
|
||||||
|
new JToggleButton(cvImagesBdl.getIcon("3dFx")),
|
||||||
|
new JToggleButton(cvImagesBdl.getIcon("RefCursor")),
|
||||||
|
};
|
||||||
|
// action commands associati con i bottoni della tool-bar.
|
||||||
|
String[] buttonsActCmd = new String[] {
|
||||||
|
XI5250EmulatorCtrl.CONNECT_CMD,
|
||||||
|
XI5250EmulatorCtrl.DISCONNECT_CMD,
|
||||||
|
null,
|
||||||
|
XI5250EmulatorCtrl.COPY_CMD,
|
||||||
|
XI5250EmulatorCtrl.PASTE_CMD,
|
||||||
|
null,
|
||||||
|
XI5250EmulatorCtrl.SNAPSHOT_CMD,
|
||||||
|
XI5250EmulatorCtrl.PRINT_CMD,
|
||||||
|
null,
|
||||||
|
INFRAME_CMD,
|
||||||
|
null,
|
||||||
|
XI5250EmulatorCtrl.SWITCH_3DFX_CMD,
|
||||||
|
XI5250EmulatorCtrl.REFERENCE_CURSOR_CMD,
|
||||||
|
};
|
||||||
|
// Hint associati ad i vari bottoni.
|
||||||
|
String[] buttonHints = new String[] {
|
||||||
|
cvRes.getString("TXT_Connect"),
|
||||||
|
cvRes.getString("TXT_Disconnect"),
|
||||||
|
null,
|
||||||
|
cvRes.getString("TXT_Copy"),
|
||||||
|
cvRes.getString("TXT_Paste"),
|
||||||
|
null,
|
||||||
|
cvRes.getString("TXT_SnapShot"),
|
||||||
|
cvRes.getString("TXT_Print"),
|
||||||
|
null,
|
||||||
|
cvRes.getString("TXT_InFrame"),
|
||||||
|
null,
|
||||||
|
cvRes.getString("TXT_3dFx"),
|
||||||
|
cvRes.getString("TXT_RefCursor"),
|
||||||
|
};
|
||||||
|
|
||||||
|
JToolBar toolBar = new JToolBar();
|
||||||
|
toolBar.setFloatable(false);
|
||||||
|
|
||||||
|
Dimension size = new Dimension(26, 26);
|
||||||
|
|
||||||
|
for (int i = 0; i < buttons.length; i++) {
|
||||||
|
if (buttons[i] != null) {
|
||||||
|
AbstractButton button = (AbstractButton)buttons[i];
|
||||||
|
toolBar.add(button);
|
||||||
|
button.setToolTipText(buttonHints[i]);
|
||||||
|
button.setMinimumSize(size);
|
||||||
|
button.setPreferredSize(size);
|
||||||
|
button.setMaximumSize(size);
|
||||||
|
button.setRequestFocusEnabled(false);
|
||||||
|
getCommandMgr().handleCommand(button, buttonsActCmd[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
toolBar.addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
return toolBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
super.paint(g);
|
||||||
|
if (ivFrame != null) {
|
||||||
|
Rectangle rt = getBounds();
|
||||||
|
g.setColor(Color.darkGray);
|
||||||
|
|
||||||
|
int hh = rt.height;
|
||||||
|
for (int x = -hh; x < rt.width; x += 16)
|
||||||
|
g.drawLine(x, hh, x + hh, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private class EmulatorFrame extends XI5250Frame {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public EmulatorFrame(String aTitle, XI5250Emulator aCrt) {
|
||||||
|
super(aTitle, aCrt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void processExitCmd() {
|
||||||
|
if (UNDEAD_FRAME && ivDestroyed)
|
||||||
|
super.processExitCmd();
|
||||||
|
else
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void processWindowEvent(WindowEvent e) {
|
||||||
|
switch(e.getID()) {
|
||||||
|
case WindowEvent.WINDOW_CLOSED:
|
||||||
|
XI5250Applet.this.frameClosed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.processWindowEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
60
net/infordata/em/tn5250/XI5250Cmd.java
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class for all 5250 commands
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public abstract class XI5250Cmd {
|
||||||
|
|
||||||
|
protected XI5250Emulator ivEmulator;
|
||||||
|
|
||||||
|
|
||||||
|
protected void init(XI5250Emulator aEmulator) {
|
||||||
|
ivEmulator = aEmulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
protected abstract void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception;
|
||||||
|
|
||||||
|
|
||||||
|
protected abstract void execute();
|
||||||
|
|
||||||
|
|
||||||
|
protected void executePending(int anAidCode, boolean isMasked) {
|
||||||
|
throw new RuntimeException("executePending() not supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
181
net/infordata/em/tn5250/XI5250CmdList.java
Normal file
|
|
@ -0,0 +1,181 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.infordata.em.tnprot.XITelnet;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Commands list (Works like a macro command).
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250CmdList extends XI5250Cmd {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(XI5250CmdList.class.getName());
|
||||||
|
|
||||||
|
private static Class<?>[] cv5250CmdClasses = new Class[256];;
|
||||||
|
|
||||||
|
protected List<XI5250Cmd> ivCmdVect;
|
||||||
|
|
||||||
|
// flags used across command execution
|
||||||
|
protected boolean ivICOrderExecuted;
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_READ_IMMEDIATE)] =
|
||||||
|
XIReadImmediateCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_READ_FIELDS)] =
|
||||||
|
XIReadFieldsCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_READ_MDT_FIELDS)] =
|
||||||
|
XIReadMdtFieldsCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_READ_SCREEN)] =
|
||||||
|
XIReadScreenCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_SAVE_SCREEN)] =
|
||||||
|
XISaveScreenCmd.class;
|
||||||
|
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_CLEAR_FMT_TABLE)] =
|
||||||
|
XIClearFmtTableCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_CLEAR_UNIT)] =
|
||||||
|
XIClearUnitCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_CLEAR_UNIT_ALT)] =
|
||||||
|
XIClearUnitAltCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_RESTORE_SCREEN)] =
|
||||||
|
XIRestoreScreenCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_ROLL)] =
|
||||||
|
XIRollCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_WRITE_ERROR_CODE)] =
|
||||||
|
XIWriteErrorCodeCmd.class;
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_WRITE_TO_DISPLAY)] =
|
||||||
|
XIWriteToDisplayCmd.class;
|
||||||
|
|
||||||
|
cv5250CmdClasses[XITelnet.toInt(XI5250Emulator.CMD_QUERY_DEVICE)] =
|
||||||
|
XIQueryCmd.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected XI5250CmdList(XI5250Emulator aEmulator) {
|
||||||
|
init(aEmulator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
int bb;
|
||||||
|
XI5250Cmd cmd;
|
||||||
|
ivCmdVect = new ArrayList<XI5250Cmd>(100);
|
||||||
|
|
||||||
|
if (LOGGER.isLoggable(Level.FINER))
|
||||||
|
LOGGER.finer("START OF COMMANDS LIST");
|
||||||
|
|
||||||
|
// jump until ESC is found
|
||||||
|
while ((bb = inStream.read()) != -1 && (byte)bb != XI5250Emulator.ESC)
|
||||||
|
;
|
||||||
|
|
||||||
|
// start from 1 because ESC is already read
|
||||||
|
for (int i = 1; (bb = inStream.read()) != -1; i++) {
|
||||||
|
switch (i % 2) {
|
||||||
|
case 0:
|
||||||
|
if ((byte)bb != XI5250Emulator.ESC)
|
||||||
|
throw new XI5250Exception("Malformed 5250 packet", XI5250Emulator.ERR_INVALID_COMMAND);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
try {
|
||||||
|
cmd = createCmdInstance(XITelnet.toInt((byte)bb));
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd != null) {
|
||||||
|
cmd.init(ivEmulator);
|
||||||
|
cmd.readFrom5250Stream(inStream);
|
||||||
|
|
||||||
|
if (LOGGER.isLoggable(Level.FINER))
|
||||||
|
LOGGER.finer("" + cmd);
|
||||||
|
|
||||||
|
ivCmdVect.add(cmd);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new XI5250Exception("Command not supported : 0x" +
|
||||||
|
XITelnet.toHex((byte)bb),
|
||||||
|
XI5250Emulator.ERR_INVALID_COMMAND);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
for (int i = 0; i < ivCmdVect.size(); i++)
|
||||||
|
ivCmdVect.get(i).execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the 5250 command related to the given 5250 command id.
|
||||||
|
* @exception IllegalAccessException .
|
||||||
|
* @exception InstantiationException .
|
||||||
|
*/
|
||||||
|
protected XI5250Cmd createCmdInstance(int aCmd)
|
||||||
|
throws IllegalAccessException, InstantiationException {
|
||||||
|
Class<?> cls;
|
||||||
|
|
||||||
|
cls = cv5250CmdClasses[aCmd];
|
||||||
|
if (cls != null)
|
||||||
|
return (XI5250Cmd)cls.newInstance();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String ss = super.toString() + ivCmdVect.toString();
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
}
|
||||||
2099
net/infordata/em/tn5250/XI5250Emulator.java
Normal file
74
net/infordata/em/tn5250/XI5250EmulatorAdapter.java
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XI5250EmulatorListener adapter.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250EmulatorAdapter implements XI5250EmulatorListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void connecting(XI5250EmulatorEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void connected(XI5250EmulatorEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void disconnected(XI5250EmulatorEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void stateChanged(XI5250EmulatorEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void newPanelReceived(XI5250EmulatorEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void fieldsRemoved(XI5250EmulatorEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void dataSended(XI5250EmulatorEvent e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
102
net/infordata/em/tn5250/XI5250EmulatorBeanInfo.java
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
import java.beans.BeanInfo;
|
||||||
|
import java.beans.IntrospectionException;
|
||||||
|
import java.beans.Introspector;
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.beans.SimpleBeanInfo;
|
||||||
|
|
||||||
|
public class XI5250EmulatorBeanInfo extends SimpleBeanInfo {
|
||||||
|
Class<XI5250Emulator> beanClass = XI5250Emulator.class;
|
||||||
|
String iconColor16x16Filename = "resources/XI5250Emulator_16.gif";
|
||||||
|
String iconColor32x32Filename = "resources/XI5250Emulator_32.gif";
|
||||||
|
String iconMono16x16Filename;
|
||||||
|
String iconMono32x32Filename;
|
||||||
|
|
||||||
|
|
||||||
|
public XI5250EmulatorBeanInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDescriptor[] getPropertyDescriptors() {
|
||||||
|
try {
|
||||||
|
PropertyDescriptor _active =
|
||||||
|
new PropertyDescriptor("active", beanClass, "isActive", "setActive");
|
||||||
|
|
||||||
|
PropertyDescriptor _host =
|
||||||
|
new PropertyDescriptor("host", beanClass, "getHost", "setHost");
|
||||||
|
|
||||||
|
PropertyDescriptor _keyboardQueue =
|
||||||
|
new PropertyDescriptor("keyboardQueue", beanClass,
|
||||||
|
"isKeyboardQueue", "setKeyboardQueue");
|
||||||
|
|
||||||
|
PropertyDescriptor _terminalType =
|
||||||
|
new PropertyDescriptor("terminalType", beanClass,
|
||||||
|
"getTerminalType", "setTerminalType");
|
||||||
|
|
||||||
|
PropertyDescriptor _altFKeyRemap =
|
||||||
|
new PropertyDescriptor("altFKeyRemap", beanClass,
|
||||||
|
"getAltFKeyRemap", "setAltFKeyRemap");
|
||||||
|
|
||||||
|
PropertyDescriptor[] pds = new PropertyDescriptor[] {
|
||||||
|
_active,
|
||||||
|
_host,
|
||||||
|
_keyboardQueue,
|
||||||
|
_terminalType,
|
||||||
|
_altFKeyRemap,
|
||||||
|
};
|
||||||
|
return pds;
|
||||||
|
}
|
||||||
|
catch (IntrospectionException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.awt.Image getIcon(int iconKind) {
|
||||||
|
switch (iconKind) {
|
||||||
|
case BeanInfo.ICON_COLOR_16x16:
|
||||||
|
return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null;
|
||||||
|
case BeanInfo.ICON_COLOR_32x32:
|
||||||
|
return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null;
|
||||||
|
case BeanInfo.ICON_MONO_16x16:
|
||||||
|
return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null;
|
||||||
|
case BeanInfo.ICON_MONO_32x32:
|
||||||
|
return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BeanInfo[] getAdditionalBeanInfo() {
|
||||||
|
Class<?> superclass = beanClass.getSuperclass();
|
||||||
|
try {
|
||||||
|
BeanInfo superBeanInfo = Introspector.getBeanInfo(superclass);
|
||||||
|
return new BeanInfo[] { superBeanInfo };
|
||||||
|
}
|
||||||
|
catch (IntrospectionException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
204
net/infordata/em/tn5250/XI5250EmulatorCtrl.java
Normal file
|
|
@ -0,0 +1,204 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
!!V 09/07/98 rel. 1.10 - creation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XI5250Crt;
|
||||||
|
import net.infordata.em.crt5250.XI5250CrtCtrl;
|
||||||
|
import net.infordata.em.crt5250.XI5250CrtFrame;
|
||||||
|
import net.infordata.em.util.XICommand;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles common commands shared by XI5250Frame and XI5250Applet.
|
||||||
|
*/
|
||||||
|
public class XI5250EmulatorCtrl extends XI5250CrtCtrl {
|
||||||
|
|
||||||
|
// images
|
||||||
|
private static XIImagesBdl cvImagesBdl =
|
||||||
|
net.infordata.em.tn5250.XIImagesBdl.getImagesBdl();
|
||||||
|
|
||||||
|
private static ResourceBundle cvRes =
|
||||||
|
ResourceBundle.getBundle("net.infordata.em.tn5250.resources.Res");
|
||||||
|
|
||||||
|
public static final String CONNECT_CMD = "CONNECT_CMD";
|
||||||
|
public static final String DISCONNECT_CMD = "DISCONNECT_CMD";
|
||||||
|
|
||||||
|
public static final String ABOUT_CMD = "ABOUT_CMD";
|
||||||
|
|
||||||
|
public static final String SNAPSHOT_CMD = "SNAPSHOT_CMD";
|
||||||
|
|
||||||
|
private int ivSnapShotCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250EmulatorCtrl(XI5250Emulator aCrt) {
|
||||||
|
super(aCrt);
|
||||||
|
|
||||||
|
getEmulator().addEmulatorListener(new EmulatorListener());
|
||||||
|
|
||||||
|
// Connect command
|
||||||
|
getCommandMgr().enableCommand(
|
||||||
|
CONNECT_CMD, !getEmulator().isActive());
|
||||||
|
getCommandMgr().setCommand(CONNECT_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processConnectCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Disconnect command
|
||||||
|
getCommandMgr().enableCommand(
|
||||||
|
DISCONNECT_CMD, getEmulator().isActive());
|
||||||
|
getCommandMgr().setCommand(DISCONNECT_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processDisconnectCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// About command
|
||||||
|
getCommandMgr().setCommand(ABOUT_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processAboutCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Snapshot command
|
||||||
|
getCommandMgr().setCommand(SNAPSHOT_CMD, new XICommand() {
|
||||||
|
public void execute() {
|
||||||
|
processSnapShotCmd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XI5250Emulator getEmulator() {
|
||||||
|
return (XI5250Emulator)getCrt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processConnectCmd() {
|
||||||
|
if (!getEmulator().isActive()) {
|
||||||
|
Object ret = JOptionPane.showInputDialog(
|
||||||
|
getEmulator(),
|
||||||
|
cvRes.getString("TXT_HostNameInput"),
|
||||||
|
"", JOptionPane.QUESTION_MESSAGE, null,
|
||||||
|
null, getEmulator().getHost());
|
||||||
|
if (ret == null)
|
||||||
|
return;
|
||||||
|
getEmulator().setHost((String)ret);
|
||||||
|
}
|
||||||
|
getEmulator().setActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processDisconnectCmd() {
|
||||||
|
if (getEmulator().isActive()) {
|
||||||
|
int ret = JOptionPane.showConfirmDialog(
|
||||||
|
getEmulator(),
|
||||||
|
cvRes.getString("TXT_ConfirmDisconnect"),
|
||||||
|
"", JOptionPane.YES_NO_OPTION);
|
||||||
|
if (ret == JOptionPane.NO_OPTION)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getEmulator().setActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processAboutCmd() {
|
||||||
|
String forkedFrom = cvRes.getString("TXT_Forked").replaceFirst("%1s", "xtn5250");
|
||||||
|
forkedFrom = forkedFrom.replaceFirst("%2s", "Infordata S.p.A.");
|
||||||
|
JOptionPane.showMessageDialog(getEmulator(),
|
||||||
|
cvRes.getString("TXT_Version").replaceFirst("%1s", XI5250Emulator.VERSION) + "\n" +
|
||||||
|
"\n" +
|
||||||
|
"Mahefa Randimbisoa http://xtn5250mg.sf.net\n" +
|
||||||
|
"\n" +
|
||||||
|
forkedFrom + "\n" +
|
||||||
|
"http://xtn5250.sourceforge.net",
|
||||||
|
cvRes.getString("TXT_About"),
|
||||||
|
JOptionPane.INFORMATION_MESSAGE,
|
||||||
|
cvImagesBdl.getIcon("Logo"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected void processSnapShotCmd() {
|
||||||
|
XI5250Crt clone = getEmulator().getStaticClone();
|
||||||
|
String title = cvRes.getString("TXT_SnapShot") + " " + getEmulator().getHost() + " #" +
|
||||||
|
(++ivSnapShotCount);
|
||||||
|
XI5250CrtFrame frm = new XI5250CrtFrame(title, clone);
|
||||||
|
frm.setBounds(0, 0, 728, 512);
|
||||||
|
frm.centerOnScreen();
|
||||||
|
frm.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Usata per sincronizzare i comandi con lo stato dell' emulator.
|
||||||
|
*/
|
||||||
|
class EmulatorListener extends XI5250EmulatorAdapter {
|
||||||
|
|
||||||
|
protected void enableCmd() {
|
||||||
|
getCommandMgr().enableCommand(
|
||||||
|
CONNECT_CMD, !getEmulator().isActive());
|
||||||
|
getCommandMgr().enableCommand(
|
||||||
|
DISCONNECT_CMD, getEmulator().isActive());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connecting(XI5250EmulatorEvent e) {
|
||||||
|
enableCmd();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connected(XI5250EmulatorEvent e) {
|
||||||
|
enableCmd();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disconnected(XI5250EmulatorEvent e) {
|
||||||
|
enableCmd();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stateChanged(XI5250EmulatorEvent e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
124
net/infordata/em/tn5250/XI5250EmulatorEvent.java
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XI5250Emulator notification event.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250EmulatorEvent extends EventObject {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired just before trying to connect.
|
||||||
|
*/
|
||||||
|
public static final int CONNECTING = 0;
|
||||||
|
/**
|
||||||
|
* Connection established.
|
||||||
|
*/
|
||||||
|
public static final int CONNECTED = 1;
|
||||||
|
/**
|
||||||
|
* Connection closed.
|
||||||
|
*/
|
||||||
|
public static final int DISCONNECTED = 2;
|
||||||
|
/**
|
||||||
|
* Internal state is changed.
|
||||||
|
*/
|
||||||
|
public static final int STATE_CHANGED = 3;
|
||||||
|
/**
|
||||||
|
* A new 5250 panel has been received and it is ready for the user.
|
||||||
|
*/
|
||||||
|
public static final int NEW_PANEL_RECEIVED = 4;
|
||||||
|
/**
|
||||||
|
* Fields removed.
|
||||||
|
*/
|
||||||
|
public static final int FIELDS_REMOVED = 5;
|
||||||
|
/**
|
||||||
|
* Data have been sended (ie. an aid-code was pressed)
|
||||||
|
*/
|
||||||
|
public static final int DATA_SENDED = 6;
|
||||||
|
|
||||||
|
protected static final String[] cvIdDescr = {"CONNECTING",
|
||||||
|
"CONNECTED",
|
||||||
|
"DISCONNECTED",
|
||||||
|
"STATE_CHANGED",
|
||||||
|
"NEW_PANEL_RECEIVED",
|
||||||
|
"FIELDS_REMOVED",
|
||||||
|
"DATA_SENDED"};
|
||||||
|
|
||||||
|
protected int ivId;
|
||||||
|
protected byte ivAidCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250EmulatorEvent(int aId, XI5250Emulator aEm) {
|
||||||
|
super(aEm);
|
||||||
|
ivId = aId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250EmulatorEvent(int aId, XI5250Emulator aEm, byte anAidCode) {
|
||||||
|
this(aId, aEm);
|
||||||
|
ivAidCode = anAidCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public int getID() {
|
||||||
|
return ivId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250Emulator get5250Emulator() {
|
||||||
|
return (XI5250Emulator)getSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The aid code (DATA_SENDED event)
|
||||||
|
*/
|
||||||
|
public byte getAidCode() {
|
||||||
|
return ivAidCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + "[" + cvIdDescr[ivId] + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
77
net/infordata/em/tn5250/XI5250EmulatorListener.java
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.EventListener;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for XI5250EmulatorEvent.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public interface XI5250EmulatorListener extends EventListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250EmulatorEvent#CONNECTING
|
||||||
|
*/
|
||||||
|
public void connecting(XI5250EmulatorEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250EmulatorEvent#CONNECTED
|
||||||
|
*/
|
||||||
|
public void connected(XI5250EmulatorEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250EmulatorEvent#DISCONNECTED
|
||||||
|
*/
|
||||||
|
public void disconnected(XI5250EmulatorEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250EmulatorEvent#STATE_CHANGED
|
||||||
|
*/
|
||||||
|
public void stateChanged(XI5250EmulatorEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250EmulatorEvent#NEW_PANEL_RECEIVED
|
||||||
|
*/
|
||||||
|
public void newPanelReceived(XI5250EmulatorEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250EmulatorEvent#FIELDS_REMOVED
|
||||||
|
*/
|
||||||
|
public void fieldsRemoved(XI5250EmulatorEvent e);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see XI5250EmulatorEvent#DATA_SENDED
|
||||||
|
*/
|
||||||
|
public void dataSended(XI5250EmulatorEvent e);
|
||||||
|
}
|
||||||
83
net/infordata/em/tn5250/XI5250EmulatorMemento.java
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XI5250CrtBuffer;
|
||||||
|
import net.infordata.em.crt5250.XI5250FieldsList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to store, without exposing it, the internal state of XI5250Emulator.
|
||||||
|
*
|
||||||
|
* @see XI5250Emulator#createMemento
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250EmulatorMemento {
|
||||||
|
|
||||||
|
protected XI5250FieldsList ivFields;
|
||||||
|
|
||||||
|
protected int ivFunctionKeysMask;
|
||||||
|
|
||||||
|
protected XI5250Cmd ivPendingCmd;
|
||||||
|
|
||||||
|
protected int ivState;
|
||||||
|
protected int ivPrevState;
|
||||||
|
|
||||||
|
protected int ivCol;
|
||||||
|
protected int ivRow;
|
||||||
|
|
||||||
|
protected int ivErrorRow;
|
||||||
|
|
||||||
|
// from super classes
|
||||||
|
protected XI5250CrtBuffer ivCrtBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
public XI5250EmulatorMemento(XI5250FieldsList aFieldList,
|
||||||
|
int aFunctionKeysMask, XI5250Cmd aPendingCmd,
|
||||||
|
int aState, int aPrevState,
|
||||||
|
int aCol, int aRow,
|
||||||
|
int aErrorRow,
|
||||||
|
XI5250CrtBuffer aCrtBuffer) {
|
||||||
|
ivFields = aFieldList;
|
||||||
|
|
||||||
|
ivFunctionKeysMask = aFunctionKeysMask;
|
||||||
|
|
||||||
|
ivPendingCmd = aPendingCmd;
|
||||||
|
|
||||||
|
ivState = aState;
|
||||||
|
ivPrevState = aPrevState;
|
||||||
|
|
||||||
|
ivCol = aCol;
|
||||||
|
ivRow = aRow;
|
||||||
|
|
||||||
|
ivErrorRow = aErrorRow;
|
||||||
|
|
||||||
|
ivCrtBuffer = aCrtBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
47
net/infordata/em/tn5250/XI5250Exception.java
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used internally.<br>
|
||||||
|
* It is raised if an error is detected while reading and parsing the 5250 stream.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250Exception extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final int ivErrorCode;
|
||||||
|
|
||||||
|
public XI5250Exception(String s, int errorCode) {
|
||||||
|
super(s);
|
||||||
|
ivErrorCode = errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getErrorCode() {
|
||||||
|
return ivErrorCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
331
net/infordata/em/tn5250/XI5250Frame.java
Normal file
|
|
@ -0,0 +1,331 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
!!V 07/07/98 rel. 1.07 - creation.
|
||||||
|
04/02/99 rel. 1.11 - Swing 1.1 + ivSizeControlledFrame.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import javax.swing.AbstractButton;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.JToolBar;
|
||||||
|
import javax.swing.KeyStroke;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XI5250Crt;
|
||||||
|
import net.infordata.em.crt5250.XI5250CrtCtrl;
|
||||||
|
import net.infordata.em.crt5250.XI5250CrtFrame;
|
||||||
|
import net.infordata.em.util.XIUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class XI5250Frame extends XI5250CrtFrame {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// images
|
||||||
|
private static XIImagesBdl cvImagesBdl =
|
||||||
|
net.infordata.em.tn5250.XIImagesBdl.getImagesBdl();
|
||||||
|
|
||||||
|
private static ResourceBundle cvRes =
|
||||||
|
ResourceBundle.getBundle("net.infordata.em.tn5250.resources.Res");
|
||||||
|
|
||||||
|
private final String ivTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250Frame(String aTitle, XI5250Emulator aCrt) {
|
||||||
|
super(aTitle, aCrt);
|
||||||
|
ivTitle = aTitle;
|
||||||
|
init(aCrt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250Frame(String aTitle, XI5250Emulator aCrt,
|
||||||
|
boolean sizeControlledFrame) {
|
||||||
|
super(aTitle, aCrt, sizeControlledFrame);
|
||||||
|
ivTitle = aTitle;
|
||||||
|
init(aCrt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void init(XI5250Emulator aCrt) {
|
||||||
|
if (aCrt.isActive())
|
||||||
|
setTitle("*" + aCrt.getHost() + " - " + ivTitle);
|
||||||
|
aCrt.addEmulatorListener(new XI5250EmulatorAdapter() {
|
||||||
|
@Override
|
||||||
|
public void connected(XI5250EmulatorEvent e) {
|
||||||
|
setTitle("~" + e.get5250Emulator().getHost() + " - " + ivTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disconnected(XI5250EmulatorEvent e) {
|
||||||
|
setTitle("! " + ivTitle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected XI5250CrtCtrl createController(XI5250Crt crt) {
|
||||||
|
return new XI5250EmulatorCtrl((XI5250Emulator)crt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected final XI5250EmulatorCtrl getEmulatorCtrl() {
|
||||||
|
return (XI5250EmulatorCtrl)getCrtCtrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XI5250Emulator getEmulator() {
|
||||||
|
return getEmulatorCtrl().getEmulator();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void processExitCmd() {
|
||||||
|
if (getEmulator().isActive()) {
|
||||||
|
//!!1.13a otherwise a dead-lock may occur !!
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
int ret = JOptionPane.showConfirmDialog(
|
||||||
|
XI5250Frame.this,
|
||||||
|
cvRes.getString("TXT_ConfirmExit"),
|
||||||
|
"", JOptionPane.YES_NO_OPTION);
|
||||||
|
if (ret != JOptionPane.NO_OPTION) {
|
||||||
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void processWindowEvent(WindowEvent e) {
|
||||||
|
super.processWindowEvent(e);
|
||||||
|
switch(e.getID()) {
|
||||||
|
case WindowEvent.WINDOW_OPENED:
|
||||||
|
if (getEmulator().getHost() == null)
|
||||||
|
getCommandMgr().dispatchCommand(XI5250EmulatorCtrl.CONNECT_CMD);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected JMenuBar createMenuBar() {
|
||||||
|
String str;
|
||||||
|
|
||||||
|
str = cvRes.getString("TXT_Communications");
|
||||||
|
JMenu commMenu = new JMenu(XIUtil.removeMnemonics(str));
|
||||||
|
commMenu.setMnemonic(XIUtil.getMnemonic(str));
|
||||||
|
{
|
||||||
|
JMenuItem connItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Connect"));
|
||||||
|
JMenuItem disconnItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Disconnect"));
|
||||||
|
JMenuItem aboutItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_About"));
|
||||||
|
JMenuItem exitItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Exit"));
|
||||||
|
exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4,
|
||||||
|
ActionEvent.ALT_MASK));
|
||||||
|
|
||||||
|
commMenu.add(connItem);
|
||||||
|
commMenu.add(disconnItem);
|
||||||
|
commMenu.addSeparator();
|
||||||
|
commMenu.add(aboutItem);
|
||||||
|
commMenu.addSeparator();
|
||||||
|
commMenu.add(exitItem);
|
||||||
|
|
||||||
|
getCommandMgr().handleCommand(connItem,
|
||||||
|
XI5250EmulatorCtrl.CONNECT_CMD);
|
||||||
|
getCommandMgr().handleCommand(disconnItem,
|
||||||
|
XI5250EmulatorCtrl.DISCONNECT_CMD);
|
||||||
|
getCommandMgr().handleCommand(aboutItem,
|
||||||
|
XI5250EmulatorCtrl.ABOUT_CMD);
|
||||||
|
getCommandMgr().handleCommand(exitItem,
|
||||||
|
EXIT_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
str = cvRes.getString("TXT_Edit");
|
||||||
|
JMenu editMenu = new JMenu(XIUtil.removeMnemonics(str));
|
||||||
|
editMenu.setMnemonic(XIUtil.getMnemonic(str));
|
||||||
|
{
|
||||||
|
JMenuItem copyItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Copy"));
|
||||||
|
JMenuItem pasteItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Paste"));
|
||||||
|
JMenuItem snapShotItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_SnapShot"));
|
||||||
|
JMenuItem printItem =
|
||||||
|
new JMenuItem(cvRes.getString("TXT_Print"));
|
||||||
|
|
||||||
|
editMenu.add(copyItem);
|
||||||
|
editMenu.add(pasteItem);
|
||||||
|
editMenu.addSeparator();
|
||||||
|
editMenu.add(snapShotItem);
|
||||||
|
editMenu.addSeparator();
|
||||||
|
editMenu.add(printItem);
|
||||||
|
|
||||||
|
getCommandMgr().handleCommand(copyItem,
|
||||||
|
XI5250EmulatorCtrl.COPY_CMD);
|
||||||
|
getCommandMgr().handleCommand(pasteItem,
|
||||||
|
XI5250EmulatorCtrl.PASTE_CMD);
|
||||||
|
getCommandMgr().handleCommand(snapShotItem,
|
||||||
|
XI5250EmulatorCtrl.SNAPSHOT_CMD);
|
||||||
|
getCommandMgr().handleCommand(printItem,
|
||||||
|
XI5250EmulatorCtrl.PRINT_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
str = cvRes.getString("TXT_Options");
|
||||||
|
JMenu optionsMenu = new JMenu(XIUtil.removeMnemonics(str));
|
||||||
|
optionsMenu.setMnemonic(XIUtil.getMnemonic(str));
|
||||||
|
{
|
||||||
|
JCheckBoxMenuItem switch3DfxItem =
|
||||||
|
new JCheckBoxMenuItem(cvRes.getString("TXT_3dFx"));
|
||||||
|
JCheckBoxMenuItem referenceCursorItem =
|
||||||
|
new JCheckBoxMenuItem(cvRes.getString("TXT_RefCursor"));
|
||||||
|
|
||||||
|
optionsMenu.add(switch3DfxItem);
|
||||||
|
optionsMenu.add(referenceCursorItem);
|
||||||
|
|
||||||
|
getCommandMgr().handleCommand(switch3DfxItem,
|
||||||
|
XI5250EmulatorCtrl.SWITCH_3DFX_CMD);
|
||||||
|
getCommandMgr().handleCommand(referenceCursorItem,
|
||||||
|
XI5250EmulatorCtrl.REFERENCE_CURSOR_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
JMenuBar menuBar = new JMenuBar();
|
||||||
|
menuBar.add(commMenu);
|
||||||
|
menuBar.add(editMenu);
|
||||||
|
menuBar.add(optionsMenu);
|
||||||
|
return menuBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserisce nella tool-bar i bottoni di default.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected JToolBar createToolBar() {
|
||||||
|
// bottoni della tool-bar
|
||||||
|
AbstractButton[] buttons = new AbstractButton[] {
|
||||||
|
new JButton(cvImagesBdl.getIcon("Connect")),
|
||||||
|
new JButton(cvImagesBdl.getIcon("Disconnect")),
|
||||||
|
null,
|
||||||
|
new JButton(cvImagesBdl.getIcon("Copy")),
|
||||||
|
new JButton(cvImagesBdl.getIcon("Paste")),
|
||||||
|
null,
|
||||||
|
new JButton(cvImagesBdl.getIcon("SnapShot")),
|
||||||
|
new JButton(cvImagesBdl.getIcon("Print")),
|
||||||
|
null,
|
||||||
|
new JToggleButton(cvImagesBdl.getIcon("3dFx")),
|
||||||
|
new JToggleButton(cvImagesBdl.getIcon("RefCursor")),
|
||||||
|
};
|
||||||
|
// action commands associati con i bottoni della tool-bar.
|
||||||
|
String[] buttonsActCmd = new String[] {
|
||||||
|
XI5250EmulatorCtrl.CONNECT_CMD,
|
||||||
|
XI5250EmulatorCtrl.DISCONNECT_CMD,
|
||||||
|
null,
|
||||||
|
XI5250EmulatorCtrl.COPY_CMD,
|
||||||
|
XI5250EmulatorCtrl.PASTE_CMD,
|
||||||
|
null,
|
||||||
|
XI5250EmulatorCtrl.SNAPSHOT_CMD,
|
||||||
|
XI5250EmulatorCtrl.PRINT_CMD,
|
||||||
|
null,
|
||||||
|
XI5250EmulatorCtrl.SWITCH_3DFX_CMD,
|
||||||
|
XI5250EmulatorCtrl.REFERENCE_CURSOR_CMD,
|
||||||
|
};
|
||||||
|
// Hint associati ad i vari bottoni.
|
||||||
|
String[] buttonHints = new String[] {
|
||||||
|
cvRes.getString("TXT_Connect"),
|
||||||
|
cvRes.getString("TXT_Disconnect"),
|
||||||
|
null,
|
||||||
|
cvRes.getString("TXT_Copy"),
|
||||||
|
cvRes.getString("TXT_Paste"),
|
||||||
|
null,
|
||||||
|
cvRes.getString("TXT_SnapShot"),
|
||||||
|
cvRes.getString("TXT_Print"),
|
||||||
|
null,
|
||||||
|
cvRes.getString("TXT_3dFx"),
|
||||||
|
cvRes.getString("TXT_RefCursor"),
|
||||||
|
};
|
||||||
|
|
||||||
|
JToolBar toolBar = new JToolBar();
|
||||||
|
toolBar.setFloatable(false);
|
||||||
|
|
||||||
|
Dimension size = new Dimension(26, 26);
|
||||||
|
|
||||||
|
for (int i = 0; i < buttons.length; i++) {
|
||||||
|
if (buttons[i] != null) {
|
||||||
|
AbstractButton button = (AbstractButton)buttons[i];
|
||||||
|
toolBar.add(button);
|
||||||
|
button.setToolTipText(buttonHints[i]);
|
||||||
|
button.setMinimumSize(size);
|
||||||
|
button.setPreferredSize(size);
|
||||||
|
button.setMaximumSize(size);
|
||||||
|
button.setRequestFocusEnabled(false);
|
||||||
|
getCommandMgr().handleCommand(button, buttonsActCmd[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
toolBar.addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
return toolBar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
55
net/infordata/em/tn5250/XI5250Ord.java
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract base class for all 5250 Orders
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public abstract class XI5250Ord {
|
||||||
|
protected XI5250Emulator ivEmulator;
|
||||||
|
|
||||||
|
|
||||||
|
protected void init(XI5250Emulator aEmulator) {
|
||||||
|
ivEmulator = aEmulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if order parameters are wrong.
|
||||||
|
*/
|
||||||
|
protected abstract void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception;
|
||||||
|
|
||||||
|
|
||||||
|
protected abstract void execute();
|
||||||
|
}
|
||||||
206
net/infordata/em/tn5250/XI5250OrdList.java
Normal file
|
|
@ -0,0 +1,206 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 15/07/97 rel. 1.02c- XIDataOrd includes 0x1F char.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.infordata.em.tnprot.XITelnet;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Orders list.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250OrdList extends XI5250Ord {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(XI5250OrdList.class.getName());
|
||||||
|
|
||||||
|
private static Class<?>[] cv5250OrdClasses = new Class<?>[256];
|
||||||
|
|
||||||
|
protected List<XI5250Ord> ivOrdVect;
|
||||||
|
|
||||||
|
protected boolean[] ivOrdPresent = new boolean[256];
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_IC] = XIICOrd.class;
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_RA] = XIRAOrd.class;
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_SBA] = XISBAOrd.class;
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_SF] = XISFOrd.class;
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_SOH] = XISOHOrd.class;
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_MC] = XIMCOrd.class;
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_EA] = XIEAOrd.class;
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_TD] = XITDOrd.class;
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_WEA] = XIWEAOrd.class;
|
||||||
|
cv5250OrdClasses[XI5250Emulator.ORD_WDSF] = XIWdsfOrd.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected XI5250OrdList(XI5250Emulator aEmulator) {
|
||||||
|
init(aEmulator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public boolean isOrderPresent(byte aOrder) {
|
||||||
|
return ivOrdPresent[aOrder];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if order parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
|
||||||
|
int bb;
|
||||||
|
XI5250Ord ord;
|
||||||
|
ivOrdVect = new ArrayList<XI5250Ord>(100);
|
||||||
|
|
||||||
|
if (LOGGER.isLoggable(Level.FINER))
|
||||||
|
LOGGER.finer(" START OF ORDERS LIST");
|
||||||
|
|
||||||
|
for (int i = 0; ; i++) {
|
||||||
|
inStream.mark(1);
|
||||||
|
if ((bb = inStream.read()) == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if ((byte)bb == XI5250Emulator.ESC) {
|
||||||
|
inStream.reset();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (XIDataOrd.isDataCharacter(bb)) {
|
||||||
|
inStream.reset(); // need it (it is also the color attribute)
|
||||||
|
if (ivEmulator.isStrPcCmdEnabled()) {
|
||||||
|
inStream.mark(XI5250Emulator.STRPCCMD.length);
|
||||||
|
byte[] lhbb = new byte[XI5250Emulator.STRPCCMD.length];
|
||||||
|
int sz = inStream.read(lhbb);
|
||||||
|
if (sz == XI5250Emulator.STRPCCMD.length) {
|
||||||
|
if (Arrays.equals(lhbb, XI5250Emulator.STRPCCMD)) {
|
||||||
|
ivEmulator.receivedStrPcCmd();
|
||||||
|
}
|
||||||
|
else if (Arrays.equals(lhbb, XI5250Emulator.ENDSTRPCCMD)) {
|
||||||
|
ivEmulator.receivedEndStrPcCmd();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inStream.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inStream.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ivOrdPresent[bb] = true; // remember orders present
|
||||||
|
|
||||||
|
try {
|
||||||
|
ord = createOrdInstance(bb);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ord != null) {
|
||||||
|
ord.init(ivEmulator);
|
||||||
|
ord.readFrom5250Stream(inStream);
|
||||||
|
|
||||||
|
if (LOGGER.isLoggable(Level.FINER))
|
||||||
|
LOGGER.finer(" " + ord);
|
||||||
|
|
||||||
|
ivOrdVect.add(ord);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (LOGGER.isLoggable(Level.FINE)) {
|
||||||
|
LOGGER.fine("Order not supported : 0x" + XITelnet.toHex((byte)bb));
|
||||||
|
for (int ii = 0; ii < ivOrdVect.size(); ii++) {
|
||||||
|
LOGGER.fine("Prev. order[" + ii + "]: " + ivOrdVect.get(ii));
|
||||||
|
}
|
||||||
|
byte[] buf = new byte[10];
|
||||||
|
int count = inStream.read(buf);
|
||||||
|
LOGGER.fine("Next " + count + " bytes: " + XITelnet.toHex(buf, count));
|
||||||
|
}
|
||||||
|
throw new XI5250Exception("Order not supported : 0x" + XITelnet.toHex((byte)bb),
|
||||||
|
XI5250Emulator.ERR_INVALID_COMMAND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
for (int i = 0; i < ivOrdVect.size(); i++)
|
||||||
|
ivOrdVect.get(i).execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the 5250 order instance related to the given 5250 order id.
|
||||||
|
* @exception IllegalAccessException .
|
||||||
|
* @exception InstantiationException .
|
||||||
|
*/
|
||||||
|
public XI5250Ord createOrdInstance(int aOrd)
|
||||||
|
throws IllegalAccessException, InstantiationException {
|
||||||
|
|
||||||
|
Class<?> cls;
|
||||||
|
|
||||||
|
if (XIDataOrd.isDataCharacter(aOrd))
|
||||||
|
cls = XIDataOrd.class;
|
||||||
|
else
|
||||||
|
cls = cv5250OrdClasses[aOrd];
|
||||||
|
|
||||||
|
if (cls != null)
|
||||||
|
return (XI5250Ord)cls.newInstance();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String ss = super.toString() + ivOrdVect.toString();
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
}
|
||||||
358
net/infordata/em/tn5250/XI5250StatusBar.java
Normal file
|
|
@ -0,0 +1,358 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
30/07/99 rel. 1.14b- removed statusbar.* sub package.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Insets;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
|
||||||
|
import net.infordata.em.util.XIRatioLayout;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 5250 status bar.
|
||||||
|
*/
|
||||||
|
public class XI5250StatusBar extends JPanel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//
|
||||||
|
public final static int SHIFT_UP = 0;
|
||||||
|
public final static int SHIFT_DOWN = 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
public final static int CAPS_LOCK_UP = 0;
|
||||||
|
public final static int CAPS_LOCK_DOWN = 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
public final static int MESSAGE_OFF = 0;
|
||||||
|
public final static int MESSAGE_ON = 1;
|
||||||
|
|
||||||
|
// images
|
||||||
|
static XIImagesBdl cvImagesBdl = XIImagesBdl.getImagesBdl();
|
||||||
|
|
||||||
|
private static Image
|
||||||
|
cvTemporaryLockImage = cvImagesBdl.getImage("TemporaryLock");
|
||||||
|
private static Image
|
||||||
|
cvNormalLockImage = cvImagesBdl.getImage("NormalLock");
|
||||||
|
private static Image
|
||||||
|
cvHelpImage = cvImagesBdl.getImage("Help");
|
||||||
|
private static Image
|
||||||
|
cvShiftDownImage = cvImagesBdl.getImage("ShiftDown");
|
||||||
|
private static Image
|
||||||
|
cvCapsLockImage = cvImagesBdl.getImage("CapsLock");
|
||||||
|
private static Image
|
||||||
|
cvMessageImage = cvImagesBdl.getImage("Message");
|
||||||
|
private static Image
|
||||||
|
cvFlashImage = cvImagesBdl.getImage("Flash");
|
||||||
|
|
||||||
|
// status bar components
|
||||||
|
private TextAndImage ivFlashArea;
|
||||||
|
private TextAndImage ivStateArea;
|
||||||
|
private TextAndImage ivMessageArea;
|
||||||
|
private TextAndImage ivShiftArea;
|
||||||
|
private TextAndImage ivCapsLockArea;
|
||||||
|
private JLabel ivCoordArea;
|
||||||
|
|
||||||
|
private boolean ivFlashOn;
|
||||||
|
private int ivShiftAreaState = -1;
|
||||||
|
private int ivState = XI5250Emulator.ST_NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XI5250StatusBar() {
|
||||||
|
super(new XIRatioLayout(4));
|
||||||
|
setBorder(BorderFactory.createRaisedBevelBorder());
|
||||||
|
|
||||||
|
// add components
|
||||||
|
addComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isValidateRoot() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void addComponents() {
|
||||||
|
Border border = BorderFactory.createEtchedBorder();
|
||||||
|
|
||||||
|
ivFlashArea = new TextAndImage(TextAndImage.CENTER);
|
||||||
|
ivFlashArea.setBorder(border);
|
||||||
|
add(ivFlashArea, new XIRatioLayout.Constraints(0.03f));
|
||||||
|
|
||||||
|
JComponent dummyArea = new TextAndImage(TextAndImage.CENTER);
|
||||||
|
dummyArea.setBorder(border);
|
||||||
|
add(dummyArea, new XIRatioLayout.Constraints(0.03f));
|
||||||
|
|
||||||
|
// STATE AREA
|
||||||
|
ivStateArea = new TextAndImage();
|
||||||
|
ivStateArea.setBorder(border);
|
||||||
|
add(ivStateArea, new XIRatioLayout.Constraints(0.3f));
|
||||||
|
|
||||||
|
// MESSAGE AREA
|
||||||
|
ivMessageArea = new TextAndImage(TextAndImage.CENTER);
|
||||||
|
ivMessageArea.setBorder(border);
|
||||||
|
add(ivMessageArea, new XIRatioLayout.Constraints(0.03f));
|
||||||
|
|
||||||
|
// SHIFT AREA
|
||||||
|
ivShiftArea = new TextAndImage(TextAndImage.CENTER);
|
||||||
|
ivShiftArea.setBorder(border);
|
||||||
|
add(ivShiftArea, new XIRatioLayout.Constraints(0.03f));
|
||||||
|
|
||||||
|
// CAPS LOCK AREA
|
||||||
|
ivCapsLockArea = new TextAndImage(TextAndImage.CENTER);
|
||||||
|
ivCapsLockArea.setBorder(border);
|
||||||
|
add(ivCapsLockArea, new XIRatioLayout.Constraints(0.03f));
|
||||||
|
|
||||||
|
// COORD AREA
|
||||||
|
ivCoordArea = new JLabel(null, null, JLabel.RIGHT);
|
||||||
|
ivCoordArea.setFont(null);
|
||||||
|
ivCoordArea.setBorder(border);
|
||||||
|
add(ivCoordArea, new XIRatioLayout.Constraints(0.15f, XIRatioLayout.RIGHT));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setCoordArea(int aCol, int aRow) {
|
||||||
|
ivCoordArea.setText(aRow + " / " + aCol + " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setFlashArea(boolean flag) {
|
||||||
|
if (flag == ivFlashOn)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ivFlashOn = flag;
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
ivFlashArea.setImage(cvFlashImage);
|
||||||
|
else
|
||||||
|
ivFlashArea.setImage(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setShiftArea(int aState) {
|
||||||
|
if (aState == ivShiftAreaState)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ivShiftAreaState = aState;
|
||||||
|
|
||||||
|
if (aState == SHIFT_DOWN)
|
||||||
|
ivShiftArea.setImage(cvShiftDownImage);
|
||||||
|
else
|
||||||
|
ivShiftArea.setImage(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setCapsLockArea(int aState) {
|
||||||
|
if (aState == CAPS_LOCK_DOWN) {
|
||||||
|
ivCapsLockArea.setImage(cvCapsLockImage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ivCapsLockArea.setImage(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setMessageArea(int aState) {
|
||||||
|
if (aState == MESSAGE_ON) {
|
||||||
|
ivMessageArea.setImage(cvMessageImage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ivMessageArea.setImage(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setStateArea(int aState) {
|
||||||
|
if (aState == ivState)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (aState) {
|
||||||
|
|
||||||
|
case XI5250Emulator.ST_HARDWARE_ERROR:
|
||||||
|
ivStateArea.setImage(null);
|
||||||
|
ivStateArea.setText("HARDWARE_ERROR");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XI5250Emulator.ST_NORMAL_LOCKED:
|
||||||
|
ivStateArea.setImage(cvNormalLockImage);
|
||||||
|
ivStateArea.setText("SYSTEM");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XI5250Emulator.ST_NORMAL_UNLOCKED:
|
||||||
|
ivStateArea.setImage(null);
|
||||||
|
ivStateArea.setText("");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XI5250Emulator.ST_POST_HELP:
|
||||||
|
ivStateArea.setImage(null);
|
||||||
|
ivStateArea.setText("POST_HELP");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XI5250Emulator.ST_POWER_ON:
|
||||||
|
ivStateArea.setImage(null);
|
||||||
|
ivStateArea.setText("");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XI5250Emulator.ST_PRE_HELP:
|
||||||
|
ivStateArea.setImage(cvHelpImage);
|
||||||
|
ivStateArea.setText("");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XI5250Emulator.ST_SS_MESSAGE:
|
||||||
|
ivStateArea.setImage(null);
|
||||||
|
ivStateArea.setText("SS_MESSAGE");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XI5250Emulator.ST_SYSTEM_REQUEST:
|
||||||
|
ivStateArea.setImage(null);
|
||||||
|
ivStateArea.setText("SYSTEM_REQUEST");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XI5250Emulator.ST_TEMPORARY_LOCK:
|
||||||
|
ivStateArea.setImage(cvTemporaryLockImage);
|
||||||
|
ivStateArea.setText("");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
public void revalidate() {
|
||||||
|
// otherwise causes interferences with the emulator when it tries to
|
||||||
|
// force the position and the size of the status bar
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected static class TextAndImage extends JComponent {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static final int LEFT = 0;
|
||||||
|
public static final int CENTER = 1;
|
||||||
|
|
||||||
|
private Image ivImage = null;
|
||||||
|
private String ivText = null;
|
||||||
|
|
||||||
|
private int ivAlignment;
|
||||||
|
|
||||||
|
private final int ivHGap = 2;
|
||||||
|
|
||||||
|
|
||||||
|
public TextAndImage(int alignment) {
|
||||||
|
ivAlignment = alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public TextAndImage() {
|
||||||
|
this(LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setText(String aText) {
|
||||||
|
ivText = aText;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setImage(Image aImage) {
|
||||||
|
ivImage = aImage;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintComponent(Graphics gr) {
|
||||||
|
|
||||||
|
Insets insets = getInsets();
|
||||||
|
int imageWidth = 0;
|
||||||
|
int imageHeight = 0;
|
||||||
|
int textWidth = 0;
|
||||||
|
Dimension dim = getSize();
|
||||||
|
FontMetrics fm = null;
|
||||||
|
|
||||||
|
if ((ivImage != null)) {
|
||||||
|
int w = ivImage.getWidth(this);
|
||||||
|
int h = ivImage.getHeight(this);
|
||||||
|
imageHeight = dim.height - insets.top - insets.bottom;
|
||||||
|
imageWidth = w * imageHeight / h;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ivText != null && ivText.length() != 0) {
|
||||||
|
fm = gr.getFontMetrics();
|
||||||
|
textWidth = fm.stringWidth(ivText);
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = imageWidth + textWidth +
|
||||||
|
((ivImage != null && fm != null) ? ivHGap : 0);
|
||||||
|
int x = insets.left;
|
||||||
|
if (ivAlignment == CENTER)
|
||||||
|
x = (dim.width - width) / 2;
|
||||||
|
|
||||||
|
if ((ivImage != null)) {
|
||||||
|
gr.drawImage(ivImage, x, insets.top,
|
||||||
|
imageWidth, imageHeight, this);
|
||||||
|
x += imageWidth + ivHGap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm != null) {
|
||||||
|
gr.setColor(getForeground());
|
||||||
|
int y = (dim.height + fm.getHeight()) / 2;
|
||||||
|
gr.drawString(ivText, x, y - fm.getDescent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
152
net/infordata/em/tn5250/XICCCmd.java
Normal file
|
|
@ -0,0 +1,152 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
01/09/97 rel. 1.04a- executeCC1() implemented.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XI5250Field;
|
||||||
|
import net.infordata.em.tnprot.XITelnet;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract base class for all 5250 commands with CC parameter.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public abstract class XICCCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
protected byte[] ivCC;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected abstract void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected abstract void execute();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
protected void readCC(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
|
||||||
|
int bb;
|
||||||
|
int i;
|
||||||
|
ivCC = new byte[2];
|
||||||
|
|
||||||
|
for (i = 0; (i < 2) && ((bb = inStream.read()) != -1); i++)
|
||||||
|
ivCC[i] = (byte)bb;
|
||||||
|
|
||||||
|
if (i < 2)
|
||||||
|
throw new XI5250Exception("CC required", XI5250Emulator.ERR_INVALID_COMMAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void executeCC1() {
|
||||||
|
//!!1.04a
|
||||||
|
int cc1 = ivCC[0] & 0xE0;
|
||||||
|
|
||||||
|
// reset pending aid; lock keyboard
|
||||||
|
if (cc1 != 0) {
|
||||||
|
ivEmulator.ivPendingCmd = null;
|
||||||
|
ivEmulator.setState(XI5250Emulator.ST_NORMAL_LOCKED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear master mdt; reset mdt in nonbypass-fields
|
||||||
|
if (cc1 == 0x40 || cc1 == 0xA0 || cc1 == 0xC0) {
|
||||||
|
//!!V gestire master mdt
|
||||||
|
XI5250Field field;
|
||||||
|
for (Iterator<XI5250Field> e = ivEmulator.getFields().iterator(); e.hasNext(); ) {
|
||||||
|
field = e.next();
|
||||||
|
if (!field.isOrgBypassField())
|
||||||
|
field.resetMDT();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear master mdt; reset mdt in all fields
|
||||||
|
if (cc1 == 0x60 || cc1 == 0xE0) {
|
||||||
|
//!!V gestire master mdt
|
||||||
|
XI5250Field field;
|
||||||
|
for (Iterator<XI5250Field> e = ivEmulator.getFields().iterator(); e.hasNext(); ) {
|
||||||
|
field = e.next();
|
||||||
|
field.resetMDT();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// null nonbypass-fields with mdt on
|
||||||
|
if (cc1 == 0x80 || cc1 == 0xC0) {
|
||||||
|
XI5250Field field;
|
||||||
|
for (Iterator<XI5250Field> e = ivEmulator.getFields().iterator(); e.hasNext(); ) {
|
||||||
|
field = e.next();
|
||||||
|
if (!field.isOrgBypassField() && field.isMDTOn())
|
||||||
|
field.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// null all nonbypass-fields
|
||||||
|
if (cc1 == 0xA0 || cc1 == 0xE0) {
|
||||||
|
XI5250Field field;
|
||||||
|
for (Iterator<XI5250Field> e = ivEmulator.getFields().iterator(); e.hasNext(); ) {
|
||||||
|
field = e.next();
|
||||||
|
if (!field.isBypassField())
|
||||||
|
field.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void executeCC2() {
|
||||||
|
if ((ivCC[1] & 0x10) != 0)
|
||||||
|
ivEmulator.setBlinkingCursor(true);
|
||||||
|
else if ((ivCC[1] & 0x20) != 0)
|
||||||
|
ivEmulator.setBlinkingCursor(false);
|
||||||
|
|
||||||
|
// unlock the keyboard
|
||||||
|
if ((ivCC[1] & 0x08) != 0)
|
||||||
|
ivEmulator.setState(XI5250Emulator.ST_NORMAL_UNLOCKED);
|
||||||
|
|
||||||
|
if ((ivCC[1] & 0x04) != 0)
|
||||||
|
Toolkit.getDefaultToolkit().beep();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " [CC=[" + XITelnet.toHex(ivCC[0]) + "," + XITelnet.toHex(ivCC[1]) + "]]";
|
||||||
|
}
|
||||||
|
}
|
||||||
53
net/infordata/em/tn5250/XIClearFmtTableCmd.java
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear Format Table
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIClearFmtTableCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.setState(XI5250Emulator.ST_NORMAL_LOCKED);
|
||||||
|
ivEmulator.ivPendingCmd = null;
|
||||||
|
|
||||||
|
ivEmulator.setDefAttr(0x20);
|
||||||
|
ivEmulator.removeFields();
|
||||||
|
ivEmulator.setErrorRow(ivEmulator.getCrtSize().height - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
70
net/infordata/em/tn5250/XIClearUnitAltCmd.java
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 14/07/97 rel. 1.02 - added support for 27x132 terminal type (IBM-3477-FC).
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear Unit Alternative
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIClearUnitAltCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
protected int ivPar;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException, XI5250Exception {
|
||||||
|
ivPar = Math.max(0, inStream.read()); //!!1.02
|
||||||
|
if (ivPar != 0x00 && ivPar != 0x80)
|
||||||
|
throw new XI5250Exception("Invalid clear unit param: " + ivPar,
|
||||||
|
XI5250Emulator.ERR_INVALID_CLEAR_UNIT_ALT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.setState(XI5250Emulator.ST_NORMAL_LOCKED);
|
||||||
|
ivEmulator.ivPendingCmd = null;
|
||||||
|
|
||||||
|
if (ivEmulator.ivPrevFont == null) { //!!1.04a
|
||||||
|
Font ft = ivEmulator.getFont();
|
||||||
|
ivEmulator.ivPrevFont = new Font(ft.getName(), ft.getStyle(), ft.getSize()); //!!1.03a
|
||||||
|
}
|
||||||
|
|
||||||
|
ivEmulator.setCrtSize(132, 27); //!!1.02
|
||||||
|
|
||||||
|
ivEmulator.setDefAttr(0x20);
|
||||||
|
ivEmulator.clear();
|
||||||
|
ivEmulator.removeFields();
|
||||||
|
ivEmulator.setErrorRow(ivEmulator.getCrtSize().height - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
63
net/infordata/em/tn5250/XIClearUnitCmd.java
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 14/07/97 rel. 1.02 - added support for 27x132 terminal type (IBM-3477-FC).
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Clear unit command
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIClearUnitCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.setState(XI5250Emulator.ST_NORMAL_LOCKED);
|
||||||
|
ivEmulator.ivPendingCmd = null;
|
||||||
|
|
||||||
|
ivEmulator.setCrtSize(80, 24); //!!1.02
|
||||||
|
|
||||||
|
ivEmulator.setDefAttr(0x20);
|
||||||
|
ivEmulator.clear();
|
||||||
|
ivEmulator.removeFields();
|
||||||
|
ivEmulator.setErrorRow(ivEmulator.getCrtSize().height - 1);
|
||||||
|
|
||||||
|
// switch back to the previous used font
|
||||||
|
if (ivEmulator.ivPrevFont != null) { //!!1.03a
|
||||||
|
ivEmulator.setFont(ivEmulator.ivPrevFont);
|
||||||
|
ivEmulator.ivPrevFont = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
130
net/infordata/em/tn5250/XIDataOrd.java
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 15/07/97 rel. 1.02c- XIDataOrd includes 0x1F char.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XIEbcdicTranslator;
|
||||||
|
import net.infordata.em.tnprot.XITelnet;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Data Order
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIDataOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected String ivData;
|
||||||
|
protected byte ivColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* see http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/co2e2001/15.6.2?SHELF=&DT=19950629163252&CASE=
|
||||||
|
* and IBM SA21-9247-6 pg. 2.13
|
||||||
|
*/
|
||||||
|
public static final boolean isDataCharacter(int bb) {
|
||||||
|
// 0x1F instead of 0x20 and keep 0xFF chars
|
||||||
|
// return (bb == 0x00 || bb == 0x1C || bb == 0x1E || bb == 0x0E || bb == 0x0F ||
|
||||||
|
// (bb >= 0x1F && bb <= 0xFF));
|
||||||
|
switch (bb) {
|
||||||
|
case XI5250Emulator.ORD_IC:
|
||||||
|
case XI5250Emulator.ORD_RA:
|
||||||
|
case XI5250Emulator.ORD_SBA:
|
||||||
|
case XI5250Emulator.ORD_SF:
|
||||||
|
case XI5250Emulator.ORD_SOH:
|
||||||
|
case XI5250Emulator.ORD_MC:
|
||||||
|
case XI5250Emulator.ORD_EA:
|
||||||
|
case XI5250Emulator.ORD_TD:
|
||||||
|
case XI5250Emulator.ORD_WEA:
|
||||||
|
case XI5250Emulator.ORD_WDSF:
|
||||||
|
case XI5250Emulator.ESC:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException {
|
||||||
|
XIEbcdicTranslator translator = ivEmulator.getTranslator();
|
||||||
|
int bb;
|
||||||
|
|
||||||
|
ivColor = 0;
|
||||||
|
StringBuilder sb = new StringBuilder(128);
|
||||||
|
|
||||||
|
for (int i = 0; ; i++) {
|
||||||
|
inStream.mark(1);
|
||||||
|
bb = inStream.read();
|
||||||
|
|
||||||
|
if (bb == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// see IBM SA21-9247-6 pg. 2.13
|
||||||
|
if (isDataCharacter(bb)) {
|
||||||
|
// is it a color ?
|
||||||
|
if (bb > 0x1F && bb <= 0x3F) {
|
||||||
|
if (i == 0)
|
||||||
|
ivColor = (byte)bb;
|
||||||
|
else {
|
||||||
|
// cut string if different color
|
||||||
|
inStream.reset();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sb.append(translator.toChar((byte)bb));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inStream.reset();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ivData = sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
if (ivColor != 0) {
|
||||||
|
ivEmulator.setDefAttr(XITelnet.toInt(ivColor));
|
||||||
|
ivEmulator.drawString(String.valueOf(XI5250Emulator.ATTRIBUTE_PLACE_HOLDER),
|
||||||
|
ivEmulator.getSBACol(), ivEmulator.getSBARow());
|
||||||
|
ivEmulator.setSBA(ivEmulator.getSBA() + 1);
|
||||||
|
}
|
||||||
|
ivEmulator.drawString(ivData, ivEmulator.getSBACol(), ivEmulator.getSBARow());
|
||||||
|
ivEmulator.setSBA(ivEmulator.getSBA() + ivData.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " [" + XITelnet.toHex(ivColor) + "," + ",\"" + ivData + "\"" + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
87
net/infordata/em/tn5250/XIEAOrd.java
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.infordata.em.tnprot.XITelnet;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EA - Erase to address
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* see: http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/co2e2001/15.6.8?DT=19950629163252
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIEAOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected int ivRow;
|
||||||
|
protected int ivCol;
|
||||||
|
protected int ivLen;
|
||||||
|
|
||||||
|
protected byte[] ivAttributeTypes;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if order parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
{
|
||||||
|
byte[] buf = new byte[3];
|
||||||
|
if (inStream.read(buf) < buf.length)
|
||||||
|
throw new XI5250Exception("EOF reached", XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
ivRow = XITelnet.toInt(buf[0]);
|
||||||
|
ivCol = XITelnet.toInt(buf[1]);
|
||||||
|
ivLen = XITelnet.toInt(buf[2]);
|
||||||
|
}
|
||||||
|
if (ivLen < 2 || ivLen > 5)
|
||||||
|
throw new XI5250Exception("Invalid len: " + ivLen, XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
ivLen--;
|
||||||
|
ivAttributeTypes = new byte[ivLen];
|
||||||
|
if (inStream.read(ivAttributeTypes) < ivLen)
|
||||||
|
throw new XI5250Exception("EOF reached", XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
//TODO
|
||||||
|
throw new IllegalStateException("Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " [" + ivRow + "," + ivCol + "," + ivLen + "," + ",[" +
|
||||||
|
XITelnet.toHex(ivAttributeTypes) + "]" + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
157
net/infordata/em/tn5250/XIFieldTo5250Stream.java
Normal file
|
|
@ -0,0 +1,157 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 10/04/97 rel. 0.93 - some fix to add SignedNumeric fields handling.
|
||||||
|
06/08/97 rel. 1.03c- bug fix.
|
||||||
|
02/09/97 rel. 1.04a- changed to make XIReadFieldsCmd and XIReadImmediateCmd work.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XI5250Field;
|
||||||
|
import net.infordata.em.crt5250.XI5250FieldSaver;
|
||||||
|
import net.infordata.em.crt5250.XIEbcdicTranslator;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements XI5250FieldSaver to write fields content to an OutputStream.
|
||||||
|
*
|
||||||
|
* @see XI5250Emulator#send5250Data
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIFieldTo5250Stream implements XI5250FieldSaver {
|
||||||
|
|
||||||
|
XI5250Emulator ivEmulator;
|
||||||
|
OutputStream ivOut;
|
||||||
|
boolean ivOnlyMDT;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public XIFieldTo5250Stream(XI5250Emulator aEmulator, OutputStream aOutStream,
|
||||||
|
boolean onlyMDT) {
|
||||||
|
ivEmulator = aEmulator;
|
||||||
|
ivOut = aOutStream;
|
||||||
|
ivOnlyMDT = onlyMDT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void write(XI5250Field aField, String aStr)
|
||||||
|
throws IOException {
|
||||||
|
if (ivOnlyMDT && !aField.isMDTOn())
|
||||||
|
return;
|
||||||
|
|
||||||
|
XIEbcdicTranslator translator = ivEmulator.getTranslator();
|
||||||
|
|
||||||
|
// requires some special handling
|
||||||
|
// see IBM 5250 function reference manual page 2-70
|
||||||
|
if (aStr.length() > 0) {
|
||||||
|
if (aField.isSignedNumeric()) {
|
||||||
|
StringBuilder strBuf = new StringBuilder(aStr);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// find last digit char
|
||||||
|
for (i = strBuf.length() - 1;
|
||||||
|
(i >= 0) && !Character.isDigit(strBuf.charAt(i)); i--)
|
||||||
|
;
|
||||||
|
|
||||||
|
// replace non digit chars between digit char with zeroes
|
||||||
|
for (int j = i - 1; j >= 0; j--)
|
||||||
|
if (!Character.isDigit(strBuf.charAt(j)))
|
||||||
|
strBuf.setCharAt(j, '0');
|
||||||
|
|
||||||
|
if (strBuf.charAt(strBuf.length() - 1) == '-') {
|
||||||
|
if (i >= 0) {
|
||||||
|
byte xx = translator.toEBCDIC(strBuf.charAt(i));
|
||||||
|
xx &= 0x0F;
|
||||||
|
xx |= 0xD0;
|
||||||
|
strBuf.setCharAt(i, translator.toChar(xx));
|
||||||
|
aStr = new String(strBuf).substring(0, strBuf.length() - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aStr = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aStr = new String(strBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = aStr.length() - 1;
|
||||||
|
|
||||||
|
if (ivOnlyMDT) { //!!1.04a
|
||||||
|
byte[] cBuf = {XI5250Emulator.ORD_SBA,
|
||||||
|
(byte)(aField.getRow() + 1),
|
||||||
|
(byte)(aField.getCol() + 1)};
|
||||||
|
|
||||||
|
ivOut.write(cBuf);
|
||||||
|
|
||||||
|
// exclude trailing null chars
|
||||||
|
for (; (i >= 0) && (aStr.charAt(i) == '\u0000'); i--)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] strBuf = new byte[i + 1];
|
||||||
|
{
|
||||||
|
int linearPos = ivEmulator.toLinearPos(aField.getCol(), aField.getRow());
|
||||||
|
int j;
|
||||||
|
int len = Math.min(i + 1, aStr.length());
|
||||||
|
byte space = translator.toEBCDIC(' ');
|
||||||
|
|
||||||
|
for (j = 0; j < len; j++) {
|
||||||
|
char ch = aStr.charAt(j);
|
||||||
|
if (ch == XI5250Emulator.ATTRIBUTE_PLACE_HOLDER) {
|
||||||
|
ch = (char)ivEmulator.getAttr(ivEmulator.toColPos(linearPos + j),
|
||||||
|
ivEmulator.toRowPos(linearPos + j));
|
||||||
|
strBuf[j] = (byte)ch; // leave attributes as is
|
||||||
|
}
|
||||||
|
else if (ch == '\u0000') {
|
||||||
|
strBuf[j] = space;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
strBuf[j] = translator.toEBCDIC(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// fill with space
|
||||||
|
for (j = len; j < i + 1; j++)
|
||||||
|
strBuf[j] = space;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= 0) {
|
||||||
|
for (int j = 0; j < (i + 1); j++) {
|
||||||
|
// convert nulls to EBCDIC spaces
|
||||||
|
if (strBuf[j] == 0)
|
||||||
|
strBuf[j] = 0x40;
|
||||||
|
}
|
||||||
|
|
||||||
|
ivOut.write(strBuf, 0, i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
66
net/infordata/em/tn5250/XIICOrd.java
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 IC Order
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIICOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected int ivRow, ivCol;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException, XI5250Exception {
|
||||||
|
ivRow = Math.max(0, inStream.read());
|
||||||
|
ivCol = Math.max(0, inStream.read());
|
||||||
|
// Cannot deal with real dimensions, since they can be not applied yet
|
||||||
|
if (ivRow <= 0 || ivRow > XI5250Emulator.MAX_ROWS ||
|
||||||
|
ivCol <= 0 || ivCol > XI5250Emulator.MAX_COLS)
|
||||||
|
throw new XI5250Exception("Invalid screen coord: " + ivRow + "," + ivCol,
|
||||||
|
XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.setCursorPos(ivCol - 1, ivRow - 1);
|
||||||
|
ivEmulator.ivCmdList.ivICOrderExecuted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " [" + ivRow + "," + ivCol + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
134
net/infordata/em/tn5250/XIImagesBdl.java
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
07/07/98 rel. 1.07 - Uses XIUtil.createImage(), the old approach doesn' t
|
||||||
|
work at design time.
|
||||||
|
15/06/99 rel. 1.13 - Introduced crt5250 bundle.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.ListResourceBundle;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.Icon;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
import net.infordata.em.util.XIUtil;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The image bundle.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIImagesBdl extends ListResourceBundle {
|
||||||
|
|
||||||
|
private static XIImagesBdl cvImagesBdl;
|
||||||
|
|
||||||
|
private static Object[][] cvContents = null;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Object[][] contents = new Object[][] {
|
||||||
|
{"TemporaryLock",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/TemporaryLockState.gif")},
|
||||||
|
{"NormalLock",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/NormalLockState.gif")},
|
||||||
|
{"Help",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/HelpState.gif")},
|
||||||
|
{"Message",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/Message.gif")},
|
||||||
|
{"Flash",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/Flash.gif")},
|
||||||
|
//
|
||||||
|
{"Connect",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/Connect.gif")},
|
||||||
|
{"Disconnect",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/Disconnect.gif")},
|
||||||
|
{"InFrame",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/InFrame.gif")},
|
||||||
|
{"SnapShot",
|
||||||
|
XIUtil.createImage(
|
||||||
|
XIImagesBdl.class, "resources/SnapShot.gif")},
|
||||||
|
};
|
||||||
|
|
||||||
|
Object[][] superContents =
|
||||||
|
net.infordata.em.crt5250.XIImagesBdl.getImagesBdl().getContents();
|
||||||
|
cvContents = new Object[superContents.length + contents.length][2];
|
||||||
|
System.arraycopy(superContents, 0, cvContents, 0, superContents.length);
|
||||||
|
System.arraycopy(contents, 0, cvContents, superContents.length, contents.length);
|
||||||
|
}
|
||||||
|
catch (RuntimeException ex) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private XIImagesBdl() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static XIImagesBdl getImagesBdl() {
|
||||||
|
if (cvImagesBdl == null) {
|
||||||
|
cvImagesBdl = new XIImagesBdl();
|
||||||
|
}
|
||||||
|
|
||||||
|
return cvImagesBdl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[][] getContents() {
|
||||||
|
return cvContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final Image getImage(String anImageName) {
|
||||||
|
return ((ImageIcon)getIcon(anImageName)).getImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Map<String, Icon> ivIcons = new HashMap<String, Icon>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public synchronized final Icon getIcon(String anImageName) {
|
||||||
|
Icon icon = (Icon)ivIcons.get(anImageName);
|
||||||
|
if (icon == null) {
|
||||||
|
icon = new ImageIcon((Image)getObject(anImageName));
|
||||||
|
ivIcons.put(anImageName, icon);
|
||||||
|
}
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
71
net/infordata/em/tn5250/XIMCOrd.java
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MC - Move cursor
|
||||||
|
*
|
||||||
|
* see: http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/co2e2001/15.6.6?DT=19950629163252
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIMCOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected int ivRow, ivCol;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if order parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
ivRow = Math.max(0, inStream.read());
|
||||||
|
ivCol = Math.max(0, inStream.read());
|
||||||
|
// Cannot deal with real dimensions, since they can be not applied yet
|
||||||
|
if (ivRow <= 0 || ivRow > XI5250Emulator.MAX_ROWS ||
|
||||||
|
ivCol <= 0 || ivCol > XI5250Emulator.MAX_COLS)
|
||||||
|
throw new XI5250Exception("Invalid screen coord: " + ivRow + "," + ivCol,
|
||||||
|
XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.setCursorPos(ivCol - 1, ivRow - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " [" + ivRow + "," + ivCol + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
90
net/infordata/em/tn5250/XIQueryCmd.java
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XIEbcdicTranslator;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Query command.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIQueryCmd extends XI5250Cmd {
|
||||||
|
protected int[] ivPar = new int[5];
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException {
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
ivPar[i] = inStream.read();
|
||||||
|
|
||||||
|
if (ivPar[0] != 0x00 || ivPar[1] != 0x05 ||
|
||||||
|
ivPar[2] != 0xD9 || ivPar[3] != 0x70 ||
|
||||||
|
ivPar[4] != 0x00)
|
||||||
|
; //!!V gestire errori
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
XIEbcdicTranslator trans = ivEmulator.getTranslator();
|
||||||
|
// see rfc 1205
|
||||||
|
byte[] buf = {
|
||||||
|
(byte)0x00, (byte)0x00,
|
||||||
|
(byte)0x88,
|
||||||
|
(byte)0x00, (byte)0x3A,
|
||||||
|
(byte)0xD9,
|
||||||
|
(byte)0x70,
|
||||||
|
(byte)0x80,
|
||||||
|
(byte)0x06, (byte)0x00, // any other 5250 emulator
|
||||||
|
(byte)0x01, (byte)0x01, (byte)0x00, // version
|
||||||
|
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
|
||||||
|
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
|
||||||
|
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
|
||||||
|
(byte)0x01,
|
||||||
|
(byte)trans.toEBCDIC('5'), (byte)trans.toEBCDIC('2'), (byte)trans.toEBCDIC('5'), (byte)trans.toEBCDIC('1'), // 5251
|
||||||
|
(byte)trans.toEBCDIC('0'), (byte)trans.toEBCDIC('1'), (byte)trans.toEBCDIC('1'),
|
||||||
|
(byte)0x02, (byte)0x00, // keyboard
|
||||||
|
(byte)0x00,
|
||||||
|
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // S/N
|
||||||
|
(byte)0x01, (byte)0x00, // max input fields
|
||||||
|
(byte)0x00, (byte)0x00, (byte)0x00,
|
||||||
|
(byte)0x01, // Row 1 e col 1 support
|
||||||
|
(byte)(0x03 | 0x40), // 24x80 and 27x132 color supported
|
||||||
|
(byte)0x00, // reserved
|
||||||
|
(byte)0x00,
|
||||||
|
(byte)0x00, //0x07, // enhanced mode ??
|
||||||
|
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
|
||||||
|
(byte)0x00, (byte)0x00, (byte)0x00};
|
||||||
|
|
||||||
|
ivEmulator.send5250Packet((byte)0x00, (byte)0x00, buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
75
net/infordata/em/tn5250/XIRAOrd.java
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 RA Order
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIRAOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected int ivEndRow, ivEndCol;
|
||||||
|
protected char ivChar;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException, XI5250Exception {
|
||||||
|
ivEndRow = Math.max(0, inStream.read());
|
||||||
|
ivEndCol = Math.max(0, inStream.read());
|
||||||
|
ivChar = ivEmulator.getTranslator().toChar((byte)Math.max(0, inStream.read()));
|
||||||
|
// Cannot deal with real dimensions, since they can be not applied yet
|
||||||
|
if (ivEndRow <= 0 || ivEndRow > XI5250Emulator.MAX_ROWS ||
|
||||||
|
ivEndCol <= 0 || ivEndCol > XI5250Emulator.MAX_COLS)
|
||||||
|
throw new XI5250Exception("Invalid screen coord: " + ivEndRow + "," + ivEndCol,
|
||||||
|
XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
int start = ivEmulator.toLinearPos(ivEmulator.getSBACol(), ivEmulator.getSBARow());
|
||||||
|
int end = ivEmulator.toLinearPos(ivEndCol - 1, ivEndRow - 1);
|
||||||
|
StringBuilder str = new StringBuilder(end - start + 1);
|
||||||
|
for (int i = 0; i < (end - start + 1); i++)
|
||||||
|
str.append(ivChar);
|
||||||
|
|
||||||
|
ivEmulator.drawString(str.toString(), ivEmulator.getSBACol(), ivEmulator.getSBARow());
|
||||||
|
ivEmulator.setSBA(ivEmulator.getSBA() + (end - start + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() +
|
||||||
|
" [" + ivEndRow + "," + ivEndCol + ",'" + ivChar + "'" + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
63
net/infordata/em/tn5250/XIReadFieldsCmd.java
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Read fields
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIReadFieldsCmd extends XICCCmd {
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
readCC(inStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.ivPendingCmd = this;
|
||||||
|
executeCC1();
|
||||||
|
executeCC2();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void executePending(int anAidCode, boolean isMasked) {
|
||||||
|
ivEmulator.setState(XI5250Emulator.ST_TEMPORARY_LOCK);
|
||||||
|
ivEmulator.send5250Data(anAidCode, ivEmulator.isMasterMDTSet() && !isMasked, false);
|
||||||
|
//!!0.92a ivEmulator.ivPendingCmd = null;
|
||||||
|
//ivEmulator.removeFields();
|
||||||
|
}
|
||||||
|
}
|
||||||
49
net/infordata/em/tn5250/XIReadImmediateCmd.java
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Read Immediate
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIReadImmediateCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.send5250Data(0x00, ivEmulator.isMasterMDTSet(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
65
net/infordata/em/tn5250/XIReadMdtFieldsCmd.java
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Read MDT fields command
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIReadMdtFieldsCmd extends XICCCmd {
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
readCC(inStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.ivPendingCmd = this;
|
||||||
|
executeCC1();
|
||||||
|
executeCC2();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void executePending(int anAidCode, boolean isMasked) {
|
||||||
|
ivEmulator.setState(XI5250Emulator.ST_TEMPORARY_LOCK);
|
||||||
|
ivEmulator.send5250Data(anAidCode,
|
||||||
|
ivEmulator.isMasterMDTSet() && !isMasked, true);
|
||||||
|
//!!0.92a ivEmulator.ivPendingCmd = null;
|
||||||
|
//!!V1 ivEmulator.removeFields();
|
||||||
|
}
|
||||||
|
}
|
||||||
49
net/infordata/em/tn5250/XIReadScreenCmd.java
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 read screen command
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIReadScreenCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.send5250Screen();
|
||||||
|
}
|
||||||
|
}
|
||||||
71
net/infordata/em/tn5250/XIRestoreScreenCmd.java
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Restore screen command
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIRestoreScreenCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
protected int ivPos;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
ivPos = inStream.read();
|
||||||
|
if (ivPos == -1)
|
||||||
|
throw new XI5250Exception("Restore screen position required",
|
||||||
|
XI5250Emulator.ERR_INVALID_COMMAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
try {
|
||||||
|
/*!!1.06a
|
||||||
|
XI5250EmulatorMemento mm = (XI5250EmulatorMemento)ivEmulator.ivSavedScreenList.elementAt(ivPos);
|
||||||
|
ivEmulator.ivSavedScreenList.setSize(ivPos + 1);
|
||||||
|
*/
|
||||||
|
//!!1.06a
|
||||||
|
XI5250EmulatorMemento mm = ivEmulator.ivSavedScreens[ivPos];
|
||||||
|
|
||||||
|
ivEmulator.restoreMemento(mm);
|
||||||
|
}
|
||||||
|
catch (ArrayIndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
79
net/infordata/em/tn5250/XIRollCmd.java
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Roll command
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIRollCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
boolean ivDown;
|
||||||
|
int ivNRows;
|
||||||
|
int ivTopRow;
|
||||||
|
int ivBottomRow;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
int[] bb = new int[3];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 3 && (bb[i] = inStream.read()) >= 0; i++)
|
||||||
|
;
|
||||||
|
|
||||||
|
if (i < 3)
|
||||||
|
throw new XI5250Exception("Roll parameter missing",
|
||||||
|
XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
|
||||||
|
ivDown = ((bb[0] & 0x80) != 0);
|
||||||
|
|
||||||
|
ivNRows = (bb[0] & 0x1F);
|
||||||
|
|
||||||
|
ivTopRow = bb[1];
|
||||||
|
ivBottomRow = bb[2];
|
||||||
|
|
||||||
|
if (ivTopRow > ivBottomRow)
|
||||||
|
throw new XI5250Exception("TopRow greater then BottomRow",
|
||||||
|
XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.scroll(ivDown, ivTopRow - 1, ivBottomRow, ivNRows);
|
||||||
|
}
|
||||||
|
}
|
||||||
65
net/infordata/em/tn5250/XISBAOrd.java
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 SBA Order
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XISBAOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected int ivRow, ivCol;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException, XI5250Exception {
|
||||||
|
ivRow = Math.max(0, inStream.read());
|
||||||
|
ivCol = Math.max(0, inStream.read());
|
||||||
|
// Cannot deal with real dimensions, since they can be not applied yet
|
||||||
|
if (ivRow <= 0 || ivRow > XI5250Emulator.MAX_ROWS ||
|
||||||
|
ivCol <= 0 || ivCol > XI5250Emulator.MAX_COLS)
|
||||||
|
throw new XI5250Exception("Invalid screen coord: " + ivRow + "," + ivCol,
|
||||||
|
XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.setSBA(ivCol - 1, ivRow - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " [" + ivRow + "," + ivCol + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
106
net/infordata/em/tn5250/XISFOrd.java
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 04/06/97 rel. 1.00b- uses XI5250Emulator create5250Field factory method.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.infordata.em.tnprot.XITelnet;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 SF Order
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XISFOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected byte[] FFW = new byte[2];
|
||||||
|
protected byte[] FCW = new byte[2];
|
||||||
|
protected byte ivScreenAttr;
|
||||||
|
protected int ivFieldLen;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException {
|
||||||
|
byte bb;
|
||||||
|
|
||||||
|
inStream.mark(1);
|
||||||
|
bb = (byte)Math.max(0, inStream.read());
|
||||||
|
// check if FFW is present
|
||||||
|
if ((bb & 0xC0) == 0x40) {
|
||||||
|
FFW[0] = bb;
|
||||||
|
FFW[1] = (byte)Math.max(0, inStream.read());
|
||||||
|
|
||||||
|
inStream.mark(1);
|
||||||
|
bb = (byte)Math.max(0, inStream.read());
|
||||||
|
// check if FCW is present
|
||||||
|
if ((bb & 0xC0) == 0x80) {
|
||||||
|
FCW[0] = bb;
|
||||||
|
FCW[1] = (byte)Math.max(0, inStream.read());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
inStream.reset();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
inStream.reset();
|
||||||
|
|
||||||
|
ivScreenAttr = (byte)Math.max(0, inStream.read());
|
||||||
|
ivFieldLen = (Math.max(0, inStream.read()) << 8) + Math.max(0, inStream.read());
|
||||||
|
//!!V effettuare check dei parametri
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
if (ivScreenAttr != 0) {
|
||||||
|
//NO ivEmulator.setDefAttr(XITelnet.toInt(ivScreenAttr));
|
||||||
|
ivEmulator.drawString(String.valueOf(XI5250Emulator.ATTRIBUTE_PLACE_HOLDER),
|
||||||
|
ivEmulator.getSBACol(), ivEmulator.getSBARow(),
|
||||||
|
ivScreenAttr);
|
||||||
|
ivEmulator.setSBA(ivEmulator.getSBA() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -1 to force attribute reload
|
||||||
|
ivEmulator.addField(ivEmulator.create5250Field((byte[])FFW.clone(),
|
||||||
|
(byte[])FCW.clone(),
|
||||||
|
ivEmulator.getSBACol(),
|
||||||
|
ivEmulator.getSBARow(),
|
||||||
|
ivFieldLen, -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " [FFW=[" + XITelnet.toHex(FFW[0]) + "," +
|
||||||
|
XITelnet.toHex(FFW[1]) + "]," +
|
||||||
|
"FCW=[" + XITelnet.toHex(FCW[0]) + "," +
|
||||||
|
XITelnet.toHex(FCW[1]) + "]," +
|
||||||
|
XITelnet.toHex(ivScreenAttr) + "," + ivFieldLen + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
102
net/infordata/em/tn5250/XISOHOrd.java
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.infordata.em.tnprot.XITelnet;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 SOH Order
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XISOHOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected byte[] ivData;
|
||||||
|
protected int ivLen;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if order parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
int i = 0;
|
||||||
|
int bb;
|
||||||
|
|
||||||
|
ivLen = inStream.read();
|
||||||
|
if (ivLen > 0) {
|
||||||
|
ivData = new byte[ivLen];
|
||||||
|
for (i = 0; (i < ivLen) && ((bb = inStream.read()) != -1); i++)
|
||||||
|
ivData[i] = (byte)bb;
|
||||||
|
}
|
||||||
|
// parameters check
|
||||||
|
if (ivLen < 0 || ivLen > 7 || i < ivLen)
|
||||||
|
throw new XI5250Exception("Bad SOH Order", XI5250Emulator.ERR_INVALID_SOH_LENGTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
// I didn' t found them on docs, but i need them
|
||||||
|
ivEmulator.ivCmdList.ivICOrderExecuted = false;
|
||||||
|
ivEmulator.removeFields();
|
||||||
|
|
||||||
|
ivEmulator.ivPendingCmd = null; //!!0.92a
|
||||||
|
|
||||||
|
if (ivLen >= 2) {
|
||||||
|
// resequencing byte present
|
||||||
|
if (ivLen >= 3) {
|
||||||
|
// error line address present
|
||||||
|
if (ivLen >= 4) {
|
||||||
|
ivEmulator.setErrorRow(ivData[3] - 1);
|
||||||
|
// function keys mask present
|
||||||
|
if (ivLen >= 7) {
|
||||||
|
int xx = XITelnet.toInt(ivData[4]) << 16 | //!!1.05a
|
||||||
|
XITelnet.toInt(ivData[5]) << 8 |
|
||||||
|
XITelnet.toInt(ivData[6]);
|
||||||
|
|
||||||
|
ivEmulator.setFunctionKeysMask(xx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String str = "";
|
||||||
|
for (int i = 0; i < ivLen; i++)
|
||||||
|
str += XITelnet.toHex(ivData[i]) + ",";
|
||||||
|
return super.toString() + " [" + ivLen + ",[" + str + "]]";
|
||||||
|
}
|
||||||
|
}
|
||||||
57
net/infordata/em/tn5250/XISaveScreenCmd.java
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Save screen command
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XISaveScreenCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
/*!!1.06a
|
||||||
|
int pos = ivEmulator.ivSavedScreenList.size();
|
||||||
|
ivEmulator.ivSavedScreenList.addElement(ivEmulator.createMemento());
|
||||||
|
*/
|
||||||
|
//!!1.06a
|
||||||
|
int pos = (ivEmulator.ivSavedScreensIdx++) % ivEmulator.ivSavedScreens.length;
|
||||||
|
ivEmulator.ivSavedScreens[pos] = ivEmulator.createMemento();
|
||||||
|
|
||||||
|
ivEmulator.send5250SavedScreen(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
90
net/infordata/em/tn5250/XITDOrd.java
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XIEbcdicTranslator;
|
||||||
|
import net.infordata.em.tnprot.XITelnet;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TD - Transparent data
|
||||||
|
*
|
||||||
|
* see: http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/co2e2001/15.6.10?DT=19950629163252
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XITDOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected String ivData;
|
||||||
|
protected int ivLen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if order parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
{
|
||||||
|
byte[] buf = new byte[2];
|
||||||
|
if (inStream.read(buf) < buf.length)
|
||||||
|
throw new XI5250Exception("EOF reached", XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
ivLen = (XITelnet.toInt(buf[0]) << 8) | XITelnet.toInt(buf[1]);
|
||||||
|
// Cannot deal with real dimensions, since they can be not applied yet
|
||||||
|
if (ivLen < 0 || ivLen > (XI5250Emulator.MAX_ROWS * XI5250Emulator.MAX_COLS))
|
||||||
|
throw new XI5250Exception("Invalid len", XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
byte[] buf = new byte[ivLen];
|
||||||
|
int count = inStream.read(buf);
|
||||||
|
if (count < buf.length)
|
||||||
|
throw new XI5250Exception("EOF reached, requested: " + ivLen +
|
||||||
|
" readden:" + count, XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
XIEbcdicTranslator translator = ivEmulator.getTranslator();
|
||||||
|
StringBuilder sb = new StringBuilder(ivLen);
|
||||||
|
for (int i = 0; i < count ; i++) {
|
||||||
|
sb.append(translator.toChar(buf[i]));
|
||||||
|
}
|
||||||
|
ivData = sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.drawString(ivData, ivEmulator.getSBACol(), ivEmulator.getSBARow());
|
||||||
|
ivEmulator.setSBA(ivEmulator.getSBA() + ivData.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " [" + ivLen + ",\"" + ivData + "\"" + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
82
net/infordata/em/tn5250/XIWEAOrd.java
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.infordata.em.tnprot.XITelnet;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WEA - Write extended attribute
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* see: http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/co2e2001/15.6.11?DT=19950629163252
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIWEAOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
protected byte ivAttributeType;
|
||||||
|
protected byte ivAttribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if order parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
// If not in enhanced mode ...
|
||||||
|
if (true)
|
||||||
|
throw new XI5250Exception("Not supported", XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
{
|
||||||
|
byte[] buf = new byte[2];
|
||||||
|
if (inStream.read(buf) < buf.length)
|
||||||
|
throw new XI5250Exception("EOF reached", XI5250Emulator.ERR_INVALID_EXT_ATTR_TYPE);
|
||||||
|
ivAttributeType = buf[0];
|
||||||
|
ivAttribute = buf[1];
|
||||||
|
if (ivAttributeType != 0x01 && ivAttributeType != 0x03 && ivAttributeType != 0x05)
|
||||||
|
throw new XI5250Exception("Invalid attr type: " + XITelnet.toHex(ivAttributeType),
|
||||||
|
XI5250Emulator.ERR_INVALID_EXT_ATTR_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
//TODO
|
||||||
|
throw new IllegalStateException("Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " [" + XITelnet.toHex(ivAttributeType) + "," +
|
||||||
|
XITelnet.toHex(ivAttribute) + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
65
net/infordata/em/tn5250/XIWdsfOrd.java
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WDSF - Write to Display Structured Field
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* see: http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/co2e2001/15.6.13?DT=19950629163252
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIWdsfOrd extends XI5250Ord {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if order parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
// If not in enhanced mode ...
|
||||||
|
if (true)
|
||||||
|
throw new XI5250Exception("Not supported", XI5250Emulator.ERR_INVALID_ROW_COL_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
throw new IllegalStateException("Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
64
net/infordata/em/tn5250/XIWriteErrorCodeCmd.java
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 12/05/97 rel. 0.95d- setDefAttr() to 0x20.
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 Write error code command
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIWriteErrorCodeCmd extends XI5250Cmd {
|
||||||
|
|
||||||
|
protected XI5250OrdList ivOrdList;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
ivOrdList = ivEmulator.createOrdList(ivEmulator);
|
||||||
|
ivOrdList.readFrom5250Stream(inStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
ivEmulator.setState(XI5250Emulator.ST_PRE_HELP);
|
||||||
|
|
||||||
|
ivEmulator.setDefAttr(0x20); //!!0.95d
|
||||||
|
|
||||||
|
ivEmulator.setSBA(0, ivEmulator.getErrorRow());
|
||||||
|
ivOrdList.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
97
net/infordata/em/tn5250/XIWriteToDisplayCmd.java
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***
|
||||||
|
30/06/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import net.infordata.em.crt5250.XI5250Field;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5250 write to display command
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XIWriteToDisplayCmd extends XICCCmd {
|
||||||
|
|
||||||
|
protected XI5250OrdList ivOrdList;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exception XI5250Exception raised if command parameters are wrong.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void readFrom5250Stream(InputStream inStream)
|
||||||
|
throws IOException, XI5250Exception {
|
||||||
|
readCC(inStream);
|
||||||
|
|
||||||
|
ivOrdList = ivEmulator.createOrdList(ivEmulator);
|
||||||
|
ivOrdList.readFrom5250Stream(inStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void execute() {
|
||||||
|
//ivEmulator.setSBA(0, 0);
|
||||||
|
|
||||||
|
executeCC1();
|
||||||
|
|
||||||
|
// if format table is going to be altered then enter NORMAL_LOCKED state
|
||||||
|
if (ivOrdList.isOrderPresent(XI5250Emulator.ORD_SF) ||
|
||||||
|
ivOrdList.isOrderPresent(XI5250Emulator.ORD_SOH)) {
|
||||||
|
ivEmulator.setState(XI5250Emulator.ST_NORMAL_LOCKED);
|
||||||
|
}
|
||||||
|
|
||||||
|
ivOrdList.execute();
|
||||||
|
|
||||||
|
if (ivEmulator.getState() != XI5250Emulator.ST_NORMAL_UNLOCKED) {
|
||||||
|
//if (!ivOrdList.isOrderPresent(XI5250Emulator.ORD_IC))
|
||||||
|
if (!ivEmulator.ivCmdList.ivICOrderExecuted) {
|
||||||
|
// search first not bypass field
|
||||||
|
XI5250Field field;
|
||||||
|
boolean found = false;
|
||||||
|
for (Iterator<XI5250Field> e = ivEmulator.getFields().iterator(); e.hasNext(); ) {
|
||||||
|
field = e.next();
|
||||||
|
if (!field.isBypassField()) {
|
||||||
|
ivEmulator.setCursorPos(field.getCol(), field.getRow());
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
ivEmulator.setCursorPos(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
executeCC2();
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
net/infordata/em/tn5250/resources/Connect.gif
Normal file
|
After Width: | Height: | Size: 166 B |
BIN
net/infordata/em/tn5250/resources/Disconnect.gif
Normal file
|
After Width: | Height: | Size: 160 B |
BIN
net/infordata/em/tn5250/resources/Flash.gif
Normal file
|
After Width: | Height: | Size: 186 B |
BIN
net/infordata/em/tn5250/resources/HelpState.gif
Normal file
|
After Width: | Height: | Size: 221 B |
BIN
net/infordata/em/tn5250/resources/InFrame.gif
Normal file
|
After Width: | Height: | Size: 165 B |
BIN
net/infordata/em/tn5250/resources/Message.gif
Normal file
|
After Width: | Height: | Size: 225 B |
BIN
net/infordata/em/tn5250/resources/NormalLockState.gif
Normal file
|
After Width: | Height: | Size: 140 B |
28
net/infordata/em/tn5250/resources/Res.properties
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
# tn5250
|
||||||
|
|
||||||
|
TXT_Copy = Copy
|
||||||
|
TXT_Options = &Options
|
||||||
|
TXT_RefCursor = Ref. cursor
|
||||||
|
TXT_Exit = Exit
|
||||||
|
TXT_Paste = Paste
|
||||||
|
TXT_Edit = &Edit
|
||||||
|
TXT_3dFx = 3dFx
|
||||||
|
|
||||||
|
TXT_About = About
|
||||||
|
|
||||||
|
TXT_ConfirmExit = Confirm exit
|
||||||
|
|
||||||
|
TXT_Communications = &Communications
|
||||||
|
TXT_Connect = Connect
|
||||||
|
TXT_Disconnect = Disconnect
|
||||||
|
|
||||||
|
TXT_ConfirmDisconnect = Close connection
|
||||||
|
TXT_HostNameInput = Enter host-name or ip-address
|
||||||
|
|
||||||
|
TXT_InFrame = Emulator in window
|
||||||
|
|
||||||
|
TXT_SnapShot = Snap-shot
|
||||||
|
TXT_Print = Print
|
||||||
|
TXT_Forked = Forked from %1s by %2s
|
||||||
|
TXT_Version = Version %1s
|
||||||
|
|
||||||
27
net/infordata/em/tn5250/resources/Res_fr.properties
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# tn5250
|
||||||
|
|
||||||
|
TXT_Copy = Copier
|
||||||
|
TXT_Options = &Options
|
||||||
|
TXT_RefCursor = Réf. curseur
|
||||||
|
TXT_Exit = Quitter
|
||||||
|
TXT_Paste = Coller
|
||||||
|
TXT_Edit = &Editer
|
||||||
|
TXT_3dFx = Effets 3D
|
||||||
|
|
||||||
|
TXT_About = A propos
|
||||||
|
|
||||||
|
TXT_ConfirmExit = Confirmer clôture
|
||||||
|
|
||||||
|
TXT_Communications = &Communications
|
||||||
|
TXT_Connect = Connecter
|
||||||
|
TXT_Disconnect = Déconnecter
|
||||||
|
|
||||||
|
TXT_ConfirmDisconnect = Fermer la connexion
|
||||||
|
TXT_HostNameInput = Entrer adresse ip ou nom serveur
|
||||||
|
|
||||||
|
TXT_InFrame = Emulateur dans une fenêtre
|
||||||
|
|
||||||
|
TXT_SnapShot = Copie-écran
|
||||||
|
TXT_Print = Imprimer
|
||||||
|
TXT_Forked = Un fork du projet %1s de %2s
|
||||||
|
TXT_Version = Version %1s
|
||||||
26
net/infordata/em/tn5250/resources/Res_it.properties
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# tn5250
|
||||||
|
|
||||||
|
TXT_Copy = Copia
|
||||||
|
TXT_Options = &Opzioni
|
||||||
|
TXT_RefCursor = Cursore di riferimento
|
||||||
|
TXT_Exit = Chiudi
|
||||||
|
TXT_Paste = Incolla
|
||||||
|
TXT_Edit = &Modifica
|
||||||
|
TXT_3dFx = 3dFx
|
||||||
|
|
||||||
|
TXT_About = Informazioni
|
||||||
|
|
||||||
|
TXT_ConfirmExit = Confermi chiusura
|
||||||
|
|
||||||
|
TXT_Communications = &Collegamento
|
||||||
|
TXT_Connect = Connetti
|
||||||
|
TXT_Disconnect = Disconnetti
|
||||||
|
|
||||||
|
TXT_ConfirmDisconnect = Chiudo connessione
|
||||||
|
TXT_HostNameInput = Immetti nome host o indirizzo IP
|
||||||
|
|
||||||
|
TXT_InFrame = Emulatore in finestra
|
||||||
|
|
||||||
|
TXT_SnapShot = Foto pannello
|
||||||
|
TXT_Print = Stampa pannello
|
||||||
|
|
||||||
BIN
net/infordata/em/tn5250/resources/SnapShot.gif
Normal file
|
After Width: | Height: | Size: 926 B |
BIN
net/infordata/em/tn5250/resources/TemporaryLockState.gif
Normal file
|
After Width: | Height: | Size: 227 B |
BIN
net/infordata/em/tn5250/resources/XI5250Emulator_16.gif
Normal file
|
After Width: | Height: | Size: 151 B |
BIN
net/infordata/em/tn5250/resources/XI5250Emulator_32.gif
Normal file
|
After Width: | Height: | Size: 254 B |
115
net/infordata/em/tn5250ext/PSHBTNCHCHandler.java
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
package net.infordata.em.tn5250ext;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
|
||||||
|
import net.infordata.em.crt.XICrt;
|
||||||
|
import net.infordata.em.crt5250.XI5250Field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class PSHBTNCHCHandler extends XI5250PanelHandler {
|
||||||
|
|
||||||
|
private PSHBTNCHCHandler.FontsCache ivFontsCache;
|
||||||
|
private List<JButton> ivButtons = new ArrayList<JButton>();
|
||||||
|
|
||||||
|
public PSHBTNCHCHandler(XI5250PanelsDispatcher disp) {
|
||||||
|
super(disp, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void sizeChanged() {
|
||||||
|
super.sizeChanged();
|
||||||
|
final XI5250EmulatorExt em = getEmulator();
|
||||||
|
for (JButton btn : ivButtons) {
|
||||||
|
btn.setFont(ivFontsCache.getFont(
|
||||||
|
Math.max(1, em.getFont().getSize() - 2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean detailedTest() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void start() {
|
||||||
|
ivButtons.clear();
|
||||||
|
final XI5250EmulatorExt em = getEmulator();
|
||||||
|
final int crtWidth = em.getCrtSize().width;
|
||||||
|
for (Iterator<XI5250Field> e = getFields().iterator(); e.hasNext(); ) {
|
||||||
|
final XI5250Field field = e.next();
|
||||||
|
if (field.isIOOnly()) {
|
||||||
|
final int col = field.getCol() - 1;
|
||||||
|
final int row = field.getRow();
|
||||||
|
if (col >= 0 &&
|
||||||
|
"<".equals(em.getString(col, row, 1))) {
|
||||||
|
final int len;
|
||||||
|
{
|
||||||
|
final int fieldEnd = col + field.getLength();
|
||||||
|
String str = em.getString(fieldEnd + 1, row, crtWidth - fieldEnd);
|
||||||
|
int idx = str.indexOf(">");
|
||||||
|
len = (idx < 0) ? -1 : idx + 2 + 1;
|
||||||
|
}
|
||||||
|
if (len > 0) {
|
||||||
|
final String txt = em.getString(col + 1, row, len - 2);
|
||||||
|
JButton btn = new JButton(txt);
|
||||||
|
if (ivFontsCache == null)
|
||||||
|
ivFontsCache = new FontsCache(btn.getFont());
|
||||||
|
btn.setFont(ivFontsCache.getFont(Math.max(1, em.getFont().getSize() - 2)));
|
||||||
|
btn.setMargin(new Insets(2, 2, 2, 2));
|
||||||
|
btn.setFocusable(false);
|
||||||
|
btn.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
em.setCursorPos(field.getCol(), field.getRow());
|
||||||
|
em.requestFocusInWindow();
|
||||||
|
em.processRawKeyEvent(new KeyEvent(em, KeyEvent.KEY_PRESSED, 0,
|
||||||
|
0, KeyEvent.VK_ENTER, (char)KeyEvent.VK_ENTER));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ivButtons.add(btn);
|
||||||
|
new XI5250PanelConnection(this,
|
||||||
|
btn, col, row, len, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void stop() {
|
||||||
|
ivButtons.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////
|
||||||
|
|
||||||
|
private static class FontsCache {
|
||||||
|
|
||||||
|
private Font[] ivFonts = new Font[XICrt.MAX_FONT_SIZE - XICrt.MIN_FONT_SIZE + 1];
|
||||||
|
private Font ivFont;
|
||||||
|
|
||||||
|
|
||||||
|
public FontsCache(Font font) {
|
||||||
|
ivFont = font;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Font getFont(int size) {
|
||||||
|
if (ivFonts[size - XICrt.MIN_FONT_SIZE] == null) {
|
||||||
|
ivFonts[size - XICrt.MIN_FONT_SIZE] =
|
||||||
|
new Font(ivFont.getName(),
|
||||||
|
ivFont.getStyle(),
|
||||||
|
size);
|
||||||
|
}
|
||||||
|
return ivFonts[size - XICrt.MIN_FONT_SIZE];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
184
net/infordata/em/tn5250ext/Test.java
Normal file
|
|
@ -0,0 +1,184 @@
|
||||||
|
package net.infordata.em.tn5250ext;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.SystemColor;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
|
||||||
|
import net.infordata.em.crt.XICrt;
|
||||||
|
import net.infordata.em.crt5250.XI5250Field;
|
||||||
|
import net.infordata.em.tn5250.XI5250Emulator;
|
||||||
|
import net.infordata.em.tn5250.XI5250Frame;
|
||||||
|
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
private Test() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String[] argv) {
|
||||||
|
XI5250EmulatorExt em = new XI5250EmulatorExt();
|
||||||
|
em.setTerminalType("IBM-3477-FC");
|
||||||
|
em.setKeyboardQueue(true);
|
||||||
|
|
||||||
|
em.setHintOnActiveField(true);
|
||||||
|
XI5250PanelsDispatcher disp = new XI5250SimplePanelsDispatcher(em);
|
||||||
|
new TestHandler(disp);
|
||||||
|
|
||||||
|
if (argv.length >= 1) {
|
||||||
|
em.setHost(argv[0]);
|
||||||
|
em.setActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
XI5250Frame frm = new XI5250Frame("tn5250ext" + " " +
|
||||||
|
XI5250Emulator.VERSION, em);
|
||||||
|
|
||||||
|
//3D FX
|
||||||
|
if (argv.length >= 2 && "3DFX".equals(argv[1].toUpperCase())) {
|
||||||
|
em.setDefFieldsBorderStyle(XI5250Field.LOWERED_BORDER);
|
||||||
|
em.setDefBackground(SystemColor.control);
|
||||||
|
}
|
||||||
|
|
||||||
|
frm.addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
frm.setBounds(0, 0, 570, 510);
|
||||||
|
frm.centerOnScreen();
|
||||||
|
frm.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private static class TestHandler extends XI5250PanelHandler {
|
||||||
|
|
||||||
|
private FontsCache ivFontsCache;
|
||||||
|
private List<JButton> ivButtons = new ArrayList<JButton>();
|
||||||
|
|
||||||
|
public TestHandler(XI5250PanelsDispatcher disp) {
|
||||||
|
super(disp, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void sizeChanged() {
|
||||||
|
super.sizeChanged();
|
||||||
|
final XI5250EmulatorExt em = getEmulator();
|
||||||
|
for (JButton btn : ivButtons) {
|
||||||
|
btn.setFont(ivFontsCache.getFont(
|
||||||
|
Math.max(1, em.getFont().getSize() - 2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean detailedTest() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void start() {
|
||||||
|
ivButtons.clear();
|
||||||
|
final XI5250EmulatorExt em = getEmulator();
|
||||||
|
final int crtWidth = em.getCrtSize().width;
|
||||||
|
for (Iterator<XI5250Field> e = getFields().iterator(); e.hasNext(); ) {
|
||||||
|
final XI5250Field field = e.next();
|
||||||
|
boolean isButton = false;
|
||||||
|
if (field.isIOOnly()) {
|
||||||
|
final int col = field.getCol() - 1;
|
||||||
|
final int row = field.getRow();
|
||||||
|
if (col >= 0 &&
|
||||||
|
"<".equals(em.getString(col, row, 1))) {
|
||||||
|
final int len;
|
||||||
|
{
|
||||||
|
final int fieldEnd = col + field.getLength();
|
||||||
|
String str = em.getString(fieldEnd + 1, row, crtWidth - fieldEnd);
|
||||||
|
int idx = str.indexOf(">");
|
||||||
|
len = (idx < 0) ? -1 : idx + 2 + 1;
|
||||||
|
}
|
||||||
|
if (len > 0) {
|
||||||
|
isButton = true;
|
||||||
|
final String txt = em.getString(col + 1, row, len - 2);
|
||||||
|
JButton btn = new JButton(txt);
|
||||||
|
if (ivFontsCache == null)
|
||||||
|
ivFontsCache = new FontsCache(btn.getFont());
|
||||||
|
btn.setFont(ivFontsCache.getFont(Math.max(1, em.getFont().getSize() - 2)));
|
||||||
|
btn.setMargin(new Insets(2, 2, 2, 2));
|
||||||
|
btn.setFocusable(false);
|
||||||
|
btn.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
em.setCursorPos(field.getCol(), field.getRow());
|
||||||
|
em.requestFocusInWindow();
|
||||||
|
em.processRawKeyEvent(new KeyEvent(em, KeyEvent.KEY_PRESSED, 0,
|
||||||
|
0, KeyEvent.VK_ENTER, (char)KeyEvent.VK_ENTER));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ivButtons.add(btn);
|
||||||
|
new XI5250PanelConnection(this,
|
||||||
|
btn, col, row, len, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isButton) {
|
||||||
|
setFieldHint(field, new XIHint(field.toString()));
|
||||||
|
|
||||||
|
JPopupMenu pm = new JPopupMenu();
|
||||||
|
pm.add(new JMenuItem(field.toString()));
|
||||||
|
setFieldPopupMenu(field, pm);
|
||||||
|
|
||||||
|
JButton btn = new JButton();
|
||||||
|
new XI5250FieldConnection(this, field, btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
new XI5250PanelConnection(this,
|
||||||
|
new JButton("+-"),
|
||||||
|
15, 15, 10, 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void stop() {
|
||||||
|
ivButtons.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///////
|
||||||
|
|
||||||
|
private static class FontsCache {
|
||||||
|
|
||||||
|
private Font[] ivFonts = new Font[XICrt.MAX_FONT_SIZE - XICrt.MIN_FONT_SIZE + 1];
|
||||||
|
private Font ivFont;
|
||||||
|
|
||||||
|
|
||||||
|
public FontsCache(Font font) {
|
||||||
|
ivFont = font;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Font getFont(int size) {
|
||||||
|
if (ivFonts[size - XICrt.MIN_FONT_SIZE] == null) {
|
||||||
|
ivFonts[size - XICrt.MIN_FONT_SIZE] =
|
||||||
|
new Font(ivFont.getName(),
|
||||||
|
ivFont.getStyle(),
|
||||||
|
size);
|
||||||
|
}
|
||||||
|
return ivFonts[size - XICrt.MIN_FONT_SIZE];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
74
net/infordata/em/tn5250ext/XI5250AppletExt.java
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250ext;
|
||||||
|
|
||||||
|
import net.infordata.em.tn5250.XI5250Applet;
|
||||||
|
|
||||||
|
|
||||||
|
public class XI5250AppletExt extends XI5250Applet {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected XI5250EmulatorExt createEmulator() {
|
||||||
|
return new XI5250EmulatorExt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
super.init();
|
||||||
|
final boolean pPSHBTNCHC = "true".equalsIgnoreCase(getParameter("PSHBTNCHC"));
|
||||||
|
if (pPSHBTNCHC) {
|
||||||
|
XI5250EmulatorExt emext = getEmulatorExt();
|
||||||
|
PanelsDispatcher disp = new PanelsDispatcher();
|
||||||
|
disp.setEmulator(emext);
|
||||||
|
new PSHBTNCHCHandler(disp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public final XI5250EmulatorExt getEmulatorExt() {
|
||||||
|
return (XI5250EmulatorExt)super.getEmulator();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////
|
||||||
|
|
||||||
|
private static class PanelsDispatcher extends XI5250PanelsDispatcher {
|
||||||
|
|
||||||
|
private XI5250PanelHandler ivHandler;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void addPanelHandler(XI5250PanelHandler panel) {
|
||||||
|
if (ivHandler != null)
|
||||||
|
throw new IllegalArgumentException("Handler already setted");
|
||||||
|
ivHandler = panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected synchronized XI5250PanelHandler getCurrentPanelHandler() {
|
||||||
|
return ivHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void removePanelHandler(XI5250PanelHandler panel) {
|
||||||
|
if (ivHandler != panel)
|
||||||
|
throw new IllegalArgumentException("Not the registered handler " + panel);
|
||||||
|
ivHandler = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
147
net/infordata/em/tn5250ext/XI5250EmulatorExt.java
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
/*
|
||||||
|
Copyright 2007 Infordata S.p.A.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
!!V 09/09/97 rel. 1.04c- creation.
|
||||||
|
24/09/97 rel. 1.05 - DNCX project.
|
||||||
|
***
|
||||||
|
10/07/98 rel. _.___- Swing, JBuilder2 e VSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package net.infordata.em.tn5250ext;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import net.infordata.em.tn5250.XI5250Emulator;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* THE 5250 EMULATOR extension.
|
||||||
|
*
|
||||||
|
* @version
|
||||||
|
* @author Valentino Proietti - Infordata S.p.A.
|
||||||
|
*/
|
||||||
|
public class XI5250EmulatorExt extends XI5250Emulator implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private boolean ivShowHints = true;
|
||||||
|
private boolean ivHintOnActiveField = false;
|
||||||
|
|
||||||
|
transient private ArrayList<XI5250PanelsDispatcher> ivDispatchers =
|
||||||
|
new ArrayList<XI5250PanelsDispatcher>();
|
||||||
|
|
||||||
|
public static final String SHOW_HINTS = "showHints";
|
||||||
|
public static final String HINT_ON_ACTIVE_FIELD = "hintOnActiveField";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default contructor.
|
||||||
|
*/
|
||||||
|
public XI5250EmulatorExt() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected synchronized void addDispatcher(XI5250PanelsDispatcher aDispatcher) {
|
||||||
|
if (!ivDispatchers.contains(aDispatcher))
|
||||||
|
ivDispatchers.add(aDispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected synchronized void removeDispatcher(XI5250PanelsDispatcher aDispatcher) {
|
||||||
|
ivDispatchers.remove(aDispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected synchronized void refreshHint() {
|
||||||
|
XI5250PanelsDispatcher disp;
|
||||||
|
XI5250PanelHandler hndl;
|
||||||
|
for (Iterator<XI5250PanelsDispatcher> en = ivDispatchers.iterator(); en.hasNext(); ) {
|
||||||
|
disp = en.next();
|
||||||
|
hndl = disp.getCurrentPanelHandler();
|
||||||
|
|
||||||
|
if (hndl != null)
|
||||||
|
hndl.refreshHint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables the fields hints showing (default true).
|
||||||
|
*/
|
||||||
|
public void setShowHints(boolean aFlag) {
|
||||||
|
if (ivShowHints == aFlag)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean oldShowHints = ivShowHints;
|
||||||
|
ivShowHints = aFlag;
|
||||||
|
|
||||||
|
//!!1.04d refreshHint();
|
||||||
|
|
||||||
|
firePropertyChange(SHOW_HINTS, oldShowHints, ivShowHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public boolean getShowHints() {
|
||||||
|
return ivShowHints;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void setHintOnActiveField(boolean aFlag) {
|
||||||
|
if (ivHintOnActiveField == aFlag)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean oldHintOnActiveField = ivHintOnActiveField;
|
||||||
|
ivHintOnActiveField = aFlag;
|
||||||
|
|
||||||
|
//!!1.04d refreshHint();
|
||||||
|
|
||||||
|
firePropertyChange(HINT_ON_ACTIVE_FIELD,
|
||||||
|
oldHintOnActiveField, ivHintOnActiveField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public boolean isHintOnActiveField() {
|
||||||
|
return ivHintOnActiveField;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// */
|
||||||
|
// void writeObject(ObjectOutputStream oos) throws IOException {
|
||||||
|
// oos.defaultWriteObject();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||||
|
// ois.defaultReadObject();
|
||||||
|
// }
|
||||||
|
}
|
||||||