6 Commits

Author SHA1 Message Date
rudi 6296cf4341 IBM-DYNAMIC
Release j3270 / Build & Publish Release (push) Successful in 1m23s
Build and Test j3270 / Build JAR & Run Tests (push) Successful in 1m28s
2026-09-03 16:43:22 -04:00
rudi db6043cb39 Handle HeadlessException in UI tests for automated testing
Release j3270 / Build & Publish Release (push) Successful in 1m28s
Build and Test j3270 / Build JAR & Run Tests (push) Successful in 1m31s
2026-09-01 10:17:29 -04:00
rudi 161364a95f Overnight churnings
Build and Test j3270 / Build JAR & Run Tests (push) Failing after 1m23s
Release j3270 / Build & Publish Release (push) Failing after 1m15s
2026-09-01 09:45:40 -04:00
rudi a56aa5f059 More NVT stuff
Build and Test j3270 / Build JAR & Run Tests (push) Successful in 1m24s
2026-08-31 15:54:26 -04:00
rudi 7b5bc7ec11 Add consts and update tests
Build and Test j3270 / Build JAR & Run Tests (push) Successful in 1m20s
2026-08-31 10:22:12 -04:00
rudi a9956298e2 More functional changes and UI adaptations from overnight 2026-08-31 09:16:32 -04:00
294 changed files with 33291 additions and 1531 deletions
+2 -4
View File
@@ -118,7 +118,7 @@ public class TestRunner {
public static void main(String[] args) { public static void main(String[] args) {
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors( .selectors(
selectPackage("haus.nightmare.lib3270j") selectPackage("haus.nightmare")
) )
.build(); .build();
@@ -131,9 +131,7 @@ public class TestRunner {
summary.printTo(new PrintWriter(System.out)); summary.printTo(new PrintWriter(System.out));
summary.printFailuresTo(new PrintWriter(System.err)); summary.printFailuresTo(new PrintWriter(System.err));
if (summary.getTotalFailureCount() > 0) { System.exit(summary.getTotalFailureCount() > 0 ? 1 : 0);
System.exit(1);
}
} }
} }
EOF EOF
@@ -53,6 +53,8 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
buildUI(); buildUI();
buildMenuBar(); buildMenuBar();
ThemeManager.addThemeChangeListener(this::onThemeChanged);
pack(); pack();
setLocationRelativeTo(null); setLocationRelativeTo(null);
setMinimumSize(new Dimension(640, 400)); setMinimumSize(new Dimension(640, 400));
@@ -97,10 +99,16 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
getContentPane().add(statusBar, BorderLayout.SOUTH); getContentPane().add(statusBar, BorderLayout.SOUTH);
} }
private void onThemeChanged(UITheme theme) {
buildMenuBar();
statusBar.applyTheme(theme);
ThemeManager.applyThemeToWindow(this);
terminalPanel.repaint();
}
private void buildMenuBar() { private void buildMenuBar() {
JMenuBar menuBar = new JMenuBar(); JMenuBar menuBar = new JMenuBar();
menuBar.setBackground(new Color(30, 30, 30)); ThemeManager.styleMenuBar(menuBar);
menuBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(50, 50, 50)));
int shortcutMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(); int shortcutMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
@@ -137,12 +145,69 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
// 3. View menu // 3. View menu
JMenu viewMenu = createMenu("View"); JMenu viewMenu = createMenu("View");
viewMenu.add(createMenuItem("Font Size +", KeyEvent.VK_EQUALS, () -> adjustFontSize(2))); viewMenu.add(createMenuItem("Font Size +", KeyEvent.VK_EQUALS, () -> adjustFontSize(2), true));
viewMenu.add(createMenuItem("Font Size -", KeyEvent.VK_MINUS, () -> adjustFontSize(-2))); viewMenu.add(createMenuItem("Font Size -", KeyEvent.VK_MINUS, () -> adjustFontSize(-2), true));
viewMenu.add(createMenuItem("Reset Font", KeyEvent.VK_0, () -> { viewMenu.add(createMenuItem("Reset Font", KeyEvent.VK_0, () -> {
terminalPanel.setFontSize(16); terminalPanel.setFontSize(16);
terminalPanel.guardedPack(); terminalPanel.guardedPack();
})); }, true));
viewMenu.addSeparator();
// UI Theme Submenu
JMenu themeMenu = createMenu("UI Theme");
ButtonGroup themeGroup = new ButtonGroup();
JRadioButtonMenuItem darkThemeItem = new JRadioButtonMenuItem("Dark Mode", ThemeManager.isDark());
ThemeManager.styleMenuItem(darkThemeItem);
darkThemeItem.addActionListener(e -> {
haus.nightmare.j3270.config.Settings.setJavaUiTheme(UITheme.DARK);
ThemeManager.setTheme(UITheme.DARK);
});
themeGroup.add(darkThemeItem);
themeMenu.add(darkThemeItem);
JRadioButtonMenuItem lightThemeItem = new JRadioButtonMenuItem("Light Mode", ThemeManager.isLight());
ThemeManager.styleMenuItem(lightThemeItem);
lightThemeItem.addActionListener(e -> {
haus.nightmare.j3270.config.Settings.setJavaUiTheme(UITheme.LIGHT);
ThemeManager.setTheme(UITheme.LIGHT);
});
themeGroup.add(lightThemeItem);
themeMenu.add(lightThemeItem);
viewMenu.add(themeMenu);
viewMenu.addSeparator();
JCheckBoxMenuItem rulerItem = new JCheckBoxMenuItem("Crosshair Ruler", terminalPanel.isCrosshairRulerEnabled());
ThemeManager.styleMenuItem(rulerItem);
rulerItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
rulerItem.addActionListener(e -> {
boolean en = rulerItem.isSelected();
terminalPanel.setCrosshairRulerEnabled(en);
haus.nightmare.j3270.config.Settings.setCrosshairRuler(en);
});
viewMenu.add(rulerItem);
JMenu cursorMenu = createMenu("Cursor Style");
ButtonGroup cursorGroup = new ButtonGroup();
JRadioButtonMenuItem blockCursorItem = new JRadioButtonMenuItem("Block Cursor", terminalPanel.getCursorStyle() == TerminalPanel.CursorStyle.BLOCK);
ThemeManager.styleMenuItem(blockCursorItem);
blockCursorItem.addActionListener(e -> {
terminalPanel.setCursorStyle(TerminalPanel.CursorStyle.BLOCK);
haus.nightmare.j3270.config.Settings.setCursorStyle("BLOCK");
});
cursorGroup.add(blockCursorItem);
cursorMenu.add(blockCursorItem);
JRadioButtonMenuItem underlineCursorItem = new JRadioButtonMenuItem("Underline Cursor", terminalPanel.getCursorStyle() == TerminalPanel.CursorStyle.UNDERLINE);
ThemeManager.styleMenuItem(underlineCursorItem);
underlineCursorItem.addActionListener(e -> {
terminalPanel.setCursorStyle(TerminalPanel.CursorStyle.UNDERLINE);
haus.nightmare.j3270.config.Settings.setCursorStyle("UNDERLINE");
});
cursorGroup.add(underlineCursorItem);
cursorMenu.add(underlineCursorItem);
viewMenu.add(cursorMenu);
viewMenu.addSeparator(); viewMenu.addSeparator();
// CodePage Submenu // CodePage Submenu
@@ -174,8 +239,7 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
for (String cpItem : codePages) { for (String cpItem : codePages) {
String cpId = cpItem.split(" -")[0].trim(); String cpId = cpItem.split(" -")[0].trim();
JMenuItem cpMi = new JMenuItem(cpItem); JMenuItem cpMi = new JMenuItem(cpItem);
cpMi.setBackground(new Color(40, 40, 40)); ThemeManager.styleMenuItem(cpMi);
cpMi.setForeground(new Color(200, 200, 200));
cpMi.addActionListener(e -> changeCodePage(cpId)); cpMi.addActionListener(e -> changeCodePage(cpId));
cpMenu.add(cpMi); cpMenu.add(cpMi);
} }
@@ -185,8 +249,7 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
JMenu gfxMenu = createMenu("Graphics Mode"); JMenu gfxMenu = createMenu("Graphics Mode");
for (GraphicsMode gm : GraphicsMode.values()) { for (GraphicsMode gm : GraphicsMode.values()) {
JMenuItem gmMi = new JMenuItem(gm.name()); JMenuItem gmMi = new JMenuItem(gm.name());
gmMi.setBackground(new Color(40, 40, 40)); ThemeManager.styleMenuItem(gmMi);
gmMi.setForeground(new Color(200, 200, 200));
gmMi.addActionListener(e -> changeGraphicsMode(gm)); gmMi.addActionListener(e -> changeGraphicsMode(gm));
gfxMenu.add(gmMi); gfxMenu.add(gmMi);
} }
@@ -203,17 +266,17 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
client.sendEnter(); client.sendEnter();
terminalPanel.repaint(); terminalPanel.repaint();
} }
})); }, true));
actionsMenu.add(createMenuItem("Clear", KeyEvent.VK_K, () -> { actionsMenu.add(createMenuItem("Clear", KeyEvent.VK_K, () -> {
if (client != null) if (client != null)
client.sendClear(); client.sendClear();
terminalPanel.repaint(); terminalPanel.repaint();
})); }, true));
actionsMenu.add(createMenuItem("Reset", KeyEvent.VK_R, () -> { actionsMenu.add(createMenuItem("Reset", KeyEvent.VK_R, () -> {
if (client != null) if (client != null)
client.reset(); client.reset();
terminalPanel.repaint(); terminalPanel.repaint();
})); }, true));
actionsMenu.add(createMenuItem("Erase Input", KeyEvent.VK_E, () -> { actionsMenu.add(createMenuItem("Erase Input", KeyEvent.VK_E, () -> {
if (client != null && client.getConnectionState().isFullSession()) { if (client != null && client.getConnectionState().isFullSession()) {
client.eraseInput(); client.eraseInput();
@@ -241,7 +304,7 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
}, true)); }, true));
actionsMenu.addSeparator(); actionsMenu.addSeparator();
actionsMenu.add(createMenuItem("Run Keystrokes / Script...", -1, this::showScriptDialog)); actionsMenu.add(createMenuItem("Run Keystrokes / Script...", -1, this::showScriptDialog));
actionsMenu.add(createMenuItem("File Transfer...", KeyEvent.VK_T, this::showFileTransferDialog)); actionsMenu.add(createMenuItem("File Transfer...", KeyEvent.VK_T, this::showFileTransferDialog, true));
menuBar.add(actionsMenu); menuBar.add(actionsMenu);
// 5. Help menu // 5. Help menu
@@ -257,14 +320,12 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
private JMenu createMenu(String name) { private JMenu createMenu(String name) {
JMenu menu = new JMenu(name); JMenu menu = new JMenu(name);
menu.setForeground(new Color(200, 200, 200)); return ThemeManager.styleMenu(menu);
return menu;
} }
private JMenuItem createMenuItem(String name, int mnemonic, Runnable action, boolean useAlt) { private JMenuItem createMenuItem(String name, int mnemonic, Runnable action, boolean useAlt) {
JMenuItem item = new JMenuItem(name); JMenuItem item = new JMenuItem(name);
item.setBackground(new Color(40, 40, 40)); ThemeManager.styleMenuItem(item);
item.setForeground(new Color(200, 200, 200));
if (mnemonic > 0) { if (mnemonic > 0) {
int modifier = useAlt ? KeyEvent.ALT_DOWN_MASK : Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(); int modifier = useAlt ? KeyEvent.ALT_DOWN_MASK : Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
item.setAccelerator(KeyStroke.getKeyStroke(mnemonic, modifier)); item.setAccelerator(KeyStroke.getKeyStroke(mnemonic, modifier));
@@ -675,27 +736,28 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
"Delete — Delete character\n" + "Delete — Delete character\n" +
"Backspace — Backspace\n" + "Backspace — Backspace\n" +
"Insert — Toggle insert mode\n" + "Insert — Toggle insert mode\n" +
"Escape — Reset\n" + "Escape / Alt+R — Reset\n" +
"PageUp/Down — PF7/PF8\n" + "PageUp/Down — PF7/PF8\n" +
"Alt+C / Ctrl+K — Clear\n" + "Alt+C / Alt+K — Clear\n" +
"Alt+E — Erase Input\n" + "Alt+E — Erase Input\n" +
"Alt+A — Attention\n" + "Alt+A — Attention\n" +
"Alt+S — System Request\n" + "Alt+S — System Request\n" +
"Alt+Q — Cursor Select\n" + "Alt+Q — Cursor Select\n" +
"Alt+L — Toggle Light Pen\n" + "Alt+L — Toggle Light Pen\n" +
"Alt+T — File Transfer\n" +
"Alt+Shift+R — Crosshair Ruler\n" +
"Alt+=/-/0 — Font size +/-/reset\n" +
"Cmd/Ctrl+F — Find on Screen\n" + "Cmd/Ctrl+F — Find on Screen\n" +
"Cmd/Ctrl+G / F3— Find Next\n" + "Cmd/Ctrl+G / F3— Find Next\n" +
"Cmd/Ctrl+T — File Transfer\n" +
"Cmd/Ctrl+D — Disconnect\n" + "Cmd/Ctrl+D — Disconnect\n" +
"Cmd/Ctrl+Q — Quit\n" + "Cmd/Ctrl+Q — Quit";
"Cmd/Ctrl+=/-/0 — Font size +/-/reset";
JTextArea area = new JTextArea(text); JTextArea area = new JTextArea(text);
area.setEditable(false); area.setEditable(false);
area.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); area.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13));
area.setBackground(new Color(30, 30, 30)); ThemeManager.styleTextArea(area);
area.setForeground(new Color(200, 200, 200));
JScrollPane sp = new JScrollPane(area); JScrollPane sp = new JScrollPane(area);
ThemeManager.styleScrollPane(sp);
sp.setPreferredSize(new Dimension(380, 430)); sp.setPreferredSize(new Dimension(380, 430));
JOptionPane.showMessageDialog(this, sp, "Key Mappings", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(this, sp, "Key Mappings", JOptionPane.INFORMATION_MESSAGE);
} }
@@ -726,9 +788,9 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
JTextArea area = new JTextArea(text); JTextArea area = new JTextArea(text);
area.setEditable(false); area.setEditable(false);
area.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); area.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13));
area.setBackground(new Color(30, 30, 30)); ThemeManager.styleTextArea(area);
area.setForeground(new Color(200, 200, 200));
JScrollPane sp = new JScrollPane(area); JScrollPane sp = new JScrollPane(area);
ThemeManager.styleScrollPane(sp);
sp.setPreferredSize(new Dimension(440, 430)); sp.setPreferredSize(new Dimension(440, 430));
JOptionPane.showMessageDialog(this, sp, "Mnemonic Keystroke Reference", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(this, sp, "Mnemonic Keystroke Reference", JOptionPane.INFORMATION_MESSAGE);
} }
@@ -758,45 +820,47 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
Boolean cliTn3270e = null; Boolean cliTn3270e = null;
GraphicsMode cliGraphicsMode = null; GraphicsMode cliGraphicsMode = null;
String configFile = null; String configFile = null;
java.util.List<String> remainingArgs = new java.util.ArrayList<>(); java.util.List<String> remainingArgs = new java.util.ArrayList<>();
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
if ("--debug".equals(args[i]) || "-d".equals(args[i])) { String arg = args[i];
if ("-d".equals(arg) || "--debug".equals(arg)) {
debug = true; debug = true;
} else if ("--tls".equals(args[i]) || "--ssl".equals(args[i]) || "-s".equals(args[i])) { } else if ("-s".equals(arg) || "--tls".equals(arg) || "--ssl".equals(arg)) {
cliTls = true; cliTls = true;
} else if ("--no-verify-cert".equals(args[i]) || "--insecure".equals(args[i]) || "-k".equals(args[i])) { } else if ("--no-verify-cert".equals(arg) || "--insecure".equals(arg) || "-k".equals(arg)) {
cliNoVerifyCert = true; cliNoVerifyCert = true;
} else if ("--no-tn3270e".equals(args[i]) || "--plain-tn3270".equals(args[i]) || "--plain".equals(args[i]) || "-P".equals(args[i]) || "-p".equals(args[i]) || "--non-e".equals(args[i])) { } else if ("--no-tn3270e".equals(arg) || "--plain-tn3270".equals(arg) || "--plain".equals(arg) || "-P".equals(arg) || "-p".equals(arg) || "--non-e".equals(arg)) {
cliTn3270e = false; cliTn3270e = false;
} else if ("--tn3270e".equals(args[i])) { } else if ("--tn3270e".equals(arg)) {
cliTn3270e = true; cliTn3270e = true;
} else if (args[i].startsWith("--graphics=")) { } else if (arg.startsWith("--graphics=")) {
cliGraphicsMode = GraphicsMode.fromString(args[i].substring(11)); cliGraphicsMode = GraphicsMode.fromString(arg.substring(11));
} else if (("--graphics".equals(args[i]) || "-g".equals(args[i])) && i + 1 < args.length && !args[i + 1].startsWith("-")) { } else if (("--graphics".equals(arg) || "-g".equals(arg)) && i + 1 < args.length && !args[i + 1].startsWith("-")) {
cliGraphicsMode = GraphicsMode.fromString(args[++i]); cliGraphicsMode = GraphicsMode.fromString(args[++i]);
} else if ("--no-graphics".equals(args[i])) { } else if ("--no-graphics".equals(arg)) {
cliGraphicsMode = GraphicsMode.NONE; cliGraphicsMode = GraphicsMode.NONE;
} else if (("-c".equals(args[i]) || "--config".equals(args[i])) && i + 1 < args.length) { } else if (("-c".equals(arg) || "--config".equals(arg)) && i + 1 < args.length) {
configFile = args[++i]; configFile = args[++i];
} else if (arg.startsWith("-")) {
System.err.println("Unknown option: " + arg);
} else { } else {
remainingArgs.add(args[i]); remainingArgs.add(arg);
} }
} }
Level logLevel = debug ? Level.ALL : Level.INFO; Level logLevel = debug ? Level.FINE : Level.INFO;
Logger globalRoot = Logger.getLogger(""); Logger globalRoot = Logger.getLogger("");
for (java.util.logging.Handler h : globalRoot.getHandlers()) { for (java.util.logging.Handler h : globalRoot.getHandlers()) {
globalRoot.removeHandler(h); globalRoot.removeHandler(h);
} }
globalRoot.setLevel(Level.ALL);
java.util.logging.Filter appFilter = record -> { java.util.logging.Filter appFilter = record -> record.getLoggerName() != null &&
String name = record.getLoggerName(); (record.getLoggerName().startsWith("haus.nightmare") || record.getLoggerName().startsWith("org.pubvm"));
return name != null && (name.startsWith("haus.nightmare.lib3270j") || name.startsWith("haus.nightmare.j3270"));
};
ConsoleHandler consoleHandler = new ConsoleHandler(); ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(logLevel); consoleHandler.setLevel(Level.ALL);
consoleHandler.setFormatter(new SimpleFormatter()); consoleHandler.setFormatter(new SimpleFormatter());
consoleHandler.setFilter(appFilter); consoleHandler.setFilter(appFilter);
globalRoot.addHandler(consoleHandler); globalRoot.addHandler(consoleHandler);
@@ -837,6 +901,8 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
} catch (Exception e) { } catch (Exception e) {
log.fine("Could not set system look and feel"); log.fine("Could not set system look and feel");
} }
ThemeManager.applyUIManagerDefaults(haus.nightmare.j3270.config.Settings.getJavaUiTheme());
ThemeManager.setTheme(haus.nightmare.j3270.config.Settings.getJavaUiTheme());
System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("apple.awt.application.name", "j3270"); System.setProperty("apple.awt.application.name", "j3270");
@@ -860,11 +926,16 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
} }
TerminalModel model = TerminalModel.IBM_3279_4; TerminalModel model = TerminalModel.IBM_3279_4;
if (remainingArgs.size() >= 3) { if (remainingArgs.size() >= 3) {
String mArg = remainingArgs.get(2).trim();
if (mArg.equalsIgnoreCase("dynamic") || mArg.equals("0")) {
model = TerminalModel.IBM_DYNAMIC;
} else {
try { try {
int modelNum = Integer.parseInt(remainingArgs.get(2)); int modelNum = Integer.parseInt(mArg);
model = TerminalModel.forModel(modelNum, true); model = TerminalModel.forModel(modelNum, true);
} catch (Exception ignored) {} } catch (Exception ignored) {}
} }
}
ConnectionConfig config = ConnectionConfig.parseHostString(hostArg, port, model); ConnectionConfig config = ConnectionConfig.parseHostString(hostArg, port, model);
if (finalTls) { if (finalTls) {
config.setUseTls(true); config.setUseTls(true);
@@ -1,5 +1,6 @@
package haus.nightmare.j3270.config; package haus.nightmare.j3270.config;
import haus.nightmare.j3270.ui.UITheme;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import java.awt.Color; import java.awt.Color;
import java.io.*; import java.io.*;
@@ -17,6 +18,15 @@ public class Settings {
AUTO_CONNECT AUTO_CONNECT
} }
public static UITheme getJavaUiTheme() {
String themeStr = prefs.get("javaUiTheme", UITheme.DARK.name());
return UITheme.fromString(themeStr);
}
public static void setJavaUiTheme(UITheme theme) {
prefs.put("javaUiTheme", (theme != null ? theme : UITheme.DARK).name());
}
public static String getFontFamily() { public static String getFontFamily() {
return prefs.get("fontFamily", "Monospaced"); return prefs.get("fontFamily", "Monospaced");
} }
@@ -103,6 +113,22 @@ public class Settings {
prefs.put("codePage", (codePage != null && !codePage.trim().isEmpty()) ? codePage.trim() : "037"); prefs.put("codePage", (codePage != null && !codePage.trim().isEmpty()) ? codePage.trim() : "037");
} }
public static int getDynamicRows() {
return prefs.getInt("dynamicRows", 62);
}
public static void setDynamicRows(int rows) {
prefs.putInt("dynamicRows", Math.max(1, rows));
}
public static int getDynamicCols() {
return prefs.getInt("dynamicCols", 160);
}
public static void setDynamicCols(int cols) {
prefs.putInt("dynamicCols", Math.max(1, cols));
}
public static Color getColorOverride(int index, Color defaultColor) { public static Color getColorOverride(int index, Color defaultColor) {
String hex = prefs.get("color_" + index, null); String hex = prefs.get("color_" + index, null);
try { try {
@@ -223,12 +249,44 @@ public class Settings {
prefs.putBoolean("blockSelectMode", block); prefs.putBoolean("blockSelectMode", block);
} }
// ========== Crosshair Ruler ==========
public static boolean getCrosshairRuler() {
return prefs.getBoolean("crosshairRuler", false);
}
public static void setCrosshairRuler(boolean enabled) {
prefs.putBoolean("crosshairRuler", enabled);
}
// ========== Cursor Style ==========
public static String getCursorStyle() {
return prefs.get("cursorStyle", "BLOCK");
}
public static void setCursorStyle(String style) {
prefs.put("cursorStyle", style != null ? style.toUpperCase() : "BLOCK");
}
private static void applyConfigEntry(String section, String key, String value) { private static void applyConfigEntry(String section, String key, String value) {
switch (section) { switch (section) {
case "appearance": case "appearance":
switch (key) { switch (key) {
case "fontFamily": setFontFamily(value); break; case "fontFamily": setFontFamily(value); break;
case "fontSize": setFontSize(Integer.parseInt(value)); break; case "fontSize": setFontSize(Integer.parseInt(value)); break;
case "javaUiTheme":
case "theme":
case "uiTheme":
setJavaUiTheme(UITheme.fromString(value));
break;
case "crosshairRuler":
case "ruler":
setCrosshairRuler(Boolean.parseBoolean(value));
break;
case "cursorStyle":
setCursorStyle(value);
break;
default: default:
log.warning("Unknown appearance key: " + key); log.warning("Unknown appearance key: " + key);
} }
@@ -269,6 +327,14 @@ public class Settings {
case "charset": case "charset":
setCodePage(value); setCodePage(value);
break; break;
case "dynamicRows":
case "dynamic_rows":
setDynamicRows(Integer.parseInt(value));
break;
case "dynamicCols":
case "dynamic_cols":
setDynamicCols(Integer.parseInt(value));
break;
case "blockSelectMode": setBlockSelectMode(Boolean.parseBoolean(value)); break; case "blockSelectMode": setBlockSelectMode(Boolean.parseBoolean(value)); break;
default: default:
log.warning("Unknown behavior/connection key: " + key); log.warning("Unknown behavior/connection key: " + key);
@@ -322,8 +388,11 @@ public class Settings {
// [appearance] // [appearance]
w.println("[appearance]"); w.println("[appearance]");
w.println("javaUiTheme = " + getJavaUiTheme().name());
w.println("fontFamily = " + getFontFamily()); w.println("fontFamily = " + getFontFamily());
w.println("fontSize = " + getFontSize()); w.println("fontSize = " + getFontSize());
w.println("crosshairRuler = " + getCrosshairRuler());
w.println("cursorStyle = " + getCursorStyle());
w.println(); w.println();
// [behavior] // [behavior]
@@ -338,6 +407,8 @@ public class Settings {
w.println("autoConnectTn3270e = " + getAutoConnectTn3270e()); w.println("autoConnectTn3270e = " + getAutoConnectTn3270e());
} }
w.println("codePage = " + getCodePage()); w.println("codePage = " + getCodePage());
w.println("dynamicRows = " + getDynamicRows());
w.println("dynamicCols = " + getDynamicCols());
w.println("blockSelectMode = " + getBlockSelectMode()); w.println("blockSelectMode = " + getBlockSelectMode());
w.println(); w.println();
@@ -1,6 +1,7 @@
package haus.nightmare.j3270.ft; package haus.nightmare.j3270.ft;
import haus.nightmare.j3270.ui.HostDirectoryDialog; import haus.nightmare.j3270.ui.HostDirectoryDialog;
import haus.nightmare.j3270.ui.ThemeManager;
import haus.nightmare.lib3270j.ft.FTConfig; import haus.nightmare.lib3270j.ft.FTConfig;
import haus.nightmare.lib3270j.ft.FTConstants; import haus.nightmare.lib3270j.ft.FTConstants;
@@ -88,6 +89,7 @@ public class FileTransferDialog extends JDialog {
// Local File // Local File
localFileField = new JTextField(20); localFileField = new JTextField(20);
browseLocalButton = new JButton("Browse..."); browseLocalButton = new JButton("Browse...");
ThemeManager.styleButton(browseLocalButton, ThemeManager.ButtonVariant.DEFAULT);
browseLocalButton.addActionListener(e -> browseLocalFile()); browseLocalButton.addActionListener(e -> browseLocalFile());
JPanel localPanel = new JPanel(new BorderLayout(5, 0)); JPanel localPanel = new JPanel(new BorderLayout(5, 0));
localPanel.setOpaque(false); localPanel.setOpaque(false);
@@ -98,6 +100,7 @@ public class FileTransferDialog extends JDialog {
// Host File // Host File
hostFileField = new JTextField(20); hostFileField = new JTextField(20);
browseHostButton = new JButton("Browse Host..."); browseHostButton = new JButton("Browse Host...");
ThemeManager.styleButton(browseHostButton, ThemeManager.ButtonVariant.DEFAULT);
browseHostButton.addActionListener(e -> browseHostDirectory()); browseHostButton.addActionListener(e -> browseHostDirectory());
JPanel hostPanel = new JPanel(new BorderLayout(5, 0)); JPanel hostPanel = new JPanel(new BorderLayout(5, 0));
hostPanel.setOpaque(false); hostPanel.setOpaque(false);
@@ -154,10 +157,7 @@ public class FileTransferDialog extends JDialog {
// Host-specific options panel (TSO dataset allocation) // Host-specific options panel (TSO dataset allocation)
JPanel hostOptsPanel = new JPanel(new GridLayout(2, 4, 5, 5)); JPanel hostOptsPanel = new JPanel(new GridLayout(2, 4, 5, 5));
hostOptsPanel.setOpaque(false); hostOptsPanel.setOpaque(false);
hostOptsPanel.setBorder(BorderFactory.createTitledBorder( hostOptsPanel.setBorder(ThemeManager.createTitledBorder("TSO Allocation Options (Send Only)"));
BorderFactory.createLineBorder(new Color(60, 60, 60)),
"TSO Allocation Options (Send Only)"));
((javax.swing.border.TitledBorder)hostOptsPanel.getBorder()).setTitleColor(new Color(180, 180, 180));
hostOptsPanel.add(new JLabel("RECFM:")); hostOptsPanel.add(new JLabel("RECFM:"));
recfmField = new JTextField(5); recfmField = new JTextField(5);
@@ -181,10 +181,7 @@ public class FileTransferDialog extends JDialog {
// CMS options // CMS options
JPanel vmOptsPanel = new JPanel(new BorderLayout(5, 0)); JPanel vmOptsPanel = new JPanel(new BorderLayout(5, 0));
vmOptsPanel.setOpaque(false); vmOptsPanel.setOpaque(false);
vmOptsPanel.setBorder(BorderFactory.createTitledBorder( vmOptsPanel.setBorder(ThemeManager.createTitledBorder("CMS Options"));
BorderFactory.createLineBorder(new Color(60, 60, 60)),
"CMS Options"));
((javax.swing.border.TitledBorder)vmOptsPanel.getBorder()).setTitleColor(new Color(180, 180, 180));
optionsField = new JTextField(20); optionsField = new JTextField(20);
vmOptsPanel.add(new JLabel("Additional Options: "), BorderLayout.WEST); vmOptsPanel.add(new JLabel("Additional Options: "), BorderLayout.WEST);
@@ -200,9 +197,11 @@ public class FileTransferDialog extends JDialog {
buttonPanel.setOpaque(false); buttonPanel.setOpaque(false);
transferButton = new JButton("Start Transfer"); transferButton = new JButton("Start Transfer");
ThemeManager.styleButton(transferButton, ThemeManager.ButtonVariant.PRIMARY);
transferButton.addActionListener(e -> startTransfer()); transferButton.addActionListener(e -> startTransfer());
cancelButton = new JButton("Close"); cancelButton = new JButton("Close");
ThemeManager.styleButton(cancelButton, ThemeManager.ButtonVariant.CANCEL);
cancelButton.addActionListener(e -> dispose()); cancelButton.addActionListener(e -> dispose());
buttonPanel.add(cancelButton); buttonPanel.add(cancelButton);
@@ -212,7 +211,7 @@ public class FileTransferDialog extends JDialog {
setContentPane(mainPanel); setContentPane(mainPanel);
applyTheme(mainPanel); ThemeManager.applyThemeToWindow(this);
updateOptionStates(); updateOptionStates();
} }
@@ -14,6 +14,10 @@ public class ConnectDialog extends JDialog {
private JTextField hostField; private JTextField hostField;
private JTextField portField; private JTextField portField;
private JComboBox<TerminalModel> modelCombo; private JComboBox<TerminalModel> modelCombo;
private JLabel dynamicDimLabel;
private JPanel dynamicDimPanel;
private JSpinner dynamicRowsSpinner;
private JSpinner dynamicColsSpinner;
private JComboBox<haus.nightmare.lib3270j.graphics.GraphicsMode> graphicsCombo; private JComboBox<haus.nightmare.lib3270j.graphics.GraphicsMode> graphicsCombo;
private JComboBox<String> codePageCombo; private JComboBox<String> codePageCombo;
private JTextField luField; private JTextField luField;
@@ -34,24 +38,21 @@ public class ConnectDialog extends JDialog {
private void buildUI() { private void buildUI() {
JPanel mainPanel = new JPanel(new GridBagLayout()); JPanel mainPanel = new JPanel(new GridBagLayout());
mainPanel.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16)); mainPanel.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));
mainPanel.setBackground(new Color(30, 30, 30));
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(4, 4, 4, 4); gbc.insets = new Insets(5, 6, 5, 6);
gbc.fill = GridBagConstraints.HORIZONTAL; gbc.fill = GridBagConstraints.HORIZONTAL;
Font labelFont = new Font(Font.SANS_SERIF, Font.PLAIN, 14); Font labelFont = new Font(Font.SANS_SERIF, Font.PLAIN, 13);
Color fg = new Color(200, 200, 200);
// Host // Host
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 0; gbc.gridy = 0;
JLabel hostLabel = new JLabel("Host:"); JLabel hostLabel = new JLabel("Host:");
hostLabel.setForeground(fg);
hostLabel.setFont(labelFont); hostLabel.setFont(labelFont);
mainPanel.add(hostLabel, gbc); mainPanel.add(hostLabel, gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.weightx = 1.0; gbc.weightx = 1.0;
hostField = createDarkField(20); hostField = createField(20);
mainPanel.add(hostField, gbc); mainPanel.add(hostField, gbc);
// Port // Port
@@ -59,12 +60,11 @@ public class ConnectDialog extends JDialog {
gbc.gridy = 1; gbc.gridy = 1;
gbc.weightx = 0; gbc.weightx = 0;
JLabel portLabel = new JLabel("Port:"); JLabel portLabel = new JLabel("Port:");
portLabel.setForeground(fg);
portLabel.setFont(labelFont); portLabel.setFont(labelFont);
mainPanel.add(portLabel, gbc); mainPanel.add(portLabel, gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.weightx = 1.0; gbc.weightx = 1.0;
portField = createDarkField(6); portField = createField(6);
portField.setText("23"); portField.setText("23");
mainPanel.add(portField, gbc); mainPanel.add(portField, gbc);
@@ -73,54 +73,87 @@ public class ConnectDialog extends JDialog {
gbc.gridy = 2; gbc.gridy = 2;
gbc.weightx = 0; gbc.weightx = 0;
JLabel modelLabel = new JLabel("Model:"); JLabel modelLabel = new JLabel("Model:");
modelLabel.setForeground(fg);
modelLabel.setFont(labelFont); modelLabel.setFont(labelFont);
mainPanel.add(modelLabel, gbc); mainPanel.add(modelLabel, gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.weightx = 1.0; gbc.weightx = 1.0;
modelCombo = new JComboBox<>(TerminalModel.values()); modelCombo = new JComboBox<>(TerminalModel.values());
modelCombo.setSelectedItem(TerminalModel.IBM_3279_4); modelCombo.setSelectedItem(TerminalModel.IBM_3279_4);
modelCombo.setBackground(new Color(45, 45, 45));
modelCombo.setForeground(fg);
modelCombo.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); modelCombo.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13));
ThemeManager.styleComboBox(modelCombo);
mainPanel.add(modelCombo, gbc); mainPanel.add(modelCombo, gbc);
// LU Name // Dynamic Dimensions (shown when IBM-DYNAMIC is selected)
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 3; gbc.gridy = 3;
gbc.weightx = 0; gbc.weightx = 0;
dynamicDimLabel = new JLabel("Screen Size:");
dynamicDimLabel.setFont(labelFont);
mainPanel.add(dynamicDimLabel, gbc);
gbc.gridx = 1;
gbc.weightx = 1.0;
dynamicDimPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 6, 0));
dynamicDimPanel.setOpaque(false);
JLabel rowsLabel = new JLabel("Rows:");
rowsLabel.setFont(labelFont);
dynamicRowsSpinner = new JSpinner(new SpinnerNumberModel(haus.nightmare.j3270.config.Settings.getDynamicRows(), 24, 255, 1));
ThemeManager.styleSpinner(dynamicRowsSpinner);
JLabel colsLabel = new JLabel("Cols:");
colsLabel.setFont(labelFont);
dynamicColsSpinner = new JSpinner(new SpinnerNumberModel(haus.nightmare.j3270.config.Settings.getDynamicCols(), 80, 255, 1));
ThemeManager.styleSpinner(dynamicColsSpinner);
dynamicDimPanel.add(rowsLabel);
dynamicDimPanel.add(dynamicRowsSpinner);
dynamicDimPanel.add(colsLabel);
dynamicDimPanel.add(dynamicColsSpinner);
mainPanel.add(dynamicDimPanel, gbc);
Runnable updateDynamicVisibility = () -> {
TerminalModel m = (TerminalModel) modelCombo.getSelectedItem();
boolean isDyn = (m != null && m.isDynamic());
dynamicDimLabel.setVisible(isDyn);
dynamicDimPanel.setVisible(isDyn);
pack();
};
modelCombo.addActionListener(e -> updateDynamicVisibility.run());
updateDynamicVisibility.run();
// LU Name
gbc.gridx = 0;
gbc.gridy = 4;
gbc.weightx = 0;
JLabel luLabel = new JLabel("LU Name:"); JLabel luLabel = new JLabel("LU Name:");
luLabel.setForeground(fg);
luLabel.setFont(labelFont); luLabel.setFont(labelFont);
mainPanel.add(luLabel, gbc); mainPanel.add(luLabel, gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.weightx = 1.0; gbc.weightx = 1.0;
luField = createDarkField(12); luField = createField(12);
mainPanel.add(luField, gbc); mainPanel.add(luField, gbc);
// Graphics Mode // Graphics Mode
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 4; gbc.gridy = 5;
gbc.weightx = 0; gbc.weightx = 0;
JLabel graphicsLabel = new JLabel("Graphics:"); JLabel graphicsLabel = new JLabel("Graphics:");
graphicsLabel.setForeground(fg);
graphicsLabel.setFont(labelFont); graphicsLabel.setFont(labelFont);
mainPanel.add(graphicsLabel, gbc); mainPanel.add(graphicsLabel, gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.weightx = 1.0; gbc.weightx = 1.0;
graphicsCombo = new JComboBox<>(haus.nightmare.lib3270j.graphics.GraphicsMode.values()); graphicsCombo = new JComboBox<>(haus.nightmare.lib3270j.graphics.GraphicsMode.values());
graphicsCombo.setSelectedItem(haus.nightmare.j3270.config.Settings.getGraphicsMode()); graphicsCombo.setSelectedItem(haus.nightmare.j3270.config.Settings.getGraphicsMode());
graphicsCombo.setBackground(new Color(45, 45, 45));
graphicsCombo.setForeground(fg);
graphicsCombo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13)); graphicsCombo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
ThemeManager.styleComboBox(graphicsCombo);
mainPanel.add(graphicsCombo, gbc); mainPanel.add(graphicsCombo, gbc);
// Code Page // Code Page
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 5; gbc.gridy = 6;
gbc.weightx = 0; gbc.weightx = 0;
JLabel cpLabel = new JLabel("Code Page:"); JLabel cpLabel = new JLabel("Code Page:");
cpLabel.setForeground(fg);
cpLabel.setFont(labelFont); cpLabel.setFont(labelFont);
mainPanel.add(cpLabel, gbc); mainPanel.add(cpLabel, gbc);
gbc.gridx = 1; gbc.gridx = 1;
@@ -139,14 +172,27 @@ public class ConnectDialog extends JDialog {
"870 - Eastern Europe / Latin-2", "870 - Eastern Europe / Latin-2",
"871 - Iceland", "871 - Iceland",
"875 - Greece (Greek)", "875 - Greece (Greek)",
"1026 - Turkey (Turkish)", "1026 - Turkey (Turkish Latin-5)",
"1155 - Turkey (Turkish Latin-5 Euro \u20AC)",
"905 - Turkey (Turkish Latin-3)",
"420 - Arabic Bilingual",
"424 - Hebrew (with Lowercase)",
"803 - Hebrew Old / Standard",
"838 - Thai",
"1160 - Thai (Euro \u20AC)",
"1025 - Cyrillic Multilingual",
"1123 - Cyrillic Ukraine",
"1154 - Cyrillic Multilingual (Euro \u20AC)",
"880 - Cyrillic Russian",
"1140 - US / Canada (Euro \u20AC)", "1140 - US / Canada (Euro \u20AC)",
"1141 - Germany / Austria (Euro \u20AC)", "1141 - Germany / Austria (Euro \u20AC)",
"1148 - International (Euro \u20AC)", "1148 - International (Euro \u20AC)",
"930 - Japanese Katakana Mixed DBCS", "930 - Japanese Katakana Mixed DBCS",
"939 - Japanese Latin Mixed DBCS", "939 - Japanese Latin Mixed DBCS",
"935 - Simplified Chinese Mixed DBCS", "935 - Simplified Chinese Mixed DBCS",
"1388 - Simplified Chinese Extended Mixed DBCS",
"937 - Traditional Chinese Mixed DBCS", "937 - Traditional Chinese Mixed DBCS",
"1371 - Traditional Chinese Extended Mixed DBCS",
"933 - Korean Mixed DBCS" "933 - Korean Mixed DBCS"
}; };
codePageCombo = new JComboBox<>(commonCodePages); codePageCombo = new JComboBox<>(commonCodePages);
@@ -158,20 +204,17 @@ public class ConnectDialog extends JDialog {
break; break;
} }
} }
codePageCombo.setBackground(new Color(45, 45, 45));
codePageCombo.setForeground(fg);
codePageCombo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13)); codePageCombo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
ThemeManager.styleComboBox(codePageCombo);
mainPanel.add(codePageCombo, gbc); mainPanel.add(codePageCombo, gbc);
// TLS / SSL Checkbox // TLS / SSL Checkbox
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 6; gbc.gridy = 7;
gbc.weightx = 1.0; gbc.weightx = 1.0;
tlsCheckBox = new JCheckBox("Enable TLS/SSL"); tlsCheckBox = new JCheckBox("Enable TLS/SSL");
tlsCheckBox.setBackground(new Color(30, 30, 30)); ThemeManager.styleCheckBox(tlsCheckBox);
tlsCheckBox.setForeground(fg);
tlsCheckBox.setFont(labelFont); tlsCheckBox.setFont(labelFont);
tlsCheckBox.setFocusPainted(false);
tlsCheckBox.addActionListener(e -> { tlsCheckBox.addActionListener(e -> {
boolean isTls = tlsCheckBox.isSelected(); boolean isTls = tlsCheckBox.isSelected();
verifyCertCheckBox.setEnabled(isTls); verifyCertCheckBox.setEnabled(isTls);
@@ -186,40 +229,33 @@ public class ConnectDialog extends JDialog {
// Verify Certificate Checkbox // Verify Certificate Checkbox
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 7; gbc.gridy = 8;
verifyCertCheckBox = new JCheckBox("Verify Server Certificate"); verifyCertCheckBox = new JCheckBox("Verify Server Certificate");
verifyCertCheckBox.setBackground(new Color(30, 30, 30)); ThemeManager.styleCheckBox(verifyCertCheckBox);
verifyCertCheckBox.setForeground(new Color(160, 160, 160));
verifyCertCheckBox.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13)); verifyCertCheckBox.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
verifyCertCheckBox.setSelected(true); verifyCertCheckBox.setSelected(true);
verifyCertCheckBox.setEnabled(false); verifyCertCheckBox.setEnabled(false);
verifyCertCheckBox.setFocusPainted(false);
mainPanel.add(verifyCertCheckBox, gbc); mainPanel.add(verifyCertCheckBox, gbc);
// TN3270E Checkbox // TN3270E Checkbox
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 8; gbc.gridy = 9;
tn3270eCheckBox = new JCheckBox("Enable TN3270E (Extended 3270)"); tn3270eCheckBox = new JCheckBox("Enable TN3270E (Extended 3270)");
tn3270eCheckBox.setBackground(new Color(30, 30, 30)); ThemeManager.styleCheckBox(tn3270eCheckBox);
tn3270eCheckBox.setForeground(fg);
tn3270eCheckBox.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13)); tn3270eCheckBox.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
tn3270eCheckBox.setSelected(haus.nightmare.j3270.config.Settings.getAutoConnectTn3270e()); tn3270eCheckBox.setSelected(haus.nightmare.j3270.config.Settings.getAutoConnectTn3270e());
tn3270eCheckBox.setFocusPainted(false);
mainPanel.add(tn3270eCheckBox, gbc); mainPanel.add(tn3270eCheckBox, gbc);
// Buttons // Buttons
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 4));
buttonPanel.setBackground(new Color(30, 30, 30));
JButton connectBtn = new JButton("Connect"); JButton connectBtn = new JButton("Connect");
connectBtn.setBackground(new Color(50, 120, 50)); ThemeManager.styleButton(connectBtn, ThemeManager.ButtonVariant.PRIMARY);
connectBtn.setForeground(Color.WHITE);
connectBtn.setFont(labelFont); connectBtn.setFont(labelFont);
connectBtn.addActionListener(e -> onConnect()); connectBtn.addActionListener(e -> onConnect());
JButton cancelBtn = new JButton("Cancel"); JButton cancelBtn = new JButton("Cancel");
cancelBtn.setBackground(new Color(60, 60, 60)); ThemeManager.styleButton(cancelBtn, ThemeManager.ButtonVariant.CANCEL);
cancelBtn.setForeground(fg);
cancelBtn.setFont(labelFont); cancelBtn.setFont(labelFont);
cancelBtn.addActionListener(e -> { cancelBtn.addActionListener(e -> {
confirmed = false; confirmed = false;
@@ -230,25 +266,21 @@ public class ConnectDialog extends JDialog {
buttonPanel.add(connectBtn); buttonPanel.add(connectBtn);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 9; gbc.gridy = 10;
gbc.gridwidth = 2; gbc.gridwidth = 2;
mainPanel.add(buttonPanel, gbc); mainPanel.add(buttonPanel, gbc);
setContentPane(mainPanel); setContentPane(mainPanel);
ThemeManager.applyThemeToWindow(this);
// Enter key triggers connect // Enter key triggers connect
getRootPane().setDefaultButton(connectBtn); getRootPane().setDefaultButton(connectBtn);
} }
private JTextField createDarkField(int cols) { private JTextField createField(int cols) {
JTextField field = new JTextField(cols); JTextField field = new JTextField(cols);
field.setBackground(new Color(45, 45, 45));
field.setForeground(new Color(200, 200, 200));
field.setCaretColor(new Color(200, 200, 200));
field.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); field.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
field.setBorder(BorderFactory.createCompoundBorder( ThemeManager.styleTextField(field);
BorderFactory.createLineBorder(new Color(60, 60, 60)),
BorderFactory.createEmptyBorder(4, 6, 4, 6)));
return field; return field;
} }
@@ -267,7 +299,15 @@ public class ConnectDialog extends JDialog {
return; return;
} }
result = new ConnectionConfig(host, port, (TerminalModel) modelCombo.getSelectedItem()); TerminalModel selectedModel = (TerminalModel) modelCombo.getSelectedItem();
result = new ConnectionConfig(host, port, selectedModel);
if (selectedModel != null && selectedModel.isDynamic()) {
int dRows = (Integer) dynamicRowsSpinner.getValue();
int dCols = (Integer) dynamicColsSpinner.getValue();
result.setDynamicDimensions(dRows, dCols);
haus.nightmare.j3270.config.Settings.setDynamicRows(dRows);
haus.nightmare.j3270.config.Settings.setDynamicCols(dCols);
}
String lu = luField.getText().trim(); String lu = luField.getText().trim();
if (!lu.isEmpty()) { if (!lu.isEmpty()) {
result.setLuName(lu); result.setLuName(lu);
@@ -28,12 +28,6 @@ public class FieldInspectorDialog extends JDialog implements ScreenUpdateListene
private JTable table; private JTable table;
private JLabel countLabel; private JLabel countLabel;
private static final Color DARK_BG = new Color(35, 35, 35);
private static final Color DARK_FIELD_BG = new Color(45, 45, 45);
private static final Color DARK_FG = new Color(220, 220, 220);
private static final Color DARK_BORDER = new Color(65, 65, 65);
private static final Color DARK_SELECTION = new Color(75, 110, 175);
public FieldInspectorDialog(Frame parent, Telnet3270Client client, TerminalPanel terminalPanel) { public FieldInspectorDialog(Frame parent, Telnet3270Client client, TerminalPanel terminalPanel) {
super(parent, "3270 Presentation Space Field Inspector", false); super(parent, "3270 Presentation Space Field Inspector", false);
this.client = client; this.client = client;
@@ -61,19 +55,16 @@ public class FieldInspectorDialog extends JDialog implements ScreenUpdateListene
private void buildUI() { private void buildUI() {
JPanel mainPanel = new JPanel(new BorderLayout(8, 8)); JPanel mainPanel = new JPanel(new BorderLayout(8, 8));
mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
mainPanel.setBackground(DARK_BG);
// Top info bar // Top info bar
JPanel topPanel = new JPanel(new BorderLayout()); JPanel topPanel = new JPanel(new BorderLayout());
topPanel.setOpaque(false); topPanel.setOpaque(false);
countLabel = new JLabel("0 fields detected on screen"); countLabel = new JLabel("0 fields detected on screen");
countLabel.setForeground(DARK_FG);
countLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 13)); countLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 13));
topPanel.add(countLabel, BorderLayout.WEST); topPanel.add(countLabel, BorderLayout.WEST);
JButton refreshBtn = new JButton("Refresh"); JButton refreshBtn = new JButton("Refresh");
refreshBtn.setBackground(new Color(55, 55, 55)); ThemeManager.styleButton(refreshBtn, ThemeManager.ButtonVariant.DEFAULT);
refreshBtn.setForeground(DARK_FG);
refreshBtn.addActionListener(e -> refreshFields()); refreshBtn.addActionListener(e -> refreshFields());
topPanel.add(refreshBtn, BorderLayout.EAST); topPanel.add(refreshBtn, BorderLayout.EAST);
mainPanel.add(topPanel, BorderLayout.NORTH); mainPanel.add(topPanel, BorderLayout.NORTH);
@@ -91,18 +82,12 @@ public class FieldInspectorDialog extends JDialog implements ScreenUpdateListene
}; };
table = new JTable(tableModel); table = new JTable(tableModel);
table.setBackground(DARK_FIELD_BG); ThemeManager.styleTable(table);
table.setForeground(DARK_FG);
table.setSelectionBackground(DARK_SELECTION);
table.setSelectionForeground(Color.WHITE);
table.setGridColor(DARK_BORDER);
table.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); table.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setRowHeight(20); table.setRowHeight(20);
JTableHeader header = table.getTableHeader(); JTableHeader header = table.getTableHeader();
header.setBackground(new Color(50, 50, 50));
header.setForeground(DARK_FG);
header.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12)); header.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
// Column widths // Column widths
@@ -125,8 +110,7 @@ public class FieldInspectorDialog extends JDialog implements ScreenUpdateListene
}); });
JScrollPane scrollPane = new JScrollPane(table); JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBorder(new LineBorder(DARK_BORDER)); ThemeManager.styleScrollPane(scrollPane);
scrollPane.getViewport().setBackground(DARK_FIELD_BG);
mainPanel.add(scrollPane, BorderLayout.CENTER); mainPanel.add(scrollPane, BorderLayout.CENTER);
// Bottom panel // Bottom panel
@@ -134,8 +118,7 @@ public class FieldInspectorDialog extends JDialog implements ScreenUpdateListene
bottomPanel.setOpaque(false); bottomPanel.setOpaque(false);
JButton jumpBtn = new JButton("Jump to Selected Field"); JButton jumpBtn = new JButton("Jump to Selected Field");
jumpBtn.setBackground(new Color(50, 100, 160)); ThemeManager.styleButton(jumpBtn, ThemeManager.ButtonVariant.PRIMARY);
jumpBtn.setForeground(Color.WHITE);
jumpBtn.addActionListener(e -> { jumpBtn.addActionListener(e -> {
int row = table.getSelectedRow(); int row = table.getSelectedRow();
if (row >= 0) { if (row >= 0) {
@@ -144,8 +127,7 @@ public class FieldInspectorDialog extends JDialog implements ScreenUpdateListene
}); });
JButton closeBtn = new JButton("Close"); JButton closeBtn = new JButton("Close");
closeBtn.setBackground(new Color(55, 55, 55)); ThemeManager.styleButton(closeBtn, ThemeManager.ButtonVariant.CANCEL);
closeBtn.setForeground(DARK_FG);
closeBtn.addActionListener(e -> dispose()); closeBtn.addActionListener(e -> dispose());
bottomPanel.add(jumpBtn); bottomPanel.add(jumpBtn);
@@ -153,6 +135,7 @@ public class FieldInspectorDialog extends JDialog implements ScreenUpdateListene
mainPanel.add(bottomPanel, BorderLayout.SOUTH); mainPanel.add(bottomPanel, BorderLayout.SOUTH);
setContentPane(mainPanel); setContentPane(mainPanel);
ThemeManager.applyThemeToWindow(this);
} }
public synchronized void refreshFields() { public synchronized void refreshFields() {
@@ -42,7 +42,6 @@ public class FindDialog extends JDialog {
private void buildUI() { private void buildUI() {
JPanel mainPanel = new JPanel(new BorderLayout(10, 10)); JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
mainPanel.setBorder(new EmptyBorder(12, 14, 12, 14)); mainPanel.setBorder(new EmptyBorder(12, 14, 12, 14));
mainPanel.setBackground(new Color(35, 35, 35));
// Form // Form
JPanel formPanel = new JPanel(new GridBagLayout()); JPanel formPanel = new JPanel(new GridBagLayout());
@@ -51,14 +50,12 @@ public class FindDialog extends JDialog {
gbc.insets = new Insets(4, 4, 4, 4); gbc.insets = new Insets(4, 4, 4, 4);
gbc.fill = GridBagConstraints.HORIZONTAL; gbc.fill = GridBagConstraints.HORIZONTAL;
Color fg = new Color(220, 220, 220);
Font labelFont = new Font(Font.SANS_SERIF, Font.PLAIN, 13); Font labelFont = new Font(Font.SANS_SERIF, Font.PLAIN, 13);
// Search text // Search text
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 0; gbc.gridy = 0;
JLabel findLabel = new JLabel("Find what:"); JLabel findLabel = new JLabel("Find what:");
findLabel.setForeground(fg);
findLabel.setFont(labelFont); findLabel.setFont(labelFont);
formPanel.add(findLabel, gbc); formPanel.add(findLabel, gbc);
@@ -66,23 +63,16 @@ public class FindDialog extends JDialog {
gbc.weightx = 1.0; gbc.weightx = 1.0;
searchField = new JTextField(20); searchField = new JTextField(20);
searchField.setText(lastSearchText); searchField.setText(lastSearchText);
searchField.setBackground(new Color(50, 50, 50));
searchField.setForeground(fg);
searchField.setCaretColor(fg);
searchField.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); searchField.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13));
searchField.setBorder(BorderFactory.createCompoundBorder( ThemeManager.styleTextField(searchField);
BorderFactory.createLineBorder(new Color(70, 70, 70)),
BorderFactory.createEmptyBorder(3, 6, 3, 6)));
formPanel.add(searchField, gbc); formPanel.add(searchField, gbc);
// Options // Options
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 1; gbc.gridy = 1;
matchCaseCheck = new JCheckBox("Match case", lastMatchCase); matchCaseCheck = new JCheckBox("Match case", lastMatchCase);
matchCaseCheck.setForeground(fg); ThemeManager.styleCheckBox(matchCaseCheck);
matchCaseCheck.setOpaque(false);
matchCaseCheck.setFont(labelFont); matchCaseCheck.setFont(labelFont);
matchCaseCheck.setFocusPainted(false);
formPanel.add(matchCaseCheck, gbc); formPanel.add(matchCaseCheck, gbc);
// Direction // Direction
@@ -91,16 +81,11 @@ public class FindDialog extends JDialog {
JPanel dirPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel dirPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
dirPanel.setOpaque(false); dirPanel.setOpaque(false);
JLabel dirLabel = new JLabel("Direction: "); JLabel dirLabel = new JLabel("Direction: ");
dirLabel.setForeground(fg);
dirLabel.setFont(labelFont); dirLabel.setFont(labelFont);
forwardRadio = new JRadioButton("Down", lastForward); forwardRadio = new JRadioButton("Down", lastForward);
backwardRadio = new JRadioButton("Up", !lastForward); backwardRadio = new JRadioButton("Up", !lastForward);
forwardRadio.setForeground(fg); ThemeManager.styleRadioButton(forwardRadio);
backwardRadio.setForeground(fg); ThemeManager.styleRadioButton(backwardRadio);
forwardRadio.setOpaque(false);
backwardRadio.setOpaque(false);
forwardRadio.setFocusPainted(false);
backwardRadio.setFocusPainted(false);
ButtonGroup bg = new ButtonGroup(); ButtonGroup bg = new ButtonGroup();
bg.add(forwardRadio); bg.add(forwardRadio);
@@ -116,7 +101,7 @@ public class FindDialog extends JDialog {
gbc.gridy = 3; gbc.gridy = 3;
gbc.gridwidth = 2; gbc.gridwidth = 2;
statusLabel = new JLabel(" "); statusLabel = new JLabel(" ");
statusLabel.setForeground(new Color(255, 120, 120)); statusLabel.setForeground(ThemeManager.getOiaFgAlert());
statusLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); statusLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
formPanel.add(statusLabel, gbc); formPanel.add(statusLabel, gbc);
@@ -127,14 +112,12 @@ public class FindDialog extends JDialog {
buttonPanel.setOpaque(false); buttonPanel.setOpaque(false);
JButton findNextBtn = new JButton("Find Next"); JButton findNextBtn = new JButton("Find Next");
findNextBtn.setBackground(new Color(60, 63, 65)); ThemeManager.styleButton(findNextBtn, ThemeManager.ButtonVariant.PRIMARY);
findNextBtn.setForeground(fg);
findNextBtn.setFont(labelFont); findNextBtn.setFont(labelFont);
findNextBtn.addActionListener(e -> findNext()); findNextBtn.addActionListener(e -> findNext());
JButton closeBtn = new JButton("Close"); JButton closeBtn = new JButton("Close");
closeBtn.setBackground(new Color(60, 63, 65)); ThemeManager.styleButton(closeBtn, ThemeManager.ButtonVariant.CANCEL);
closeBtn.setForeground(fg);
closeBtn.setFont(labelFont); closeBtn.setFont(labelFont);
closeBtn.addActionListener(e -> dispose()); closeBtn.addActionListener(e -> dispose());
@@ -144,6 +127,7 @@ public class FindDialog extends JDialog {
mainPanel.add(buttonPanel, BorderLayout.SOUTH); mainPanel.add(buttonPanel, BorderLayout.SOUTH);
setContentPane(mainPanel); setContentPane(mainPanel);
ThemeManager.applyThemeToWindow(this);
getRootPane().setDefaultButton(findNextBtn); getRootPane().setDefaultButton(findNextBtn);
searchField.addKeyListener(new KeyAdapter() { searchField.addKeyListener(new KeyAdapter() {
@@ -49,9 +49,7 @@ public class HostDirectoryDialog extends JDialog {
private void buildUI(String initialQuery) { private void buildUI(String initialQuery) {
JPanel mainPanel = new JPanel(new BorderLayout(10, 10)); JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
mainPanel.setBorder(new EmptyBorder(12, 12, 12, 12)); mainPanel.setBorder(new EmptyBorder(12, 12, 12, 12));
mainPanel.setBackground(new Color(35, 35, 35));
Color fg = new Color(220, 220, 220);
Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 13); Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 13);
// Top Query bar // Top Query bar
@@ -62,7 +60,6 @@ public class HostDirectoryDialog extends JDialog {
gbc.fill = GridBagConstraints.HORIZONTAL; gbc.fill = GridBagConstraints.HORIZONTAL;
JLabel envLabel = new JLabel("System:"); JLabel envLabel = new JLabel("System:");
envLabel.setForeground(fg);
envLabel.setFont(font); envLabel.setFont(font);
topPanel.add(envLabel, gbc); topPanel.add(envLabel, gbc);
@@ -70,33 +67,25 @@ public class HostDirectoryDialog extends JDialog {
hostTypeCombo = new JComboBox<>(new FTConfig.HostType[]{FTConfig.HostType.TSO, FTConfig.HostType.CMS}); hostTypeCombo = new JComboBox<>(new FTConfig.HostType[]{FTConfig.HostType.TSO, FTConfig.HostType.CMS});
if (initialHostType == FTConfig.HostType.CMS) hostTypeCombo.setSelectedItem(FTConfig.HostType.CMS); if (initialHostType == FTConfig.HostType.CMS) hostTypeCombo.setSelectedItem(FTConfig.HostType.CMS);
else hostTypeCombo.setSelectedItem(FTConfig.HostType.TSO); else hostTypeCombo.setSelectedItem(FTConfig.HostType.TSO);
hostTypeCombo.setBackground(new Color(50, 50, 50)); ThemeManager.styleComboBox(hostTypeCombo);
hostTypeCombo.setForeground(fg);
topPanel.add(hostTypeCombo, gbc); topPanel.add(hostTypeCombo, gbc);
gbc.gridx = 2; gbc.gridx = 2;
JLabel queryLabel = new JLabel("Query Pattern / Text:"); JLabel queryLabel = new JLabel("Query Pattern / Text:");
queryLabel.setForeground(fg);
queryLabel.setFont(font); queryLabel.setFont(font);
topPanel.add(queryLabel, gbc); topPanel.add(queryLabel, gbc);
gbc.gridx = 3; gbc.gridx = 3;
gbc.weightx = 1.0; gbc.weightx = 1.0;
queryField = new JTextField(initialQuery != null ? initialQuery : "", 16); queryField = new JTextField(initialQuery != null ? initialQuery : "", 16);
queryField.setBackground(new Color(50, 50, 50));
queryField.setForeground(fg);
queryField.setCaretColor(fg);
queryField.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); queryField.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13));
queryField.setBorder(BorderFactory.createCompoundBorder( ThemeManager.styleTextField(queryField);
new LineBorder(new Color(70, 70, 70)),
new EmptyBorder(3, 5, 3, 5)));
topPanel.add(queryField, gbc); topPanel.add(queryField, gbc);
gbc.gridx = 4; gbc.gridx = 4;
gbc.weightx = 0; gbc.weightx = 0;
JButton parseBtn = new JButton("Query / Parse"); JButton parseBtn = new JButton("Query / Parse");
parseBtn.setBackground(new Color(55, 55, 55)); ThemeManager.styleButton(parseBtn, ThemeManager.ButtonVariant.DEFAULT);
parseBtn.setForeground(fg);
parseBtn.setFont(font); parseBtn.setFont(font);
parseBtn.addActionListener(e -> runQuery()); parseBtn.addActionListener(e -> runQuery());
topPanel.add(parseBtn, gbc); topPanel.add(parseBtn, gbc);
@@ -106,18 +95,12 @@ public class HostDirectoryDialog extends JDialog {
// Table // Table
tableModel = new DefaultTableModel(); tableModel = new DefaultTableModel();
table = new JTable(tableModel); table = new JTable(tableModel);
table.setBackground(new Color(45, 45, 45)); ThemeManager.styleTable(table);
table.setForeground(fg);
table.setSelectionBackground(new Color(75, 110, 175));
table.setSelectionForeground(Color.WHITE);
table.setGridColor(new Color(65, 65, 65));
table.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); table.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setRowHeight(20); table.setRowHeight(20);
JTableHeader header = table.getTableHeader(); JTableHeader header = table.getTableHeader();
header.setBackground(new Color(50, 50, 50));
header.setForeground(fg);
header.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12)); header.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
table.addMouseListener(new MouseAdapter() { table.addMouseListener(new MouseAdapter() {
@@ -130,8 +113,7 @@ public class HostDirectoryDialog extends JDialog {
}); });
JScrollPane scrollPane = new JScrollPane(table); JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBorder(new LineBorder(new Color(65, 65, 65))); ThemeManager.styleScrollPane(scrollPane);
scrollPane.getViewport().setBackground(new Color(45, 45, 45));
mainPanel.add(scrollPane, BorderLayout.CENTER); mainPanel.add(scrollPane, BorderLayout.CENTER);
// Bottom // Bottom
@@ -139,7 +121,7 @@ public class HostDirectoryDialog extends JDialog {
bottomPanel.setOpaque(false); bottomPanel.setOpaque(false);
statusLabel = new JLabel("Enter a dataset pattern or parse active screen."); statusLabel = new JLabel("Enter a dataset pattern or parse active screen.");
statusLabel.setForeground(new Color(170, 170, 170)); statusLabel.setForeground(ThemeManager.getFgMuted());
statusLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); statusLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
bottomPanel.add(statusLabel, BorderLayout.WEST); bottomPanel.add(statusLabel, BorderLayout.WEST);
@@ -147,20 +129,17 @@ public class HostDirectoryDialog extends JDialog {
btnPanel.setOpaque(false); btnPanel.setOpaque(false);
JButton pasteScreenBtn = new JButton("Parse Current Screen"); JButton pasteScreenBtn = new JButton("Parse Current Screen");
pasteScreenBtn.setBackground(new Color(50, 50, 50)); ThemeManager.styleButton(pasteScreenBtn, ThemeManager.ButtonVariant.DEFAULT);
pasteScreenBtn.setForeground(fg);
pasteScreenBtn.setFont(font); pasteScreenBtn.setFont(font);
pasteScreenBtn.addActionListener(e -> parseCurrentScreen()); pasteScreenBtn.addActionListener(e -> parseCurrentScreen());
JButton selectBtn = new JButton("Select Dataset"); JButton selectBtn = new JButton("Select Dataset");
selectBtn.setBackground(new Color(50, 120, 50)); ThemeManager.styleButton(selectBtn, ThemeManager.ButtonVariant.PRIMARY);
selectBtn.setForeground(Color.WHITE);
selectBtn.setFont(font); selectBtn.setFont(font);
selectBtn.addActionListener(e -> onConfirmSelection()); selectBtn.addActionListener(e -> onConfirmSelection());
JButton cancelBtn = new JButton("Cancel"); JButton cancelBtn = new JButton("Cancel");
cancelBtn.setBackground(new Color(60, 60, 60)); ThemeManager.styleButton(cancelBtn, ThemeManager.ButtonVariant.CANCEL);
cancelBtn.setForeground(fg);
cancelBtn.setFont(font); cancelBtn.setFont(font);
cancelBtn.addActionListener(e -> { cancelBtn.addActionListener(e -> {
confirmed = false; confirmed = false;
@@ -176,6 +155,7 @@ public class HostDirectoryDialog extends JDialog {
mainPanel.add(bottomPanel, BorderLayout.SOUTH); mainPanel.add(bottomPanel, BorderLayout.SOUTH);
setContentPane(mainPanel); setContentPane(mainPanel);
ThemeManager.applyThemeToWindow(this);
// Initial setup // Initial setup
setupTableColumns(); setupTableColumns();
@@ -45,10 +45,6 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
// Spool Display // Spool Display
private JTextArea spoolArea; private JTextArea spoolArea;
private static final Color DARK_BG = new Color(35, 35, 35);
private static final Color DARK_FG = new Color(220, 220, 220);
private static final Color DARK_FIELD_BG = new Color(45, 45, 45);
public PrinterSessionDialog(Frame parent, String defaultHost, int defaultPort, boolean defaultTls) { public PrinterSessionDialog(Frame parent, String defaultHost, int defaultPort, boolean defaultTls) {
super(parent, "IBM 3287 Printer Session Manager", false); super(parent, "IBM 3287 Printer Session Manager", false);
this.parent = parent; this.parent = parent;
@@ -65,14 +61,11 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
private void buildUI() { private void buildUI() {
JPanel mainPanel = new JPanel(new BorderLayout(10, 10)); JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
mainPanel.setBorder(new EmptyBorder(12, 14, 12, 14)); mainPanel.setBorder(new EmptyBorder(12, 14, 12, 14));
mainPanel.setBackground(DARK_BG);
// Top: Configuration Panel // Top: Configuration Panel
JPanel topPanel = new JPanel(new GridBagLayout()); JPanel topPanel = new JPanel(new GridBagLayout());
topPanel.setOpaque(false); topPanel.setOpaque(false);
topPanel.setBorder(BorderFactory.createTitledBorder( topPanel.setBorder(ThemeManager.createTitledBorder("Printer Session Configuration"));
new LineBorder(new Color(65, 65, 65)), "Printer Session Configuration"));
((TitledBorder) topPanel.getBorder()).setTitleColor(DARK_FG);
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(3, 4, 3, 4); gbc.insets = new Insets(3, 4, 3, 4);
@@ -83,60 +76,59 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
// Host / Port // Host / Port
gbc.gridx = 0; gbc.gridy = 0; gbc.gridx = 0; gbc.gridy = 0;
JLabel hLbl = new JLabel("Host:"); JLabel hLbl = new JLabel("Host:");
hLbl.setForeground(DARK_FG); hLbl.setFont(labelFont); hLbl.setFont(labelFont);
topPanel.add(hLbl, gbc); topPanel.add(hLbl, gbc);
gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridx = 1; gbc.weightx = 1.0;
hostField = createDarkField(config.getHost() != null ? config.getHost() : "localhost", 14); hostField = createField(config.getHost() != null ? config.getHost() : "localhost", 14);
topPanel.add(hostField, gbc); topPanel.add(hostField, gbc);
gbc.gridx = 2; gbc.weightx = 0; gbc.gridx = 2; gbc.weightx = 0;
JLabel pLbl = new JLabel("Port:"); JLabel pLbl = new JLabel("Port:");
pLbl.setForeground(DARK_FG); pLbl.setFont(labelFont); pLbl.setFont(labelFont);
topPanel.add(pLbl, gbc); topPanel.add(pLbl, gbc);
gbc.gridx = 3; gbc.weightx = 0.5; gbc.gridx = 3; gbc.weightx = 0.5;
portField = createDarkField(String.valueOf(config.getPort()), 5); portField = createField(String.valueOf(config.getPort()), 5);
topPanel.add(portField, gbc); topPanel.add(portField, gbc);
// Printer LU / Display LU // Printer LU / Display LU
gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 0; gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 0;
JLabel pluLbl = new JLabel("Printer LU:"); JLabel pluLbl = new JLabel("Printer LU:");
pluLbl.setForeground(DARK_FG); pluLbl.setFont(labelFont); pluLbl.setFont(labelFont);
topPanel.add(pluLbl, gbc); topPanel.add(pluLbl, gbc);
gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridx = 1; gbc.weightx = 1.0;
printerLuField = createDarkField("", 10); printerLuField = createField("", 10);
topPanel.add(printerLuField, gbc); topPanel.add(printerLuField, gbc);
gbc.gridx = 2; gbc.weightx = 0; gbc.gridx = 2; gbc.weightx = 0;
JLabel assocLbl = new JLabel("Assoc LU:"); JLabel assocLbl = new JLabel("Assoc LU:");
assocLbl.setForeground(DARK_FG); assocLbl.setFont(labelFont); assocLbl.setFont(labelFont);
topPanel.add(assocLbl, gbc); topPanel.add(assocLbl, gbc);
gbc.gridx = 3; gbc.weightx = 0.5; gbc.gridx = 3; gbc.weightx = 0.5;
displayLuField = createDarkField("", 10); displayLuField = createField("", 10);
topPanel.add(displayLuField, gbc); topPanel.add(displayLuField, gbc);
// CodePage & TLS // CodePage & TLS
gbc.gridx = 0; gbc.gridy = 2; gbc.weightx = 0; gbc.gridx = 0; gbc.gridy = 2; gbc.weightx = 0;
JLabel cpLbl = new JLabel("CodePage:"); JLabel cpLbl = new JLabel("CodePage:");
cpLbl.setForeground(DARK_FG); cpLbl.setFont(labelFont); cpLbl.setFont(labelFont);
topPanel.add(cpLbl, gbc); topPanel.add(cpLbl, gbc);
gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridx = 1; gbc.weightx = 1.0;
codePageCombo = new JComboBox<>(new String[]{"037", "1047", "500", "273", "277", "278", "280", "284", "285", "297", "870", "1140"}); codePageCombo = new JComboBox<>(new String[]{"037", "1047", "500", "273", "277", "278", "280", "284", "285", "297", "870", "1140"});
codePageCombo.setBackground(DARK_FIELD_BG); ThemeManager.styleComboBox(codePageCombo);
codePageCombo.setForeground(DARK_FG);
topPanel.add(codePageCombo, gbc); topPanel.add(codePageCombo, gbc);
gbc.gridx = 2; gbc.gridwidth = 2; gbc.gridx = 2; gbc.gridwidth = 2;
JPanel tlsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 0)); JPanel tlsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 0));
tlsPanel.setOpaque(false); tlsPanel.setOpaque(false);
tlsCheck = new JCheckBox("TLS/SSL", config.isUseTls()); tlsCheck = new JCheckBox("TLS/SSL", config.isUseTls());
tlsCheck.setOpaque(false); tlsCheck.setForeground(DARK_FG); tlsCheck.setFocusPainted(false); ThemeManager.styleCheckBox(tlsCheck);
verifyCertCheck = new JCheckBox("Verify Cert", config.isTlsVerifyCert()); verifyCertCheck = new JCheckBox("Verify Cert", config.isTlsVerifyCert());
verifyCertCheck.setOpaque(false); verifyCertCheck.setForeground(DARK_FG); verifyCertCheck.setFocusPainted(false); ThemeManager.styleCheckBox(verifyCertCheck);
tlsPanel.add(tlsCheck); tlsPanel.add(tlsCheck);
tlsPanel.add(verifyCertCheck); tlsPanel.add(verifyCertCheck);
topPanel.add(tlsPanel, gbc); topPanel.add(tlsPanel, gbc);
@@ -144,23 +136,22 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
// Destination Type & Target // Destination Type & Target
gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 1; gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 1;
JLabel destLbl = new JLabel("Destination:"); JLabel destLbl = new JLabel("Destination:");
destLbl.setForeground(DARK_FG); destLbl.setFont(labelFont); destLbl.setFont(labelFont);
topPanel.add(destLbl, gbc); topPanel.add(destLbl, gbc);
gbc.gridx = 1; gbc.gridx = 1;
destinationCombo = new JComboBox<>(PrinterConfig.DestinationType.values()); destinationCombo = new JComboBox<>(PrinterConfig.DestinationType.values());
destinationCombo.setSelectedItem(PrinterConfig.DestinationType.MEMORY); destinationCombo.setSelectedItem(PrinterConfig.DestinationType.MEMORY);
destinationCombo.setBackground(DARK_FIELD_BG); ThemeManager.styleComboBox(destinationCombo);
destinationCombo.setForeground(DARK_FG);
topPanel.add(destinationCombo, gbc); topPanel.add(destinationCombo, gbc);
gbc.gridx = 2; gbc.gridx = 2;
JLabel tgtLbl = new JLabel("Target Path:"); JLabel tgtLbl = new JLabel("Target Path:");
tgtLbl.setForeground(DARK_FG); tgtLbl.setFont(labelFont); tgtLbl.setFont(labelFont);
topPanel.add(tgtLbl, gbc); topPanel.add(tgtLbl, gbc);
gbc.gridx = 3; gbc.gridx = 3;
targetField = createDarkField("printer_output.txt", 12); targetField = createField("printer_output.txt", 12);
topPanel.add(targetField, gbc); topPanel.add(targetField, gbc);
// Connect / Disconnect Buttons // Connect / Disconnect Buttons
@@ -169,13 +160,11 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
connBtnPan.setOpaque(false); connBtnPan.setOpaque(false);
connectBtn = new JButton("Start Printer Session"); connectBtn = new JButton("Start Printer Session");
connectBtn.setBackground(new Color(50, 120, 50)); ThemeManager.styleButton(connectBtn, ThemeManager.ButtonVariant.PRIMARY);
connectBtn.setForeground(Color.WHITE);
connectBtn.addActionListener(e -> startPrinterSession()); connectBtn.addActionListener(e -> startPrinterSession());
disconnectBtn = new JButton("Stop Session"); disconnectBtn = new JButton("Stop Session");
disconnectBtn.setBackground(new Color(120, 50, 50)); ThemeManager.styleButton(disconnectBtn, ThemeManager.ButtonVariant.DANGER);
disconnectBtn.setForeground(Color.WHITE);
disconnectBtn.setEnabled(false); disconnectBtn.setEnabled(false);
disconnectBtn.addActionListener(e -> stopPrinterSession()); disconnectBtn.addActionListener(e -> stopPrinterSession());
@@ -188,9 +177,7 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
// Center: Spool Area & Status // Center: Spool Area & Status
JPanel centerPanel = new JPanel(new BorderLayout(6, 6)); JPanel centerPanel = new JPanel(new BorderLayout(6, 6));
centerPanel.setOpaque(false); centerPanel.setOpaque(false);
centerPanel.setBorder(BorderFactory.createTitledBorder( centerPanel.setBorder(ThemeManager.createTitledBorder("Printer Spool & Status"));
new LineBorder(new Color(65, 65, 65)), "Printer Spool & Status"));
((TitledBorder) centerPanel.getBorder()).setTitleColor(DARK_FG);
// Status Header // Status Header
JPanel statusHeader = new JPanel(new GridLayout(1, 4, 10, 0)); JPanel statusHeader = new JPanel(new GridLayout(1, 4, 10, 0));
@@ -198,19 +185,16 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
statusHeader.setBorder(new EmptyBorder(0, 4, 4, 4)); statusHeader.setBorder(new EmptyBorder(0, 4, 4, 4));
statusLabel = new JLabel("Status: Disconnected"); statusLabel = new JLabel("Status: Disconnected");
statusLabel.setForeground(new Color(180, 180, 180)); statusLabel.setForeground(ThemeManager.getFgMuted());
statusLabel.setFont(labelFont); statusLabel.setFont(labelFont);
sessionTypeLabel = new JLabel("Session: -"); sessionTypeLabel = new JLabel("Session: -");
sessionTypeLabel.setForeground(DARK_FG);
sessionTypeLabel.setFont(labelFont); sessionTypeLabel.setFont(labelFont);
pagesLabel = new JLabel("Pages: 0"); pagesLabel = new JLabel("Pages: 0");
pagesLabel.setForeground(DARK_FG);
pagesLabel.setFont(labelFont); pagesLabel.setFont(labelFont);
bytesLabel = new JLabel("Bytes: 0"); bytesLabel = new JLabel("Bytes: 0");
bytesLabel.setForeground(DARK_FG);
bytesLabel.setFont(labelFont); bytesLabel.setFont(labelFont);
statusHeader.add(statusLabel); statusHeader.add(statusLabel);
@@ -221,14 +205,12 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
// Spool text area // Spool text area
spoolArea = new JTextArea(); spoolArea = new JTextArea();
spoolArea.setBackground(new Color(25, 25, 25));
spoolArea.setForeground(new Color(100, 255, 100));
spoolArea.setCaretColor(Color.WHITE);
spoolArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); spoolArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
spoolArea.setEditable(false); spoolArea.setEditable(false);
ThemeManager.styleTextArea(spoolArea);
JScrollPane spoolScroll = new JScrollPane(spoolArea); JScrollPane spoolScroll = new JScrollPane(spoolArea);
spoolScroll.setBorder(new LineBorder(new Color(60, 60, 60))); ThemeManager.styleScrollPane(spoolScroll);
centerPanel.add(spoolScroll, BorderLayout.CENTER); centerPanel.add(spoolScroll, BorderLayout.CENTER);
mainPanel.add(centerPanel, BorderLayout.CENTER); mainPanel.add(centerPanel, BorderLayout.CENTER);
@@ -238,8 +220,7 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
bottomPanel.setOpaque(false); bottomPanel.setOpaque(false);
JButton clearSpoolBtn = new JButton("Clear Spool"); JButton clearSpoolBtn = new JButton("Clear Spool");
clearSpoolBtn.setBackground(new Color(50, 50, 50)); ThemeManager.styleButton(clearSpoolBtn, ThemeManager.ButtonVariant.DEFAULT);
clearSpoolBtn.setForeground(DARK_FG);
clearSpoolBtn.addActionListener(e -> { clearSpoolBtn.addActionListener(e -> {
spoolArea.setText(""); spoolArea.setText("");
if (printerSession != null && printerSession.getPD() != null) { if (printerSession != null && printerSession.getPD() != null) {
@@ -250,18 +231,15 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
}); });
JButton saveSpoolBtn = new JButton("Save Spool As..."); JButton saveSpoolBtn = new JButton("Save Spool As...");
saveSpoolBtn.setBackground(new Color(50, 50, 50)); ThemeManager.styleButton(saveSpoolBtn, ThemeManager.ButtonVariant.DEFAULT);
saveSpoolBtn.setForeground(DARK_FG);
saveSpoolBtn.addActionListener(e -> saveSpool()); saveSpoolBtn.addActionListener(e -> saveSpool());
JButton printSpoolBtn = new JButton("Print Spool..."); JButton printSpoolBtn = new JButton("Print Spool...");
printSpoolBtn.setBackground(new Color(50, 100, 160)); ThemeManager.styleButton(printSpoolBtn, ThemeManager.ButtonVariant.DEFAULT);
printSpoolBtn.setForeground(Color.WHITE);
printSpoolBtn.addActionListener(e -> printSpool()); printSpoolBtn.addActionListener(e -> printSpool());
JButton closeBtn = new JButton("Close"); JButton closeBtn = new JButton("Close");
closeBtn.setBackground(new Color(60, 60, 60)); ThemeManager.styleButton(closeBtn, ThemeManager.ButtonVariant.CANCEL);
closeBtn.setForeground(DARK_FG);
closeBtn.addActionListener(e -> dispose()); closeBtn.addActionListener(e -> dispose());
bottomPanel.add(clearSpoolBtn); bottomPanel.add(clearSpoolBtn);
@@ -273,17 +251,13 @@ public class PrinterSessionDialog extends JDialog implements PrintSessionListene
mainPanel.add(bottomPanel, BorderLayout.SOUTH); mainPanel.add(bottomPanel, BorderLayout.SOUTH);
setContentPane(mainPanel); setContentPane(mainPanel);
ThemeManager.applyThemeToWindow(this);
} }
private JTextField createDarkField(String text, int cols) { private JTextField createField(String text, int cols) {
JTextField tf = new JTextField(text, cols); JTextField tf = new JTextField(text, cols);
tf.setBackground(DARK_FIELD_BG);
tf.setForeground(DARK_FG);
tf.setCaretColor(DARK_FG);
tf.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); tf.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
tf.setBorder(BorderFactory.createCompoundBorder( ThemeManager.styleTextField(tf);
new LineBorder(new Color(65, 65, 65)),
new EmptyBorder(2, 4, 2, 4)));
return tf; return tf;
} }
@@ -98,19 +98,21 @@ public class ScreenExporter {
writer.write("<style>\n"); writer.write("<style>\n");
writer.write("body { background-color: #0a0a0a; color: #32cd32; font-family: 'Courier New', Courier, monospace; font-size: 14px; margin: 20px; }\n"); writer.write("body { background-color: #0a0a0a; color: #32cd32; font-family: 'Courier New', Courier, monospace; font-size: 14px; margin: 20px; }\n");
writer.write(".screen { background-color: #000; padding: 15px; border-radius: 4px; display: inline-block; box-shadow: 0 0 10px rgba(0,0,0,0.8); line-height: 1.2; }\n"); writer.write(".screen { background-color: #000; padding: 15px; border-radius: 4px; display: inline-block; box-shadow: 0 0 10px rgba(0,0,0,0.8); line-height: 1.2; }\n");
writer.write(".c-blue { color: #5078ff; }\n"); writer.write(".c-blue { color: #7890f0; }\n");
writer.write(".c-red { color: #ff3232; }\n"); writer.write(".c-red { color: #ff0000; }\n");
writer.write(".c-pink { color: #ff82b4; }\n"); writer.write(".c-pink { color: #ff00ff; }\n");
writer.write(".c-green { color: #32cd32; }\n"); writer.write(".c-green { color: #00ff00; }\n");
writer.write(".c-turq { color: #40e0d0; }\n"); writer.write(".c-turq { color: #00ffff; }\n");
writer.write(".c-yellow { color: #ffff50; }\n"); writer.write(".c-yellow { color: #ffff00; }\n");
writer.write(".c-white { color: #ffffff; }\n"); writer.write(".c-white { color: #ffffff; }\n");
writer.write(".c-black { color: #000000; }\n"); writer.write(".c-black { color: #000000; }\n");
writer.write(".c-orange { color: #ffa500; }\n"); writer.write(".c-deepblue { color: #000080; }\n");
writer.write(".c-purple { color: #b482ff; }\n"); writer.write(".c-orange { color: #ffa200; }\n");
writer.write(".c-palegreen { color: #90ee90; }\n"); writer.write(".c-purple { color: #800080; }\n");
writer.write(".c-paleturq { color: #afeeee; }\n"); writer.write(".c-palegreen { color: #008000; }\n");
writer.write(".c-grey { color: #aaaaaa; }\n"); writer.write(".c-paleturq { color: #008080; }\n");
writer.write(".c-mustard { color: #a0a000; }\n");
writer.write(".c-grey { color: #c0c0c0; }\n");
writer.write(".bold { font-weight: bold; }\n"); writer.write(".bold { font-weight: bold; }\n");
writer.write(".underline { text-decoration: underline; }\n"); writer.write(".underline { text-decoration: underline; }\n");
writer.write("</style>\n</head>\n<body>\n<div class=\"screen\"><pre>"); writer.write("</style>\n</head>\n<body>\n<div class=\"screen\"><pre>");
@@ -209,17 +211,17 @@ public class ScreenExporter {
case 6: return "c-yellow"; case 6: return "c-yellow";
case 7: return "c-white"; case 7: return "c-white";
case 8: return "c-black"; case 8: return "c-black";
case 9: return "c-blue"; case 9: return "c-deepblue";
case 10: return "c-orange"; case 10: return "c-orange";
case 11: return "c-purple"; case 11: return "c-purple";
case 12: return "c-palegreen"; case 12: return "c-palegreen";
case 13: return "c-paleturq"; case 13: return "c-paleturq";
case 14: return "c-grey"; case 14: return "c-mustard";
case 15: return "c-white"; case 15: return "c-grey";
} }
} }
if (faIsProtected(currentFA & 0xFF)) { if (faIsProtected(currentFA & 0xFF)) {
return faIsHigh(currentFA & 0xFF) ? "c-white" : "c-blue"; return faIsHigh(currentFA & 0xFF) ? "c-white" : "c-turq";
} }
return faIsHigh(currentFA & 0xFF) ? "c-red" : "c-green"; return faIsHigh(currentFA & 0xFF) ? "c-red" : "c-green";
} }
@@ -34,9 +34,7 @@ public class ScriptDialog extends JDialog {
private void buildUI() { private void buildUI() {
JPanel mainPanel = new JPanel(new BorderLayout(10, 10)); JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
mainPanel.setBorder(new EmptyBorder(12, 14, 12, 14)); mainPanel.setBorder(new EmptyBorder(12, 14, 12, 14));
mainPanel.setBackground(new Color(35, 35, 35));
Color fg = new Color(220, 220, 220);
Font labelFont = new Font(Font.SANS_SERIF, Font.PLAIN, 13); Font labelFont = new Font(Font.SANS_SERIF, Font.PLAIN, 13);
// Header // Header
@@ -44,31 +42,24 @@ public class ScriptDialog extends JDialog {
topPanel.setOpaque(false); topPanel.setOpaque(false);
JLabel descLabel = new JLabel("<html>Compose keystrokes and ECL bracketed mnemonics to stream to the mainframe.<br>" JLabel descLabel = new JLabel("<html>Compose keystrokes and ECL bracketed mnemonics to stream to the mainframe.<br>"
+ "Example: <code>TSO[enter]USER[tab]PASSWORD[enter]</code> or <code>[pf3][clear]</code></html>"); + "Example: <code>TSO[enter]USER[tab]PASSWORD[enter]</code> or <code>[pf3][clear]</code></html>");
descLabel.setForeground(new Color(180, 180, 180));
descLabel.setFont(labelFont); descLabel.setFont(labelFont);
topPanel.add(descLabel, BorderLayout.CENTER); topPanel.add(descLabel, BorderLayout.CENTER);
mainPanel.add(topPanel, BorderLayout.NORTH); mainPanel.add(topPanel, BorderLayout.NORTH);
// Script area // Script area
scriptArea = new JTextArea(); scriptArea = new JTextArea();
scriptArea.setBackground(new Color(25, 25, 25));
scriptArea.setForeground(new Color(50, 205, 50));
scriptArea.setCaretColor(Color.WHITE);
scriptArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); scriptArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13));
scriptArea.setLineWrap(true); scriptArea.setLineWrap(true);
scriptArea.setWrapStyleWord(false); scriptArea.setWrapStyleWord(false);
ThemeManager.styleTextArea(scriptArea);
JScrollPane scrollPane = new JScrollPane(scriptArea); JScrollPane scrollPane = new JScrollPane(scriptArea);
scrollPane.setBorder(BorderFactory.createCompoundBorder( ThemeManager.styleScrollPane(scrollPane);
new LineBorder(new Color(60, 60, 60)),
new EmptyBorder(2, 2, 2, 2)));
// Mnemonic helper buttons // Mnemonic helper buttons
JPanel tokenPanel = new JPanel(new WrapLayout(FlowLayout.LEFT, 4, 4)); JPanel tokenPanel = new JPanel(new WrapLayout(FlowLayout.LEFT, 4, 4));
tokenPanel.setOpaque(false); tokenPanel.setOpaque(false);
tokenPanel.setBorder(BorderFactory.createTitledBorder( tokenPanel.setBorder(ThemeManager.createTitledBorder("Insert Keystroke Token"));
new LineBorder(new Color(60, 60, 60)), "Insert Keystroke Token"));
((TitledBorder) tokenPanel.getBorder()).setTitleColor(new Color(180, 180, 180));
String[] tokens = { String[] tokens = {
"[enter]", "[tab]", "[backtab]", "[clear]", "[reset]", "[enter]", "[tab]", "[backtab]", "[clear]", "[reset]",
@@ -84,8 +75,7 @@ public class ScriptDialog extends JDialog {
for (String token : tokens) { for (String token : tokens) {
JButton btn = new JButton(token); JButton btn = new JButton(token);
btn.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11)); btn.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
btn.setBackground(new Color(50, 50, 50)); ThemeManager.styleButton(btn, ThemeManager.ButtonVariant.DEFAULT);
btn.setForeground(fg);
btn.setFocusable(false); btn.setFocusable(false);
btn.setMargin(new Insets(2, 4, 2, 4)); btn.setMargin(new Insets(2, 4, 2, 4));
btn.addActionListener(e -> insertToken(token)); btn.addActionListener(e -> insertToken(token));
@@ -103,7 +93,7 @@ public class ScriptDialog extends JDialog {
bottomPanel.setOpaque(false); bottomPanel.setOpaque(false);
statusLabel = new JLabel("Ready"); statusLabel = new JLabel("Ready");
statusLabel.setForeground(new Color(160, 160, 160)); statusLabel.setForeground(ThemeManager.getFgMuted());
statusLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); statusLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
bottomPanel.add(statusLabel, BorderLayout.WEST); bottomPanel.add(statusLabel, BorderLayout.WEST);
@@ -111,26 +101,22 @@ public class ScriptDialog extends JDialog {
buttonPanel.setOpaque(false); buttonPanel.setOpaque(false);
JButton loadBtn = new JButton("Load Script..."); JButton loadBtn = new JButton("Load Script...");
loadBtn.setBackground(new Color(50, 50, 50)); ThemeManager.styleButton(loadBtn, ThemeManager.ButtonVariant.DEFAULT);
loadBtn.setForeground(fg);
loadBtn.setFont(labelFont); loadBtn.setFont(labelFont);
loadBtn.addActionListener(e -> loadScript()); loadBtn.addActionListener(e -> loadScript());
JButton saveBtn = new JButton("Save Script..."); JButton saveBtn = new JButton("Save Script...");
saveBtn.setBackground(new Color(50, 50, 50)); ThemeManager.styleButton(saveBtn, ThemeManager.ButtonVariant.DEFAULT);
saveBtn.setForeground(fg);
saveBtn.setFont(labelFont); saveBtn.setFont(labelFont);
saveBtn.addActionListener(e -> saveScript()); saveBtn.addActionListener(e -> saveScript());
JButton runBtn = new JButton("Execute"); JButton runBtn = new JButton("Execute");
runBtn.setBackground(new Color(50, 120, 50)); ThemeManager.styleButton(runBtn, ThemeManager.ButtonVariant.PRIMARY);
runBtn.setForeground(Color.WHITE);
runBtn.setFont(labelFont); runBtn.setFont(labelFont);
runBtn.addActionListener(e -> executeScript()); runBtn.addActionListener(e -> executeScript());
JButton closeBtn = new JButton("Close"); JButton closeBtn = new JButton("Close");
closeBtn.setBackground(new Color(60, 60, 60)); ThemeManager.styleButton(closeBtn, ThemeManager.ButtonVariant.CANCEL);
closeBtn.setForeground(fg);
closeBtn.setFont(labelFont); closeBtn.setFont(labelFont);
closeBtn.addActionListener(e -> dispose()); closeBtn.addActionListener(e -> dispose());
@@ -144,6 +130,7 @@ public class ScriptDialog extends JDialog {
mainPanel.add(bottomPanel, BorderLayout.SOUTH); mainPanel.add(bottomPanel, BorderLayout.SOUTH);
setContentPane(mainPanel); setContentPane(mainPanel);
ThemeManager.applyThemeToWindow(this);
} }
private void insertToken(String token) { private void insertToken(String token) {
@@ -19,16 +19,8 @@ public class SettingsDialog extends JDialog {
private final J3270App parentApp; private final J3270App parentApp;
// Dark theme colors
private static final Color DARK_BG = new Color(43, 43, 43);
private static final Color DARK_BG_LIGHTER = new Color(55, 55, 55);
private static final Color DARK_FG = new Color(224, 224, 224);
private static final Color DARK_BORDER = new Color(70, 70, 70);
private static final Color DARK_SELECTION = new Color(75, 110, 175);
private static final Color DARK_BUTTON_BG = new Color(60, 63, 65);
private static final Color DARK_FIELD_BG = new Color(50, 50, 50);
// Appearance tab // Appearance tab
private JComboBox<UITheme> uiThemeBox;
private JComboBox<String> fontBox; private JComboBox<String> fontBox;
private JSpinner fontSizeSpinner; private JSpinner fontSizeSpinner;
private JComboBox<haus.nightmare.lib3270j.graphics.GraphicsMode> graphicsModeBox; private JComboBox<haus.nightmare.lib3270j.graphics.GraphicsMode> graphicsModeBox;
@@ -39,6 +31,8 @@ public class SettingsDialog extends JDialog {
private JTextField hostField; private JTextField hostField;
private JTextField portField; private JTextField portField;
private JCheckBox blockSelectCheck; private JCheckBox blockSelectCheck;
private JSpinner dynamicRowsSpinner;
private JSpinner dynamicColsSpinner;
// Advanced tab state tracking // Advanced tab state tracking
private final Color[] tempHostColors = new Color[16]; private final Color[] tempHostColors = new Color[16];
@@ -51,22 +45,30 @@ public class SettingsDialog extends JDialog {
this.parentApp = parent; this.parentApp = parent;
initComponents(); initComponents();
setSize(550, 450); setSize(560, 480);
setLocationRelativeTo(parent); setLocationRelativeTo(parent);
} }
private void initComponents() { private void initComponents() {
JTabbedPane tabbedPane = new JTabbedPane(); JTabbedPane tabbedPane = new JTabbedPane();
ThemeManager.styleTabbedPane(tabbedPane);
tabbedPane.addTab("Appearance", createAppearancePanel()); tabbedPane.addTab("Appearance", createAppearancePanel());
tabbedPane.addTab("Behavior", createBehaviorPanel()); tabbedPane.addTab("Behavior", createBehaviorPanel());
tabbedPane.addTab("Advanced", createAdvancedPanel()); tabbedPane.addTab("Advanced", createAdvancedPanel());
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 8));
JButton btnExport = new JButton("Export Config..."); JButton btnExport = new JButton("Export Config...");
JButton btnOk = new JButton("OK"); ThemeManager.styleButton(btnExport, ThemeManager.ButtonVariant.DEFAULT);
JButton btnApply = new JButton("Apply"); JButton btnApply = new JButton("Apply");
ThemeManager.styleButton(btnApply, ThemeManager.ButtonVariant.DEFAULT);
JButton btnCancel = new JButton("Cancel"); JButton btnCancel = new JButton("Cancel");
ThemeManager.styleButton(btnCancel, ThemeManager.ButtonVariant.CANCEL);
JButton btnOk = new JButton("OK");
ThemeManager.styleButton(btnOk, ThemeManager.ButtonVariant.PRIMARY);
btnExport.addActionListener((ActionEvent e) -> { btnExport.addActionListener((ActionEvent e) -> {
exportConfig(); exportConfig();
@@ -96,132 +98,11 @@ public class SettingsDialog extends JDialog {
getContentPane().add(tabbedPane, BorderLayout.CENTER); getContentPane().add(tabbedPane, BorderLayout.CENTER);
getContentPane().add(buttonPanel, BorderLayout.SOUTH); getContentPane().add(buttonPanel, BorderLayout.SOUTH);
// Apply dark theme to all components for cross-platform readability ThemeManager.applyThemeToWindow(this);
applyDarkTheme(getContentPane());
applyDarkTheme(tabbedPane);
applyDarkTheme(buttonPanel);
getContentPane().setBackground(DARK_BG);
} }
// ========== Dark Theme Utility ==========
/**
* Recursively apply dark theme to a component and all its children.
* Ensures the Settings dialog is readable on Windows, Linux, and macOS.
*/
private void applyDarkTheme(Component comp) { private void applyDarkTheme(Component comp) {
if (comp instanceof JTabbedPane) { ThemeManager.applyTheme(comp);
JTabbedPane tp = (JTabbedPane) comp;
tp.setBackground(DARK_BG);
tp.setForeground(DARK_FG);
for (int i = 0; i < tp.getTabCount(); i++) {
applyDarkTheme(tp.getComponentAt(i));
}
return;
}
if (comp instanceof JTable) {
JTable table = (JTable) comp;
table.setBackground(DARK_FIELD_BG);
table.setForeground(DARK_FG);
table.setSelectionBackground(DARK_SELECTION);
table.setSelectionForeground(Color.WHITE);
table.setGridColor(DARK_BORDER);
JTableHeader header = table.getTableHeader();
if (header != null) {
header.setBackground(DARK_BG_LIGHTER);
header.setForeground(DARK_FG);
DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer();
headerRenderer.setBackground(DARK_BG_LIGHTER);
headerRenderer.setForeground(DARK_FG);
header.setDefaultRenderer(headerRenderer);
}
return;
}
if (comp instanceof JScrollPane) {
JScrollPane sp = (JScrollPane) comp;
sp.setBackground(DARK_BG);
sp.getViewport().setBackground(DARK_FIELD_BG);
applyDarkTheme(sp.getViewport().getView());
return;
}
if (comp instanceof JButton) {
JButton btn = (JButton) comp;
btn.setBackground(DARK_BUTTON_BG);
btn.setForeground(DARK_FG);
btn.setFocusPainted(false);
btn.setBorder(BorderFactory.createCompoundBorder(
new LineBorder(DARK_BORDER, 1),
BorderFactory.createEmptyBorder(3, 10, 3, 10)));
btn.setOpaque(true);
return;
}
if (comp instanceof JComboBox) {
JComboBox<?> cb = (JComboBox<?>) comp;
cb.setBackground(DARK_FIELD_BG);
cb.setForeground(DARK_FG);
return;
}
if (comp instanceof JSpinner) {
JSpinner sp = (JSpinner) comp;
sp.setBackground(DARK_FIELD_BG);
sp.setForeground(DARK_FG);
JComponent editor = sp.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField();
tf.setBackground(DARK_FIELD_BG);
tf.setForeground(DARK_FG);
tf.setCaretColor(DARK_FG);
}
return;
}
if (comp instanceof JTextField) {
JTextField tf = (JTextField) comp;
tf.setBackground(DARK_FIELD_BG);
tf.setForeground(DARK_FG);
tf.setCaretColor(DARK_FG);
return;
}
if (comp instanceof JCheckBox) {
JCheckBox cb = (JCheckBox) comp;
cb.setBackground(DARK_BG);
cb.setForeground(DARK_FG);
return;
}
if (comp instanceof JLabel) {
comp.setForeground(DARK_FG);
return;
}
// Generic panel / container
// Skip color swatch panels their background IS the color
if (comp instanceof JPanel && "colorSwatch".equals(comp.getName())) {
return;
}
comp.setBackground(DARK_BG);
comp.setForeground(DARK_FG);
if (comp instanceof JPanel) {
JPanel panel = (JPanel) comp;
// Style titled borders
if (panel.getBorder() instanceof TitledBorder) {
TitledBorder tb = (TitledBorder) panel.getBorder();
tb.setTitleColor(DARK_FG);
}
}
if (comp instanceof Container) {
for (Component child : ((Container) comp).getComponents()) {
applyDarkTheme(child);
}
}
} }
// ========== Tab Panels ========== // ========== Tab Panels ==========
@@ -232,9 +113,22 @@ public class SettingsDialog extends JDialog {
gbc.insets = new Insets(10, 10, 10, 10); gbc.insets = new Insets(10, 10, 10, 10);
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
// Font family // UI Theme
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 0; gbc.gridy = 0;
JLabel themeLabel = new JLabel("Java UI Theme:");
panel.add(themeLabel, gbc);
uiThemeBox = new JComboBox<>(UITheme.values());
uiThemeBox.setSelectedItem(Settings.getJavaUiTheme());
gbc.gridx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
panel.add(uiThemeBox, gbc);
// Font family
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.NONE;
JLabel fontLabel = new JLabel("Terminal Font:"); JLabel fontLabel = new JLabel("Terminal Font:");
panel.add(fontLabel, gbc); panel.add(fontLabel, gbc);
@@ -254,7 +148,7 @@ public class SettingsDialog extends JDialog {
// Font size // Font size
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 1; gbc.gridy = 2;
gbc.fill = GridBagConstraints.NONE; gbc.fill = GridBagConstraints.NONE;
JLabel sizeLabel = new JLabel("Font Size:"); JLabel sizeLabel = new JLabel("Font Size:");
panel.add(sizeLabel, gbc); panel.add(sizeLabel, gbc);
@@ -267,7 +161,7 @@ public class SettingsDialog extends JDialog {
// Graphics Mode // Graphics Mode
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 2; gbc.gridy = 3;
gbc.fill = GridBagConstraints.NONE; gbc.fill = GridBagConstraints.NONE;
JLabel graphicsLabel = new JLabel("Graphics Mode:"); JLabel graphicsLabel = new JLabel("Graphics Mode:");
panel.add(graphicsLabel, gbc); panel.add(graphicsLabel, gbc);
@@ -279,7 +173,7 @@ public class SettingsDialog extends JDialog {
panel.add(graphicsModeBox, gbc); panel.add(graphicsModeBox, gbc);
// Fill remaining space // Fill remaining space
gbc.gridy = 3; gbc.gridy = 4;
gbc.weighty = 1.0; gbc.weighty = 1.0;
panel.add(Box.createGlue(), gbc); panel.add(Box.createGlue(), gbc);
@@ -343,8 +237,30 @@ public class SettingsDialog extends JDialog {
blockSelectCheck = new JCheckBox("Block selection mode (rectangular select)", Settings.getBlockSelectMode()); blockSelectCheck = new JCheckBox("Block selection mode (rectangular select)", Settings.getBlockSelectMode());
panel.add(blockSelectCheck, gbc); panel.add(blockSelectCheck, gbc);
// Placeholder for potentially more behavior options below // Default Dynamic Screen Size
gbc.gridy = 3; gbc.gridy = 3;
gbc.gridwidth = 1;
gbc.gridx = 0;
panel.add(new JLabel("Default Dynamic Screen:"), gbc);
JPanel dynDimPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 6, 0));
dynDimPanel.setOpaque(false);
dynDimPanel.add(new JLabel("Rows:"));
dynamicRowsSpinner = new JSpinner(new SpinnerNumberModel(Settings.getDynamicRows(), 24, 255, 1));
ThemeManager.styleSpinner(dynamicRowsSpinner);
dynDimPanel.add(dynamicRowsSpinner);
dynDimPanel.add(new JLabel("Cols:"));
dynamicColsSpinner = new JSpinner(new SpinnerNumberModel(Settings.getDynamicCols(), 80, 255, 1));
ThemeManager.styleSpinner(dynamicColsSpinner);
dynDimPanel.add(dynamicColsSpinner);
gbc.gridx = 1;
panel.add(dynDimPanel, gbc);
// Placeholder for potentially more behavior options below
gbc.gridx = 0;
gbc.gridy = 4;
gbc.gridwidth = 2;
gbc.weighty = 1.0; gbc.weighty = 1.0;
panel.add(Box.createGlue(), gbc); panel.add(Box.createGlue(), gbc);
@@ -429,6 +345,7 @@ public class SettingsDialog extends JDialog {
JPanel resetPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JPanel resetPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JButton btnResetColors = new JButton("Reset to Defaults"); JButton btnResetColors = new JButton("Reset to Defaults");
ThemeManager.styleButton(btnResetColors, ThemeManager.ButtonVariant.DEFAULT);
btnResetColors.addActionListener(e -> { btnResetColors.addActionListener(e -> {
for (int i=0; i<16; i++) { for (int i=0; i<16; i++) {
tempHostColors[i] = TerminalPanel.DEFAULT_HOST_COLORS[i]; tempHostColors[i] = TerminalPanel.DEFAULT_HOST_COLORS[i];
@@ -436,8 +353,6 @@ public class SettingsDialog extends JDialog {
for (int i=0; i<monoKeys.length; i++) { for (int i=0; i<monoKeys.length; i++) {
tempMonoColors.put(monoKeys[i], monoDefs[i]); tempMonoColors.put(monoKeys[i], monoDefs[i]);
} }
// Repaint container implicitly handled if we trigger a UI update,
// but for simplicity user can just close/reopen or have it refresh on save
JOptionPane.showMessageDialog(main, "Colors reset. Click Apply to save."); JOptionPane.showMessageDialog(main, "Colors reset. Click Apply to save.");
}); });
resetPanel.add(btnResetColors); resetPanel.add(btnResetColors);
@@ -498,6 +413,7 @@ public class SettingsDialog extends JDialog {
} }
JTable table = new JTable(keymapModel); JTable table = new JTable(keymapModel);
ThemeManager.styleTable(table);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setFillsViewportHeight(true); table.setFillsViewportHeight(true);
@@ -510,9 +426,8 @@ public class SettingsDialog extends JDialog {
captureDialog.setSize(320, 100); captureDialog.setSize(320, 100);
captureDialog.setLocationRelativeTo(this); captureDialog.setLocationRelativeTo(this);
JLabel lbl = new JLabel("Press any key combination now...", SwingConstants.CENTER); JLabel lbl = new JLabel("Press any key combination now...", SwingConstants.CENTER);
lbl.setForeground(DARK_FG);
captureDialog.getContentPane().setBackground(DARK_BG);
captureDialog.add(lbl); captureDialog.add(lbl);
ThemeManager.applyThemeToWindow(captureDialog);
captureDialog.addKeyListener(new KeyAdapter() { captureDialog.addKeyListener(new KeyAdapter() {
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
@@ -532,6 +447,7 @@ public class SettingsDialog extends JDialog {
// Replace Binding sets the action to exactly one new key // Replace Binding sets the action to exactly one new key
JButton btnReplace = new JButton("Replace Binding"); JButton btnReplace = new JButton("Replace Binding");
ThemeManager.styleButton(btnReplace, ThemeManager.ButtonVariant.DEFAULT);
btnReplace.addActionListener(e -> { btnReplace.addActionListener(e -> {
int row = table.getSelectedRow(); int row = table.getSelectedRow();
if (row < 0) return; if (row < 0) return;
@@ -545,6 +461,7 @@ public class SettingsDialog extends JDialog {
// Add Binding appends an additional key to the existing binding(s) // Add Binding appends an additional key to the existing binding(s)
JButton btnAdd = new JButton("Add Binding"); JButton btnAdd = new JButton("Add Binding");
ThemeManager.styleButton(btnAdd, ThemeManager.ButtonVariant.DEFAULT);
btnAdd.addActionListener(e -> { btnAdd.addActionListener(e -> {
int row = table.getSelectedRow(); int row = table.getSelectedRow();
if (row < 0) return; if (row < 0) return;
@@ -565,6 +482,7 @@ public class SettingsDialog extends JDialog {
// Remove Last removes the last comma-separated binding entry // Remove Last removes the last comma-separated binding entry
JButton btnRemoveLast = new JButton("Remove Last"); JButton btnRemoveLast = new JButton("Remove Last");
ThemeManager.styleButton(btnRemoveLast, ThemeManager.ButtonVariant.DEFAULT);
btnRemoveLast.addActionListener(e -> { btnRemoveLast.addActionListener(e -> {
int row = table.getSelectedRow(); int row = table.getSelectedRow();
if (row < 0) return; if (row < 0) return;
@@ -585,6 +503,7 @@ public class SettingsDialog extends JDialog {
// Unbind All clears all bindings for the action // Unbind All clears all bindings for the action
JButton btnUnbind = new JButton("Unbind All"); JButton btnUnbind = new JButton("Unbind All");
ThemeManager.styleButton(btnUnbind, ThemeManager.ButtonVariant.DEFAULT);
btnUnbind.addActionListener(e -> { btnUnbind.addActionListener(e -> {
int row = table.getSelectedRow(); int row = table.getSelectedRow();
if (row < 0) return; if (row < 0) return;
@@ -596,6 +515,7 @@ public class SettingsDialog extends JDialog {
// Reset Keymaps restore all defaults // Reset Keymaps restore all defaults
JButton btnReset = new JButton("Reset All"); JButton btnReset = new JButton("Reset All");
ThemeManager.styleButton(btnReset, ThemeManager.ButtonVariant.DEFAULT);
btnReset.addActionListener(e -> { btnReset.addActionListener(e -> {
for (int row = 0; row < keymapModel.getRowCount(); row++) { for (int row = 0; row < keymapModel.getRowCount(); row++) {
String action = (String) keymapModel.getValueAt(row, 0); String action = (String) keymapModel.getValueAt(row, 0);
@@ -628,6 +548,12 @@ public class SettingsDialog extends JDialog {
private boolean applySettings() { private boolean applySettings() {
try { try {
// Apply Appearance // Apply Appearance
UITheme selectedTheme = (UITheme) uiThemeBox.getSelectedItem();
if (selectedTheme != null) {
Settings.setJavaUiTheme(selectedTheme);
ThemeManager.setTheme(selectedTheme);
}
String fontFam = (String) fontBox.getSelectedItem(); String fontFam = (String) fontBox.getSelectedItem();
if (fontFam != null) { if (fontFam != null) {
Settings.setFontFamily(fontFam); Settings.setFontFamily(fontFam);
@@ -653,6 +579,12 @@ public class SettingsDialog extends JDialog {
// Block select mode // Block select mode
Settings.setBlockSelectMode(blockSelectCheck.isSelected()); Settings.setBlockSelectMode(blockSelectCheck.isSelected());
// Default Dynamic screen dimensions
if (dynamicRowsSpinner != null && dynamicColsSpinner != null) {
Settings.setDynamicRows((Integer) dynamicRowsSpinner.getValue());
Settings.setDynamicCols((Integer) dynamicColsSpinner.getValue());
}
// Propagate visual changes to the app // Propagate visual changes to the app
// Save Colors // Save Colors
for (int i=0; i<16; i++) { for (int i=0; i<16; i++) {
@@ -668,6 +600,7 @@ public class SettingsDialog extends JDialog {
} }
parentApp.getTerminalPanel().reloadSettings(); parentApp.getTerminalPanel().reloadSettings();
ThemeManager.applyThemeToWindow(this);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
@@ -26,29 +26,22 @@ public class StatusBar extends JPanel {
private Telnet3270Client client; private Telnet3270Client client;
private TerminalPanel terminalPanel; private TerminalPanel terminalPanel;
// OIA colors
private static final Color OIA_BG = new Color(20, 20, 20);
private static final Color OIA_FG = new Color(50, 205, 50);
private static final Color OIA_DIM = new Color(80, 80, 80);
private static final Color OIA_ALERT = new Color(255, 80, 80);
private static final Color OIA_WARN = new Color(255, 200, 80);
public StatusBar() { public StatusBar() {
setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
setBackground(OIA_BG); setBackground(ThemeManager.getStatusBarBg());
setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(40, 40, 40))); setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, ThemeManager.getStatusBarBorder()));
setPreferredSize(new Dimension(800, 22)); setPreferredSize(new Dimension(800, 22));
Font oiaFont = new Font(Font.MONOSPACED, Font.PLAIN, 12); Font oiaFont = new Font(Font.MONOSPACED, Font.PLAIN, 12);
connectionStatus = createLabel("Not Connected", oiaFont, OIA_DIM); connectionStatus = createLabel("Not Connected", oiaFont, ThemeManager.getOiaFgDim());
tlsStatus = createLabel("", oiaFont, OIA_FG); tlsStatus = createLabel("", oiaFont, ThemeManager.getOiaFgNormal());
luName = createLabel("", oiaFont, OIA_FG); luName = createLabel("", oiaFont, ThemeManager.getOiaFgNormal());
lockStatus = createLabel("", oiaFont, OIA_ALERT); lockStatus = createLabel("", oiaFont, ThemeManager.getOiaFgAlert());
fieldTypeStatus = createLabel("", oiaFont, OIA_DIM); fieldTypeStatus = createLabel("", oiaFont, ThemeManager.getOiaFgDim());
codePageInfo = createLabel("", oiaFont, OIA_DIM); codePageInfo = createLabel("", oiaFont, ThemeManager.getOiaFgDim());
modelInfo = createLabel("", oiaFont, OIA_DIM); modelInfo = createLabel("", oiaFont, ThemeManager.getOiaFgDim());
cursorPosition = createLabel("001/001 [0000]", oiaFont, OIA_FG); cursorPosition = createLabel("001/001 [0000]", oiaFont, ThemeManager.getOiaFgNormal());
add(Box.createHorizontalStrut(6)); add(Box.createHorizontalStrut(6));
add(connectionStatus); add(connectionStatus);
@@ -82,10 +75,17 @@ public class StatusBar extends JPanel {
updateStatus(); updateStatus();
} }
public void applyTheme(UITheme theme) {
setBackground(ThemeManager.getStatusBarBg(theme));
setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, ThemeManager.getStatusBarBorder(theme)));
updateStatus();
}
public void updateStatus() { public void updateStatus() {
UITheme theme = ThemeManager.getTheme();
if (client == null) { if (client == null) {
connectionStatus.setText("Not Connected"); connectionStatus.setText("Not Connected");
connectionStatus.setForeground(OIA_DIM); connectionStatus.setForeground(ThemeManager.getOiaFgDim(theme));
tlsStatus.setText(""); tlsStatus.setText("");
luName.setText(""); luName.setText("");
lockStatus.setText(""); lockStatus.setText("");
@@ -101,38 +101,38 @@ public class StatusBar extends JPanel {
switch (state) { switch (state) {
case NOT_CONNECTED: case NOT_CONNECTED:
connectionStatus.setText("Not Connected"); connectionStatus.setText("Not Connected");
connectionStatus.setForeground(OIA_DIM); connectionStatus.setForeground(ThemeManager.getOiaFgDim(theme));
break; break;
case TCP_PENDING: case TCP_PENDING:
case TELNET_PENDING: case TELNET_PENDING:
connectionStatus.setText("Connecting..."); connectionStatus.setText("Connecting...");
connectionStatus.setForeground(OIA_ALERT); connectionStatus.setForeground(ThemeManager.getOiaFgAlert(theme));
break; break;
case CONNECTED_3270: case CONNECTED_3270:
connectionStatus.setText("TN3270"); connectionStatus.setText("TN3270");
connectionStatus.setForeground(OIA_FG); connectionStatus.setForeground(ThemeManager.getOiaStatusSysAvail());
break; break;
case CONNECTED_TN3270E: case CONNECTED_TN3270E:
connectionStatus.setText("TN3270E"); connectionStatus.setText("TN3270E");
connectionStatus.setForeground(OIA_FG); connectionStatus.setForeground(ThemeManager.getOiaStatusSysAvail());
break; break;
case CONNECTED_SSCP: case CONNECTED_SSCP:
connectionStatus.setText("SSCP-LU"); connectionStatus.setText("SSCP-LU");
connectionStatus.setForeground(OIA_FG); connectionStatus.setForeground(ThemeManager.getOiaStatusSysAvail());
break; break;
case CONNECTED_NVT: case CONNECTED_NVT:
case CONNECTED_NVT_CHAR: case CONNECTED_NVT_CHAR:
case CONNECTED_E_NVT: case CONNECTED_E_NVT:
connectionStatus.setText("NVT"); connectionStatus.setText("NVT");
connectionStatus.setForeground(OIA_FG); connectionStatus.setForeground(ThemeManager.getOiaStatusSysAvail());
break; break;
case CONNECTED_UNBOUND: case CONNECTED_UNBOUND:
connectionStatus.setText("Unbound"); connectionStatus.setText("Unbound");
connectionStatus.setForeground(OIA_WARN); connectionStatus.setForeground(ThemeManager.getOiaAttention());
break; break;
default: default:
connectionStatus.setText(state.name()); connectionStatus.setText(state.name());
connectionStatus.setForeground(OIA_DIM); connectionStatus.setForeground(ThemeManager.getOiaFgDim(theme));
break; break;
} }
@@ -144,11 +144,11 @@ public class StatusBar extends JPanel {
String protocol = session != null ? session.getProtocol() : "TLS"; String protocol = session != null ? session.getProtocol() : "TLS";
if (verified) { if (verified) {
tlsStatus.setText("🔒 TLS"); tlsStatus.setText("🔒 TLS");
tlsStatus.setForeground(OIA_FG); tlsStatus.setForeground(ThemeManager.getOiaStatusSysAvail());
tlsStatus.setToolTipText(protocol + " / " + cipher + " (Verified)"); tlsStatus.setToolTipText(protocol + " / " + cipher + " (Verified)");
} else { } else {
tlsStatus.setText("🔓 TLS (Unverified)"); tlsStatus.setText("🔓 TLS (Unverified)");
tlsStatus.setForeground(new Color(255, 180, 80)); tlsStatus.setForeground(ThemeManager.getOiaAttention());
tlsStatus.setToolTipText(protocol + " / " + cipher + " (Verification Bypassed)"); tlsStatus.setToolTipText(protocol + " / " + cipher + " (Verification Bypassed)");
} }
} else { } else {
@@ -164,37 +164,46 @@ public class StatusBar extends JPanel {
lu = "LU:" + client.getConfig().getLuName(); lu = "LU:" + client.getConfig().getLuName();
} }
luName.setText(lu); luName.setText(lu);
luName.setForeground(ThemeManager.getOiaStatusSysAvail());
// Lock / Inhibit status // Lock / Inhibit status
int inhibit = client.getOIA().getInputInhibited(); int inhibit = client.getOIA().getInputInhibited();
if (inhibit != ECLConstants.INHIBIT_NOT_INHIBITED) { if (inhibit != ECLConstants.INHIBIT_NOT_INHIBITED) {
Color lockFg = ThemeManager.getOiaInputInhibited(); // White (oII)
switch (inhibit) { switch (inhibit) {
case ECLConstants.INHIBIT_SYSTEM_LOCK: case ECLConstants.INHIBIT_SYSTEM_LOCK:
lockStatus.setText("X SYSTEM"); lockStatus.setText("X SYSTEM");
lockFg = ThemeManager.getOiaInputInhibited(); // White (oII)
break; break;
case ECLConstants.INHIBIT_COMM_CHECK: case ECLConstants.INHIBIT_COMM_CHECK:
lockStatus.setText("X COMM"); lockStatus.setText("X COMM");
lockFg = ThemeManager.getOiaCommCheck(); // Red (oEI)
break; break;
case ECLConstants.INHIBIT_NUMERIC_ONLY: case ECLConstants.INHIBIT_NUMERIC_ONLY:
lockStatus.setText("X NUM"); lockStatus.setText("X NUM");
lockFg = ThemeManager.getOiaAttention(); // Yellow (oAI)
break; break;
case ECLConstants.INHIBIT_PROTECTED_FIELD: case ECLConstants.INHIBIT_PROTECTED_FIELD:
lockStatus.setText("X PROT"); lockStatus.setText("X PROT");
lockFg = ThemeManager.getOiaInputInhibited(); // White (oII)
break; break;
case ECLConstants.INHIBIT_OVERFLOW: case ECLConstants.INHIBIT_OVERFLOW:
lockStatus.setText("X >"); lockStatus.setText("X >");
lockFg = ThemeManager.getOiaAttention(); // Yellow (oAI)
break; break;
case ECLConstants.INHIBIT_OPERATOR_DUE: case ECLConstants.INHIBIT_OPERATOR_DUE:
lockStatus.setText("X OP"); lockStatus.setText("X OP");
lockFg = ThemeManager.getOiaAttention(); // Yellow (oAI)
break; break;
default: default:
lockStatus.setText("X LOCKED"); lockStatus.setText("X LOCKED");
lockFg = ThemeManager.getOiaInputInhibited(); // White (oII)
break; break;
} }
lockStatus.setForeground(OIA_ALERT); lockStatus.setForeground(lockFg);
} else if (client.getInputProcessor().isInsertMode()) { } else if (client.getInputProcessor().isInsertMode()) {
lockStatus.setText("INSERT"); lockStatus.setText("INSERT");
lockStatus.setForeground(OIA_FG); lockStatus.setForeground(ThemeManager.getOiaStatusSysAvail());
} else { } else {
lockStatus.setText(""); lockStatus.setText("");
} }
@@ -203,10 +212,10 @@ public class StatusBar extends JPanel {
if (state.isFullSession() && client.getScreenBuffer().isFormatted()) { if (state.isFullSession() && client.getScreenBuffer().isFormatted()) {
if (client.getOIA().isNumeric()) { if (client.getOIA().isNumeric()) {
fieldTypeStatus.setText("NUM"); fieldTypeStatus.setText("NUM");
fieldTypeStatus.setForeground(OIA_WARN); fieldTypeStatus.setForeground(ThemeManager.getOiaFgWarn(theme));
} else { } else {
fieldTypeStatus.setText("ALPHA"); fieldTypeStatus.setText("ALPHA");
fieldTypeStatus.setForeground(OIA_DIM); fieldTypeStatus.setForeground(ThemeManager.getOiaFgDim(theme));
} }
} else { } else {
fieldTypeStatus.setText(""); fieldTypeStatus.setText("");
@@ -215,18 +224,27 @@ public class StatusBar extends JPanel {
// Active Code Page // Active Code Page
String cp = client.getCodePage(); String cp = client.getCodePage();
codePageInfo.setText(cp != null ? "CP" + cp : ""); codePageInfo.setText(cp != null ? "CP" + cp : "");
codePageInfo.setForeground(ThemeManager.getOiaFgDim(theme));
codePageInfo.setToolTipText("Active EBCDIC Code Page: CP" + cp); codePageInfo.setToolTipText("Active EBCDIC Code Page: CP" + cp);
// Model & Dimensions info // Model & Dimensions info
ScreenBuffer sb = client.getScreenBuffer(); ScreenBuffer sb = client.getScreenBuffer();
int rows = sb.getDisplayRows(); int rows = sb.getDisplayRows();
int cols = sb.getDisplayCols(); int cols = sb.getDisplayCols();
modelInfo.setText(client.getConfig().getModel().name().replace('_', '-') + " [" + rows + "x" + cols + "]"); String modelName;
if (client.getConfig().isDynamicModel() || (client.getConfig().getModel() != null && client.getConfig().getModel().isDynamic())) {
modelName = "IBM-DYNAMIC [" + rows + "x" + cols + "]";
} else {
modelName = client.getConfig().getModel().name().replace('_', '-') + " [" + rows + "x" + cols + "]";
}
modelInfo.setText(modelName);
modelInfo.setForeground(ThemeManager.getOiaFgDim(theme));
// Cursor position and buffer address // Cursor position and buffer address
int curAddr = sb.getCursorAddress(); int curAddr = sb.getCursorAddress();
int row = sb.getCursorRow() + 1; int row = sb.getCursorRow() + 1;
int col = sb.getCursorCol() + 1; int col = sb.getCursorCol() + 1;
cursorPosition.setText(String.format("%03d/%03d [%04d]", row, col, curAddr)); cursorPosition.setText(String.format("%03d/%03d [%04d]", row, col, curAddr));
cursorPosition.setForeground(ThemeManager.getOiaFgNormal(theme));
} }
} }
@@ -57,11 +57,22 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
CHAR_STRINGS[i] = String.valueOf((char) i); CHAR_STRINGS[i] = String.valueOf((char) i);
} }
} }
public enum CursorStyle {
BLOCK,
UNDERLINE
}
private CursorStyle cursorStyle = CursorStyle.BLOCK;
private static final Color CURSOR_COLOR = new Color(255, 255, 255, 180); private static final Color CURSOR_COLOR = new Color(255, 255, 255, 180);
private boolean crosshairRulerEnabled = false;
private static final Color CROSSHAIR_RULER_COLOR = new Color(0, 255, 0, 102); // 40% alpha (cRC)
private boolean textBlinkVisible = true;
private Image wallpaperImage = null;
private haus.nightmare.lib3270j.graphics.HODWallpaper hodWallpaper = null;
private int selectionStartRow = -1, selectionStartCol = -1; private int selectionStartRow = -1, selectionStartCol = -1;
private int selectionEndRow = -1, selectionEndCol = -1; private int selectionEndRow = -1, selectionEndCol = -1;
private boolean isDragging = false; private boolean isDragging = false;
private static final Color SELECTION_COLOR = new Color(75, 110, 175, 100); private static final Color SELECTION_COLOR = new Color(75, 110, 175, 102); // 40% alpha blend
// ========== Search Highlight state ========== // ========== Search Highlight state ==========
private int searchHighlightAddr = -1; private int searchHighlightAddr = -1;
@@ -96,31 +107,31 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
return Math.max(padding, extra / 2); return Math.max(padding, extra / 2);
} }
// Default Host color mapping // Default Host color mapping aligned 1:1 with IBM Host On-Demand ColorRemapModel3270
public static final Color[] DEFAULT_HOST_COLORS = { public static final Color[] DEFAULT_HOST_COLORS = {
new Color(0, 0, 0), // 0: Neutral Black new Color(0, 0, 0), // 0: Neutral Black
new Color(80, 120, 255), // 1: Blue new Color(120, 144, 240), // 1: Blue (0x7890F0 CUSTOMBLUE)
new Color(255, 50, 50), // 2: Red new Color(255, 0, 0), // 2: Red
new Color(255, 130, 180), // 3: Pink new Color(255, 0, 255), // 3: Pink
new Color(50, 205, 50), // 4: Green new Color(0, 255, 0), // 4: Green
new Color(64, 224, 208), // 5: Turquoise new Color(0, 255, 255), // 5: Turquoise / Cyan
new Color(255, 255, 80), // 6: Yellow new Color(255, 255, 0), // 6: Yellow
new Color(255, 255, 255), // 7: Neutral White new Color(255, 255, 255), // 7: Neutral White
new Color(0, 0, 0), // 8: Black new Color(0, 0, 0), // 8: Black
new Color(30, 60, 180), // 9: Deep Blue new Color(0, 0, 128), // 9: Deep Blue
new Color(255, 165, 0), // 10: Orange new Color(255, 162, 0), // 10: Orange (0xFFFFA200)
new Color(180, 130, 255), // 11: Purple new Color(128, 0, 128), // 11: Purple
new Color(144, 238, 144), // 12: Pale Green new Color(0, 128, 0), // 12: Pale Green
new Color(175, 238, 238), // 13: Pale Turquoise new Color(0, 128, 128), // 13: Pale Turquoise
new Color(170, 170, 170), // 14: Grey new Color(160, 160, 0), // 14: Mustard (0xFFA0A000)
new Color(255, 255, 255), // 15: White new Color(192, 192, 192), // 15: Grey (0xFFC0C0C0)
}; };
// Default 3278 monochrome colors // Default 3278 / base monochrome colors aligned with HoD
public static final Color DEFAULT_MONO_NORMAL = new Color(50, 205, 50); public static final Color DEFAULT_MONO_NORMAL = new Color(0, 255, 0); // Green
public static final Color DEFAULT_MONO_INTENSIFY = new Color(255, 255, 255); public static final Color DEFAULT_MONO_INTENSIFY = new Color(255, 0, 0); // Red
public static final Color DEFAULT_MONO_PROTECTED = new Color(80, 120, 255); public static final Color DEFAULT_MONO_PROTECTED = new Color(0, 255, 255); // Cyan / Turquoise
public static final Color DEFAULT_MONO_PROTECTED_HIGH = new Color(255, 255, 255); public static final Color DEFAULT_MONO_PROTECTED_HIGH = new Color(255, 255, 255); // White
// Default Background // Default Background
public static final Color DEFAULT_BG_COLOR = Color.BLACK; public static final Color DEFAULT_BG_COLOR = Color.BLACK;
@@ -138,6 +149,9 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
setupCursorBlink(); setupCursorBlink();
blockSelectMode = haus.nightmare.j3270.config.Settings.getBlockSelectMode(); blockSelectMode = haus.nightmare.j3270.config.Settings.getBlockSelectMode();
crosshairRulerEnabled = haus.nightmare.j3270.config.Settings.getCrosshairRuler();
String cStyle = haus.nightmare.j3270.config.Settings.getCursorStyle();
cursorStyle = "UNDERLINE".equalsIgnoreCase(cStyle) ? CursorStyle.UNDERLINE : CursorStyle.BLOCK;
// Handle mouse clicks to position cursor, selection, and grab focus // Handle mouse clicks to position cursor, selection, and grab focus
MouseAdapter mouseHandler = new MouseAdapter() { MouseAdapter mouseHandler = new MouseAdapter() {
@@ -434,6 +448,16 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
public void pasteClipboard() { public void pasteClipboard() {
if (client == null || !client.getConnectionState().isFullSession()) return; if (client == null || !client.getConnectionState().isFullSession()) return;
if (client.getConnectionState().isNvt()) {
try {
String text = (String) Toolkit.getDefaultToolkit().getSystemClipboard()
.getData(DataFlavor.stringFlavor);
if (text != null && !text.isEmpty()) {
client.sendNVTString(text);
}
} catch (Exception ignored) {}
return;
}
try { try {
String text = (String) Toolkit.getDefaultToolkit().getSystemClipboard() String text = (String) Toolkit.getDefaultToolkit().getSystemClipboard()
.getData(DataFlavor.stringFlavor); .getData(DataFlavor.stringFlavor);
@@ -481,24 +505,29 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void showContextMenu(MouseEvent e) { private void showContextMenu(MouseEvent e) {
JPopupMenu popup = new JPopupMenu(); JPopupMenu popup = new JPopupMenu();
ThemeManager.stylePopupMenu(popup);
JMenuItem copyItem = new JMenuItem("Copy"); JMenuItem copyItem = new JMenuItem("Copy");
ThemeManager.styleMenuItem(copyItem);
copyItem.setEnabled(hasSelection()); copyItem.setEnabled(hasSelection());
copyItem.addActionListener(ev -> copySelection()); copyItem.addActionListener(ev -> copySelection());
popup.add(copyItem); popup.add(copyItem);
JMenuItem pasteItem = new JMenuItem("Paste"); JMenuItem pasteItem = new JMenuItem("Paste");
ThemeManager.styleMenuItem(pasteItem);
pasteItem.setEnabled(client != null && client.getConnectionState().isFullSession()); pasteItem.setEnabled(client != null && client.getConnectionState().isFullSession());
pasteItem.addActionListener(ev -> pasteClipboard()); pasteItem.addActionListener(ev -> pasteClipboard());
popup.add(pasteItem); popup.add(pasteItem);
JMenuItem selectAllItem = new JMenuItem("Select All"); JMenuItem selectAllItem = new JMenuItem("Select All");
ThemeManager.styleMenuItem(selectAllItem);
selectAllItem.addActionListener(ev -> selectAll()); selectAllItem.addActionListener(ev -> selectAll());
popup.add(selectAllItem); popup.add(selectAllItem);
popup.addSeparator(); popup.addSeparator();
JCheckBoxMenuItem blockModeItem = new JCheckBoxMenuItem("Block Select Mode", blockSelectMode); JCheckBoxMenuItem blockModeItem = new JCheckBoxMenuItem("Block Select Mode", blockSelectMode);
ThemeManager.styleMenuItem(blockModeItem);
blockModeItem.addActionListener(ev -> { blockModeItem.addActionListener(ev -> {
blockSelectMode = blockModeItem.isSelected(); blockSelectMode = blockModeItem.isSelected();
haus.nightmare.j3270.config.Settings.setBlockSelectMode(blockSelectMode); haus.nightmare.j3270.config.Settings.setBlockSelectMode(blockSelectMode);
@@ -693,19 +722,73 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
@Override @Override
protected void processKeyEvent(KeyEvent e) { protected void processKeyEvent(KeyEvent e) {
if (client != null) {
ConnectionState state = client.getConnectionState();
if (state.isNvt()) {
if (e.getID() == KeyEvent.KEY_TYPED) { if (e.getID() == KeyEvent.KEY_TYPED) {
char ch = e.getKeyChar(); char ch = e.getKeyChar();
if (ch >= 0x20 && ch != 0x7F && ch != KeyEvent.CHAR_UNDEFINED if (ch >= 0x20 && ch != 0x7F && ch != KeyEvent.CHAR_UNDEFINED
&& !e.isControlDown() && !e.isAltDown() && !e.isMetaDown()) { && !e.isControlDown() && !e.isAltDown() && !e.isMetaDown()) {
if (client != null) {
ConnectionState state = client.getConnectionState();
if (state == ConnectionState.CONNECTED_NVT || state == ConnectionState.CONNECTED_NVT_CHAR || state == ConnectionState.CONNECTED_E_NVT) {
try { try {
client.sendNVTChar(ch); client.sendNVTChar(ch);
} catch (Exception ignored) {} } catch (Exception ignored) {}
e.consume(); e.consume();
return; return;
} else if (state.isFullSession()) { } else if (e.isControlDown() && !e.isAltDown() && !e.isMetaDown()) {
if (ch > 0 && ch < 0x20) {
try {
client.sendNVTChar(ch);
} catch (Exception ignored) {}
e.consume();
return;
}
}
} else if (e.getID() == KeyEvent.KEY_PRESSED) {
if (client.getNvtProcessor() != null && client.getNvtProcessor().isApplicationKeypad()) {
String kp = client.getNvtProcessor().mapKeypadKey(e.getKeyCode());
if (kp != null) {
try {
client.sendNVTString(kp);
} catch (Exception ignored) {}
e.consume();
return;
}
}
if (e.isControlDown() && !e.isAltDown() && !e.isMetaDown()) {
int code = e.getKeyCode();
if (code >= KeyEvent.VK_A && code <= KeyEvent.VK_Z) {
char ctrlChar = (char) (code - KeyEvent.VK_A + 1);
try {
client.sendNVTChar(ctrlChar);
} catch (Exception ignored) {}
e.consume();
return;
} else if (code == KeyEvent.VK_OPEN_BRACKET) { // Ctrl+[ = ESC
try {
client.sendNVTChar('\u001B');
} catch (Exception ignored) {}
e.consume();
return;
} else if (code == KeyEvent.VK_BACK_SLASH) { // Ctrl+\ = FS
try {
client.sendNVTChar('\u001C');
} catch (Exception ignored) {}
e.consume();
return;
} else if (code == KeyEvent.VK_CLOSE_BRACKET) { // Ctrl+] = GS
try {
client.sendNVTChar('\u001D');
} catch (Exception ignored) {}
e.consume();
return;
}
}
}
} else if (e.getID() == KeyEvent.KEY_TYPED) {
char ch = e.getKeyChar();
if (ch >= 0x20 && ch != 0x7F && ch != KeyEvent.CHAR_UNDEFINED
&& !e.isControlDown() && !e.isAltDown() && !e.isMetaDown()) {
if (state.isFullSession()) {
client.typeCharacter(ch); client.typeCharacter(ch);
refreshScreen(); refreshScreen();
e.consume(); e.consume();
@@ -731,7 +814,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void handleEnter() { private void handleEnter() {
if (client != null) { if (client != null) {
ConnectionState state = client.getConnectionState(); ConnectionState state = client.getConnectionState();
if (state == ConnectionState.CONNECTED_NVT || state == ConnectionState.CONNECTED_NVT_CHAR || state == ConnectionState.CONNECTED_E_NVT) { if (state.isNvt()) {
try { try {
client.sendNVTString("\r\n"); client.sendNVTString("\r\n");
} catch (Exception ignored) {} } catch (Exception ignored) {}
@@ -744,6 +827,12 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void handleReset() { private void handleReset() {
if (client != null) { if (client != null) {
if (client.getConnectionState().isNvt()) {
try {
client.sendNVTChar('\u001B');
} catch (Exception ignored) {}
return;
}
clearSearchHighlight(); clearSearchHighlight();
clearSelection(); clearSelection();
client.reset(); client.reset();
@@ -753,6 +842,16 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void handleTab(boolean shift) { private void handleTab(boolean shift) {
if (client != null && client.getConnectionState().isFullSession()) { if (client != null && client.getConnectionState().isFullSession()) {
if (client.getConnectionState().isNvt()) {
try {
if (shift) {
client.sendNVTString("\u001B[Z");
} else {
client.sendNVTChar('\t');
}
} catch (Exception ignored) {}
return;
}
if (shift) client.backTab(); if (shift) client.backTab();
else client.tab(); else client.tab();
refreshScreen(); refreshScreen();
@@ -761,6 +860,26 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void handleCursor(String dir) { private void handleCursor(String dir) {
if (client != null && client.getConnectionState().isFullSession()) { if (client != null && client.getConnectionState().isFullSession()) {
if (client.getConnectionState().isNvt()) {
try {
int vk = KeyEvent.VK_UP;
if ("down".equals(dir)) vk = KeyEvent.VK_DOWN;
else if ("left".equals(dir)) vk = KeyEvent.VK_LEFT;
else if ("right".equals(dir)) vk = KeyEvent.VK_RIGHT;
else if ("home".equals(dir)) vk = KeyEvent.VK_HOME;
boolean handled = client.sendNVTKey(vk, '\0', false, false, false);
if (!handled) {
switch (dir) {
case "up": client.sendNVTString("\u001B[A"); break;
case "down": client.sendNVTString("\u001B[B"); break;
case "left": client.sendNVTString("\u001B[D"); break;
case "right": client.sendNVTString("\u001B[C"); break;
case "home": client.sendNVTString("\u001B[H"); break;
}
}
} catch (Exception ignored) {}
return;
}
switch (dir) { switch (dir) {
case "up": client.cursorUp(); break; case "up": client.cursorUp(); break;
case "down": client.cursorDown(); break; case "down": client.cursorDown(); break;
@@ -774,11 +893,39 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void handlePF(int n) { private void handlePF(int n) {
if (client != null && client.getConnectionState().isFullSession()) { if (client != null && client.getConnectionState().isFullSession()) {
if (client.getConnectionState().isNvt()) {
try {
if (client.getNvtProcessor() != null) {
client.sendNVTString(client.getNvtProcessor().getFunctionKeySequence(n));
} else {
client.sendNVTString(getNvtFunctionKeySequence(n));
}
} catch (Exception ignored) {}
return;
}
client.sendPF(n); client.sendPF(n);
refreshScreen(); refreshScreen();
} }
} }
private String getNvtFunctionKeySequence(int n) {
switch (n) {
case 1: return "\u001BOP";
case 2: return "\u001BOQ";
case 3: return "\u001BOR";
case 4: return "\u001BOS";
case 5: return "\u001B[15~";
case 6: return "\u001B[17~";
case 7: return "\u001B[18~";
case 8: return "\u001B[19~";
case 9: return "\u001B[20~";
case 10: return "\u001B[21~";
case 11: return "\u001B[23~";
case 12: return "\u001B[24~";
default: return "";
}
}
private void handlePA(int n) { private void handlePA(int n) {
if (client != null && client.getConnectionState().isFullSession()) { if (client != null && client.getConnectionState().isFullSession()) {
client.sendPA(n); client.sendPA(n);
@@ -788,6 +935,12 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void handleEraseEOF() { private void handleEraseEOF() {
if (client != null && client.getConnectionState().isFullSession()) { if (client != null && client.getConnectionState().isFullSession()) {
if (client.getConnectionState().isNvt()) {
try {
client.sendNVTString("\u001B[F");
} catch (Exception ignored) {}
return;
}
client.getInputProcessor().eraseEof(); client.getInputProcessor().eraseEof();
refreshScreen(); refreshScreen();
} }
@@ -795,6 +948,12 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void handleDelete() { private void handleDelete() {
if (client != null && client.getConnectionState().isFullSession()) { if (client != null && client.getConnectionState().isFullSession()) {
if (client.getConnectionState().isNvt()) {
try {
client.sendNVTString("\u001B[3~");
} catch (Exception ignored) {}
return;
}
client.getInputProcessor().deleteChar(); client.getInputProcessor().deleteChar();
refreshScreen(); refreshScreen();
} }
@@ -803,7 +962,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void handleBackspace() { private void handleBackspace() {
if (client != null) { if (client != null) {
ConnectionState state = client.getConnectionState(); ConnectionState state = client.getConnectionState();
if (state == ConnectionState.CONNECTED_NVT || state == ConnectionState.CONNECTED_NVT_CHAR || state == ConnectionState.CONNECTED_E_NVT) { if (state.isNvt()) {
try { try {
client.sendNVTChar('\b'); client.sendNVTChar('\b');
} catch (Exception ignored) {} } catch (Exception ignored) {}
@@ -824,6 +983,12 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
private void handleClear() { private void handleClear() {
if (client != null && client.getConnectionState().isFullSession()) { if (client != null && client.getConnectionState().isFullSession()) {
if (client.getConnectionState().isNvt()) {
try {
client.sendNVTChar('\u000C');
} catch (Exception ignored) {}
return;
}
client.sendClear(); client.sendClear();
refreshScreen(); refreshScreen();
} }
@@ -924,6 +1089,9 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
setupKeyBindings(); setupKeyBindings();
setupFont(); setupFont();
blockSelectMode = haus.nightmare.j3270.config.Settings.getBlockSelectMode(); blockSelectMode = haus.nightmare.j3270.config.Settings.getBlockSelectMode();
crosshairRulerEnabled = haus.nightmare.j3270.config.Settings.getCrosshairRuler();
String cStyle = haus.nightmare.j3270.config.Settings.getCursorStyle();
cursorStyle = "UNDERLINE".equalsIgnoreCase(cStyle) ? CursorStyle.UNDERLINE : CursorStyle.BLOCK;
revalidate(); revalidate();
repaint(); repaint();
} }
@@ -952,18 +1120,54 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
} }
private void setupCursorBlink() { private void setupCursorBlink() {
blinkTimer = new Timer(530, e -> { blinkTimer = new Timer(500, e -> {
cursorVisible = !cursorVisible; cursorVisible = !cursorVisible;
textBlinkVisible = !textBlinkVisible;
repaint(); repaint();
}); });
blinkTimer.start(); blinkTimer.start();
} }
public Telnet3270Client getClient() {
return client;
}
public void setClient(Telnet3270Client client) { public void setClient(Telnet3270Client client) {
this.client = client; this.client = client;
if (client != null) { if (client != null) {
setupGraphicsPlaneRenderer(); setupGraphicsPlaneRenderer();
updateCellSize(); updateCellSize();
client.setNvtClipboardHandler(new haus.nightmare.lib3270j.nvt.NvtProcessor.ClipboardHandler() {
@Override
public String getClipboardText() {
try {
return (String) Toolkit.getDefaultToolkit().getSystemClipboard()
.getData(DataFlavor.stringFlavor);
} catch (Exception e) {
return "";
}
}
@Override
public void setClipboardText(String text) {
if (text != null) {
try {
StringSelection ss = new StringSelection(text);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
} catch (Exception ignored) {}
}
}
});
client.addNvtTitleListener(title -> {
SwingUtilities.invokeLater(() -> {
Container top = getTopLevelAncestor();
if (top instanceof JFrame) {
((JFrame) top).setTitle(title != null && !title.isEmpty() ? ("j3270 - " + title) : "j3270");
}
});
});
} }
} }
@@ -1065,7 +1269,18 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
int cols = sb.getDisplayCols(); int cols = sb.getDisplayCols();
boolean isColorModel = client.getConfig().getModel().isColor(); boolean isColorModel = client.getConfig().getModel().isColor();
// Draw Vector Graphics Plane under text if present // Layer 0: Optional Wallpaper / Background Image
if (hodWallpaper != null) {
int gridW = cols * cellWidth;
int gridH = rows * cellHeight;
hodWallpaper.paint(this, g2, ox, oy, gridW, gridH);
} else if (wallpaperImage != null) {
int gridW = cols * cellWidth;
int gridH = rows * cellHeight;
g2.drawImage(wallpaperImage, ox, oy, gridW, gridH, null);
}
// Layer 1: Draw Vector Graphics Plane under text if present
if (client.getGraphicsPlane() != null && client.getGraphicsPlane().hasContent()) { if (client.getGraphicsPlane() != null && client.getGraphicsPlane().hasContent()) {
int gridW = cols * cellWidth; int gridW = cols * cellWidth;
int gridH = rows * cellHeight; int gridH = rows * cellHeight;
@@ -1087,6 +1302,22 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
} }
} }
// Layer 2: Optional Crosshair Ruler under character glyphs
if (crosshairRulerEnabled && client.getConnectionState().isFullSession()) {
int curAddr = sb.getDisplayCursorAddress();
int curRow = curAddr / cols;
int curCol = curAddr % cols;
int cx = ox + curCol * cellWidth;
int cy = oy + curRow * cellHeight;
int gridW = cols * cellWidth;
int gridH = rows * cellHeight;
g2.setColor(CROSSHAIR_RULER_COLOR);
g2.fillRect(ox, cy, gridW, cellHeight);
g2.fillRect(cx, oy, cellWidth, gridH);
}
// Layer 3: Character / Text Plane
byte currentFA = 0; byte currentFA = 0;
ExtendedAttribute currentFieldEa = null; ExtendedAttribute currentFieldEa = null;
@@ -1114,7 +1345,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
continue; continue;
} }
// Determine foreground color // Determine foreground and background colors
if (isColorModel) { if (isColorModel) {
fgColor = getColorForAttribute(ea, currentFieldEa, currentFA); fgColor = getColorForAttribute(ea, currentFieldEa, currentFA);
bgColor = getBackgroundForAttribute(ea, currentFieldEa); bgColor = getBackgroundForAttribute(ea, currentFieldEa);
@@ -1123,6 +1354,9 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
bgColor = this.bgColor; bgColor = this.bgColor;
} }
int rawBg = ea.bg != 0 ? (ea.bg & 0xFF) : (currentFieldEa != null ? (currentFieldEa.bg & 0xFF) : 0);
boolean bgIsExplicit = (rawBg >= 0xF0 && rawBg <= 0xFF && rawBg != HOST_COLOR_NEUTRAL_BLACK && rawBg != HOST_COLOR_BLACK);
// Graphics rendition // Graphics rendition
byte gr = ea.gr != 0 ? ea.gr : (currentFieldEa != null ? currentFieldEa.gr : 0); byte gr = ea.gr != 0 ? ea.gr : (currentFieldEa != null ? currentFieldEa.gr : 0);
if (gr != 0) { if (gr != 0) {
@@ -1152,22 +1386,26 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
if (reverse) { if (reverse) {
Color tmp = fgColor; Color tmp = fgColor;
fgColor = bgColor; fgColor = (rawBg == 0) ? this.bgColor : bgColor;
bgColor = tmp; bgColor = tmp;
} g2.setColor(bgColor);
g2.fillRect(x, y, cellWidth, cellHeight);
if (!bgColor.equals(this.bgColor) || reverse) { } else if (bgIsExplicit || !bgColor.equals(this.bgColor)) {
g2.setColor(bgColor); g2.setColor(bgColor);
g2.fillRect(x, y, cellWidth, cellHeight); g2.fillRect(x, y, cellWidth, cellHeight);
} }
// Check text blink (500ms cycle)
boolean blink = (gr & GR_BLINK) != 0;
boolean suppressGlyph = blink && !textBlinkVisible;
// Draw character or Programmed Symbol // Draw character or Programmed Symbol
int cs = (ea.cs != 0) ? (ea.cs & 0xFF) : (currentFieldEa != null ? (currentFieldEa.cs & 0xFF) : 0); int cs = (ea.cs != 0) ? (ea.cs & 0xFF) : (currentFieldEa != null ? (currentFieldEa.cs & 0xFF) : 0);
boolean drawnAsPs = false; boolean drawnAsPs = false;
if (cs >= 0x40 && client.getProgramSymbolManager() != null) { if (cs >= 0x40 && client.getProgramSymbolManager() != null && !suppressGlyph) {
haus.nightmare.lib3270j.graphics.ProgramSymbolSet.SymbolSlot slot = client.getProgramSymbolManager().getSymbol(cs, ea.ec & 0xFF); haus.nightmare.lib3270j.graphics.ProgramSymbolSet.SymbolSlot slot = client.getProgramSymbolManager().getSymbol(cs, ea.ec & 0xFF);
if (slot != null) { if (slot != null) {
int symBg = (!bgColor.equals(this.bgColor) || reverse) ? bgColor.getRGB() : 0; int symBg = (bgIsExplicit || reverse) ? bgColor.getRGB() : 0;
java.awt.image.BufferedImage img = slot.getScaledImage(cellWidth, cellHeight, fgColor.getRGB(), symBg); java.awt.image.BufferedImage img = slot.getScaledImage(cellWidth, cellHeight, fgColor.getRGB(), symBg);
if (img != null) { if (img != null) {
g2.drawImage(img, x, y, null); g2.drawImage(img, x, y, null);
@@ -1176,7 +1414,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
} }
} }
if (!drawnAsPs) { if (!drawnAsPs && !suppressGlyph) {
char ch = ea.ucs4; char ch = ea.ucs4;
if (ch > 0x20 && ch != 0xFF) { if (ch > 0x20 && ch != 0xFF) {
Font f = bold ? boldTerminalFont : terminalFont; Font f = bold ? boldTerminalFont : terminalFont;
@@ -1203,7 +1441,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
g2.fillRect(x, y, cellWidth, cellHeight); g2.fillRect(x, y, cellWidth, cellHeight);
} }
// Draw selection highlight // Draw selection highlight (40% alpha blend over cell)
if (isCellSelected(row, col)) { if (isCellSelected(row, col)) {
g2.setColor(SELECTION_COLOR); g2.setColor(SELECTION_COLOR);
g2.fillRect(x, y, cellWidth, cellHeight); g2.fillRect(x, y, cellWidth, cellHeight);
@@ -1212,9 +1450,15 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
} }
// Draw Graphic Cursor if active // Draw Graphic Cursor if active
if (client.getGocaDecoder() != null && client.getGocaDecoder().isGraphicsCursorActive() && client.getGraphicsPlane() != null) { boolean isGraphicCursor = (client.getGocaDecoder() != null && client.getGocaDecoder().isGraphicsCursorActive())
int gocaX = client.getGocaDecoder().getGraphicCursorX(); || (client.getGraphicsPlane() != null && client.getGraphicsPlane().isGraphicCursorAttached());
int gocaY = client.getGocaDecoder().getGraphicCursorY(); if (isGraphicCursor && client.getGraphicsPlane() != null) {
int gocaX = (client.getGocaDecoder() != null && client.getGocaDecoder().isGraphicsCursorActive())
? client.getGocaDecoder().getGraphicCursorX()
: client.getGraphicsPlane().getGraphicCursorX();
int gocaY = (client.getGocaDecoder() != null && client.getGocaDecoder().isGraphicsCursorActive())
? client.getGocaDecoder().getGraphicCursorY()
: client.getGraphicsPlane().getGraphicCursorY();
int canvasPx = client.getGraphicsPlane().mapX(gocaX); int canvasPx = client.getGraphicsPlane().mapX(gocaX);
int canvasPy = client.getGraphicsPlane().mapY(gocaY); int canvasPy = client.getGraphicsPlane().mapY(gocaY);
int gridW = cols * cellWidth; int gridW = cols * cellWidth;
@@ -1226,12 +1470,19 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
g2.setColor(Color.WHITE); g2.setColor(Color.WHITE);
g2.setXORMode(Color.BLACK); g2.setXORMode(Color.BLACK);
g2.drawLine(px - 6, py, px + 6, py); int shape = client.getGraphicsPlane().getHodCursorShape();
g2.drawLine(px, py - 6, px, py + 6); if (shape == 2) {
// Shape 2: Box cursor per HoD
g2.drawRect(px - 3, py - 3, 6, 6);
} else {
// Shape 1 (default): Crosshair per HoD
g2.drawLine(px - 8, py, px + 8, py);
g2.drawLine(px, py - 8, px, py + 8);
}
g2.setPaintMode(); g2.setPaintMode();
} }
// Draw 3270 text cursor // Draw 3270 text cursor with alpha blending (Block / Underline)
if (cursorVisible && client.getConnectionState().isFullSession()) { if (cursorVisible && client.getConnectionState().isFullSession()) {
int curAddr = sb.getDisplayCursorAddress(); int curAddr = sb.getDisplayCursorAddress();
int curRow = curAddr / cols; int curRow = curAddr / cols;
@@ -1239,12 +1490,78 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
int cx = ox + curCol * cellWidth; int cx = ox + curCol * cellWidth;
int cy = oy + curRow * cellHeight; int cy = oy + curRow * cellHeight;
boolean isUnderline = (cursorStyle == CursorStyle.UNDERLINE) ||
(client.getInputProcessor() != null && client.getInputProcessor().isInsertMode());
g2.setColor(CURSOR_COLOR); g2.setColor(CURSOR_COLOR);
g2.setXORMode(bgColor); if (isUnderline) {
int ulH = Math.max(2, cellHeight / 6);
g2.fillRect(cx, cy + cellHeight - ulH, cellWidth, ulH);
} else {
g2.fillRect(cx, cy, cellWidth, cellHeight); g2.fillRect(cx, cy, cellWidth, cellHeight);
g2.setPaintMode();
} }
} }
}
public boolean isCrosshairRulerEnabled() {
return crosshairRulerEnabled;
}
public void setCrosshairRulerEnabled(boolean enabled) {
this.crosshairRulerEnabled = enabled;
repaint();
}
public void toggleCrosshairRuler() {
setCrosshairRulerEnabled(!crosshairRulerEnabled);
}
public CursorStyle getCursorStyle() {
return cursorStyle;
}
public void setCursorStyle(CursorStyle style) {
this.cursorStyle = (style != null) ? style : CursorStyle.BLOCK;
repaint();
}
public Image getWallpaperImage() {
return wallpaperImage;
}
public void setWallpaperImage(Image wallpaperImage) {
this.wallpaperImage = wallpaperImage;
if (wallpaperImage != null) {
if (this.hodWallpaper == null) {
this.hodWallpaper = new haus.nightmare.lib3270j.graphics.HODWallpaper(wallpaperImage, haus.nightmare.lib3270j.graphics.HODWallpaper.HOD_STRETCH);
} else {
this.hodWallpaper.setImage(wallpaperImage);
}
} else {
this.hodWallpaper = null;
}
repaint();
}
public haus.nightmare.lib3270j.graphics.HODWallpaper getHodWallpaper() {
return hodWallpaper;
}
public void setHodWallpaper(haus.nightmare.lib3270j.graphics.HODWallpaper wallpaper) {
this.hodWallpaper = wallpaper;
if (wallpaper != null) {
this.wallpaperImage = wallpaper.getHODImage();
}
repaint();
}
public void setWallpaperMode(int displayMode) {
if (this.hodWallpaper == null && this.wallpaperImage != null) {
this.hodWallpaper = new haus.nightmare.lib3270j.graphics.HODWallpaper(this.wallpaperImage, displayMode);
} else if (this.hodWallpaper != null) {
this.hodWallpaper.setDisplay(displayMode);
}
repaint();
}
private Color getColorForAttribute(ExtendedAttribute ea, ExtendedAttribute currentFieldEa, byte currentFA) { private Color getColorForAttribute(ExtendedAttribute ea, ExtendedAttribute currentFieldEa, byte currentFA) {
int fg = ea.fg != 0 ? (ea.fg & 0xFF) int fg = ea.fg != 0 ? (ea.fg & 0xFF)
@@ -1253,7 +1570,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
return hostColors[fg - 0xf0]; return hostColors[fg - 0xf0];
} }
if (faIsProtected(currentFA & 0xFF)) { if (faIsProtected(currentFA & 0xFF)) {
return faIsHigh(currentFA & 0xFF) ? hostColors[HOST_COLOR_WHITE] : hostColors[HOST_COLOR_BLUE]; return faIsHigh(currentFA & 0xFF) ? hostColors[HOST_COLOR_WHITE] : hostColors[HOST_COLOR_TURQUOISE];
} }
return faIsHigh(currentFA & 0xFF) ? hostColors[HOST_COLOR_RED] : hostColors[HOST_COLOR_GREEN]; return faIsHigh(currentFA & 0xFF) ? hostColors[HOST_COLOR_RED] : hostColors[HOST_COLOR_GREEN];
} }
@@ -0,0 +1,968 @@
package haus.nightmare.j3270.ui;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.plaf.basic.BasicButtonUI;
import javax.swing.plaf.basic.BasicMenuBarUI;
import javax.swing.plaf.basic.BasicMenuItemUI;
import javax.swing.plaf.basic.BasicMenuUI;
import javax.swing.plaf.basic.BasicPopupMenuUI;
import javax.swing.plaf.basic.BasicTabbedPaneUI;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
/**
* Centralized theme manager for j3270 Java desktop UI.
* Provides high-contrast, platform-independent Light and Dark theme palettes,
* custom Swing UI delegates, and recursive styling helpers for all dialogs and menus.
*/
public final class ThemeManager {
private static UITheme currentTheme = UITheme.DARK;
private static final List<Consumer<UITheme>> themeChangeListeners = new ArrayList<>();
private ThemeManager() {}
public static UITheme getTheme() {
return currentTheme;
}
public static boolean isDark() {
return currentTheme == UITheme.DARK;
}
public static boolean isLight() {
return currentTheme == UITheme.LIGHT;
}
public static void setTheme(UITheme theme) {
if (theme == null) theme = UITheme.DARK;
if (currentTheme != theme) {
currentTheme = theme;
applyUIManagerDefaults(theme);
for (Consumer<UITheme> listener : new ArrayList<>(themeChangeListeners)) {
try {
listener.accept(theme);
} catch (Exception ignored) {}
}
}
}
public static void addThemeChangeListener(Consumer<UITheme> listener) {
if (listener != null && !themeChangeListeners.contains(listener)) {
themeChangeListeners.add(listener);
}
}
public static void removeThemeChangeListener(Consumer<UITheme> listener) {
themeChangeListeners.remove(listener);
}
// =========================================================================
// Color Palette Tokens
// =========================================================================
public static Color getBgMain() { return getBgMain(currentTheme); }
public static Color getBgMain(UITheme t) {
return t == UITheme.DARK ? new Color(28, 28, 28) : new Color(242, 242, 244);
}
public static Color getBgPanel() { return getBgPanel(currentTheme); }
public static Color getBgPanel(UITheme t) {
return t == UITheme.DARK ? new Color(36, 36, 36) : new Color(250, 250, 252);
}
public static Color getBgComponent() { return getBgComponent(currentTheme); }
public static Color getBgComponent(UITheme t) {
return t == UITheme.DARK ? new Color(46, 46, 46) : Color.WHITE;
}
public static Color getBgComponentLighter() { return getBgComponentLighter(currentTheme); }
public static Color getBgComponentLighter(UITheme t) {
return t == UITheme.DARK ? new Color(56, 56, 56) : new Color(236, 236, 238);
}
public static Color getFgMain() { return getFgMain(currentTheme); }
public static Color getFgMain(UITheme t) {
return t == UITheme.DARK ? new Color(238, 238, 238) : new Color(24, 24, 24);
}
public static Color getFgMuted() { return getFgMuted(currentTheme); }
public static Color getFgMuted(UITheme t) {
return t == UITheme.DARK ? new Color(175, 175, 175) : new Color(90, 90, 90);
}
public static Color getFgDisabled() { return getFgDisabled(currentTheme); }
public static Color getFgDisabled(UITheme t) {
return t == UITheme.DARK ? new Color(110, 110, 110) : new Color(160, 160, 160);
}
public static Color getBorder() { return getBorder(currentTheme); }
public static Color getBorder(UITheme t) {
return t == UITheme.DARK ? new Color(65, 65, 65) : new Color(205, 205, 205);
}
public static Color getBorderColor() { return getBorder(currentTheme); }
public static Color getBorderColor(UITheme t) { return getBorder(t); }
public static Color getBorderFocused() { return getBorderFocused(currentTheme); }
public static Color getBorderFocused(UITheme t) {
return t == UITheme.DARK ? new Color(80, 140, 230) : new Color(50, 115, 220);
}
public static Color getSelectionBg() { return getSelectionBg(currentTheme); }
public static Color getSelectionBg(UITheme t) {
return t == UITheme.DARK ? new Color(55, 105, 180) : new Color(60, 125, 215);
}
public static Color getSelectionFg() { return getSelectionFg(currentTheme); }
public static Color getSelectionFg(UITheme t) {
return Color.WHITE;
}
public static Color getMenuBarBg() { return getMenuBarBg(currentTheme); }
public static Color getMenuBarBg(UITheme t) {
return t == UITheme.DARK ? new Color(26, 26, 26) : new Color(240, 240, 242);
}
public static Color getMenuBarFg() { return getMenuBarFg(currentTheme); }
public static Color getMenuBarFg(UITheme t) {
return t == UITheme.DARK ? new Color(235, 235, 235) : new Color(25, 25, 25);
}
public static Color getMenuPopupBg() { return getMenuPopupBg(currentTheme); }
public static Color getMenuPopupBg(UITheme t) {
return t == UITheme.DARK ? new Color(38, 38, 38) : Color.WHITE;
}
public static Color getMenuItemFg() { return getMenuItemFg(currentTheme); }
public static Color getMenuItemFg(UITheme t) {
return t == UITheme.DARK ? new Color(230, 230, 230) : new Color(30, 30, 30);
}
public static Color getMenuItemHoverBg() { return getMenuItemHoverBg(currentTheme); }
public static Color getMenuItemHoverBg(UITheme t) {
return t == UITheme.DARK ? new Color(55, 95, 160) : new Color(220, 232, 250);
}
public static Color getMenuItemHoverFg() { return getMenuItemHoverFg(currentTheme); }
public static Color getMenuItemHoverFg(UITheme t) {
return t == UITheme.DARK ? Color.WHITE : new Color(15, 15, 15);
}
public static Color getTabBg() { return getTabBg(currentTheme); }
public static Color getTabBg(UITheme t) {
return t == UITheme.DARK ? new Color(34, 34, 34) : new Color(230, 230, 232);
}
public static Color getTabFg() { return getTabFg(currentTheme); }
public static Color getTabFg(UITheme t) {
return t == UITheme.DARK ? new Color(185, 185, 185) : new Color(75, 75, 75);
}
public static Color getTabSelectedBg() { return getTabSelectedBg(currentTheme); }
public static Color getTabSelectedBg(UITheme t) {
return t == UITheme.DARK ? new Color(50, 50, 50) : Color.WHITE;
}
public static Color getTabSelectedFg() { return getTabSelectedFg(currentTheme); }
public static Color getTabSelectedFg(UITheme t) {
return t == UITheme.DARK ? Color.WHITE : new Color(20, 20, 20);
}
public static Color getTableHeaderBg() { return getTableHeaderBg(currentTheme); }
public static Color getTableHeaderBg(UITheme t) {
return t == UITheme.DARK ? new Color(46, 46, 46) : new Color(232, 232, 236);
}
public static Color getTableHeaderFg() { return getTableHeaderFg(currentTheme); }
public static Color getTableHeaderFg(UITheme t) {
return t == UITheme.DARK ? new Color(235, 235, 235) : new Color(30, 30, 30);
}
public static Color getTableRowEven() { return getTableRowEven(currentTheme); }
public static Color getTableRowEven(UITheme t) {
return t == UITheme.DARK ? new Color(38, 38, 38) : Color.WHITE;
}
public static Color getTableRowOdd() { return getTableRowOdd(currentTheme); }
public static Color getTableRowOdd(UITheme t) {
return t == UITheme.DARK ? new Color(33, 33, 33) : new Color(246, 247, 249);
}
public static Color getTableGrid() { return getTableGrid(currentTheme); }
public static Color getTableGrid(UITheme t) {
return t == UITheme.DARK ? new Color(55, 55, 55) : new Color(225, 225, 225);
}
public static Color getCodeAreaBg() { return getCodeAreaBg(currentTheme); }
public static Color getCodeAreaBg(UITheme t) {
return t == UITheme.DARK ? new Color(22, 22, 22) : new Color(252, 252, 252);
}
public static Color getCodeAreaFg() { return getCodeAreaFg(currentTheme); }
public static Color getCodeAreaFg(UITheme t) {
return t == UITheme.DARK ? new Color(80, 230, 80) : new Color(0, 120, 0);
}
public static Color getStatusBarBg() { return getStatusBarBg(currentTheme); }
public static Color getStatusBarBg(UITheme t) {
return t == UITheme.DARK ? new Color(20, 20, 20) : new Color(235, 235, 238);
}
public static Color getStatusBarBorder() { return getStatusBarBorder(currentTheme); }
public static Color getStatusBarBorder(UITheme t) {
return t == UITheme.DARK ? new Color(42, 42, 42) : new Color(210, 210, 215);
}
public static Color getOiaFgNormal() { return getOiaFgNormal(currentTheme); }
public static Color getOiaFgNormal(UITheme t) {
return t == UITheme.DARK ? new Color(50, 205, 50) : new Color(0, 130, 0);
}
public static Color getOiaFgDim() { return getOiaFgDim(currentTheme); }
public static Color getOiaFgDim(UITheme t) {
return t == UITheme.DARK ? new Color(110, 110, 110) : new Color(90, 90, 90);
}
public static Color getOiaFgAlert() { return getOiaFgAlert(currentTheme); }
public static Color getOiaFgAlert(UITheme t) {
return t == UITheme.DARK ? new Color(255, 80, 80) : new Color(190, 20, 20);
}
public static Color getOiaFgWarn() { return getOiaFgWarn(currentTheme); }
public static Color getOiaFgWarn(UITheme t) {
return t == UITheme.DARK ? new Color(255, 190, 70) : new Color(180, 100, 0);
}
// Host On-Demand OIA Category Colors (oSI, oII, oAI, oEI, oOB)
public static final Color HOD_OIA_STATUS_SYS_AVAIL = new Color(120, 144, 240); // oSI: CUSTOMBLUE
public static final Color HOD_OIA_INPUT_INHIBITED = new Color(255, 255, 255); // oII: White
public static final Color HOD_OIA_ATTENTION_WARN = new Color(255, 255, 0); // oAI: Yellow
public static final Color HOD_OIA_COMM_CHECK_ERROR = new Color(255, 0, 0); // oEI: Red
public static final Color HOD_OIA_BG_BLACK = new Color(0, 0, 0); // oOB: Black
public static Color getOiaStatusSysAvail() { return HOD_OIA_STATUS_SYS_AVAIL; }
public static Color getOiaInputInhibited() { return HOD_OIA_INPUT_INHIBITED; }
public static Color getOiaAttention() { return HOD_OIA_ATTENTION_WARN; }
public static Color getOiaCommCheck() { return HOD_OIA_COMM_CHECK_ERROR; }
public static Color getOiaBackground() { return HOD_OIA_BG_BLACK; }
// =========================================================================
// Button Variants & Color helpers
// =========================================================================
public enum ButtonVariant {
DEFAULT,
PRIMARY,
CANCEL,
DANGER,
ACCENT
}
public static Color getButtonBg(ButtonVariant variant) {
return getButtonBg(variant, currentTheme, false, false);
}
public static Color getButtonBg(ButtonVariant variant, UITheme t) {
return getButtonBg(variant, t, false, false);
}
public static Color getButtonBg(ButtonVariant variant, UITheme t, boolean hover, boolean pressed) {
switch (variant) {
case PRIMARY:
if (pressed) return new Color(25, 105, 35);
if (hover) return new Color(38, 145, 48);
return new Color(32, 128, 42);
case DANGER:
if (pressed) return new Color(125, 30, 30);
if (hover) return new Color(165, 45, 45);
return new Color(145, 38, 38);
case ACCENT:
if (pressed) return new Color(35, 80, 145);
if (hover) return new Color(55, 115, 195);
return new Color(45, 100, 175);
case CANCEL:
case DEFAULT:
default:
if (t == UITheme.DARK) {
if (pressed) return new Color(42, 42, 42);
if (hover) return new Color(68, 68, 68);
return new Color(56, 56, 56);
} else {
if (pressed) return new Color(210, 210, 212);
if (hover) return new Color(228, 228, 232);
return new Color(238, 238, 240);
}
}
}
public static Color getButtonFg(ButtonVariant variant, UITheme t) {
switch (variant) {
case PRIMARY:
case DANGER:
case ACCENT:
return Color.WHITE;
case CANCEL:
case DEFAULT:
default:
return t == UITheme.DARK ? new Color(235, 235, 235) : new Color(30, 30, 30);
}
}
// =========================================================================
// UIManager Defaults Configuration
// =========================================================================
public static void applyUIManagerDefaults(UITheme theme) {
Color bgMain = getBgMain(theme);
Color bgPanel = getBgPanel(theme);
Color bgComp = getBgComponent(theme);
Color fgMain = getFgMain(theme);
Color fgMuted = getFgMuted(theme);
Color border = getBorder(theme);
Color selBg = getSelectionBg(theme);
Color selFg = getSelectionFg(theme);
UIManager.put("Panel.background", bgPanel);
UIManager.put("Panel.foreground", fgMain);
UIManager.put("Label.foreground", fgMain);
UIManager.put("TextField.background", bgComp);
UIManager.put("TextField.foreground", fgMain);
UIManager.put("TextField.caretForeground", fgMain);
UIManager.put("TextField.selectionBackground", selBg);
UIManager.put("TextField.selectionForeground", selFg);
UIManager.put("TextArea.background", bgComp);
UIManager.put("TextArea.foreground", fgMain);
UIManager.put("TextArea.caretForeground", fgMain);
UIManager.put("TextArea.selectionBackground", selBg);
UIManager.put("TextArea.selectionForeground", selFg);
UIManager.put("Button.background", getBgComponentLighter(theme));
UIManager.put("Button.foreground", fgMain);
UIManager.put("Button.select", selBg);
UIManager.put("ComboBox.background", bgComp);
UIManager.put("ComboBox.foreground", fgMain);
UIManager.put("ComboBox.selectionBackground", selBg);
UIManager.put("ComboBox.selectionForeground", selFg);
UIManager.put("Table.background", bgComp);
UIManager.put("Table.foreground", fgMain);
UIManager.put("Table.selectionBackground", selBg);
UIManager.put("Table.selectionForeground", selFg);
UIManager.put("Table.gridColor", getTableGrid(theme));
UIManager.put("TableHeader.background", getTableHeaderBg(theme));
UIManager.put("TableHeader.foreground", getTableHeaderFg(theme));
UIManager.put("ScrollPane.background", bgPanel);
UIManager.put("Viewport.background", bgComp);
UIManager.put("MenuBar.background", getMenuBarBg(theme));
UIManager.put("MenuBar.foreground", getMenuBarFg(theme));
UIManager.put("Menu.background", getMenuBarBg(theme));
UIManager.put("Menu.foreground", getMenuBarFg(theme));
UIManager.put("Menu.selectionBackground", selBg);
UIManager.put("Menu.selectionForeground", selFg);
UIManager.put("PopupMenu.background", getMenuPopupBg(theme));
UIManager.put("PopupMenu.foreground", getMenuItemFg(theme));
UIManager.put("MenuItem.background", getMenuPopupBg(theme));
UIManager.put("MenuItem.foreground", getMenuItemFg(theme));
UIManager.put("MenuItem.selectionBackground", selBg);
UIManager.put("MenuItem.selectionForeground", selFg);
UIManager.put("CheckBoxMenuItem.background", getMenuPopupBg(theme));
UIManager.put("CheckBoxMenuItem.foreground", getMenuItemFg(theme));
UIManager.put("CheckBoxMenuItem.selectionBackground", selBg);
UIManager.put("CheckBoxMenuItem.selectionForeground", selFg);
UIManager.put("RadioButtonMenuItem.background", getMenuPopupBg(theme));
UIManager.put("RadioButtonMenuItem.foreground", getMenuItemFg(theme));
UIManager.put("RadioButtonMenuItem.selectionBackground", selBg);
UIManager.put("RadioButtonMenuItem.selectionForeground", selFg);
UIManager.put("Separator.background", border);
UIManager.put("Separator.foreground", border);
UIManager.put("TabbedPane.background", getTabBg(theme));
UIManager.put("TabbedPane.foreground", getTabFg(theme));
UIManager.put("TabbedPane.selected", getTabSelectedBg(theme));
UIManager.put("TabbedPane.selectHighlight", getTabSelectedBg(theme));
UIManager.put("CheckBox.background", bgPanel);
UIManager.put("CheckBox.foreground", fgMain);
UIManager.put("RadioButton.background", bgPanel);
UIManager.put("RadioButton.foreground", fgMain);
UIManager.put("TitledBorder.titleColor", fgMain);
UIManager.put("OptionPane.background", bgPanel);
UIManager.put("OptionPane.messageForeground", fgMain);
}
// =========================================================================
// Component Styling & Custom UI Delegates
// =========================================================================
/**
* Styles a button with custom rendering, ensuring consistent high contrast
* and proper background color across Windows, macOS, and Linux.
*/
public static JButton styleButton(JButton button, ButtonVariant variant) {
if (button == null) return null;
button.setUI(new StyledButtonUI(variant));
button.setFocusPainted(false);
button.setOpaque(false);
button.setContentAreaFilled(false);
button.setBorder(BorderFactory.createEmptyBorder(6, 14, 6, 14));
button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
return button;
}
public static JButton createStyledButton(String text, ButtonVariant variant, Runnable action) {
JButton btn = new JButton(text);
styleButton(btn, variant);
if (action != null) {
btn.addActionListener(e -> action.run());
}
return btn;
}
public static JTextField styleTextField(JTextField field) {
if (field == null) return null;
field.setBackground(getBgComponent());
field.setForeground(getFgMain());
field.setCaretColor(getFgMain());
field.setSelectionColor(getSelectionBg());
field.setSelectedTextColor(getSelectionFg());
field.setBorder(BorderFactory.createCompoundBorder(
new LineBorder(getBorder(), 1, true),
new EmptyBorder(4, 8, 4, 8)));
return field;
}
public static JTextArea styleTextArea(JTextArea area) {
if (area == null) return null;
area.setBackground(getCodeAreaBg());
area.setForeground(getCodeAreaFg());
area.setCaretColor(getFgMain());
area.setSelectionColor(getSelectionBg());
area.setSelectedTextColor(getSelectionFg());
return area;
}
public static JComboBox<?> styleComboBox(JComboBox<?> box) {
if (box == null) return null;
box.setBackground(getBgComponent());
box.setForeground(getFgMain());
box.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setBorder(new EmptyBorder(4, 8, 4, 8));
if (isSelected) {
setBackground(getSelectionBg());
setForeground(getSelectionFg());
} else {
setBackground(getBgComponent());
setForeground(getFgMain());
}
return this;
}
});
return box;
}
public static JTable styleTable(JTable table) {
if (table == null) return null;
table.setBackground(getBgComponent());
table.setForeground(getFgMain());
table.setSelectionBackground(getSelectionBg());
table.setSelectionForeground(getSelectionFg());
table.setGridColor(getTableGrid());
table.setRowHeight(24);
table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable tbl, Object val, boolean isSel, boolean hasFocus, int row, int col) {
super.getTableCellRendererComponent(tbl, val, isSel, hasFocus, row, col);
setBorder(new EmptyBorder(2, 6, 2, 6));
if (isSel) {
setBackground(getSelectionBg());
setForeground(getSelectionFg());
} else {
setBackground(row % 2 == 0 ? getTableRowEven() : getTableRowOdd());
setForeground(getFgMain());
}
return this;
}
});
JTableHeader header = table.getTableHeader();
if (header != null) {
header.setBackground(getTableHeaderBg());
header.setForeground(getTableHeaderFg());
header.setFont(header.getFont().deriveFont(Font.BOLD));
header.setDefaultRenderer(new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable tbl, Object val, boolean isSel, boolean hasFocus, int row, int col) {
super.getTableCellRendererComponent(tbl, val, isSel, hasFocus, row, col);
setBackground(getTableHeaderBg());
setForeground(getTableHeaderFg());
setFont(getFont().deriveFont(Font.BOLD));
setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(0, 0, 1, 1, getBorderColor()),
new EmptyBorder(4, 6, 4, 6)));
return this;
}
});
}
return table;
}
public static JTabbedPane styleTabbedPane(JTabbedPane tp) {
if (tp == null) return null;
tp.setUI(new StyledTabbedPaneUI());
tp.setBackground(getBgMain());
tp.setForeground(getFgMain());
return tp;
}
public static JMenuBar styleMenuBar(JMenuBar bar) {
if (bar == null) return null;
bar.setUI(new StyledMenuBarUI());
bar.setBackground(getMenuBarBg());
bar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, getBorder()));
return bar;
}
public static JMenu styleMenu(JMenu menu) {
if (menu == null) return null;
menu.setUI(new StyledMenuUI());
menu.setForeground(getMenuBarFg());
menu.setBackground(getMenuBarBg());
menu.setOpaque(false);
return menu;
}
public static JMenuItem styleMenuItem(JMenuItem item) {
if (item == null) return null;
item.setUI(new StyledMenuItemUI());
item.setBackground(getMenuPopupBg());
item.setForeground(getMenuItemFg());
return item;
}
public static JPopupMenu stylePopupMenu(JPopupMenu popup) {
if (popup == null) return null;
popup.setUI(new StyledPopupMenuUI());
popup.setBackground(getMenuPopupBg());
popup.setBorder(BorderFactory.createCompoundBorder(
new LineBorder(getBorder(), 1),
new EmptyBorder(4, 0, 4, 0)));
return popup;
}
public static JScrollPane styleScrollPane(JScrollPane sp) {
if (sp == null) return null;
sp.setBackground(getBgPanel());
if (sp.getViewport() != null) {
sp.getViewport().setBackground(getBgComponent());
}
sp.setBorder(new LineBorder(getBorder(), 1));
return sp;
}
public static JSpinner styleSpinner(JSpinner sp) {
if (sp == null) return null;
sp.setBackground(getBgComponent());
sp.setForeground(getFgMain());
sp.setBorder(new LineBorder(getBorder(), 1));
JComponent editor = sp.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField();
tf.setBackground(getBgComponent());
tf.setForeground(getFgMain());
tf.setCaretColor(getFgMain());
tf.setBorder(new EmptyBorder(2, 4, 2, 4));
}
return sp;
}
public static JCheckBox styleCheckBox(JCheckBox cb) {
if (cb == null) return null;
cb.setOpaque(false);
cb.setForeground(getFgMain());
cb.setFocusPainted(false);
return cb;
}
public static JRadioButton styleRadioButton(JRadioButton rb) {
if (rb == null) return null;
rb.setOpaque(false);
rb.setForeground(getFgMain());
rb.setFocusPainted(false);
return rb;
}
public static Border createTitledBorder(String title) {
return BorderFactory.createTitledBorder(
new LineBorder(getBorder(), 1),
title,
TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION,
new Font(Font.SANS_SERIF, Font.BOLD, 12),
getFgMain());
}
// =========================================================================
// Recursive Component Styling
// =========================================================================
public static void applyTheme(Component comp) {
applyTheme(comp, currentTheme);
}
public static void applyTheme(Component comp, UITheme theme) {
if (comp == null) return;
// Skip swatch preview panels whose background is the user-configured color
if ("colorSwatch".equals(comp.getName())) {
return;
}
if (comp instanceof JMenuBar) {
styleMenuBar((JMenuBar) comp);
for (int i = 0; i < ((JMenuBar) comp).getMenuCount(); i++) {
applyTheme(((JMenuBar) comp).getMenu(i), theme);
}
return;
}
if (comp instanceof JMenu) {
styleMenu((JMenu) comp);
JMenu menu = (JMenu) comp;
for (int i = 0; i < menu.getItemCount(); i++) {
JMenuItem item = menu.getItem(i);
if (item != null) applyTheme(item, theme);
}
return;
}
if (comp instanceof JMenuItem) {
styleMenuItem((JMenuItem) comp);
return;
}
if (comp instanceof JPopupMenu) {
stylePopupMenu((JPopupMenu) comp);
for (Component child : ((JPopupMenu) comp).getComponents()) {
applyTheme(child, theme);
}
return;
}
if (comp instanceof JTabbedPane) {
styleTabbedPane((JTabbedPane) comp);
JTabbedPane tp = (JTabbedPane) comp;
for (int i = 0; i < tp.getTabCount(); i++) {
applyTheme(tp.getComponentAt(i), theme);
}
return;
}
if (comp instanceof JTable) {
styleTable((JTable) comp);
return;
}
if (comp instanceof JScrollPane) {
styleScrollPane((JScrollPane) comp);
JScrollPane sp = (JScrollPane) comp;
if (sp.getViewport() != null) {
applyTheme(sp.getViewport().getView(), theme);
}
return;
}
if (comp instanceof JButton) {
JButton btn = (JButton) comp;
if (!(btn.getUI() instanceof StyledButtonUI)) {
styleButton(btn, ButtonVariant.DEFAULT);
}
return;
}
if (comp instanceof JComboBox) {
styleComboBox((JComboBox<?>) comp);
return;
}
if (comp instanceof JSpinner) {
styleSpinner((JSpinner) comp);
return;
}
if (comp instanceof JTextArea) {
styleTextArea((JTextArea) comp);
return;
}
if (comp instanceof JTextField) {
styleTextField((JTextField) comp);
return;
}
if (comp instanceof JCheckBox) {
styleCheckBox((JCheckBox) comp);
return;
}
if (comp instanceof JRadioButton) {
styleRadioButton((JRadioButton) comp);
return;
}
if (comp instanceof JLabel) {
comp.setForeground(getFgMain(theme));
return;
}
if (comp instanceof JPanel) {
JPanel panel = (JPanel) comp;
if (panel.isOpaque()) {
panel.setBackground(getBgPanel(theme));
}
panel.setForeground(getFgMain(theme));
Border b = panel.getBorder();
if (b instanceof TitledBorder) {
TitledBorder tb = (TitledBorder) b;
tb.setTitleColor(getFgMain(theme));
tb.setBorder(new LineBorder(getBorder(theme), 1));
}
} else if (comp instanceof Container) {
comp.setBackground(getBgMain(theme));
comp.setForeground(getFgMain(theme));
}
if (comp instanceof Container) {
for (Component child : ((Container) comp).getComponents()) {
applyTheme(child, theme);
}
}
}
public static void applyThemeToWindow(Window window) {
if (window == null) return;
window.setBackground(getBgMain());
if (window instanceof RootPaneContainer) {
RootPaneContainer rpc = (RootPaneContainer) window;
if (rpc.getContentPane() != null) {
rpc.getContentPane().setBackground(getBgMain());
applyTheme(rpc.getContentPane());
}
if (rpc.getRootPane() != null && rpc.getRootPane().getJMenuBar() != null) {
applyTheme(rpc.getRootPane().getJMenuBar());
}
}
window.repaint();
}
// =========================================================================
// Custom UI Implementations
// =========================================================================
public static class StyledButtonUI extends BasicButtonUI {
private final ButtonVariant variant;
private boolean hover = false;
public StyledButtonUI(ButtonVariant variant) {
this.variant = variant != null ? variant : ButtonVariant.DEFAULT;
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
AbstractButton b = (AbstractButton) c;
b.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
hover = true;
b.repaint();
}
@Override
public void mouseExited(MouseEvent e) {
hover = false;
b.repaint();
}
});
}
@Override
public void paint(Graphics g, JComponent c) {
AbstractButton b = (AbstractButton) c;
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int w = c.getWidth();
int h = c.getHeight();
ButtonModel model = b.getModel();
boolean pressed = model.isArmed() && model.isPressed();
boolean enabled = b.isEnabled();
UITheme t = ThemeManager.getTheme();
Color bg = enabled ? ThemeManager.getButtonBg(variant, t, hover, pressed) : (t == UITheme.DARK ? new Color(40, 40, 40) : new Color(220, 220, 220));
Color fg = enabled ? ThemeManager.getButtonFg(variant, t) : ThemeManager.getFgDisabled(t);
// Background
g2.setColor(bg);
g2.fillRoundRect(0, 0, w, h, 6, 6);
// Border
if (variant == ButtonVariant.DEFAULT || variant == ButtonVariant.CANCEL) {
g2.setColor(ThemeManager.getBorder(t));
g2.drawRoundRect(0, 0, w - 1, h - 1, 6, 6);
}
// Text / Icon
FontMetrics fm = g2.getFontMetrics(b.getFont());
String text = b.getText();
if (text != null && !text.isEmpty()) {
g2.setColor(fg);
g2.setFont(b.getFont());
int tx = (w - fm.stringWidth(text)) / 2;
int ty = (h - fm.getHeight()) / 2 + fm.getAscent();
g2.drawString(text, tx, ty);
}
g2.dispose();
}
}
public static class StyledMenuBarUI extends BasicMenuBarUI {
@Override
public void paint(Graphics g, JComponent c) {
g.setColor(ThemeManager.getMenuBarBg());
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
}
public static class StyledMenuUI extends BasicMenuUI {
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
ButtonModel model = menuItem.getModel();
if (model.isArmed() || model.isSelected()) {
g.setColor(ThemeManager.getMenuItemHoverBg());
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
} else {
g.setColor(ThemeManager.getMenuBarBg());
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
}
}
@Override
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
ButtonModel model = menuItem.getModel();
if (model.isArmed() || model.isSelected()) {
g.setColor(ThemeManager.getMenuItemHoverFg());
} else {
g.setColor(ThemeManager.getMenuBarFg());
}
super.paintText(g, menuItem, textRect, text);
}
}
public static class StyledMenuItemUI extends BasicMenuItemUI {
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
ButtonModel model = menuItem.getModel();
if (model.isArmed() || model.isSelected()) {
g.setColor(ThemeManager.getSelectionBg());
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
} else {
g.setColor(ThemeManager.getMenuPopupBg());
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
}
}
@Override
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
ButtonModel model = menuItem.getModel();
if (model.isArmed() || model.isSelected()) {
g.setColor(ThemeManager.getSelectionFg());
} else {
g.setColor(ThemeManager.getMenuItemFg());
}
super.paintText(g, menuItem, textRect, text);
}
}
public static class StyledPopupMenuUI extends BasicPopupMenuUI {
@Override
public void paint(Graphics g, JComponent c) {
g.setColor(ThemeManager.getMenuPopupBg());
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
}
public static class StyledTabbedPaneUI extends BasicTabbedPaneUI {
@Override
protected void installDefaults() {
super.installDefaults();
tabInsets = new Insets(6, 16, 6, 16);
selectedTabPadInsets = new Insets(2, 2, 2, 2);
tabAreaInsets = new Insets(4, 4, 0, 4);
}
@Override
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(isSelected ? ThemeManager.getTabSelectedBg() : ThemeManager.getTabBg());
g2.fillRoundRect(x, y, w, h + 4, 6, 6);
g2.setColor(ThemeManager.getBorder());
g2.drawRoundRect(x, y, w - 1, h + 4, 6, 6);
g2.dispose();
}
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
g.setFont(font);
g.setColor(isSelected ? ThemeManager.getTabSelectedFg() : ThemeManager.getTabFg());
g.drawString(title, textRect.x, textRect.y + metrics.getAscent());
}
@Override
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
int width = tabPane.getWidth();
int height = tabPane.getHeight();
Insets insets = tabPane.getInsets();
int x = insets.left;
int y = insets.top + calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
int w = width - insets.right - insets.left;
int h = height - insets.top - insets.bottom - calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
g.setColor(ThemeManager.getTabSelectedBg());
g.fillRect(x, y, w, h);
g.setColor(ThemeManager.getBorder());
g.drawRect(x, y, w - 1, h - 1);
}
}
}
@@ -0,0 +1,33 @@
package haus.nightmare.j3270.ui;
/**
* Supported UI themes for the j3270 Java desktop interface.
*/
public enum UITheme {
DARK("Dark Mode"),
LIGHT("Light Mode");
private final String displayName;
UITheme(String displayName) {
this.displayName = displayName;
}
public String getDisplayName() {
return displayName;
}
@Override
public String toString() {
return displayName;
}
public static UITheme fromString(String name) {
if (name == null) return DARK;
String s = name.trim().toUpperCase();
if ("LIGHT".equals(s) || "LIGHT MODE".equals(s) || "LIGHT_MODE".equals(s)) {
return LIGHT;
}
return DARK;
}
}
@@ -26,25 +26,24 @@ public class UntrustedCertificateDialog extends JDialog {
private void buildUI(String host, int port, X509Certificate[] chain, CertificateException exception) { private void buildUI(String host, int port, X509Certificate[] chain, CertificateException exception) {
JPanel mainPanel = new JPanel(new BorderLayout(12, 12)); JPanel mainPanel = new JPanel(new BorderLayout(12, 12));
mainPanel.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16)); mainPanel.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));
mainPanel.setBackground(new Color(30, 30, 30));
// Header // Header
JPanel headerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0)); JPanel headerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0));
headerPanel.setBackground(new Color(30, 30, 30)); headerPanel.setOpaque(false);
JLabel iconLabel = new JLabel("⚠️"); JLabel iconLabel = new JLabel("⚠️");
iconLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 28)); iconLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 28));
headerPanel.add(iconLabel); headerPanel.add(iconLabel);
JPanel titleBox = new JPanel(new GridLayout(2, 1, 0, 2)); JPanel titleBox = new JPanel(new GridLayout(2, 1, 0, 2));
titleBox.setBackground(new Color(30, 30, 30)); titleBox.setOpaque(false);
JLabel titleLabel = new JLabel("Untrusted SSL Certificate"); JLabel titleLabel = new JLabel("Untrusted SSL Certificate");
titleLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 16)); titleLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 16));
titleLabel.setForeground(new Color(255, 180, 80)); titleLabel.setForeground(ThemeManager.getOiaFgWarn());
titleBox.add(titleLabel); titleBox.add(titleLabel);
JLabel subtitleLabel = new JLabel("The server certificate for " + host + ":" + port + " could not be verified."); JLabel subtitleLabel = new JLabel("The server certificate for " + host + ":" + port + " could not be verified.");
subtitleLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); subtitleLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
subtitleLabel.setForeground(new Color(180, 180, 180)); subtitleLabel.setForeground(ThemeManager.getFgMuted());
titleBox.add(subtitleLabel); titleBox.add(subtitleLabel);
headerPanel.add(titleBox); headerPanel.add(titleBox);
mainPanel.add(headerPanel, BorderLayout.NORTH); mainPanel.add(headerPanel, BorderLayout.NORTH);
@@ -71,30 +70,27 @@ public class UntrustedCertificateDialog extends JDialog {
JTextArea detailsArea = new JTextArea(sb.toString()); JTextArea detailsArea = new JTextArea(sb.toString());
detailsArea.setEditable(false); detailsArea.setEditable(false);
detailsArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); detailsArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
detailsArea.setBackground(new Color(20, 20, 20)); ThemeManager.styleTextArea(detailsArea);
detailsArea.setForeground(new Color(210, 210, 210));
detailsArea.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); detailsArea.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
JScrollPane scrollPane = new JScrollPane(detailsArea); JScrollPane scrollPane = new JScrollPane(detailsArea);
scrollPane.setPreferredSize(new Dimension(520, 260)); scrollPane.setPreferredSize(new Dimension(520, 260));
scrollPane.setBorder(BorderFactory.createLineBorder(new Color(60, 60, 60))); ThemeManager.styleScrollPane(scrollPane);
mainPanel.add(scrollPane, BorderLayout.CENTER); mainPanel.add(scrollPane, BorderLayout.CENTER);
// Buttons // Buttons
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0)); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0));
buttonPanel.setBackground(new Color(30, 30, 30)); buttonPanel.setOpaque(false);
JButton cancelBtn = new JButton("Cancel Connection"); JButton cancelBtn = new JButton("Cancel Connection");
cancelBtn.setBackground(new Color(60, 60, 60)); ThemeManager.styleButton(cancelBtn, ThemeManager.ButtonVariant.CANCEL);
cancelBtn.setForeground(new Color(220, 220, 220));
cancelBtn.addActionListener(e -> { cancelBtn.addActionListener(e -> {
accepted = false; accepted = false;
dispose(); dispose();
}); });
JButton trustBtn = new JButton("Connect Anyway"); JButton trustBtn = new JButton("Connect Anyway");
trustBtn.setBackground(new Color(180, 100, 40)); ThemeManager.styleButton(trustBtn, ThemeManager.ButtonVariant.DANGER);
trustBtn.setForeground(Color.WHITE);
trustBtn.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 13)); trustBtn.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 13));
trustBtn.addActionListener(e -> { trustBtn.addActionListener(e -> {
accepted = true; accepted = true;
@@ -106,6 +102,7 @@ public class UntrustedCertificateDialog extends JDialog {
mainPanel.add(buttonPanel, BorderLayout.SOUTH); mainPanel.add(buttonPanel, BorderLayout.SOUTH);
setContentPane(mainPanel); setContentPane(mainPanel);
ThemeManager.applyThemeToWindow(this);
getRootPane().setDefaultButton(trustBtn); getRootPane().setDefaultButton(trustBtn);
} }
@@ -0,0 +1,115 @@
package haus.nightmare.j3270.ui;
import haus.nightmare.j3270.J3270App;
import org.junit.jupiter.api.Test;
import javax.swing.*;
import java.awt.HeadlessException;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
public class MenuBarShortcutsTest {
private Map<String, JMenuItem> collectMenuItems(JMenu menu) {
Map<String, JMenuItem> map = new HashMap<>();
for (int i = 0; i < menu.getItemCount(); i++) {
JMenuItem item = menu.getItem(i);
if (item != null) {
map.put(item.getText(), item);
}
}
return map;
}
@Test
public void testActionAndViewShortcutsUseAlt() {
J3270App app;
try {
app = new J3270App();
} catch (HeadlessException e) {
// In automated/headless environments, JFrame cannot be initialized
return;
}
try {
JMenuBar mb = app.getJMenuBar();
assertNotNull(mb, "JMenuBar should be present");
JMenu viewMenu = null;
JMenu actionsMenu = null;
JMenu fileMenu = null;
JMenu editMenu = null;
for (int i = 0; i < mb.getMenuCount(); i++) {
JMenu m = mb.getMenu(i);
if (m != null) {
if ("View".equals(m.getText())) viewMenu = m;
else if ("Actions".equals(m.getText())) actionsMenu = m;
else if ("File".equals(m.getText())) fileMenu = m;
else if ("Edit".equals(m.getText())) editMenu = m;
}
}
assertNotNull(viewMenu, "View menu should exist");
assertNotNull(actionsMenu, "Actions menu should exist");
assertNotNull(fileMenu, "File menu should exist");
assertNotNull(editMenu, "Edit menu should exist");
// Verify View Menu items
Map<String, JMenuItem> viewItems = collectMenuItems(viewMenu);
assertAcceleratorUsesAlt(viewItems.get("Font Size +"), KeyEvent.VK_EQUALS);
assertAcceleratorUsesAlt(viewItems.get("Font Size -"), KeyEvent.VK_MINUS);
assertAcceleratorUsesAlt(viewItems.get("Reset Font"), KeyEvent.VK_0);
// Crosshair Ruler must use Alt+Shift+R
JMenuItem rulerItem = viewItems.get("Crosshair Ruler");
assertNotNull(rulerItem, "Crosshair Ruler menu item must exist");
KeyStroke rulerKs = rulerItem.getAccelerator();
assertNotNull(rulerKs, "Crosshair Ruler should have an accelerator");
assertEquals(KeyEvent.VK_R, rulerKs.getKeyCode(), "Key code mismatch for Crosshair Ruler");
int rulerMods = rulerKs.getModifiers();
assertTrue((rulerMods & (KeyEvent.ALT_DOWN_MASK | KeyEvent.ALT_MASK)) != 0,
"Crosshair Ruler accelerator must have ALT modifier");
assertTrue((rulerMods & (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.SHIFT_MASK)) != 0,
"Crosshair Ruler accelerator must have SHIFT modifier");
assertEquals(0, rulerMods & (KeyEvent.CTRL_DOWN_MASK | KeyEvent.CTRL_MASK | KeyEvent.META_DOWN_MASK | KeyEvent.META_MASK),
"Crosshair Ruler accelerator must NOT have CTRL or META modifiers");
// Verify Actions Menu items use ALT_DOWN_MASK
Map<String, JMenuItem> actionItems = collectMenuItems(actionsMenu);
assertAcceleratorUsesAlt(actionItems.get("Send Enter"), KeyEvent.VK_ENTER);
assertAcceleratorUsesAlt(actionItems.get("Clear"), KeyEvent.VK_K);
assertAcceleratorUsesAlt(actionItems.get("Reset"), KeyEvent.VK_R);
assertAcceleratorUsesAlt(actionItems.get("Erase Input"), KeyEvent.VK_E);
assertAcceleratorUsesAlt(actionItems.get("Attention"), KeyEvent.VK_A);
assertAcceleratorUsesAlt(actionItems.get("System Request"), KeyEvent.VK_S);
assertAcceleratorUsesAlt(actionItems.get("Cursor Select"), KeyEvent.VK_Q);
assertAcceleratorUsesAlt(actionItems.get("Toggle Light Pen (Alt+L)"), KeyEvent.VK_L);
assertAcceleratorUsesAlt(actionItems.get("File Transfer..."), KeyEvent.VK_T);
// Ensure Crosshair Ruler and Reset do not collide
assertNotEquals(rulerKs, actionItems.get("Reset").getAccelerator(),
"Crosshair Ruler and Reset accelerators must not collide");
} finally {
// Dispose frame
app.dispose();
}
}
private void assertAcceleratorUsesAlt(JMenuItem item, int expectedKeyCode) {
assertNotNull(item, "Menu item must exist");
KeyStroke ks = item.getAccelerator();
assertNotNull(ks, "Menu item " + item.getText() + " should have an accelerator");
assertEquals(expectedKeyCode, ks.getKeyCode(), "Key code mismatch for " + item.getText());
int mods = ks.getModifiers();
assertTrue((mods & (KeyEvent.ALT_DOWN_MASK | KeyEvent.ALT_MASK)) != 0,
"Menu item " + item.getText() + " accelerator must have ALT modifier");
assertEquals(0, mods & (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.SHIFT_MASK),
"Menu item " + item.getText() + " accelerator must NOT have SHIFT modifier");
assertEquals(0, mods & (KeyEvent.CTRL_DOWN_MASK | KeyEvent.CTRL_MASK | KeyEvent.META_DOWN_MASK | KeyEvent.META_MASK),
"Menu item " + item.getText() + " accelerator must NOT have CTRL or META modifiers");
}
}
@@ -0,0 +1,104 @@
package haus.nightmare.j3270.ui;
import haus.nightmare.j3270.config.Settings;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.awt.Color;
import java.awt.HeadlessException;
import static org.junit.jupiter.api.Assertions.*;
/**
* Verification test suite for Phase 1 UI Overlays and Color Alignment.
* Covers items 1.1, 1.2, and 1.5 of the PhasedUpdates specification.
*/
public class Phase1UiOverlayTest {
@Test
@DisplayName("Item 1.1 & 1.2: TerminalPanel host and mono colors match IBM Host On-Demand specs")
public void testTerminalPanelColorAlignment() {
// Index 10: Orange (255, 162, 0)
assertEquals(new Color(255, 162, 0), TerminalPanel.DEFAULT_HOST_COLORS[10]);
// Index 14: Mustard (160, 160, 0)
assertEquals(new Color(160, 160, 0), TerminalPanel.DEFAULT_HOST_COLORS[14]);
// Index 1: Blue (120, 144, 240)
assertEquals(new Color(120, 144, 240), TerminalPanel.DEFAULT_HOST_COLORS[1]);
// Base 4-Color mono defaults
assertEquals(new Color(0, 255, 0), TerminalPanel.DEFAULT_MONO_NORMAL);
assertEquals(new Color(255, 0, 0), TerminalPanel.DEFAULT_MONO_INTENSIFY);
assertEquals(new Color(0, 255, 255), TerminalPanel.DEFAULT_MONO_PROTECTED);
assertEquals(new Color(255, 255, 255), TerminalPanel.DEFAULT_MONO_PROTECTED_HIGH);
}
@Test
@DisplayName("Item 1.5: ThemeManager HoD OIA category colors match specification")
public void testThemeManagerOiaColors() {
// oSI: Status / System Available -> CUSTOMBLUE (120, 144, 240)
assertEquals(new Color(120, 144, 240), ThemeManager.getOiaStatusSysAvail());
// oII: Input Inhibited / X SYSTEM -> White (255, 255, 255)
assertEquals(new Color(255, 255, 255), ThemeManager.getOiaInputInhibited());
// oAI: Attention / Reminders / Message Waiting -> Yellow (255, 255, 0)
assertEquals(new Color(255, 255, 0), ThemeManager.getOiaAttention());
// oEI: Error Checks / Comm Check -> Red (255, 0, 0)
assertEquals(new Color(255, 0, 0), ThemeManager.getOiaCommCheck());
// oOB: OIA Separator / Background -> Black (0, 0, 0)
assertEquals(new Color(0, 0, 0), ThemeManager.getOiaBackground());
}
@Test
@DisplayName("Item 1.5: TerminalPanel Crosshair Ruler and Cursor Style controls")
public void testTerminalPanelRulerAndCursorStyle() {
try {
TerminalPanel panel = new TerminalPanel();
// Default cursor style is BLOCK
assertEquals(TerminalPanel.CursorStyle.BLOCK, panel.getCursorStyle());
panel.setCursorStyle(TerminalPanel.CursorStyle.UNDERLINE);
assertEquals(TerminalPanel.CursorStyle.UNDERLINE, panel.getCursorStyle());
// Crosshair ruler toggling
assertFalse(panel.isCrosshairRulerEnabled());
panel.setCrosshairRulerEnabled(true);
assertTrue(panel.isCrosshairRulerEnabled());
panel.toggleCrosshairRuler();
assertFalse(panel.isCrosshairRulerEnabled());
// Wallpaper image setter
assertNull(panel.getWallpaperImage());
} catch (HeadlessException e) {
// Handled gracefully in headless CI environments
}
}
@Test
@DisplayName("Settings persistence for Crosshair Ruler and Cursor Style")
public void testSettingsPersistence() {
boolean originalRuler = Settings.getCrosshairRuler();
String originalCursor = Settings.getCursorStyle();
try {
Settings.setCrosshairRuler(true);
assertTrue(Settings.getCrosshairRuler());
Settings.setCrosshairRuler(false);
assertFalse(Settings.getCrosshairRuler());
Settings.setCursorStyle("UNDERLINE");
assertEquals("UNDERLINE", Settings.getCursorStyle());
Settings.setCursorStyle("BLOCK");
assertEquals("BLOCK", Settings.getCursorStyle());
} finally {
Settings.setCrosshairRuler(originalRuler);
Settings.setCursorStyle(originalCursor);
}
}
}
@@ -0,0 +1,95 @@
package haus.nightmare.j3270.ui;
import haus.nightmare.lib3270j.graphics.GocaConstants;
import haus.nightmare.lib3270j.graphics.GraphicsPlane;
import haus.nightmare.lib3270j.graphics.HODWallpaper;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.image.BufferedImage;
import static org.junit.jupiter.api.Assertions.*;
/**
* Verification test suite for Phase 2 UI Vector Graphics, Wallpaper, and Cursor Overlays.
*/
public class Phase2UiGraphicsTest {
@Test
@DisplayName("Test TerminalPanel Wallpaper Integration (Tile, Center, Stretch)")
public void testTerminalPanelWallpaperModes() {
try {
TerminalPanel panel = new TerminalPanel();
assertNull(panel.getHodWallpaper());
assertNull(panel.getWallpaperImage());
BufferedImage img = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
panel.setWallpaperImage(img);
assertNotNull(panel.getWallpaperImage());
assertNotNull(panel.getHodWallpaper());
assertEquals(HODWallpaper.HOD_STRETCH, panel.getHodWallpaper().getDisplay());
panel.setWallpaperMode(HODWallpaper.HOD_TILE);
assertEquals(HODWallpaper.HOD_TILE, panel.getHodWallpaper().getDisplay());
panel.setWallpaperMode(HODWallpaper.HOD_CENTER);
assertEquals(HODWallpaper.HOD_CENTER, panel.getHodWallpaper().getDisplay());
HODWallpaper customWp = new HODWallpaper(img, HODWallpaper.HOD_TILE);
panel.setHodWallpaper(customWp);
assertSame(customWp, panel.getHodWallpaper());
// Clear wallpaper
panel.setWallpaperImage(null);
assertNull(panel.getHodWallpaper());
assertNull(panel.getWallpaperImage());
} catch (HeadlessException e) {
// Handled gracefully in headless environments
}
}
@Test
@DisplayName("Test Graphics Plane Cursor Synchronization and Rendering")
public void testGraphicsCursorOverlay() {
try {
TerminalPanel panel = new TerminalPanel();
panel.setSize(new Dimension(800, 600));
panel.setClient(new haus.nightmare.lib3270j.Telnet3270Client(new haus.nightmare.lib3270j.ConnectionConfig("localhost", 23)));
GraphicsPlane plane = panel.getClient() != null ? panel.getClient().getGraphicsPlane() : null;
if (plane != null) {
// Attach graphics cursor
plane.attachGraphicCursor(100, 100);
plane.setHodCursorShape(GocaConstants.GCURSOR_SHAPE_CROSSHAIR);
assertTrue(plane.isGraphicCursorAttached());
assertEquals(100, plane.getGraphicCursorX());
assertEquals(100, plane.getGraphicCursorY());
assertEquals(1, plane.getHodCursorShape());
// Paint component to verify no exceptions during rendering
BufferedImage offscreen = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = offscreen.createGraphics();
panel.paint(g2);
g2.dispose();
// Change cursor shape to box
plane.setHodCursorShape(GocaConstants.GCURSOR_SHAPE_BOX);
assertEquals(2, plane.getHodCursorShape());
offscreen = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB);
g2 = offscreen.createGraphics();
panel.paint(g2);
g2.dispose();
// Detach graphics cursor
plane.detachGraphicCursor();
assertFalse(plane.isGraphicCursorAttached());
}
} catch (HeadlessException e) {
// Handled gracefully in headless environments
}
}
}
@@ -14,16 +14,21 @@ public class StatusBarTest {
@Test @Test
public void testStatusBarDoesNotContainLightPenButton() { public void testStatusBarDoesNotContainLightPenButton() {
try {
StatusBar statusBar = new StatusBar(); StatusBar statusBar = new StatusBar();
// Ensure no JButton exists in StatusBar components (lightpen button removed) // Ensure no JButton exists in StatusBar components (lightpen button removed)
for (Component comp : statusBar.getComponents()) { for (Component comp : statusBar.getComponents()) {
assertFalse(comp instanceof JButton, "StatusBar should not contain any JButton (lightpen removed from bottom bar)"); assertFalse(comp instanceof JButton, "StatusBar should not contain any JButton (lightpen removed from bottom bar)");
} }
} catch (HeadlessException e) {
// Ignored in headless environments
}
} }
@Test @Test
public void testStatusBarUpdatesWithClient() { public void testStatusBarUpdatesWithClient() {
try {
ConnectionConfig config = new ConnectionConfig("mvs.example.com", 23, TerminalModel.IBM_3279_4, false); ConnectionConfig config = new ConnectionConfig("mvs.example.com", 23, TerminalModel.IBM_3279_4, false);
config.setLuName("TSU001"); config.setLuName("TSU001");
config.setCodePage("1047"); config.setCodePage("1047");
@@ -50,5 +55,8 @@ public class StatusBarTest {
assertTrue(foundCodePage, "Should display CP1047"); assertTrue(foundCodePage, "Should display CP1047");
assertTrue(foundModel, "Should display IBM-3279-4 model info"); assertTrue(foundModel, "Should display IBM-3279-4 model info");
} catch (HeadlessException e) {
// Ignored in headless environments
}
} }
} }
@@ -0,0 +1,221 @@
package haus.nightmare.j3270.ui;
import haus.nightmare.j3270.config.Settings;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.io.File;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.concurrent.atomic.AtomicReference;
import static org.junit.jupiter.api.Assertions.*;
public class ThemeManagerTest {
@BeforeEach
public void setup() {
ThemeManager.setTheme(UITheme.DARK);
}
@Test
public void testUIThemeEnum() {
assertEquals("Dark Mode", UITheme.DARK.getDisplayName());
assertEquals("Light Mode", UITheme.LIGHT.getDisplayName());
assertEquals(UITheme.DARK, UITheme.fromString("DARK"));
assertEquals(UITheme.DARK, UITheme.fromString("dark"));
assertEquals(UITheme.DARK, UITheme.fromString("Dark Mode"));
assertEquals(UITheme.LIGHT, UITheme.fromString("LIGHT"));
assertEquals(UITheme.LIGHT, UITheme.fromString("light"));
assertEquals(UITheme.LIGHT, UITheme.fromString("Light Mode"));
assertEquals(UITheme.DARK, UITheme.fromString("invalid_value"));
}
@Test
public void testColorTokensContrast() {
for (UITheme theme : UITheme.values()) {
Color bg = ThemeManager.getBgMain(theme);
Color fg = ThemeManager.getFgMain(theme);
assertNotNull(bg);
assertNotNull(fg);
// Compute luminance contrast
double bgLum = (0.299 * bg.getRed() + 0.587 * bg.getGreen() + 0.114 * bg.getBlue());
double fgLum = (0.299 * fg.getRed() + 0.587 * fg.getGreen() + 0.114 * fg.getBlue());
double lumDiff = Math.abs(bgLum - fgLum);
// Minimum luminance difference to guarantee readability
assertTrue(lumDiff > 120, "Theme " + theme + " text contrast luminance difference " + lumDiff + " must be > 120");
// Verify Menu Bar colors
Color menuBg = ThemeManager.getMenuBarBg(theme);
Color menuFg = ThemeManager.getMenuItemFg(theme);
double menuBgLum = (0.299 * menuBg.getRed() + 0.587 * menuBg.getGreen() + 0.114 * menuBg.getBlue());
double menuFgLum = (0.299 * menuFg.getRed() + 0.587 * menuFg.getGreen() + 0.114 * menuFg.getBlue());
assertTrue(Math.abs(menuBgLum - menuFgLum) > 100, "Menu contrast in " + theme + " must be high");
// Verify Status Bar colors
Color sbBg = ThemeManager.getStatusBarBg(theme);
Color sbNormal = ThemeManager.getOiaFgNormal(theme);
assertNotNull(sbBg);
assertNotNull(sbNormal);
// Verify Button colors
Color btnDefBg = ThemeManager.getButtonBg(ThemeManager.ButtonVariant.DEFAULT, theme);
Color btnDefFg = ThemeManager.getButtonFg(ThemeManager.ButtonVariant.DEFAULT, theme);
assertNotNull(btnDefBg);
assertNotNull(btnDefFg);
Color btnPriBg = ThemeManager.getButtonBg(ThemeManager.ButtonVariant.PRIMARY, theme);
Color btnPriFg = ThemeManager.getButtonFg(ThemeManager.ButtonVariant.PRIMARY, theme);
assertNotNull(btnPriBg);
assertNotNull(btnPriFg);
}
}
@Test
public void testThemeChangeListeners() {
AtomicReference<UITheme> notifiedTheme = new AtomicReference<>(null);
ThemeManager.addThemeChangeListener(notifiedTheme::set);
ThemeManager.setTheme(UITheme.LIGHT);
assertEquals(UITheme.LIGHT, ThemeManager.getTheme());
assertEquals(UITheme.LIGHT, notifiedTheme.get());
assertTrue(ThemeManager.isLight());
assertFalse(ThemeManager.isDark());
ThemeManager.setTheme(UITheme.DARK);
assertEquals(UITheme.DARK, ThemeManager.getTheme());
assertEquals(UITheme.DARK, notifiedTheme.get());
assertTrue(ThemeManager.isDark());
assertFalse(ThemeManager.isLight());
}
@Test
public void testComponentStyling() {
try {
JButton btn = new JButton("Test");
ThemeManager.styleButton(btn, ThemeManager.ButtonVariant.PRIMARY);
assertNotNull(btn.getUI());
assertTrue(btn.getUI() instanceof ThemeManager.StyledButtonUI);
JTextField tf = new JTextField("Test");
ThemeManager.styleTextField(tf);
assertNotNull(tf.getCaretColor());
JTextArea ta = new JTextArea("Test area");
ThemeManager.styleTextArea(ta);
assertNotNull(ta.getCaretColor());
JComboBox<String> cb = new JComboBox<>(new String[]{"A", "B"});
ThemeManager.styleComboBox(cb);
assertNotNull(cb.getUI());
JTable table = new JTable(new DefaultTableModel(new Object[]{"Col1"}, 1));
ThemeManager.styleTable(table);
assertNotNull(table.getSelectionBackground());
JTabbedPane tp = new JTabbedPane();
tp.addTab("Tab1", new JPanel());
ThemeManager.styleTabbedPane(tp);
assertNotNull(tp.getUI());
JMenuBar mb = new JMenuBar();
ThemeManager.styleMenuBar(mb);
JMenu menu = new JMenu("File");
ThemeManager.styleMenu(menu);
JMenuItem mi = new JMenuItem("Open");
ThemeManager.styleMenuItem(mi);
JPopupMenu popup = new JPopupMenu();
ThemeManager.stylePopupMenu(popup);
JCheckBox chk = new JCheckBox("Check");
ThemeManager.styleCheckBox(chk);
JRadioButton rb = new JRadioButton("Radio");
ThemeManager.styleRadioButton(rb);
Border tb = ThemeManager.createTitledBorder("Title");
assertNotNull(tb);
} catch (HeadlessException e) {
// Ignored in headless environments
}
}
@Test
public void testRecursiveApplyTheme() {
try {
JPanel root = new JPanel(new BorderLayout());
JButton b = new JButton("OK");
JTextField f = new JTextField("Data");
JTabbedPane tp = new JTabbedPane();
JPanel tabContent = new JPanel();
JLabel lbl = new JLabel("Label");
tabContent.add(lbl);
tp.addTab("T1", tabContent);
root.add(b, BorderLayout.NORTH);
root.add(f, BorderLayout.CENTER);
root.add(tp, BorderLayout.SOUTH);
ThemeManager.setTheme(UITheme.LIGHT);
ThemeManager.applyTheme(root);
assertEquals(ThemeManager.getBgPanel(UITheme.LIGHT), root.getBackground());
assertEquals(ThemeManager.getFgMain(UITheme.LIGHT), lbl.getForeground());
ThemeManager.setTheme(UITheme.DARK);
ThemeManager.applyTheme(root);
assertEquals(ThemeManager.getBgPanel(UITheme.DARK), root.getBackground());
assertEquals(ThemeManager.getFgMain(UITheme.DARK), lbl.getForeground());
} catch (HeadlessException e) {
// Ignored in headless environments
}
}
@Test
public void testSettingsPersistence() throws Exception {
Settings.setJavaUiTheme(UITheme.LIGHT);
assertEquals(UITheme.LIGHT, Settings.getJavaUiTheme());
File tmpIni = File.createTempFile("j3270_test_config", ".ini");
tmpIni.deleteOnExit();
try {
// Write INI file with javaUiTheme = dark
try (PrintWriter pw = new PrintWriter(tmpIni)) {
pw.println("[j3270]");
pw.println("javaUiTheme = dark");
pw.println("fontFamily = Monospaced");
pw.println("fontSize = 16");
}
Settings.loadFromIniFile(tmpIni.getAbsolutePath());
assertEquals(UITheme.DARK, Settings.getJavaUiTheme());
// Switch to light and export
Settings.setJavaUiTheme(UITheme.LIGHT);
File exportFile = File.createTempFile("j3270_export_config", ".ini");
exportFile.deleteOnExit();
Settings.exportToIniFile(exportFile.getAbsolutePath());
String exportedContent = new String(Files.readAllBytes(exportFile.toPath()));
assertTrue(exportedContent.toLowerCase().contains("javauitheme = light"));
// Reload exported file
Settings.loadFromIniFile(exportFile.getAbsolutePath());
assertEquals(UITheme.LIGHT, Settings.getJavaUiTheme());
} finally {
tmpIni.delete();
}
}
}
@@ -5,6 +5,10 @@ package haus.nightmare.lib3270j;
*/ */
public class ConnectionConfig { public class ConnectionConfig {
public enum ProxyType {
NONE, HTTP, SOCKS4, SOCKS5
}
private String host; private String host;
private int port = 23; private int port = 23;
private TerminalModel model = TerminalModel.IBM_3279_4; private TerminalModel model = TerminalModel.IBM_3279_4;
@@ -14,6 +18,16 @@ public class ConnectionConfig {
private boolean tlsVerifyCert = true; private boolean tlsVerifyCert = true;
private haus.nightmare.lib3270j.tls.TlsCertificateVerifier certificateVerifier = null; private haus.nightmare.lib3270j.tls.TlsCertificateVerifier certificateVerifier = null;
private String sslProtocol = "TLS"; private String sslProtocol = "TLS";
private String keyStorePath = null;
private String keyStorePassword = null;
private String keyStoreType = null;
private String keyStoreAlias = null;
private String trustStorePath = null;
private String trustStorePassword = null;
private String trustStoreType = null;
private ClassLoader customizedCAsClassLoader = null;
private java.util.List<String> enabledProtocols = new java.util.ArrayList<>();
private java.util.List<String> enabledCipherSuites = new java.util.ArrayList<>();
private int connectTimeoutMs = 15000; private int connectTimeoutMs = 15000;
private int nopIntervalSeconds = 0; private int nopIntervalSeconds = 0;
private String terminalName = null; // override terminal type string private String terminalName = null; // override terminal type string
@@ -23,11 +37,26 @@ public class ConnectionConfig {
private int soTimeoutMs = 0; private int soTimeoutMs = 0;
private java.util.List<String> luNames = new java.util.ArrayList<>(); private java.util.List<String> luNames = new java.util.ArrayList<>();
private boolean dynamicModel = false; private boolean dynamicModel = false;
private int dynamicRows = 24; private int dynamicRows = 62;
private int dynamicCols = 80; private int dynamicCols = 160;
private haus.nightmare.lib3270j.graphics.GraphicsMode graphicsMode = haus.nightmare.lib3270j.graphics.GraphicsMode.BOTH; private haus.nightmare.lib3270j.graphics.GraphicsMode graphicsMode = haus.nightmare.lib3270j.graphics.GraphicsMode.BOTH;
private String codePage = "037"; private String codePage = "037";
private String associatedPrinterLu = null; private String associatedPrinterLu = null;
private boolean nvtLocalEcho = false;
// Proxy configuration
private ProxyType proxyType = ProxyType.NONE;
private String proxyHost = null;
private int proxyPort = 0;
private String proxyUsername = null;
private String proxyPassword = null;
// STARTTLS (Telnet Option 46) dynamic socket elevation
private boolean startTlsEnabled = true;
// RFC 1572 / RFC 2877 Environment variables (Express Logon)
private java.util.Map<String, String> environmentVariables = new java.util.LinkedHashMap<>();
private java.util.Map<String, String> userVariables = new java.util.LinkedHashMap<>();
public ConnectionConfig() {} public ConnectionConfig() {}
@@ -62,7 +91,12 @@ public class ConnectionConfig {
public void setPort(int port) { this.port = port; } public void setPort(int port) { this.port = port; }
public TerminalModel getModel() { return model; } public TerminalModel getModel() { return model; }
public void setModel(TerminalModel model) { this.model = model; } public void setModel(TerminalModel model) {
this.model = model;
if (model != null && model.isDynamic()) {
this.dynamicModel = true;
}
}
public String getLuName() { return luName; } public String getLuName() { return luName; }
public void setLuName(String luName) { this.luName = luName; } public void setLuName(String luName) { this.luName = luName; }
@@ -85,6 +119,52 @@ public class ConnectionConfig {
public String getSslProtocol() { return sslProtocol; } public String getSslProtocol() { return sslProtocol; }
public void setSslProtocol(String protocol) { this.sslProtocol = protocol; } public void setSslProtocol(String protocol) { this.sslProtocol = protocol; }
public String getKeyStorePath() { return keyStorePath; }
public void setKeyStorePath(String path) { this.keyStorePath = path; }
public String getKeyStorePassword() { return keyStorePassword; }
public void setKeyStorePassword(String password) { this.keyStorePassword = password; }
public String getKeyStoreType() { return keyStoreType; }
public void setKeyStoreType(String type) { this.keyStoreType = type; }
public String getKeyStoreAlias() { return keyStoreAlias; }
public void setKeyStoreAlias(String alias) { this.keyStoreAlias = alias; }
public String getTrustStorePath() { return trustStorePath; }
public void setTrustStorePath(String path) { this.trustStorePath = path; }
public String getTrustStorePassword() { return trustStorePassword; }
public void setTrustStorePassword(String password) { this.trustStorePassword = password; }
public String getTrustStoreType() { return trustStoreType; }
public void setTrustStoreType(String type) { this.trustStoreType = type; }
public ClassLoader getCustomizedCAsClassLoader() { return customizedCAsClassLoader; }
public void setCustomizedCAsClassLoader(ClassLoader cl) { this.customizedCAsClassLoader = cl; }
public java.util.List<String> getEnabledProtocols() { return enabledProtocols; }
public void setEnabledProtocols(java.util.List<String> protocols) {
this.enabledProtocols = protocols != null ? new java.util.ArrayList<>(protocols) : new java.util.ArrayList<>();
}
public void setEnabledProtocols(String... protocols) {
this.enabledProtocols = new java.util.ArrayList<>();
if (protocols != null) {
for (String p : protocols) if (p != null) this.enabledProtocols.add(p);
}
}
public java.util.List<String> getEnabledCipherSuites() { return enabledCipherSuites; }
public void setEnabledCipherSuites(java.util.List<String> cipherSuites) {
this.enabledCipherSuites = cipherSuites != null ? new java.util.ArrayList<>(cipherSuites) : new java.util.ArrayList<>();
}
public void setEnabledCipherSuites(String... cipherSuites) {
this.enabledCipherSuites = new java.util.ArrayList<>();
if (cipherSuites != null) {
for (String c : cipherSuites) if (c != null) this.enabledCipherSuites.add(c);
}
}
public int getConnectTimeoutMs() { return connectTimeoutMs; } public int getConnectTimeoutMs() { return connectTimeoutMs; }
public void setConnectTimeoutMs(int ms) { this.connectTimeoutMs = ms; } public void setConnectTimeoutMs(int ms) { this.connectTimeoutMs = ms; }
@@ -101,6 +181,9 @@ public class ConnectionConfig {
this.codePage = (codePage != null && !codePage.trim().isEmpty()) ? codePage.trim() : "037"; this.codePage = (codePage != null && !codePage.trim().isEmpty()) ? codePage.trim() : "037";
} }
public boolean isNvtLocalEcho() { return nvtLocalEcho; }
public void setNvtLocalEcho(boolean nvtLocalEcho) { this.nvtLocalEcho = nvtLocalEcho; }
public String getTerminalName() { return terminalName; } public String getTerminalName() { return terminalName; }
public void setTerminalName(String name) { this.terminalName = name; } public void setTerminalName(String name) { this.terminalName = name; }
@@ -123,20 +206,84 @@ public class ConnectionConfig {
} }
} }
public boolean isDynamicModel() { return dynamicModel; } public boolean isDynamicModel() {
public void setDynamicModel(boolean dynamicModel) { this.dynamicModel = dynamicModel; } return dynamicModel || (model != null && model.isDynamic());
}
public void setDynamicModel(boolean dynamicModel) {
this.dynamicModel = dynamicModel;
if (dynamicModel && (model == null || !model.isDynamic())) {
this.model = TerminalModel.IBM_DYNAMIC;
} else if (!dynamicModel && model != null && model.isDynamic()) {
this.model = TerminalModel.IBM_3279_4;
}
}
public void setDynamic(boolean dynamic) {
setDynamicModel(dynamic);
}
public int getDynamicRows() { return dynamicRows; } public int getDynamicRows() { return dynamicRows; }
public int getDynamicCols() { return dynamicCols; } public int getDynamicCols() { return dynamicCols; }
public void setDynamicDimensions(int rows, int cols) { public void setDynamicDimensions(int rows, int cols) {
this.dynamicModel = true; this.dynamicModel = true;
this.dynamicRows = rows; this.dynamicRows = Math.max(1, rows);
this.dynamicCols = cols; this.dynamicCols = Math.max(1, cols);
this.model = TerminalModel.IBM_DYNAMIC;
}
public ProxyType getProxyType() { return proxyType; }
public void setProxyType(ProxyType proxyType) { this.proxyType = proxyType != null ? proxyType : ProxyType.NONE; }
public String getProxyHost() { return proxyHost; }
public void setProxyHost(String proxyHost) { this.proxyHost = proxyHost; }
public int getProxyPort() { return proxyPort; }
public void setProxyPort(int proxyPort) { this.proxyPort = proxyPort; }
public String getProxyUsername() { return proxyUsername; }
public void setProxyUsername(String proxyUsername) { this.proxyUsername = proxyUsername; }
public String getProxyPassword() { return proxyPassword; }
public void setProxyPassword(String proxyPassword) { this.proxyPassword = proxyPassword; }
public void setProxy(ProxyType type, String host, int port, String username, String password) {
this.proxyType = type != null ? type : ProxyType.NONE;
this.proxyHost = host;
this.proxyPort = port;
this.proxyUsername = username;
this.proxyPassword = password;
}
public boolean isStartTlsEnabled() { return startTlsEnabled; }
public void setStartTlsEnabled(boolean enabled) { this.startTlsEnabled = enabled; }
public java.util.Map<String, String> getEnvironmentVariables() { return environmentVariables; }
public void setEnvironmentVariables(java.util.Map<String, String> vars) {
this.environmentVariables = (vars != null) ? new java.util.LinkedHashMap<>(vars) : new java.util.LinkedHashMap<>();
}
public void setEnvironmentVariable(String name, String value) {
if (name != null) {
if (value != null) this.environmentVariables.put(name, value);
else this.environmentVariables.remove(name);
}
}
public java.util.Map<String, String> getUserVariables() { return userVariables; }
public void setUserVariables(java.util.Map<String, String> vars) {
this.userVariables = (vars != null) ? new java.util.LinkedHashMap<>(vars) : new java.util.LinkedHashMap<>();
}
public void setUserVariable(String name, String value) {
if (name != null) {
if (value != null) this.userVariables.put(name, value);
else this.userVariables.remove(name);
}
} }
/** /**
* Parse a host connection string which may include prefixes for TLS (e.g. "L:host:port", "ssl:host:port", "y:host:port"), * Parse a host connection string which may include prefixes for TLS (e.g. "L:host:port", "ssl:host:port", "y:host:port"),
* plain TN3270 (e.g. "P:host:port", "plain:host:port", "non-e:host:port"), or standard "host:port" formats. * plain TN3270 (e.g. "P:host:port", "plain:host:port", "non-e:host:port"), proxy flags (e.g. "--proxy=http://proxy:8080 host:23"),
* or standard "host:port" formats.
*/ */
public static ConnectionConfig parseHostString(String hostStr, int defaultPort, TerminalModel defaultModel) { public static ConnectionConfig parseHostString(String hostStr, int defaultPort, TerminalModel defaultModel) {
if (hostStr == null || hostStr.trim().isEmpty()) { if (hostStr == null || hostStr.trim().isEmpty()) {
@@ -145,6 +292,53 @@ public class ConnectionConfig {
String s = hostStr.trim(); String s = hostStr.trim();
boolean tls = false; boolean tls = false;
boolean tn3270e = true; boolean tn3270e = true;
boolean dynamic = false;
int dynRows = 62;
int dynCols = 160;
// Parse --proxy=<url> or -proxy=<url> flags
ProxyType pType = ProxyType.NONE;
String pHost = null;
int pPort = 0;
String pUser = null;
String pPass = null;
String[] tokens = s.split("\\s+");
StringBuilder remaining = new StringBuilder();
for (String tok : tokens) {
if (tok.startsWith("--proxy=") || tok.startsWith("-proxy=")) {
String proxyUrl = tok.substring(tok.indexOf('=') + 1).trim();
try {
java.net.URI uri = new java.net.URI(proxyUrl);
String scheme = uri.getScheme() != null ? uri.getScheme().toLowerCase() : "http";
if (scheme.equals("http") || scheme.equals("https")) {
pType = ProxyType.HTTP;
pPort = uri.getPort() > 0 ? uri.getPort() : 8080;
} else if (scheme.equals("socks4") || scheme.equals("socks4a")) {
pType = ProxyType.SOCKS4;
pPort = uri.getPort() > 0 ? uri.getPort() : 1080;
} else if (scheme.equals("socks5") || scheme.equals("socks")) {
pType = ProxyType.SOCKS5;
pPort = uri.getPort() > 0 ? uri.getPort() : 1080;
}
pHost = uri.getHost();
String userInfo = uri.getUserInfo();
if (userInfo != null) {
int colon = userInfo.indexOf(':');
if (colon >= 0) {
pUser = userInfo.substring(0, colon);
pPass = userInfo.substring(colon + 1);
} else {
pUser = userInfo;
}
}
} catch (Exception ignored) {}
} else {
if (remaining.length() > 0) remaining.append(" ");
remaining.append(tok);
}
}
s = remaining.toString().trim();
// Parse chained x3270-style prefixes (e.g. "L:P:host:port" or "P:host:port") // Parse chained x3270-style prefixes (e.g. "L:P:host:port" or "P:host:port")
boolean prefixFound = true; boolean prefixFound = true;
@@ -172,6 +366,29 @@ public class ConnectionConfig {
int colon = s.indexOf(':'); int colon = s.indexOf(':');
s = s.substring(colon + 1); s = s.substring(colon + 1);
prefixFound = true; prefixFound = true;
} else if (s.startsWith("D:") || s.startsWith("d:")) {
dynamic = true;
s = s.substring(2);
prefixFound = true;
} else if (s.toLowerCase().startsWith("dyn:") || s.toLowerCase().startsWith("dynamic:") ||
s.toLowerCase().startsWith("dyn[") || s.toLowerCase().startsWith("dynamic[")) {
int colon = s.indexOf(':');
if (colon > 0) {
String prefix = s.substring(0, colon);
s = s.substring(colon + 1);
prefixFound = true;
dynamic = true;
if (prefix.contains("[") && prefix.contains("]")) {
String dim = prefix.substring(prefix.indexOf('[') + 1, prefix.indexOf(']'));
String[] parts = dim.toLowerCase().split("x");
if (parts.length == 2) {
try {
dynRows = Integer.parseInt(parts[0].trim());
dynCols = Integer.parseInt(parts[1].trim());
} catch (NumberFormatException ignored) {}
}
}
}
} }
} }
@@ -200,6 +417,12 @@ public class ConnectionConfig {
ConnectionConfig config = new ConnectionConfig(host, port, defaultModel != null ? defaultModel : TerminalModel.IBM_3279_4); ConnectionConfig config = new ConnectionConfig(host, port, defaultModel != null ? defaultModel : TerminalModel.IBM_3279_4);
config.setUseTls(tls); config.setUseTls(tls);
config.setTn3270eEnabled(tn3270e); config.setTn3270eEnabled(tn3270e);
if (dynamic) {
config.setDynamicDimensions(dynRows, dynCols);
}
if (pType != ProxyType.NONE && pHost != null) {
config.setProxy(pType, pHost, pPort, pUser, pPass);
}
return config; return config;
} }
@@ -210,7 +433,7 @@ public class ConnectionConfig {
if (terminalName != null) { if (terminalName != null) {
return terminalName; return terminalName;
} }
if (dynamicModel) { if (isDynamicModel()) {
return extendedDataStream ? "IBM-DYNAMIC-E" : "IBM-DYNAMIC"; return extendedDataStream ? "IBM-DYNAMIC-E" : "IBM-DYNAMIC";
} }
return extendedDataStream ? model.getTerminalType() : model.getBaseTerminalType(); return extendedDataStream ? model.getTerminalType() : model.getBaseTerminalType();
@@ -59,4 +59,32 @@ public enum ConnectionState {
public boolean isFullSession() { public boolean isFullSession() {
return isNvt() || is3270(); return isNvt() || is3270();
} }
/**
* Map to IBM Host On-Demand ECL connection state integer codes.
* 0 = Disconnected, 1 = Connecting/Resolving, 2 = Connected (NVT/Unbound), 3 = Bound (Full 3270 session).
*/
public int toHoDStateCode() {
switch (this) {
case NOT_CONNECTED:
return 0;
case RECONNECTING:
case RESOLVING:
case TCP_PENDING:
case TLS_PENDING:
case PROXY_PENDING:
case TELNET_PENDING:
return 1;
case CONNECTED_NVT:
case CONNECTED_NVT_CHAR:
case CONNECTED_UNBOUND:
case CONNECTED_E_NVT:
case CONNECTED_SSCP:
return 2;
case CONNECTED_3270:
case CONNECTED_TN3270E:
default:
return 3;
}
}
} }
@@ -47,13 +47,23 @@ public class Telnet3270Client {
public Telnet3270Client(ConnectionConfig config) { public Telnet3270Client(ConnectionConfig config) {
this.config = config; this.config = config;
this.translator = new EbcdicTranslator(config.getCodePage()); this.translator = new EbcdicTranslator(config.getCodePage());
if (config.isDynamicModel() || (config.getModel() != null && config.getModel().isDynamic())) {
this.screenBuffer = new ScreenBuffer(
haus.nightmare.lib3270j.protocol.DS3270Constants.MODEL_2_ROWS,
haus.nightmare.lib3270j.protocol.DS3270Constants.MODEL_2_COLS,
config.getDynamicRows(),
config.getDynamicCols(),
translator);
} else {
this.screenBuffer = new ScreenBuffer(config.getModel(), translator); this.screenBuffer = new ScreenBuffer(config.getModel(), translator);
}
this.dsProcessor = new DataStreamProcessor(screenBuffer, translator); this.dsProcessor = new DataStreamProcessor(screenBuffer, translator);
this.dsProcessor.getQueryReplyBuilder().setGraphicsMode(config.getGraphicsMode()); this.dsProcessor.getQueryReplyBuilder().setGraphicsMode(config.getGraphicsMode());
this.fsm = new TelnetFSM(config, screenBuffer, dsProcessor); this.fsm = new TelnetFSM(config, screenBuffer, dsProcessor);
this.inputProcessor = new InputProcessor(screenBuffer, translator, fsm); this.inputProcessor = new InputProcessor(screenBuffer, translator, fsm);
this.ps = new haus.nightmare.lib3270j.ecl.ECLPS(screenBuffer, inputProcessor, translator); this.ps = new haus.nightmare.lib3270j.ecl.ECLPS(screenBuffer, inputProcessor, translator);
this.oia = new haus.nightmare.lib3270j.ecl.ECLOIA(screenBuffer, inputProcessor, fsm); this.oia = new haus.nightmare.lib3270j.ecl.ECLOIA(screenBuffer, inputProcessor, fsm);
this.inputProcessor.setOIA(oia);
this.xfer = new haus.nightmare.lib3270j.ecl.ECLXfer(screenBuffer, inputProcessor, dsProcessor, translator); this.xfer = new haus.nightmare.lib3270j.ecl.ECLXfer(screenBuffer, inputProcessor, dsProcessor, translator);
// Wire up the output sender: DSProcessor -> FSM -> TelnetConnection // Wire up the output sender: DSProcessor -> FSM -> TelnetConnection
@@ -62,11 +72,21 @@ public class Telnet3270Client {
inputProcessor.setGraphicsPlane(dsProcessor.getGraphicsPlane()); inputProcessor.setGraphicsPlane(dsProcessor.getGraphicsPlane());
inputProcessor.setGocaDecoder(dsProcessor.getGocaDecoder()); inputProcessor.setGocaDecoder(dsProcessor.getGocaDecoder());
// Wire screen update to ECLXfer for CUT mode screen tracking // Wire screen update to ECLXfer for CUT mode screen tracking and ECLPS for event dispatching
addScreenUpdateListener(new haus.nightmare.lib3270j.listener.ScreenUpdateListener() { addScreenUpdateListener(new haus.nightmare.lib3270j.listener.ScreenUpdateListener() {
@Override public void onScreenUpdated() { xfer.onScreenUpdated(); } @Override public void onScreenUpdated() {
@Override public void onScreenSizeChanged(int rows, int cols) {} xfer.onScreenUpdated();
@Override public void onSoundAlarm() {} ps.notifyPSUpdate(0, 0, screenBuffer.getRows() - 1, screenBuffer.getCols() - 1, true);
}
@Override public void onCursorMoved(int oldAddress, int newAddress) {
ps.notifyCursorMoved(oldAddress, newAddress);
}
@Override public void onScreenSizeChanged(int rows, int cols) {
ps.notifyScreenResized(rows, cols);
}
@Override public void onSoundAlarm() {
ps.notifyAlarm();
}
}); });
} }
@@ -89,6 +109,52 @@ public class Telnet3270Client {
fsm.onConnected(); fsm.onConnected();
} }
/**
* Connect to the configured host synchronously, blocking until the full data session is established
* (or timeout expires).
* @param timeoutMs maximum time to wait in milliseconds
* @return true if successfully connected, false if timed out
* @throws IOException if network connection fails
*/
public boolean connect(long timeoutMs) throws IOException {
connect();
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timeoutMs) {
ConnectionState state = getConnectionState();
if (state.isFullSession() || (state.isFullyConnected() && isConnected())) {
return true;
}
if (state == ConnectionState.NOT_CONNECTED && !isConnected()) {
return false;
}
try {
Thread.sleep(25);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return false;
}
}
return getConnectionState().isFullSession() || isConnected();
}
/**
* Connect to the configured host synchronously and block until the presentation space matches
* the specified screen descriptor.
* @param timeoutMs maximum time to wait in milliseconds
* @param desc ECLScreenDesc descriptor to match against
* @return true if successfully connected and screen matched, false otherwise
* @throws IOException if network connection fails
*/
public boolean connect(long timeoutMs, haus.nightmare.lib3270j.ecl.ECLScreenDesc desc) throws IOException {
long start = System.currentTimeMillis();
if (!connect(timeoutMs)) {
return false;
}
long elapsed = System.currentTimeMillis() - start;
long remaining = Math.max(1, timeoutMs - elapsed);
return ps.waitForScreen(desc, remaining);
}
/** /**
* Disconnect from the host. * Disconnect from the host.
*/ */
@@ -100,6 +166,35 @@ public class Telnet3270Client {
fsm.onDisconnect(); fsm.onDisconnect();
} }
/**
* Disconnect from host with synchronous teardown.
* @param timeoutMs maximum time to wait for graceful disconnect in milliseconds
*/
public void disconnect(long timeoutMs) {
disconnect();
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timeoutMs) {
if (getConnectionState() == ConnectionState.NOT_CONNECTED && !isConnected()) {
break;
}
try {
Thread.sleep(20);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
}
/** HoD StopCommunication compatibility alias. */
public void stopCommunication() {
disconnect();
}
public void stopCommunication(long timeoutMs) {
disconnect(timeoutMs);
}
/** /**
* Check if connected (any state past TCP pending). * Check if connected (any state past TCP pending).
*/ */
@@ -113,11 +208,28 @@ public class Telnet3270Client {
fsm.addConnectionListener(l); fsm.addConnectionListener(l);
} }
public void removeConnectionListener(ConnectionListener l) {
fsm.removeConnectionListener(l);
}
public void addScreenUpdateListener(ScreenUpdateListener l) { public void addScreenUpdateListener(ScreenUpdateListener l) {
fsm.addScreenUpdateListener(l); fsm.addScreenUpdateListener(l);
dsProcessor.addScreenUpdateListener(l); dsProcessor.addScreenUpdateListener(l);
} }
public void removeScreenUpdateListener(ScreenUpdateListener l) {
fsm.removeScreenUpdateListener(l);
dsProcessor.removeScreenUpdateListener(l);
}
public void addSCSInboundListener(haus.nightmare.lib3270j.listener.SCSInboundListener l) {
fsm.addSCSInboundListener(l);
}
public void removeSCSInboundListener(haus.nightmare.lib3270j.listener.SCSInboundListener l) {
fsm.removeSCSInboundListener(l);
}
// ========== Screen access ========== // ========== Screen access ==========
/** Get the screen buffer for rendering. */ /** Get the screen buffer for rendering. */
@@ -141,6 +253,9 @@ public class Telnet3270Client {
/** Get the data stream processor. */ /** Get the data stream processor. */
public DataStreamProcessor getDataStreamProcessor() { return dsProcessor; } public DataStreamProcessor getDataStreamProcessor() { return dsProcessor; }
/** Get the underlying telnet connection. */
public TelnetConnection getConnection() { return connection; }
/** Get the connection config. */ /** Get the connection config. */
public ConnectionConfig getConfig() { return config; } public ConnectionConfig getConfig() { return config; }
@@ -189,11 +304,48 @@ public class Telnet3270Client {
fsm.sendNVTString(s); fsm.sendNVTString(s);
} }
// ========== Convenience input methods ========== /** Send an NVT key event mapped through NVT processor. */
public boolean sendNVTKey(int keyCode, char keyChar, boolean shift, boolean ctrl, boolean alt) throws IOException {
haus.nightmare.lib3270j.nvt.NvtProcessor nvt = getNvtProcessor();
if (nvt != null) {
String seq = nvt.mapKey(keyCode, keyChar, shift, ctrl, alt);
if (seq != null && !seq.isEmpty()) {
fsm.sendNvtData(seq.getBytes(java.nio.charset.StandardCharsets.US_ASCII));
return true;
}
}
return false;
}
public void addNvtTitleListener(haus.nightmare.lib3270j.nvt.NvtProcessor.NvtTitleListener l) {
if (getNvtProcessor() != null) {
getNvtProcessor().addTitleListener(l);
}
}
public void removeNvtTitleListener(haus.nightmare.lib3270j.nvt.NvtProcessor.NvtTitleListener l) {
if (getNvtProcessor() != null) {
getNvtProcessor().removeTitleListener(l);
}
}
public void setNvtClipboardHandler(haus.nightmare.lib3270j.nvt.NvtProcessor.ClipboardHandler h) {
if (getNvtProcessor() != null) {
getNvtProcessor().setClipboardHandler(h);
}
}
// ========== Convenience input methods & HoD compatibility ==========
/** Type a character at the cursor position. */ /** Type a character at the cursor position. */
public void typeCharacter(char ch) { inputProcessor.typeCharacter(ch); } public void typeCharacter(char ch) { inputProcessor.typeCharacter(ch); }
/** Process a character at the current cursor position. */
public void processChar(char ch) { inputProcessor.processChar(ch); }
/** Process a character with explicit position and insert mode flag. */
public void processChar(char ch, int pos, boolean insert) { inputProcessor.processChar(ch, pos, insert); }
/** Type a string at the cursor position. */ /** Type a string at the cursor position. */
public void typeString(String s) { public void typeString(String s) {
for (char ch : s.toCharArray()) { for (char ch : s.toCharArray()) {
@@ -210,6 +362,7 @@ public class Telnet3270Client {
public void sendEnter() { public void sendEnter() {
inputProcessor.sendAid(haus.nightmare.lib3270j.protocol.DS3270Constants.AID_ENTER); inputProcessor.sendAid(haus.nightmare.lib3270j.protocol.DS3270Constants.AID_ENTER);
} }
public void processEnter() { inputProcessor.processEnter(); }
/** Send a PF key (1-24). */ /** Send a PF key (1-24). */
public void sendPF(int number) { public void sendPF(int number) {
@@ -231,6 +384,7 @@ public class Telnet3270Client {
} }
inputProcessor.sendAid(aid); inputProcessor.sendAid(aid);
} }
public void processPF(int number) { inputProcessor.processPF(number); }
/** Send a PA key (1-3). */ /** Send a PA key (1-3). */
public void sendPA(int number) { public void sendPA(int number) {
@@ -243,44 +397,104 @@ public class Telnet3270Client {
} }
inputProcessor.sendAid(aid); inputProcessor.sendAid(aid);
} }
public void processPA(int number) { inputProcessor.processPA(number); }
/** Send Clear key. */ /** Send Clear key. */
public void sendClear() { public void sendClear() {
inputProcessor.sendAid(haus.nightmare.lib3270j.protocol.DS3270Constants.AID_CLEAR); inputProcessor.sendAid(haus.nightmare.lib3270j.protocol.DS3270Constants.AID_CLEAR);
} }
public void processClear() { inputProcessor.processClear(); }
/** Move cursor up. */ /** Move cursor up. */
public void cursorUp() { inputProcessor.cursorUp(); } public void cursorUp() { inputProcessor.cursorUp(); }
public void processCursorUp() { inputProcessor.processCursorUp(); }
/** Move cursor down. */ /** Move cursor down. */
public void cursorDown() { inputProcessor.cursorDown(); } public void cursorDown() { inputProcessor.cursorDown(); }
public void processCursorDown() { inputProcessor.processCursorDown(); }
/** Move cursor left. */ /** Move cursor left. */
public void cursorLeft() { inputProcessor.cursorLeft(); } public void cursorLeft() { inputProcessor.cursorLeft(); }
public void processCursorLeft() { inputProcessor.processCursorLeft(); }
/** Move cursor right. */ /** Move cursor right. */
public void cursorRight() { inputProcessor.cursorRight(); } public void cursorRight() { inputProcessor.cursorRight(); }
public void processCursorRight() { inputProcessor.processCursorRight(); }
/** Move cursor to home position. */ /** Move cursor to home position. */
public void cursorHome() { inputProcessor.cursorHome(); } public void cursorHome() { inputProcessor.cursorHome(); }
public void processHome() { inputProcessor.processHome(); }
/** Tab to next unprotected field. */ /** Tab to next unprotected field. */
public void tab() { inputProcessor.tab(); } public void tab() { inputProcessor.tab(); }
public void processTab() { inputProcessor.processTab(); }
/** Back-tab to previous unprotected field. */ /** Back-tab to previous unprotected field. */
public void backTab() { inputProcessor.backTab(); } public void backTab() { inputProcessor.backTab(); }
public void processBackTab() { inputProcessor.processBackTab(); }
/** Move cursor to next line. */ /** Move cursor to next line. */
public void newline() { inputProcessor.newline(); } public void newline() { inputProcessor.newline(); }
public void processNewline() { inputProcessor.processNewline(); }
/** Delete character under cursor. */
public void deleteChar() { inputProcessor.deleteChar(); }
public void processDelete() { inputProcessor.processDelete(); }
/** Backspace character before cursor. */
public void backspace() { inputProcessor.backspace(); }
public void processBackspace() { inputProcessor.processBackspace(); }
/** Erase to end of field. */
public void eraseEof() { inputProcessor.eraseEof(); }
public void processEraseEOF() { inputProcessor.processEraseEOF(); }
/** Erase all unprotected fields. */ /** Erase all unprotected fields. */
public void eraseInput() { inputProcessor.eraseInput(); } public void eraseInput() { inputProcessor.eraseInput(); }
public void processEraseInput() { inputProcessor.processEraseInput(); }
/** Insert Duplicate order. */ /** Insert Duplicate order. */
public void dup() { inputProcessor.dup(); } public void dup() { inputProcessor.dup(); }
public void processDup() { inputProcessor.processDup(); }
/** Insert Field Mark order. */ /** Insert Field Mark order. */
public void fieldMark() { inputProcessor.fieldMark(); } public void fieldMark() { inputProcessor.fieldMark(); }
public void processFieldMark() { inputProcessor.processFieldMark(); }
/** Toggle Insert Mode. */
public void toggleInsert() { inputProcessor.setInsertMode(!inputProcessor.isInsertMode()); }
public void processToggleInsert() { inputProcessor.processToggleInsert(); }
/** Move word left. */
public void processWordLeft() { inputProcessor.processWordLeft(); }
/** Move word right. */
public void processWordRight() { inputProcessor.processWordRight(); }
/** Move to field end. */
public void processFieldEnd() { inputProcessor.processFieldEnd(); }
/** Attention key. */ /** Attention key. */
public void attn() { inputProcessor.attn(); } public void attn() { inputProcessor.attn(); }
public void processAttn() { inputProcessor.processAttn(); }
/** SysReq key. */ /** SysReq key. */
public void sysReq() { inputProcessor.sysReq(); } public void sysReq() { inputProcessor.sysReq(); }
/** Reset (unlock keyboard). */ public void processSysReq() { inputProcessor.processSysReq(); }
/** Reset (unlock keyboard, reset OIA). */
public void reset() { inputProcessor.reset(); } public void reset() { inputProcessor.reset(); }
public void processReset() { inputProcessor.processReset(); }
/** Trigger 3270 CURSR SEL (Cursor Select) key at current cursor position. */ /** Trigger 3270 CURSR SEL (Cursor Select) key at current cursor position. */
public boolean cursorSelect() { return inputProcessor.cursorSelect(); } public boolean cursorSelect() { return inputProcessor.cursorSelect(); }
/** Trigger Light Pen selection at the specified screen address. */ public boolean processCurSel() { return inputProcessor.processCurSel(); }
public boolean processCursorSelect() { return inputProcessor.processCursorSelect(); }
/** Trigger Light Pen selection at the specified screen address or cursor position. */
public boolean lightPenSelect(int address) { return inputProcessor.lightPenSelect(address); } public boolean lightPenSelect(int address) { return inputProcessor.lightPenSelect(address); }
public boolean processLightPen() { return inputProcessor.processLightPen(); }
public boolean processLightPen(int addr) { return inputProcessor.processLightPen(addr); }
public haus.nightmare.lib3270j.graphics.ProgramSymbolManager getProgramSymbolManager() { public haus.nightmare.lib3270j.graphics.ProgramSymbolManager getProgramSymbolManager() {
return dsProcessor.getProgramSymbolManager(); return dsProcessor.getProgramSymbolManager();
@@ -14,7 +14,8 @@ public enum TerminalModel {
IBM_3279_2(2, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_2_ROWS, MODEL_2_COLS), IBM_3279_2(2, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_2_ROWS, MODEL_2_COLS),
IBM_3279_3(3, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_3_ROWS, MODEL_3_COLS), IBM_3279_3(3, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_3_ROWS, MODEL_3_COLS),
IBM_3279_4(4, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_4_ROWS, MODEL_4_COLS), IBM_3279_4(4, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_4_ROWS, MODEL_4_COLS),
IBM_3279_5(5, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_5_ROWS, MODEL_5_COLS); IBM_3279_5(5, true, MODEL_2_ROWS, MODEL_2_COLS, MODEL_5_ROWS, MODEL_5_COLS),
IBM_DYNAMIC(0, true, MODEL_2_ROWS, MODEL_2_COLS, 62, 160);
private final int modelNumber; private final int modelNumber;
private final boolean color; private final boolean color;
@@ -40,12 +41,17 @@ public enum TerminalModel {
public int getDefaultCols() { return defaultCols; } public int getDefaultCols() { return defaultCols; }
public int getAlternateRows() { return alternateRows; } public int getAlternateRows() { return alternateRows; }
public int getAlternateCols() { return alternateCols; } public int getAlternateCols() { return alternateCols; }
public boolean isDynamic() { return modelNumber == 0; }
/** /**
* Returns the terminal type string for TN3270E negotiation. * Returns the terminal type string for TN3270E negotiation.
* e.g., "IBM-3279-4-E" for a color model 4 with extended data stream. * e.g., "IBM-3279-4-E" for a color model 4 with extended data stream,
* or "IBM-DYNAMIC-E" for dynamic model.
*/ */
public String getTerminalType() { public String getTerminalType() {
if (modelNumber == 0) {
return "IBM-DYNAMIC-E";
}
return String.format("IBM-327%c-%d-E", color ? '9' : '8', modelNumber); return String.format("IBM-327%c-%d-E", color ? '9' : '8', modelNumber);
} }
@@ -53,6 +59,9 @@ public enum TerminalModel {
* Returns the base terminal type without "-E" suffix (for non-extended mode). * Returns the base terminal type without "-E" suffix (for non-extended mode).
*/ */
public String getBaseTerminalType() { public String getBaseTerminalType() {
if (modelNumber == 0) {
return "IBM-DYNAMIC";
}
return String.format("IBM-327%c-%d", color ? '9' : '8', modelNumber); return String.format("IBM-327%c-%d", color ? '9' : '8', modelNumber);
} }
@@ -60,6 +69,9 @@ public enum TerminalModel {
* Look up a model by number and color mode. * Look up a model by number and color mode.
*/ */
public static TerminalModel forModel(int number, boolean isColor) { public static TerminalModel forModel(int number, boolean isColor) {
if (number == 0) {
return IBM_DYNAMIC;
}
for (TerminalModel m : values()) { for (TerminalModel m : values()) {
if (m.modelNumber == number && m.color == isColor) { if (m.modelNumber == number && m.color == isColor) {
return m; return m;
@@ -106,6 +106,19 @@ public abstract class AbstractDBCSCodePage extends AbstractCodePage {
@Override @Override
public String ebcdicToString(byte[] ebcdic, int offset, int length) { public String ebcdicToString(byte[] ebcdic, int offset, int length) {
return ebcdicToString(ebcdic, offset, length, false);
}
/**
* Translate an EBCDIC byte array slice to a Unicode String with optional SO/SI escape preservation.
*
* @param ebcdic source byte array
* @param offset start offset
* @param length number of bytes
* @param preserveSOSI if true, preserves Shift-Out (\u000E) and Shift-In (\u000F) control characters
* @return translated Unicode String
*/
public String ebcdicToString(byte[] ebcdic, int offset, int length, boolean preserveSOSI) {
if (ebcdic == null || length <= 0) return ""; if (ebcdic == null || length <= 0) return "";
StringBuilder sb = new StringBuilder(length); StringBuilder sb = new StringBuilder(length);
@@ -117,9 +130,15 @@ public abstract class AbstractDBCSCodePage extends AbstractCodePage {
int b = ebcdic[i] & 0xFF; int b = ebcdic[i] & 0xFF;
if (b == SO) { if (b == SO) {
inDBCS = true; inDBCS = true;
if (preserveSOSI) {
sb.append((char) SO);
}
i++; i++;
} else if (b == SI) { } else if (b == SI) {
inDBCS = false; inDBCS = false;
if (preserveSOSI) {
sb.append((char) SI);
}
i++; i++;
} else if (inDBCS) { } else if (inDBCS) {
if (i + 1 < end) { if (i + 1 < end) {
@@ -127,13 +146,22 @@ public abstract class AbstractDBCSCodePage extends AbstractCodePage {
if (b2 == SI) { if (b2 == SI) {
// Orphaned single byte before SI // Orphaned single byte before SI
inDBCS = false; inDBCS = false;
if (preserveSOSI) {
sb.append(ebcdicToUnicode(b));
sb.append((char) SI);
}
i += 2; i += 2;
} else if (b2 == SO) {
// Unmatched byte followed by another SO
sb.append(ebcdicToUnicode(b));
i++;
} else { } else {
sb.append(dbcsToUnicode(b, b2)); sb.append(dbcsToUnicode(b, b2));
i += 2; i += 2;
} }
} else { } else {
// Trailing byte // Trailing single byte inside unclosed DBCS shift
sb.append(ebcdicToUnicode(b));
i++; i++;
} }
} else { } else {
@@ -147,14 +175,39 @@ public abstract class AbstractDBCSCodePage extends AbstractCodePage {
@Override @Override
public byte[] stringToEbcdic(String s) { public byte[] stringToEbcdic(String s) {
return stringToEbcdic(s, true);
}
/**
* Translate a Unicode String to EBCDIC byte array with optional parsing of embedded SO/SI markers.
*
* @param s input Unicode string
* @param parseSOSIMarkers whether to interpret embedded \u000E (SO) and \u000F (SI) characters
* @return EBCDIC byte array with balanced SO/SI framing
*/
public byte[] stringToEbcdic(String s, boolean parseSOSIMarkers) {
if (s == null || s.isEmpty()) return new byte[0]; if (s == null || s.isEmpty()) return new byte[0];
// Manual state machine encoding
ByteArrayOutputStream out = new ByteArrayOutputStream(s.length() * 2); ByteArrayOutputStream out = new ByteArrayOutputStream(s.length() * 2);
boolean inDBCS = false; boolean inDBCS = false;
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i); char c = s.charAt(i);
if (parseSOSIMarkers && c == (char) SO) {
if (!inDBCS) {
out.write(SO);
inDBCS = true;
}
continue;
} else if (parseSOSIMarkers && c == (char) SI) {
if (inDBCS) {
out.write(SI);
inDBCS = false;
}
continue;
}
int dbcsCode = unicodeToDbcs(c); int dbcsCode = unicodeToDbcs(c);
if (dbcsCode >= 0) { if (dbcsCode >= 0) {
@@ -175,10 +228,26 @@ public abstract class AbstractDBCSCodePage extends AbstractCodePage {
} }
} }
// Auto-close unclosed DBCS shift sequence
if (inDBCS) { if (inDBCS) {
out.write(SI); out.write(SI);
} }
return out.toByteArray(); return out.toByteArray();
} }
/**
* Helper to decode an EBCDIC byte array to UTF-8 String preserving SO/SI control codes.
*/
public String ebcdicToUtf8WithSOSI(byte[] ebcdic) {
if (ebcdic == null) return "";
return ebcdicToString(ebcdic, 0, ebcdic.length, true);
}
/**
* Helper to encode a UTF-8/Unicode String with embedded SO/SI markers to EBCDIC.
*/
public byte[] utf8WithSOSIToEbcdic(String s) {
return stringToEbcdic(s, true);
}
} }
@@ -69,4 +69,88 @@ public interface CodePage {
* Returns -1 if unmappable. * Returns -1 if unmappable.
*/ */
int unicodeToDbcs(char unicode); int unicodeToDbcs(char unicode);
/**
* Convert an EBCDIC byte buffer to a char array matching IBM HoD conversion.
*/
default char[] convBuffByte2Char(byte[] buf, int offset, int length) {
if (buf == null || length <= 0) return new char[0];
char[] out = new char[length];
for (int i = 0; i < length; i++) {
out[i] = ebcdicToUnicode(buf[offset + i] & 0xFF);
} }
return out;
}
/**
* Convert a char array to an EBCDIC byte array matching IBM HoD conversion.
*/
default byte[] convBuffChar2Byte(char[] buf, int offset, int length) {
if (buf == null || length <= 0) return new byte[0];
byte[] out = new byte[length];
for (int i = 0; i < length; i++) {
out[i] = unicodeToEbcdicSafe(buf[offset + i]);
}
return out;
}
/**
* Get a HODByteToCharConverter instance backed by this CodePage.
*/
default haus.nightmare.lib3270j.converters.HODByteToCharConverter getByteToCharConverter() {
if (isDBCS()) {
return new haus.nightmare.lib3270j.converters.ByteToCharDBCS_EBCDIC(this);
} else {
return new haus.nightmare.lib3270j.converters.ByteToCharSingleByte(this);
}
}
/**
* Get a HODCharToByteConverter instance backed by this CodePage.
*/
default haus.nightmare.lib3270j.converters.HODCharToByteConverter getCharToByteConverter() {
if (isDBCS()) {
return new haus.nightmare.lib3270j.converters.CharToByteDBCS_EBCDIC(this);
} else {
return new haus.nightmare.lib3270j.converters.CharToByteSingleByte(this);
}
}
/**
* Helper to test if a pair of characters forms a Unicode surrogate pair.
*/
static boolean isSurrogate(char high, char low) {
return Character.isSurrogatePair(high, low);
}
/**
* Helper to test if a character is a high surrogate.
*/
static boolean isHighSurrogate(char c) {
return Character.isHighSurrogate(c);
}
/**
* Helper to test if a character is a low surrogate.
*/
static boolean isLowSurrogate(char c) {
return Character.isLowSurrogate(c);
}
/**
* Helper matching IBM HoD CodePage.ComposeChar to combine characters.
*/
static boolean ComposeChar(char[] chars) {
if (chars == null || chars.length < 2) return false;
if (chars[1] >= '\u0300' && chars[1] <= '\u036F') {
String decomposed = new String(chars, 0, 2);
String normalized = java.text.Normalizer.normalize(decomposed, java.text.Normalizer.Form.NFC);
if (normalized.length() == 1) {
chars[0] = normalized.charAt(0);
return true;
}
}
return false;
}
}
@@ -53,6 +53,9 @@ public class CodePageRegistry {
register(new Cp937.Cp1371()); register(new Cp937.Cp1371());
register(new Cp933()); register(new Cp933());
// Register Phase 8 Extended EBCDIC Codepages (Arabic, Hebrew, Thai, Cyrillic, Turkish, Extended DBCS)
registerExtendedCodepages();
// Setup common aliases // Setup common aliases
addAlias("us", "037"); addAlias("us", "037");
addAlias("usa", "037"); addAlias("usa", "037");
@@ -154,7 +157,25 @@ public class CodePageRegistry {
public static String normalizeKey(String name) { public static String normalizeKey(String name) {
if (name == null) return ""; if (name == null) return "";
String s = name.trim().toLowerCase(); String s = name.trim();
// Strip package qualifiers if present (e.g. com.ibm.eNetwork.HOD.converters.onea.ByteToCharCp273)
int lastDot = Math.max(s.lastIndexOf('.'), s.lastIndexOf('/'));
if (lastDot >= 0 && lastDot < s.length() - 1) {
s = s.substring(lastDot + 1);
}
// Strip HoD converter class prefixes
for (String pfx : new String[]{
"HODByteToChar", "HODCharToByte", "ByteToChar", "CharToByte",
"ConverterBIDIPrinter", "ConverterFT", "ConverterJDK", "ConverterVT", "PrtConverter"
}) {
if (s.startsWith(pfx)) {
s = s.substring(pfx.length());
break;
}
}
s = s.toLowerCase();
s = s.replace("_", "").replace("-", ""); s = s.replace("_", "").replace("-", "");
if (s.startsWith("ebcdiccp")) { if (s.startsWith("ebcdiccp")) {
s = s.substring(8); s = s.substring(8);
@@ -171,13 +192,12 @@ public class CodePageRegistry {
} }
/** /**
* Look up a code page by ID or alias. * Look up a code page by ID, alias, or converter name without fallback to CP037.
* If not found in built-ins, attempts to load via java.nio.charset.Charset. * Returns null if unresolvable.
* Falls back to CP037 if completely unresolvable.
*/ */
public static CodePage getCodePage(String name) { public static CodePage resolveCodePage(String name) {
if (name == null || name.trim().isEmpty()) { if (name == null || name.trim().isEmpty()) {
return CODE_PAGES.get("037"); return null;
} }
String raw = name.trim(); String raw = name.trim();
@@ -195,6 +215,9 @@ public class CodePageRegistry {
if (targetId != null) { if (targetId != null) {
cp = CODE_PAGES.get(targetId); cp = CODE_PAGES.get(targetId);
if (cp != null) return cp; if (cp != null) return cp;
String normTarget = normalizeKey(targetId);
cp = CODE_PAGES.get(normTarget);
if (cp != null) return cp;
} }
// Try standard NIO Charset dynamic adapter // Try standard NIO Charset dynamic adapter
@@ -202,22 +225,217 @@ public class CodePageRegistry {
if (Charset.isSupported(raw)) { if (Charset.isSupported(raw)) {
return new NioCodePageAdapter(raw); return new NioCodePageAdapter(raw);
} }
if (Charset.isSupported(norm)) {
return new NioCodePageAdapter(norm);
}
String ibmName = "IBM" + norm; String ibmName = "IBM" + norm;
if (Charset.isSupported(ibmName)) { if (Charset.isSupported(ibmName)) {
return new NioCodePageAdapter(ibmName); return new NioCodePageAdapter(ibmName);
} }
String ibmDashName = "IBM-" + norm;
if (Charset.isSupported(ibmDashName)) {
return new NioCodePageAdapter(ibmDashName);
}
String cpName = "Cp" + norm; String cpName = "Cp" + norm;
if (Charset.isSupported(cpName)) { if (Charset.isSupported(cpName)) {
return new NioCodePageAdapter(cpName); return new NioCodePageAdapter(cpName);
} }
String isoName = "ISO-8859-" + norm.replace("8859", "");
if (Charset.isSupported(isoName)) {
return new NioCodePageAdapter(isoName);
}
String winName = "windows-" + norm;
if (Charset.isSupported(winName)) {
return new NioCodePageAdapter(winName);
}
} catch (Exception e) { } catch (Exception e) {
log.fine("Dynamic charset loading failed for " + name + ": " + e.getMessage()); log.fine("Dynamic charset loading failed for " + name + ": " + e.getMessage());
} }
return null;
}
/**
* Look up a code page by ID or alias.
* If not found in built-ins, attempts to load via java.nio.charset.Charset.
* Falls back to CP037 if completely unresolvable.
*/
public static CodePage get(String name) {
return getCodePage(name);
}
public static CodePage getDefault() {
return getCodePage("037");
}
public static CodePage getCodePage(String name) {
CodePage cp = resolveCodePage(name);
if (cp != null) {
return cp;
}
log.warning("CodePage not recognized: '" + name + "'; falling back to CP037"); log.warning("CodePage not recognized: '" + name + "'; falling back to CP037");
return CODE_PAGES.get("037"); return CODE_PAGES.get("037");
} }
/**
* Register extended EBCDIC codepages from HoD v14 converters:
* - Arabic: Cp420, Cp424
* - Hebrew: Cp424, Cp803
* - Thai: Cp838, Cp1160
* - Cyrillic: Cp1025, Cp1123, Cp1154, Cp880
* - Turkish: Cp1155, Cp905
* - Extended Chinese DBCS: Cp1388, Cp1371
*/
public static void registerExtendedCodepages() {
// Arabic & Hebrew
register(new Cp420());
register(new Cp424());
register(new Cp803());
// Thai
register(new Cp838());
register(new Cp1160());
// Cyrillic / Russian / Ukrainian
register(new Cp1025());
register(new Cp1123());
register(new Cp1154());
register(new Cp880());
// Turkish
register(new Cp1155());
register(new Cp905());
// Extended Chinese DBCS
register(new Cp1388());
register(new Cp1371());
// Setup Extended Aliases
addAlias("ar", "420");
addAlias("arabic", "420");
addAlias("ebcdic-cp-ar", "420");
addAlias("he", "424");
addAlias("hebrew", "424");
addAlias("hebrew-lowercase", "424");
addAlias("ebcdic-cp-he", "424");
addAlias("hebrew-old", "803");
addAlias("israel", "803");
addAlias("iw", "803");
addAlias("ebcdic-cp-he-old", "803");
addAlias("th", "838");
addAlias("thai", "838");
addAlias("ebcdic-cp-th", "838");
addAlias("thai-euro", "1160");
addAlias("ru", "1025");
addAlias("russian", "1025");
addAlias("cyrillic", "1025");
addAlias("ebcdic-cp-ru", "1025");
addAlias("ukraine", "1123");
addAlias("ukrainian", "1123");
addAlias("ebcdic-cp-ua", "1123");
addAlias("cyrillic-euro", "1154");
addAlias("ru-euro", "1154");
addAlias("russian-euro", "1154");
addAlias("cyrillic-russian", "880");
addAlias("ru-old", "880");
addAlias("turkish-euro", "1155");
addAlias("tr-euro", "1155");
addAlias("turkish-latin3", "905");
addAlias("tr-latin3", "905");
addAlias("chinese-ext-simplified", "1388");
addAlias("zh-simplified-ext", "1388");
addAlias("zh-ext", "1388");
addAlias("chinese-ext-traditional", "1371");
addAlias("zh-traditional-ext", "1371");
addAlias("zh-tw-ext", "1371");
// HoD Converter aliases mapping all HoD converter names to CodePage / Charset
addAlias("1390", "930");
addAlias("1390jis2004", "930");
addAlias("1399", "939");
addAlias("1399jis2004", "939");
addAlias("937macau", "937");
addAlias("1364", "933");
addAlias("1379", "937");
addAlias("274", "500");
addAlias("275", "037");
addAlias("924", "1047");
addAlias("1153", "870");
addAlias("1156", "1025");
addAlias("1157", "1025");
addAlias("1158", "1025");
addAlias("1166", "1025");
addAlias("1112", "1025");
addAlias("1122", "1025");
addAlias("1137", "037");
addAlias("1008", "420");
addAlias("449", "420");
addAlias("1089", "420");
addAlias("1134", "424");
addAlias("1349", "424");
addAlias("8585", "875");
addAlias("8586", "875");
addAlias("220", "284");
addAlias("big5550", "937");
addAlias("cns", "937");
addAlias("tca", "937");
addAlias("ks25550", "933");
addAlias("jis", "930");
addAlias("euc", "937");
addAlias("singlebyte", "037");
addAlias("dbcsebcdic", "930");
addAlias("dbcsebcdicnibm", "930");
addAlias("dbcsebcdicibm", "930");
addAlias("dbcsascii", "930");
addAlias("encodings", "037");
addAlias("1011", "037");
addAlias("1012", "037");
addAlias("1020", "037");
addAlias("1021", "037");
addAlias("1023", "037");
addAlias("1090", "037");
addAlias("1101", "037");
addAlias("1102", "037");
addAlias("1103", "037");
addAlias("1104", "037");
addAlias("1105", "037");
addAlias("1106", "037");
}
/**
* Check if a code page or converter is registered or resolvable.
*/
public static boolean hasCodePage(String name) {
if (name == null || name.trim().isEmpty()) return false;
return resolveCodePage(name) != null;
}
/**
* Convenience factory method to get a HODByteToCharConverter by name or alias.
*/
public static haus.nightmare.lib3270j.converters.HODByteToCharConverter getByteToCharConverter(String name)
throws haus.nightmare.lib3270j.converters.HODUnsupportedCodepageException {
return haus.nightmare.lib3270j.converters.HODByteToCharConverter.getHODConverter(name);
}
/**
* Convenience factory method to get a HODCharToByteConverter by name or alias.
*/
public static haus.nightmare.lib3270j.converters.HODCharToByteConverter getCharToByteConverter(String name)
throws haus.nightmare.lib3270j.converters.HODUnsupportedCodepageException {
return haus.nightmare.lib3270j.converters.HODCharToByteConverter.getHODConverter(name);
}
/** /**
* Get an unmodifiable list of all registered built-in CodePages. * Get an unmodifiable list of all registered built-in CodePages.
*/ */
@@ -0,0 +1,68 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 1025 (Cyrillic Multilingual EBCDIC - Russian, Bulgarian, Belarusian, Serbian, Macedonian).
* CCSID / CPGID: 1025, GCSGID: 1150.
*/
public class Cp1025 extends AbstractCodePage {
public static final String ID = "1025";
public static final String DESCRIPTION = "Cyrillic Multilingual EBCDIC";
public static final int CPGID = 1025;
public static final int GCSGID = 1150;
public static final int[] MAPPING = {
// 00-0F
0x0000, 0x0001, 0x0002, 0x0003, 0x009C, 0x0009, 0x0086, 0x007F,
0x0097, 0x008D, 0x008E, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
// 10-1F
0x0010, 0x0011, 0x0012, 0x0013, 0x009D, 0x0085, 0x0008, 0x0087,
0x0018, 0x0019, 0x0092, 0x008F, 0x001C, 0x001D, 0x001E, 0x001F,
// 20-2F
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x000A, 0x0017, 0x001B,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x0005, 0x0006, 0x0007,
// 30-3F
0x0090, 0x0091, 0x0016, 0x0093, 0x0094, 0x0095, 0x0096, 0x0004,
0x0098, 0x0099, 0x009A, 0x009B, 0x0014, 0x0015, 0x009E, 0x001A,
// 40-4F
0x0020, 0x044F, 0x044E, 0x044D, 0x044C, 0x044B, 0x044A, 0x0449,
0x0448, 0x0447, 0x005B, 0x002E, 0x003C, 0x0028, 0x002B, 0x0021,
// 50-5F
0x0026, 0x0446, 0x0445, 0x0444, 0x0443, 0x0442, 0x0441, 0x0440,
0x043F, 0x043E, 0x005D, 0x0024, 0x002A, 0x0029, 0x003B, 0x005E,
// 60-6F
0x002D, 0x002F, 0x043D, 0x043C, 0x043B, 0x043A, 0x0439, 0x0438,
0x0437, 0x0436, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
// 70-7F
0x0435, 0x0434, 0x0433, 0x0432, 0x0431, 0x0430, 0x0451, 0x0453,
0x0452, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
// 80-8F
0x0454, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068, 0x0069, 0x0455, 0x0456, 0x0457, 0x0458, 0x0459, 0x045A,
// 90-9F
0x045B, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070,
0x0071, 0x0072, 0x045C, 0x045E, 0x045F, 0x0401, 0x0402, 0x0403,
// A0-AF
0x0404, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078,
0x0079, 0x007A, 0x0405, 0x0406, 0x0407, 0x0408, 0x0409, 0x040A,
// B0-BF
0x040B, 0x00A3, 0x040C, 0x00B7, 0x00A9, 0x040E, 0x040F, 0x0410,
0x0411, 0x0412, 0x00AC, 0x007C, 0x0413, 0x0414, 0x0415, 0x0416,
// C0-CF
0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C,
// D0-DF
0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
0x0051, 0x0052, 0x041D, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422,
// E0-EF
0x005C, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
0x0059, 0x005A, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428,
// F0-FF
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E,
};
public Cp1025() {
super(ID, DESCRIPTION, CPGID, GCSGID, "1025", MAPPING);
}
}
@@ -0,0 +1,68 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 1123 (Cyrillic Ukraine EBCDIC).
* CCSID / CPGID: 1123, GCSGID: 1399.
*/
public class Cp1123 extends AbstractCodePage {
public static final String ID = "1123";
public static final String DESCRIPTION = "Cyrillic Ukraine EBCDIC";
public static final int CPGID = 1123;
public static final int GCSGID = 1399;
public static final int[] MAPPING = {
// 00-0F
0x0000, 0x0001, 0x0002, 0x0003, 0x009C, 0x0009, 0x0086, 0x007F,
0x0097, 0x008D, 0x008E, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
// 10-1F
0x0010, 0x0011, 0x0012, 0x0013, 0x009D, 0x0085, 0x0008, 0x0087,
0x0018, 0x0019, 0x0092, 0x008F, 0x001C, 0x001D, 0x001E, 0x001F,
// 20-2F
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x000A, 0x0017, 0x001B,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x0005, 0x0006, 0x0007,
// 30-3F
0x0090, 0x0091, 0x0016, 0x0093, 0x0094, 0x0095, 0x0096, 0x0004,
0x0098, 0x0099, 0x009A, 0x009B, 0x0014, 0x0015, 0x009E, 0x001A,
// 40-4F
0x0020, 0x044F, 0x044E, 0x044D, 0x044C, 0x044B, 0x044A, 0x0449,
0x0448, 0x0447, 0x005B, 0x002E, 0x003C, 0x0028, 0x002B, 0x0021,
// 50-5F
0x0026, 0x0446, 0x0445, 0x0444, 0x0443, 0x0442, 0x0441, 0x0440,
0x043F, 0x043E, 0x005D, 0x0024, 0x002A, 0x0029, 0x003B, 0x005E,
// 60-6F
0x002D, 0x002F, 0x043D, 0x043C, 0x043B, 0x043A, 0x0439, 0x0438,
0x0437, 0x0436, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
// 70-7F
0x0435, 0x0434, 0x0433, 0x0432, 0x0431, 0x0430, 0x0451, 0x0491,
0x0454, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
// 80-8F
0x0456, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068, 0x0069, 0x0457, 0x00BB, 0x00F0, 0x00FD, 0x00FE, 0x00B1,
// 90-9F
0x00B0, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070,
0x0071, 0x0072, 0x00AA, 0x00BA, 0x00E6, 0x00B8, 0x00C6, 0x00A4,
// A0-AF
0x00B5, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078,
0x0079, 0x007A, 0x00A1, 0x00BF, 0x00D0, 0x00DD, 0x00DE, 0x00AE,
// B0-BF
0x00A2, 0x00A3, 0x00A5, 0x00B7, 0x00A9, 0x00A7, 0x00B6, 0x00BC,
0x00BD, 0x00BE, 0x00AC, 0x007C, 0x00AF, 0x00A8, 0x00B4, 0x00D7,
// C0-CF
0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C,
// D0-DF
0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
0x0051, 0x0052, 0x041D, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422,
// E0-EF
0x005C, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
0x0059, 0x005A, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428,
// F0-FF
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E,
};
public Cp1123() {
super(ID, DESCRIPTION, CPGID, GCSGID, "1123", MAPPING);
}
}
@@ -0,0 +1,24 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 1154 (Cyrillic Multilingual with Euro \u20AC).
* CCSID / CPGID: 1154, GCSGID: 1305.
*/
public class Cp1154 extends AbstractCodePage {
public static final String ID = "1154";
public static final String DESCRIPTION = "Cyrillic Multilingual EBCDIC (with Euro \u20AC)";
public static final int CPGID = 1154;
public static final int GCSGID = 1305;
public static final int[] MAPPING = new int[256];
static {
System.arraycopy(Cp1025.MAPPING, 0, MAPPING, 0, 256);
MAPPING[0x9F] = 0x20AC; // Euro character \u20AC
}
public Cp1154() {
super(ID, DESCRIPTION, CPGID, GCSGID, "1154", MAPPING);
}
}
@@ -0,0 +1,24 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 1155 (Turkey - Turkish Latin-5 with Euro \u20AC).
* CCSID / CPGID: 1155, GCSGID: 1306.
*/
public class Cp1155 extends AbstractCodePage {
public static final String ID = "1155";
public static final String DESCRIPTION = "Turkey - Turkish Latin-5 (with Euro \u20AC)";
public static final int CPGID = 1155;
public static final int GCSGID = 1306;
public static final int[] MAPPING = new int[256];
static {
System.arraycopy(Cp1026.MAPPING, 0, MAPPING, 0, 256);
MAPPING[0x9F] = 0x20AC; // Euro character \u20AC
}
public Cp1155() {
super(ID, DESCRIPTION, CPGID, GCSGID, "1155", MAPPING);
}
}
@@ -0,0 +1,24 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 1160 (Thai EBCDIC with Euro \u20AC).
* CCSID / CPGID: 1160, GCSGID: 1176.
*/
public class Cp1160 extends AbstractCodePage {
public static final String ID = "1160";
public static final String DESCRIPTION = "Thai EBCDIC (with Euro \u20AC)";
public static final int CPGID = 1160;
public static final int GCSGID = 1176;
public static final int[] MAPPING = new int[256];
static {
System.arraycopy(Cp838.MAPPING, 0, MAPPING, 0, 256);
MAPPING[0x9F] = 0x20AC; // Euro character \u20AC
}
public Cp1160() {
super(ID, DESCRIPTION, CPGID, GCSGID, "1160", MAPPING);
}
}
@@ -0,0 +1,17 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 1371 (Traditional Chinese Extended Mixed DBCS).
* CCSID / CPGID: 1371, GCSGID: 1174.
*/
public class Cp1371 extends AbstractDBCSCodePage {
public static final String ID = "1371";
public static final String DESCRIPTION = "Traditional Chinese Extended Mixed DBCS";
public static final int CPGID = 1371;
public static final int GCSGID = 1174;
public Cp1371() {
super(ID, DESCRIPTION, CPGID, GCSGID, Cp037.MAPPING, "x-IBM1371");
}
}
@@ -0,0 +1,17 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 1388 (Simplified Chinese Extended Mixed DBCS).
* CCSID / CPGID: 1388, GCSGID: 1175.
*/
public class Cp1388 extends AbstractDBCSCodePage {
public static final String ID = "1388";
public static final String DESCRIPTION = "Simplified Chinese Extended Mixed DBCS";
public static final int CPGID = 1388;
public static final int GCSGID = 1175;
public Cp1388() {
super(ID, DESCRIPTION, CPGID, GCSGID, Cp037.MAPPING, "x-IBM1388");
}
}
@@ -0,0 +1,68 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 420 (Arabic Bilingual EBCDIC).
* CCSID / CPGID: 420, GCSGID: 235.
*/
public class Cp420 extends AbstractCodePage {
public static final String ID = "420";
public static final String DESCRIPTION = "Arabic Bilingual EBCDIC";
public static final int CPGID = 420;
public static final int GCSGID = 235;
public static final int[] MAPPING = {
// 00-0F
0x0000, 0x0001, 0x0002, 0x0003, 0x009C, 0x0009, 0x0086, 0x007F,
0x0097, 0x008D, 0x008E, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
// 10-1F
0x0010, 0x0011, 0x0012, 0x0013, 0x009D, 0x0085, 0x0008, 0x0087,
0x0018, 0x0019, 0x0092, 0x008F, 0x001C, 0x001D, 0x001E, 0x001F,
// 20-2F
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x000A, 0x0017, 0x001B,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x0005, 0x0006, 0x0007,
// 30-3F
0x0090, 0x0091, 0x0016, 0x0093, 0x0094, 0x0095, 0x0096, 0x0004,
0x0098, 0x0099, 0x009A, 0x009B, 0x0014, 0x0015, 0x009E, 0x001A,
// 40-4F
0x0020, 0x0640, 0xFE83, 0xFE87, 0xFE85, 0xFE81, 0xFE80, 0x0621,
0xFE8D, 0xFE8B, 0x005B, 0x002E, 0x003C, 0x0028, 0x002B, 0x0021,
// 50-5F
0x0026, 0xFE8E, 0xFE8F, 0xFE91, 0xFE93, 0xFE95, 0xFE97, 0xFE99,
0xFE9B, 0xFE9D, 0x005D, 0x0024, 0x002A, 0x0029, 0x003B, 0x005E,
// 60-6F
0x002D, 0x002F, 0xFE9F, 0xFEA1, 0xFEA3, 0xFEA5, 0xFEA7, 0xFEA9,
0xFEAB, 0xFEAD, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
// 70-7F
0xFEAF, 0xFEB1, 0xFEB3, 0xFEB5, 0xFEB7, 0xFEB9, 0xFEBB, 0xFEBD,
0xFEBF, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
// 80-8F
0xFEC1, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068, 0x0069, 0xFEC3, 0xFEC5, 0xFEC7, 0xFEC9, 0xFECB, 0xFECD,
// 90-9F
0xFECF, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070,
0x0071, 0x0072, 0xFED1, 0xFED3, 0xFED5, 0xFED7, 0xFED9, 0xFEDB,
// A0-AF
0xFEDD, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078,
0x0079, 0x007A, 0xFEDF, 0xFEE1, 0xFEE3, 0xFEE5, 0xFEE7, 0xFEE9,
// B0-BF
0xFEEB, 0xFEED, 0xFEEF, 0xFEF1, 0xFEF3, 0xFEF5, 0xFEF7, 0xFEF9,
0xFEFB, 0x00AE, 0x00AC, 0x007C, 0x00AF, 0x00A8, 0x00B4, 0x00D7,
// C0-CF
0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x060C, 0x061B, 0x061F, 0x0628, 0x062A, 0x062B,
// D0-DF
0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
0x0051, 0x0052, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631,
// E0-EF
0x005C, 0x0632, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
0x0059, 0x005A, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638,
// F0-FF
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x0639, 0x063A, 0x0641, 0x0642, 0x0643, 0x009F,
};
public Cp420() {
super(ID, DESCRIPTION, CPGID, GCSGID, "420", MAPPING);
}
}
@@ -0,0 +1,68 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 424 (Hebrew with Lowercase EBCDIC).
* CCSID / CPGID: 424, GCSGID: 941.
*/
public class Cp424 extends AbstractCodePage {
public static final String ID = "424";
public static final String DESCRIPTION = "Hebrew (with Lowercase) EBCDIC";
public static final int CPGID = 424;
public static final int GCSGID = 941;
public static final int[] MAPPING = {
// 00-0F
0x0000, 0x0001, 0x0002, 0x0003, 0x009C, 0x0009, 0x0086, 0x007F,
0x0097, 0x008D, 0x008E, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
// 10-1F
0x0010, 0x0011, 0x0012, 0x0013, 0x009D, 0x0085, 0x0008, 0x0087,
0x0018, 0x0019, 0x0092, 0x008F, 0x001C, 0x001D, 0x001E, 0x001F,
// 20-2F
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x000A, 0x0017, 0x001B,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x0005, 0x0006, 0x0007,
// 30-3F
0x0090, 0x0091, 0x0016, 0x0093, 0x0094, 0x0095, 0x0096, 0x0004,
0x0098, 0x0099, 0x009A, 0x009B, 0x0014, 0x0015, 0x009E, 0x001A,
// 40-4F
0x0020, 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6,
0x05D7, 0x05D8, 0x005B, 0x002E, 0x003C, 0x0028, 0x002B, 0x0021,
// 50-5F
0x0026, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
0x05E0, 0x05E1, 0x005D, 0x0024, 0x002A, 0x0029, 0x003B, 0x005E,
// 60-6F
0x002D, 0x002F, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
0x05E8, 0x05E9, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
// 70-7F
0x05EA, 0x00A0, 0x2017, 0x00B8, 0x00A8, 0x00B4, 0x00AA, 0x00BA,
0x00DF, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
// 80-8F
0x00D8, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068, 0x0069, 0x00AB, 0x00BB, 0x00F0, 0x00FD, 0x00FE, 0x00B1,
// 90-9F
0x00B0, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070,
0x0071, 0x0072, 0x00AA, 0x00BA, 0x00E6, 0x00B8, 0x00C6, 0x00A4,
// A0-AF
0x00B5, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078,
0x0079, 0x007A, 0x00A1, 0x00BF, 0x00D0, 0x00DD, 0x00DE, 0x00AE,
// B0-BF
0x00A2, 0x00A3, 0x00A5, 0x00B7, 0x00A9, 0x00A7, 0x00B6, 0x00BC,
0x00BD, 0x00BE, 0x00AC, 0x007C, 0x00AF, 0x00A8, 0x00B4, 0x00D7,
// C0-CF
0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x00AD, 0x00F4, 0x00F6, 0x00F2, 0x00F3, 0x00F5,
// D0-DF
0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
0x0051, 0x0052, 0x00B9, 0x00FB, 0x00FC, 0x00F9, 0x00FA, 0x00FF,
// E0-EF
0x005C, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
0x0059, 0x005A, 0x00B2, 0x00D4, 0x00D6, 0x00D2, 0x00D3, 0x00D5,
// F0-FF
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x00B3, 0x00DB, 0x00DC, 0x00D9, 0x00DA, 0x009F,
};
public Cp424() {
super(ID, DESCRIPTION, CPGID, GCSGID, "424", MAPPING);
}
}
@@ -0,0 +1,68 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 803 (Hebrew Old / Standard EBCDIC).
* CCSID / CPGID: 803, GCSGID: 1147.
*/
public class Cp803 extends AbstractCodePage {
public static final String ID = "803";
public static final String DESCRIPTION = "Hebrew Old / Standard EBCDIC";
public static final int CPGID = 803;
public static final int GCSGID = 1147;
public static final int[] MAPPING = {
// 00-0F
0x0000, 0x0001, 0x0002, 0x0003, 0x009C, 0x0009, 0x0086, 0x007F,
0x0097, 0x008D, 0x008E, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
// 10-1F
0x0010, 0x0011, 0x0012, 0x0013, 0x009D, 0x0085, 0x0008, 0x0087,
0x0018, 0x0019, 0x0092, 0x008F, 0x001C, 0x001D, 0x001E, 0x001F,
// 20-2F
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x000A, 0x0017, 0x001B,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x0005, 0x0006, 0x0007,
// 30-3F
0x0090, 0x0091, 0x0016, 0x0093, 0x0094, 0x0095, 0x0096, 0x0004,
0x0098, 0x0099, 0x009A, 0x009B, 0x0014, 0x0015, 0x009E, 0x001A,
// 40-4F
0x0020, 0x00A0, 0x00E2, 0x00E4, 0x00E0, 0x00E1, 0x00E3, 0x00E5,
0x00E7, 0x00F1, 0x00A2, 0x002E, 0x003C, 0x0028, 0x002B, 0x0021,
// 50-5F
0x0026, 0x00E9, 0x00EA, 0x00EB, 0x00E8, 0x00ED, 0x00EE, 0x00EF,
0x00EC, 0x00DF, 0x005D, 0x0024, 0x002A, 0x0029, 0x003B, 0x005E,
// 60-6F
0x002D, 0x002F, 0x00C2, 0x00C4, 0x00C0, 0x00C1, 0x00C3, 0x00C5,
0x00C7, 0x00D1, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
// 70-7F
0x00F8, 0x00C9, 0x00CA, 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF,
0x00CC, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
// 80-8F
0x00D8, 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6,
0x05D7, 0x05D8, 0x00AB, 0x00BB, 0x00F0, 0x00FD, 0x00FE, 0x00B1,
// 90-9F
0x00B0, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
0x05E0, 0x05E1, 0x00AA, 0x00BA, 0x00E6, 0x00B8, 0x00C6, 0x00A4,
// A0-AF
0x00B5, 0x007E, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
0x05E8, 0x05E9, 0x00A1, 0x00BF, 0x00D0, 0x00DD, 0x00DE, 0x00AE,
// B0-BF
0x05EA, 0x00A3, 0x00A5, 0x00B7, 0x00A9, 0x00A7, 0x00B6, 0x00BC,
0x00BD, 0x00BE, 0x00AC, 0x007C, 0x00AF, 0x00A8, 0x00B4, 0x00D7,
// C0-CF
0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x00AD, 0x00F4, 0x00F6, 0x00F2, 0x00F3, 0x00F5,
// D0-DF
0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
0x0051, 0x0052, 0x00B9, 0x00FB, 0x00FC, 0x00F9, 0x00FA, 0x00FF,
// E0-EF
0x005C, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
0x0059, 0x005A, 0x00B2, 0x00D4, 0x00D6, 0x00D2, 0x00D3, 0x00D5,
// F0-FF
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x00B3, 0x00DB, 0x00DC, 0x00D9, 0x00DA, 0x009F,
};
public Cp803() {
super(ID, DESCRIPTION, CPGID, GCSGID, "803", MAPPING);
}
}
@@ -0,0 +1,68 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 838 (Thai EBCDIC).
* CCSID / CPGID: 838, GCSGID: 1176.
*/
public class Cp838 extends AbstractCodePage {
public static final String ID = "838";
public static final String DESCRIPTION = "Thai EBCDIC";
public static final int CPGID = 838;
public static final int GCSGID = 1176;
public static final int[] MAPPING = {
// 00-0F
0x0000, 0x0001, 0x0002, 0x0003, 0x009C, 0x0009, 0x0086, 0x007F,
0x0097, 0x008D, 0x008E, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
// 10-1F
0x0010, 0x0011, 0x0012, 0x0013, 0x009D, 0x0085, 0x0008, 0x0087,
0x0018, 0x0019, 0x0092, 0x008F, 0x001C, 0x001D, 0x001E, 0x001F,
// 20-2F
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x000A, 0x0017, 0x001B,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x0005, 0x0006, 0x0007,
// 30-3F
0x0090, 0x0091, 0x0016, 0x0093, 0x0094, 0x0095, 0x0096, 0x0004,
0x0098, 0x0099, 0x009A, 0x009B, 0x0014, 0x0015, 0x009E, 0x001A,
// 40-4F
0x0020, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,
0x0E08, 0x0E09, 0x005B, 0x002E, 0x003C, 0x0028, 0x002B, 0x0021,
// 50-5F
0x0026, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F, 0x0E10,
0x0E11, 0x0E12, 0x005D, 0x0024, 0x002A, 0x0029, 0x003B, 0x005E,
// 60-6F
0x002D, 0x002F, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17, 0x0E18,
0x0E19, 0x0E1A, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
// 70-7F
0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F, 0x0E20, 0x0E21, 0x0E22,
0x0E23, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
// 80-8F
0x0E24, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068, 0x0069, 0x0E25, 0x0E26, 0x0E27, 0x0E28, 0x0E29, 0x0E2A,
// 90-9F
0x0E2B, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070,
0x0071, 0x0072, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, 0x0E30, 0x0E31,
// A0-AF
0x0E32, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078,
0x0079, 0x007A, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, 0x0E38,
// B0-BF
0x0E39, 0x0E3A, 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45,
0x0E46, 0x0E47, 0x00AC, 0x007C, 0x0E48, 0x0E49, 0x0E4A, 0x0E4B,
// C0-CF
0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, 0x0E50, 0x0E51,
// D0-DF
0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
0x0051, 0x0052, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
// E0-EF
0x005C, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
0x0059, 0x005A, 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x00D3, 0x00D5,
// F0-FF
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x00B3, 0x00DB, 0x00DC, 0x00D9, 0x00DA, 0x009F,
};
public Cp838() {
super(ID, DESCRIPTION, CPGID, GCSGID, "838", MAPPING);
}
}
@@ -0,0 +1,68 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 880 (Cyrillic Russian EBCDIC).
* CCSID / CPGID: 880, GCSGID: 960.
*/
public class Cp880 extends AbstractCodePage {
public static final String ID = "880";
public static final String DESCRIPTION = "Cyrillic Russian EBCDIC";
public static final int CPGID = 880;
public static final int GCSGID = 960;
public static final int[] MAPPING = {
// 00-0F
0x0000, 0x0001, 0x0002, 0x0003, 0x009C, 0x0009, 0x0086, 0x007F,
0x0097, 0x008D, 0x008E, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
// 10-1F
0x0010, 0x0011, 0x0012, 0x0013, 0x009D, 0x0085, 0x0008, 0x0087,
0x0018, 0x0019, 0x0092, 0x008F, 0x001C, 0x001D, 0x001E, 0x001F,
// 20-2F
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x000A, 0x0017, 0x001B,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x0005, 0x0006, 0x0007,
// 30-3F
0x0090, 0x0091, 0x0016, 0x0093, 0x0094, 0x0095, 0x0096, 0x0004,
0x0098, 0x0099, 0x009A, 0x009B, 0x0014, 0x0015, 0x009E, 0x001A,
// 40-4F
0x0020, 0x00A0, 0x044F, 0x044E, 0x044D, 0x044C, 0x044B, 0x044A,
0x0449, 0x0448, 0x005B, 0x002E, 0x003C, 0x0028, 0x002B, 0x0021,
// 50-5F
0x0026, 0x0447, 0x0446, 0x0445, 0x0444, 0x0443, 0x0442, 0x0441,
0x0440, 0x043F, 0x005D, 0x0024, 0x002A, 0x0029, 0x003B, 0x005E,
// 60-6F
0x002D, 0x002F, 0x043E, 0x043D, 0x043C, 0x043B, 0x043A, 0x0439,
0x0438, 0x0437, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
// 70-7F
0x0436, 0x0435, 0x0434, 0x0433, 0x0432, 0x0431, 0x0430, 0x0451,
0x045E, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
// 80-8F
0x045F, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068, 0x0069, 0x0456, 0x0458, 0x0459, 0x045A, 0x045C, 0x045B,
// 90-9F
0x0402, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070,
0x0071, 0x0072, 0x0403, 0x0404, 0x0405, 0x0406, 0x0408, 0x0409,
// A0-AF
0x040A, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078,
0x0079, 0x007A, 0x040C, 0x040B, 0x040F, 0x040E, 0x0401, 0x00AE,
// B0-BF
0x005E, 0x00A3, 0x00A5, 0x00B7, 0x00A9, 0x00A7, 0x00B6, 0x00BC,
0x00BD, 0x00BE, 0x00AC, 0x007C, 0x00AF, 0x00A8, 0x00B4, 0x00D7,
// C0-CF
0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x041F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424,
// D0-DF
0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
0x0051, 0x0052, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A,
// E0-EF
0x005C, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
0x0059, 0x005A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, 0x0410,
// F0-FF
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x009F,
};
public Cp880() {
super(ID, DESCRIPTION, CPGID, GCSGID, "880", MAPPING);
}
}
@@ -0,0 +1,68 @@
package haus.nightmare.lib3270j.charset;
/**
* IBM Code Page 905 (Turkey - Turkish Latin-3 EBCDIC).
* CCSID / CPGID: 905, GCSGID: 1151.
*/
public class Cp905 extends AbstractCodePage {
public static final String ID = "905";
public static final String DESCRIPTION = "Turkey - Turkish Latin-3 EBCDIC";
public static final int CPGID = 905;
public static final int GCSGID = 1151;
public static final int[] MAPPING = {
// 00-0F
0x0000, 0x0001, 0x0002, 0x0003, 0x009C, 0x0009, 0x0086, 0x007F,
0x0097, 0x008D, 0x008E, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
// 10-1F
0x0010, 0x0011, 0x0012, 0x0013, 0x009D, 0x0085, 0x0008, 0x0087,
0x0018, 0x0019, 0x0092, 0x008F, 0x001C, 0x001D, 0x001E, 0x001F,
// 20-2F
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x000A, 0x0017, 0x001B,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x0005, 0x0006, 0x0007,
// 30-3F
0x0090, 0x0091, 0x0016, 0x0093, 0x0094, 0x0095, 0x0096, 0x0004,
0x0098, 0x0099, 0x009A, 0x009B, 0x0014, 0x0015, 0x009E, 0x001A,
// 40-4F
0x0020, 0x00A0, 0x00E2, 0x00E4, 0x00E0, 0x00E1, 0x00E3, 0x00E5,
0x00E7, 0x00F1, 0x011E, 0x002E, 0x003C, 0x0028, 0x002B, 0x0021,
// 50-5F
0x0026, 0x00E9, 0x00EA, 0x00EB, 0x00E8, 0x00ED, 0x00EE, 0x00EF,
0x00EC, 0x00DF, 0x0130, 0x0024, 0x002A, 0x0029, 0x003B, 0x005E,
// 60-6F
0x002D, 0x002F, 0x00C2, 0x00C4, 0x00C0, 0x00C1, 0x00C3, 0x00C5,
0x00C7, 0x00D1, 0x015E, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
// 70-7F
0x00F8, 0x00C9, 0x00CA, 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF,
0x00CC, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
// 80-8F
0x00D8, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068, 0x0069, 0x00AB, 0x00BB, 0x00F0, 0x00FD, 0x00FE, 0x00B1,
// 90-9F
0x00B0, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070,
0x0071, 0x0072, 0x00AA, 0x00BA, 0x00E6, 0x00B8, 0x00C6, 0x00A4,
// A0-AF
0x00B5, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078,
0x0079, 0x007A, 0x00A1, 0x00BF, 0x00D0, 0x00DD, 0x00DE, 0x00AE,
// B0-BF
0x00A2, 0x00A3, 0x00A5, 0x00B7, 0x00A9, 0x00A7, 0x00B6, 0x00BC,
0x00BD, 0x00BE, 0x00AC, 0x007C, 0x00AF, 0x00A8, 0x00B4, 0x00D7,
// C0-CF
0x011F, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x00AD, 0x00F4, 0x00F6, 0x00F2, 0x00F3, 0x00F5,
// D0-DF
0x0131, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
0x0051, 0x0052, 0x00B9, 0x00FB, 0x00FC, 0x00F9, 0x00FA, 0x00FF,
// E0-EF
0x015F, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
0x0059, 0x005A, 0x00B2, 0x00D4, 0x00D6, 0x00D2, 0x00D3, 0x00D5,
// F0-FF
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x00B3, 0x00DB, 0x00DC, 0x00D9, 0x00DA, 0x009F,
};
public Cp905() {
super(ID, DESCRIPTION, CPGID, GCSGID, "905", MAPPING);
}
}
@@ -1,10 +1,13 @@
package haus.nightmare.lib3270j.charset; package haus.nightmare.lib3270j.charset;
import java.util.List; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* EBCDIC Unicode character translator conforming to IBM Host On-Demand (HoD v14). * EBCDIC Unicode character translator conforming to IBM Host On-Demand (HoD v14).
* Modular architecture delegating to pluggable CodePage implementations (SBCS and DBCS). * Modular architecture delegating to pluggable CodePage implementations (SBCS and DBCS).
* Supports custom per-instance character translation override tables and complete
* IBM 3270 APL / Graphic Escape (GA23-0059) character mappings.
* Default: Code Page 037 (US/Canada EBCDIC). * Default: Code Page 037 (US/Canada EBCDIC).
*/ */
public class EbcdicTranslator { public class EbcdicTranslator {
@@ -15,6 +18,8 @@ public class EbcdicTranslator {
public static final int[] CP037_TO_UNICODE = Cp037.MAPPING; public static final int[] CP037_TO_UNICODE = Cp037.MAPPING;
private CodePage activeCodePage; private CodePage activeCodePage;
private final Map<Integer, Character> customEbcdicToUnicode = new ConcurrentHashMap<>();
private final Map<Character, Integer> customUnicodeToEbcdic = new ConcurrentHashMap<>();
public EbcdicTranslator() { public EbcdicTranslator() {
this("037"); this("037");
@@ -85,6 +90,107 @@ public class EbcdicTranslator {
return isDBCSCodePage(); return isDBCSCodePage();
} }
// =========================================================================
// Custom Character Translation Overrides
// =========================================================================
/**
* Set a bidirectional custom character translation override.
* Maps an EBCDIC byte value to a Unicode character, and vice versa.
*/
public synchronized void setCustomOverride(int ebcdicByte, char unicodeChar) {
int b = ebcdicByte & 0xFF;
customEbcdicToUnicode.put(b, unicodeChar);
customUnicodeToEbcdic.put(unicodeChar, b);
}
/**
* Set a one-way custom EBCDIC byte to Unicode character override.
*/
public synchronized void setCustomEbcdicToUnicodeOverride(int ebcdicByte, char unicodeChar) {
customEbcdicToUnicode.put(ebcdicByte & 0xFF, unicodeChar);
}
/**
* Set a one-way custom Unicode character to EBCDIC byte override.
*/
public synchronized void setCustomUnicodeToEbcdicOverride(char unicodeChar, int ebcdicByte) {
customUnicodeToEbcdic.put(unicodeChar, ebcdicByte & 0xFF);
}
/**
* Set custom translation overrides in bulk.
*/
public synchronized void setCustomOverrides(Map<Integer, Character> ebcToUni, Map<Character, Integer> uniToEbc) {
if (ebcToUni != null) {
for (Map.Entry<Integer, Character> entry : ebcToUni.entrySet()) {
if (entry.getKey() != null && entry.getValue() != null) {
setCustomOverride(entry.getKey(), entry.getValue());
}
}
}
if (uniToEbc != null) {
for (Map.Entry<Character, Integer> entry : uniToEbc.entrySet()) {
if (entry.getKey() != null && entry.getValue() != null) {
setCustomUnicodeToEbcdicOverride(entry.getKey(), entry.getValue());
}
}
}
}
/**
* Remove custom translation override for a specific EBCDIC byte.
*/
public synchronized void removeCustomOverride(int ebcdicByte) {
Character removed = customEbcdicToUnicode.remove(ebcdicByte & 0xFF);
if (removed != null) {
customUnicodeToEbcdic.remove(removed);
}
}
/**
* Remove custom translation override for a specific Unicode character.
*/
public synchronized void removeCustomUnicodeOverride(char unicodeChar) {
Integer removed = customUnicodeToEbcdic.remove(unicodeChar);
if (removed != null) {
customEbcdicToUnicode.remove(removed);
}
}
/**
* Clear all registered custom translation overrides.
*/
public synchronized void clearCustomOverrides() {
customEbcdicToUnicode.clear();
customUnicodeToEbcdic.clear();
}
/**
* Check if any custom translation overrides are active.
*/
public boolean hasCustomOverrides() {
return !customEbcdicToUnicode.isEmpty() || !customUnicodeToEbcdic.isEmpty();
}
/**
* Get an unmodifiable view of active EBCDIC-to-Unicode custom overrides.
*/
public Map<Integer, Character> getCustomEbcdicToUnicodeOverrides() {
return Collections.unmodifiableMap(new HashMap<>(customEbcdicToUnicode));
}
/**
* Get an unmodifiable view of active Unicode-to-EBCDIC custom overrides.
*/
public Map<Character, Integer> getCustomUnicodeToEbcdicOverrides() {
return Collections.unmodifiableMap(new HashMap<>(customUnicodeToEbcdic));
}
// =========================================================================
// Translation Operations
// =========================================================================
/** /**
* Translate double-byte EBCDIC pair (b1, b2) to Unicode. * Translate double-byte EBCDIC pair (b1, b2) to Unicode.
*/ */
@@ -100,10 +206,15 @@ public class EbcdicTranslator {
} }
/** /**
* Translate EBCDIC byte to Unicode character using active code page. * Translate EBCDIC byte to Unicode character using active code page and custom overrides.
*/ */
public char ebcdicToUnicode(int ebc) { public char ebcdicToUnicode(int ebc) {
return activeCodePage.ebcdicToUnicode(ebc); int b = ebc & 0xFF;
Character custom = customEbcdicToUnicode.get(b);
if (custom != null) {
return custom;
}
return activeCodePage.ebcdicToUnicode(b);
} }
/** /**
@@ -121,10 +232,14 @@ public class EbcdicTranslator {
} }
/** /**
* Translate Unicode character to EBCDIC byte using active code page. * Translate Unicode character to EBCDIC byte using active code page and custom overrides.
* Returns -1 if the character cannot be mapped. * Returns -1 if the character cannot be mapped.
*/ */
public int unicodeToEbcdic(char unicode) { public int unicodeToEbcdic(char unicode) {
Integer custom = customUnicodeToEbcdic.get(unicode);
if (custom != null) {
return custom;
}
return activeCodePage.unicodeToEbcdic(unicode); return activeCodePage.unicodeToEbcdic(unicode);
} }
@@ -132,20 +247,37 @@ public class EbcdicTranslator {
* Translate Unicode character to EBCDIC, returning EBCDIC space (0x40) if unmappable. * Translate Unicode character to EBCDIC, returning EBCDIC space (0x40) if unmappable.
*/ */
public byte unicodeToEbcdicSafe(char unicode) { public byte unicodeToEbcdicSafe(char unicode) {
return activeCodePage.unicodeToEbcdicSafe(unicode); int ebc = unicodeToEbcdic(unicode);
return (byte) (ebc >= 0 ? ebc : 0x40);
} }
/** /**
* Translate a byte array from EBCDIC to a Unicode string using active code page. * Translate a byte array from EBCDIC to a Unicode string using active code page and overrides.
*/ */
public String ebcdicToString(byte[] ebcdic, int offset, int length) { public String ebcdicToString(byte[] ebcdic, int offset, int length) {
if (ebcdic == null || length <= 0) return "";
if (hasCustomOverrides() || !(activeCodePage instanceof AbstractDBCSCodePage)) {
char[] chars = new char[length];
for (int i = 0; i < length; i++) {
chars[i] = ebcdicToUnicode(ebcdic[offset + i]);
}
return new String(chars);
}
return activeCodePage.ebcdicToString(ebcdic, offset, length); return activeCodePage.ebcdicToString(ebcdic, offset, length);
} }
/** /**
* Translate a Unicode string to EBCDIC byte array using active code page. * Translate a Unicode string to EBCDIC byte array using active code page and overrides.
*/ */
public byte[] stringToEbcdic(String s) { public byte[] stringToEbcdic(String s) {
if (s == null || s.isEmpty()) return new byte[0];
if (hasCustomOverrides() || !(activeCodePage instanceof AbstractDBCSCodePage)) {
byte[] bytes = new byte[s.length()];
for (int i = 0; i < s.length(); i++) {
bytes[i] = unicodeToEbcdicSafe(s.charAt(i));
}
return bytes;
}
return activeCodePage.stringToEbcdic(s); return activeCodePage.stringToEbcdic(s);
} }
@@ -164,11 +296,12 @@ public class EbcdicTranslator {
} }
/** /**
* Translate an IBM 3270 Graphic Escape (GE) / APL character code to Unicode. * Map an IBM 3270 APL / Graphic Escape (GE) EBCDIC code point to its Unicode glyph.
* Conforms to IBM 3270 APL / Text character set and GA23-0059 specification.
*/ */
public char getAplGraphic(int ec) { public char mapAPL(int ebcdicCodePoint) {
switch (ec & 0xFF) { switch (ebcdicCodePoint & 0xFF) {
// Box-drawing line and corner characters (standard IBM 3270 GE / APL) // Standard Box-Drawing Lines, Corners, T-Junctions, and Crosses
case 0xA2: return '\u2500'; // Horizontal Line 's' -> '─' case 0xA2: return '\u2500'; // Horizontal Line 's' -> '─'
case 0x85: return '\u2502'; // Vertical Line 'e' -> '│' case 0x85: return '\u2502'; // Vertical Line 'e' -> '│'
case 0xC5: return '\u250C'; // Top Left 'E' -> '┌' case 0xC5: return '\u250C'; // Top Left 'E' -> '┌'
@@ -181,7 +314,7 @@ public class EbcdicTranslator {
case 0xD7: return '\u2534'; // T-Junction Bottom 'P' -> '┴' case 0xD7: return '\u2534'; // T-Junction Bottom 'P' -> '┴'
case 0xCB: return '\u253C'; // Cross -> '┼' case 0xCB: return '\u253C'; // Cross -> '┼'
// Special math and APL symbols (matching x3270 cg.c / apl.c) // Mathematical Relations and Punctuation
case 0x8C: return '\u2264'; // Less-than or equal '≤' case 0x8C: return '\u2264'; // Less-than or equal '≤'
case 0xAE: return '\u2265'; // Greater-than or equal '≥' case 0xAE: return '\u2265'; // Greater-than or equal '≥'
case 0xBE: return '\u2260'; // Not equal '≠' case 0xBE: return '\u2260'; // Not equal '≠'
@@ -193,12 +326,66 @@ public class EbcdicTranslator {
case 0xB1: return '\u00B1'; // Plus-minus '±' case 0xB1: return '\u00B1'; // Plus-minus '±'
case 0xB2: return '\u00B2'; // Superscript 2 '²' case 0xB2: return '\u00B2'; // Superscript 2 '²'
case 0xB3: return '\u00B3'; // Superscript 3 '³' case 0xB3: return '\u00B3'; // Superscript 3 '³'
case 0xAF: return '\u00AF'; // Overbar '¯' case 0xAF: return '\u00AF'; // Overbar / High Minus '¯'
case 0xBA: return '\u03A9'; // Omega 'Ω' case 0xBA: return '\u03A9'; // Omega 'Ω'
case 0xBF: return '\u00B5'; // Micro 'µ' case 0xBF: return '\u00B5'; // Micro 'µ'
case 0x5F: return '\u00AC'; // Not sign '¬' case 0x5F: return '\u00AC'; // Not sign '¬'
default: return ebcdicToUnicode(ec & 0xFF); // IBM 3270 APL Operational & Structural Glyphs
case 0x80: return '\u22C4'; // Diamond '⋄'
case 0x81: return '\u237A'; // APL Alpha ''
case 0x82: return '\u22A5'; // Up Tack / Decode '⊥'
case 0x83: return '\u2229'; // Intersection '∩'
case 0x84: return '\u230A'; // Floor '⌊'
case 0x86: return '\u2286'; // Subset or equal '⊆'
case 0x87: return '\u2207'; // Del / Grad '∇'
case 0x88: return '\u2206'; // Delta '∆'
case 0x89: return '\u2373'; // Iota ''
case 0x8A: return '\u2192'; // Right Arrow '→'
case 0x8B: return '\u235E'; // Quote Quad '⍞'
case 0x8E: return '\u00D7'; // Multiply '×'
case 0x8F: return '\u00F7'; // Divide '÷'
case 0x90: return '\u235F'; // Circle Star / Log '⍟'
case 0x91: return '\u2339'; // Quad Divide / Domino '⌹'
case 0x92: return '\u22A4'; // Down Tack / Encode ''
case 0x93: return '\u222A'; // Union ''
case 0x94: return '\u2308'; // Ceiling '⌈'
case 0x95: return '\u2374'; // Rho / Shape ''
case 0x96: return '\u2375'; // APL Omega '⍵'
case 0x97: return '\u2260'; // Not equal '≠'
case 0x98: return '\u2377'; // Epsilon Underbar '⍷'
case 0x99: return '\u25CB'; // Circle '○'
case 0x9A: return '\u2190'; // Left Arrow '←'
case 0x9B: return '\u2359'; // Delta Underbar '⍙'
case 0x9C: return '\u234B'; // Grade Up '⍋'
case 0x9E: return '\u2352'; // Grade Down '⍒'
case 0x9F: return '\u235D'; // Lamp / Comment '⍝'
case 0xA1: return '\u00A8'; // Diaeresis '¨'
case 0xA4: return '\u2336'; // I-Beam '⌶'
case 0xA5: return '\u2355'; // Thorn / Format '⍕'
case 0xA6: return '\u2282'; // Left Shoe / Enclose '⊂'
case 0xA7: return '\u2283'; // Right Shoe / Disclose '⊃'
case 0xA8: return '\u2191'; // Up Arrow / Take '↑'
case 0xA9: return '\u2193'; // Down Arrow / Drop '↓'
case 0xAA: return '\u2395'; // Quad '⎕'
case 0xAB: return '\u234E'; // Execute / Hydra '⍎'
case 0xAC: return '\u2349'; // Transpose / Circle Slope '⍉'
case 0xB4: return '\u2296'; // Circle Bar / Reverse '⊖'
case 0xB5: return '\u236A'; // Comma Bar / Table '⍪'
case 0xB6: return '\u236B'; // Del Tilde '⍫'
case 0xB7: return '\u236C'; // Zilde '⍬'
case 0xB9: return '\u233F'; // Slash Bar '⌿'
case 0xBB: return '\u2340'; // Backslash Bar '⍀'
case 0xBC: return '\u2338'; // Quad Equal '⌸'
default: return ebcdicToUnicode(ebcdicCodePoint & 0xFF);
} }
} }
/**
* Translate an IBM 3270 Graphic Escape (GE) / APL character code to Unicode.
*/
public char getAplGraphic(int ec) {
return mapAPL(ec);
}
} }
@@ -0,0 +1,178 @@
package haus.nightmare.lib3270j.converters;
import haus.nightmare.lib3270j.charset.CodePage;
import haus.nightmare.lib3270j.charset.CodePageRegistry;
/**
* Concrete converter implementing mixed SBCS/DBCS byte-to-char conversion with transparent
* Shift-Out (0x0E) and Shift-In (0x0F) state management.
* Conforms to com.ibm.eNetwork.HOD.converters.ByteToCharDBCS_EBCDIC.
*/
public class ByteToCharDBCS_EBCDIC extends HODByteToCharConverter {
public ByteToCharDBCS_EBCDIC() {
this(CodePageRegistry.getCodePage("930"));
}
public ByteToCharDBCS_EBCDIC(CodePage codePage) {
super(codePage != null ? codePage : CodePageRegistry.getCodePage("930"));
}
@Override
public int convert(byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd)
throws HODCharConversionException {
if (in == null || inEnd <= inOff) {
return 0;
}
if (out == null) {
throw new HODCharConversionException("Output buffer cannot be null");
}
this.byteOff = inOff;
this.charOff = outOff;
while (this.byteOff < inEnd || this.savedBytePresent) {
int b;
boolean isSaved = false;
if (this.savedBytePresent) {
b = this.savedByte & 0xFF;
this.savedBytePresent = false;
isSaved = true;
} else {
b = in[this.byteOff] & 0xFF;
}
// Handle Shift-Out (0x0E) -> DBCS mode
if (b == SO) {
this.currentState = 1;
if (this.preserveSOSI) {
if (this.charOff >= outEnd) {
throw new HODCharConversionException("Output buffer overflow writing SO at " + this.charOff);
}
out[this.charOff++] = (char) SO;
}
if (!isSaved) this.byteOff++;
continue;
}
// Handle Shift-In (0x0F) -> SBCS mode
if (b == SI) {
this.currentState = 0;
if (this.preserveSOSI) {
if (this.charOff >= outEnd) {
throw new HODCharConversionException("Output buffer overflow writing SI at " + this.charOff);
}
out[this.charOff++] = (char) SI;
}
if (!isSaved) this.byteOff++;
continue;
}
// SBCS mode conversion
if (this.currentState == 0) {
if (this.charOff >= outEnd) {
throw new HODCharConversionException("Output buffer overflow at position " + this.charOff);
}
char c = this.codePage.ebcdicToUnicode(b);
if (c == '\uFFFD') {
if (this.subMode) {
c = this.subChars[0];
} else {
this.badInputLength = 1;
throw new HODCharConversionException("Unmappable byte 0x" + Integer.toHexString(b) + " at index " + this.byteOff);
}
}
out[this.charOff++] = c;
if (!isSaved) this.byteOff++;
} else {
// DBCS mode conversion (requires 2 bytes)
int b2;
if (isSaved) {
if (this.byteOff >= inEnd) {
// Incomplete DBCS pair at end of buffer
this.savedByte = (byte) b;
this.savedBytePresent = true;
break;
}
b2 = in[this.byteOff++] & 0xFF;
} else {
if (this.byteOff + 1 >= inEnd) {
// Trailing single byte inside DBCS shift
this.savedByte = (byte) b;
this.savedBytePresent = true;
this.byteOff++;
break;
}
b2 = in[this.byteOff + 1] & 0xFF;
this.byteOff += 2;
}
// Check for premature Shift-In
if (b2 == SI) {
this.currentState = 0;
if (this.charOff >= outEnd) {
throw new HODCharConversionException("Output buffer overflow at position " + this.charOff);
}
out[this.charOff++] = this.codePage.ebcdicToUnicode(b);
if (this.preserveSOSI) {
if (this.charOff >= outEnd) {
throw new HODCharConversionException("Output buffer overflow at position " + this.charOff);
}
out[this.charOff++] = (char) SI;
}
continue;
}
char c = this.codePage.dbcsToUnicode(b, b2);
if (c == '?' || c == '\uFFFD') {
if (this.subMode) {
c = this.subChars[0];
} else {
this.badInputLength = 2;
throw new HODCharConversionException("Unmappable DBCS pair 0x" + Integer.toHexString(b) + ", 0x" + Integer.toHexString(b2));
}
}
if (this.charOff >= outEnd) {
throw new HODCharConversionException("Output buffer overflow at position " + this.charOff);
}
out[this.charOff++] = c;
}
}
return this.charOff - outOff;
}
@Override
public int flush(char[] out, int outOff, int outEnd) throws HODCharConversionException {
int count = 0;
if (this.savedBytePresent) {
if (!this.subMode) {
reset();
this.badInputLength = 1;
throw new HODCharConversionException("Unclosed trailing DBCS byte at end of input");
}
if (outOff < outEnd) {
out[outOff] = this.subChars[0];
count = 1;
}
}
reset();
return count;
}
@Override
public void reset() {
this.byteOff = 0;
this.charOff = 0;
this.currentState = 0;
this.savedBytePresent = false;
this.savedByte = 0;
this.badInputLength = 0;
}
@Override
public String getCharacterEncoding() {
return this.codePage != null ? "Cp" + this.codePage.getCodePageId() : "DBCS_EBCDIC";
}
}
@@ -0,0 +1,74 @@
package haus.nightmare.lib3270j.converters;
import haus.nightmare.lib3270j.charset.CodePage;
import haus.nightmare.lib3270j.charset.CodePageRegistry;
/**
* Concrete converter implementing single-byte character set (SBCS) byte-to-char conversion.
* Conforms to com.ibm.eNetwork.HOD.converters.ByteToCharSingleByte.
*/
public class ByteToCharSingleByte extends HODByteToCharConverter {
public ByteToCharSingleByte() {
this(CodePageRegistry.getDefault());
}
public ByteToCharSingleByte(CodePage codePage) {
super(codePage != null ? codePage : CodePageRegistry.getDefault());
}
@Override
public int convert(byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd)
throws HODCharConversionException {
if (in == null || inEnd <= inOff) {
return 0;
}
if (out == null) {
throw new HODCharConversionException("Output buffer cannot be null");
}
this.byteOff = inOff;
this.charOff = outOff;
while (this.byteOff < inEnd) {
if (this.charOff >= outEnd) {
throw new HODCharConversionException("Output char buffer overflow at position " + this.charOff);
}
int b = in[this.byteOff] & 0xFF;
char c = this.codePage.ebcdicToUnicode(b);
if (c == '\uFFFD') {
if (this.subMode) {
c = this.subChars[0];
} else {
this.badInputLength = 1;
throw new HODCharConversionException("Unmappable byte 0x" + Integer.toHexString(b) + " at input index " + this.byteOff);
}
}
out[this.charOff++] = c;
this.byteOff++;
}
return this.charOff - outOff;
}
@Override
public int flush(char[] out, int outOff, int outEnd) {
reset();
return 0;
}
@Override
public void reset() {
this.byteOff = 0;
this.charOff = 0;
this.badInputLength = 0;
}
@Override
public String getCharacterEncoding() {
return this.codePage != null ? "Cp" + this.codePage.getCodePageId() : "SingleByte";
}
}
@@ -0,0 +1,137 @@
package haus.nightmare.lib3270j.converters;
import haus.nightmare.lib3270j.charset.CodePage;
import haus.nightmare.lib3270j.charset.CodePageRegistry;
/**
* Concrete converter implementing mixed SBCS/DBCS char-to-byte conversion with transparent
* Shift-Out (0x0E) and Shift-In (0x0F) state generation.
* Conforms to com.ibm.eNetwork.HOD.converters.CharToByteDBCS_EBCDIC.
*/
public class CharToByteDBCS_EBCDIC extends HODCharToByteConverter {
public CharToByteDBCS_EBCDIC() {
this(CodePageRegistry.getCodePage("930"));
}
public CharToByteDBCS_EBCDIC(CodePage codePage) {
super(codePage != null ? codePage : CodePageRegistry.getCodePage("930"));
}
@Override
public int convert(char[] in, int inOff, int inEnd, byte[] out, int outOff, int outEnd)
throws HODCharConversionException {
if (in == null || inEnd <= inOff) {
return 0;
}
if (out == null) {
throw new HODCharConversionException("Output buffer cannot be null");
}
this.charOff = inOff;
this.byteOff = outOff;
while (this.charOff < inEnd) {
char c = in[this.charOff];
// Explicit Shift-Out control character handling
if (c == (char) SO) {
if (this.currentState == 0) {
if (this.byteOff >= outEnd) {
throw new HODCharConversionException("Output buffer overflow writing SO at " + this.byteOff);
}
out[this.byteOff++] = SO;
this.currentState = 1;
}
this.charOff++;
continue;
}
// Explicit Shift-In control character handling
if (c == (char) SI) {
if (this.currentState == 1) {
if (this.byteOff >= outEnd) {
throw new HODCharConversionException("Output buffer overflow writing SI at " + this.byteOff);
}
out[this.byteOff++] = SI;
this.currentState = 0;
}
this.charOff++;
continue;
}
int dbcs = this.codePage.unicodeToDbcs(c);
if (dbcs >= 0) {
// Character is DBCS: ensure in DBCS mode
int needed = (this.currentState == 0) ? 3 : 2;
if (this.byteOff + needed > outEnd) {
throw new HODCharConversionException("Output buffer overflow writing DBCS character at " + this.byteOff);
}
if (this.currentState == 0) {
out[this.byteOff++] = SO;
this.currentState = 1;
}
out[this.byteOff++] = (byte) ((dbcs >> 8) & 0xFF);
out[this.byteOff++] = (byte) (dbcs & 0xFF);
} else {
// Character is SBCS: ensure in SBCS mode
int needed = (this.currentState == 1) ? 2 : 1;
if (this.byteOff + needed > outEnd) {
throw new HODCharConversionException("Output buffer overflow writing SBCS character at " + this.byteOff);
}
if (this.currentState == 1) {
out[this.byteOff++] = SI;
this.currentState = 0;
}
int ebc = this.codePage.unicodeToEbcdic(c);
if (ebc < 0) {
if (this.subMode) {
out[this.byteOff++] = this.subBytes[0];
} else {
this.badInputLength = 1;
throw new HODCharConversionException("Unmappable character '\\u" + Integer.toHexString(c) + "' at input index " + this.charOff);
}
} else {
out[this.byteOff++] = (byte) (ebc & 0xFF);
}
}
this.charOff++;
}
return this.byteOff - outOff;
}
@Override
public int flush(byte[] out, int outOff, int outEnd) throws HODCharConversionException {
int flushed = 0;
if (this.currentState == 1) {
if (outOff >= outEnd) {
throw new HODCharConversionException("Output buffer overflow during flush at " + outOff);
}
out[outOff] = SI;
flushed = 1;
this.currentState = 0;
}
reset();
return flushed;
}
@Override
public void reset() {
this.charOff = 0;
this.byteOff = 0;
this.currentState = 0;
this.badInputLength = 0;
}
@Override
public String getCharacterEncoding() {
return this.codePage != null ? "Cp" + this.codePage.getCodePageId() : "DBCS_EBCDIC";
}
}
@@ -0,0 +1,75 @@
package haus.nightmare.lib3270j.converters;
import haus.nightmare.lib3270j.charset.CodePage;
import haus.nightmare.lib3270j.charset.CodePageRegistry;
/**
* Concrete converter implementing single-byte character set (SBCS) char-to-byte conversion.
* Conforms to com.ibm.eNetwork.HOD.converters.CharToByteSingleByte.
*/
public class CharToByteSingleByte extends HODCharToByteConverter {
public CharToByteSingleByte() {
this(CodePageRegistry.getDefault());
}
public CharToByteSingleByte(CodePage codePage) {
super(codePage != null ? codePage : CodePageRegistry.getDefault());
}
@Override
public int convert(char[] in, int inOff, int inEnd, byte[] out, int outOff, int outEnd)
throws HODCharConversionException {
if (in == null || inEnd <= inOff) {
return 0;
}
if (out == null) {
throw new HODCharConversionException("Output buffer cannot be null");
}
this.charOff = inOff;
this.byteOff = outOff;
while (this.charOff < inEnd) {
if (this.byteOff >= outEnd) {
throw new HODCharConversionException("Output byte buffer overflow at position " + this.byteOff);
}
char c = in[this.charOff];
int ebc = this.codePage.unicodeToEbcdic(c);
if (ebc < 0) {
if (this.subMode) {
out[this.byteOff++] = this.subBytes[0];
} else {
this.badInputLength = 1;
throw new HODCharConversionException("Unmappable character '\\u" + Integer.toHexString(c) + "' at input index " + this.charOff);
}
} else {
out[this.byteOff++] = (byte) (ebc & 0xFF);
}
this.charOff++;
}
return this.byteOff - outOff;
}
@Override
public int flush(byte[] out, int outOff, int outEnd) {
reset();
return 0;
}
@Override
public void reset() {
this.charOff = 0;
this.byteOff = 0;
this.badInputLength = 0;
}
@Override
public String getCharacterEncoding() {
return this.codePage != null ? "Cp" + this.codePage.getCodePageId() : "SingleByte";
}
}
@@ -0,0 +1,184 @@
package haus.nightmare.lib3270j.converters;
import haus.nightmare.lib3270j.charset.CodePage;
import haus.nightmare.lib3270j.charset.CodePageRegistry;
import java.util.Objects;
/**
* High-performance adapter and bridge converting byte streams (EBCDIC, ASCII, ISO, UTF)
* to Unicode characters conforming to IBM Host On-Demand (HoD) converter specifications.
* <p>
* Supports dynamic factory resolution for all 275 HoD converter class names and transparent
* Shift-In (0x0F) / Shift-Out (0x0E) DBCS transitions.
*/
public abstract class HODByteToCharConverter {
public static final int SO = 0x0E;
public static final int SI = 0x0F;
protected int byteOff = 0;
protected int charOff = 0;
protected int badInputLength = 0;
protected boolean subMode = true;
protected char[] subChars = new char[]{'\uFFFD'};
protected CodePage codePage;
// DBCS State
protected int currentState = 0; // 0 = SBCS, 1 = DBCS
protected boolean savedBytePresent = false;
protected byte savedByte = 0;
protected boolean preserveSOSI = false;
public HODByteToCharConverter() {
}
public HODByteToCharConverter(CodePage codePage) {
this.codePage = Objects.requireNonNull(codePage, "codePage cannot be null");
}
/**
* Look up and instantiate a ByteToChar converter matching the given encoding,
* codepage ID, alias, or HoD converter class name (e.g. "Cp037", "037", "ByteToCharCp1047", "ConverterFT1047").
*
* @param encoding encoding identifier or class name
* @return initialized HODByteToCharConverter instance
* @throws HODUnsupportedCodepageException if the codepage cannot be resolved
*/
public static HODByteToCharConverter getHODConverter(String encoding) throws HODUnsupportedCodepageException {
if (encoding == null || encoding.trim().isEmpty()) {
throw new HODUnsupportedCodepageException("Encoding name cannot be null or empty");
}
CodePage cp = CodePageRegistry.resolveCodePage(encoding);
if (cp == null) {
throw new HODUnsupportedCodepageException("Unsupported codepage / converter: " + encoding);
}
if (cp.isDBCS()) {
return new ByteToCharDBCS_EBCDIC(cp);
} else {
return new ByteToCharSingleByte(cp);
}
}
/**
* Standard converter lookup alias conforming to Java/HoD converter factory patterns.
*/
public static HODByteToCharConverter getConverter(String encoding) throws HODUnsupportedCodepageException {
return getHODConverter(encoding);
}
/**
* Convert an array of bytes into an array of characters.
*
* @param in source byte buffer
* @param inOff start offset in input buffer
* @param inEnd end offset in input buffer (exclusive)
* @param out destination char buffer
* @param outOff start offset in output buffer
* @param outEnd end offset in output buffer (exclusive)
* @return number of characters converted and written into out
* @throws HODCharConversionException if an unmappable byte is encountered with substitution disabled,
* or if the output buffer overflows
*/
public abstract int convert(byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd)
throws HODCharConversionException;
/**
* Overload supporting an extra boolean flag matching HoD CFR decompiled signature.
*/
public int convert(byte[] in, int inOff, int inEnd, char[] out, int outOff, int outEnd, boolean bl)
throws HODCharConversionException {
return convert(in, inOff, inEnd, out, outOff, outEnd);
}
/**
* Flush any buffered / trailing state into the output char buffer.
*
* @param out destination char buffer
* @param outOff start offset
* @param outEnd end offset
* @return number of characters flushed
* @throws HODCharConversionException if flush fails or trailing incomplete sequence cannot be converted
*/
public abstract int flush(char[] out, int outOff, int outEnd) throws HODCharConversionException;
/**
* Reset converter state and offsets to defaults.
*/
public abstract void reset();
/**
* Get the canonical character encoding name (e.g. "Cp037", "Cp930").
*/
public abstract String getCharacterEncoding();
/**
* Convert an entire byte array to a char array matching IBM HoD's hodConvertAll API.
*/
public char[] hodConvertAll(byte[] in) throws HODCharConversionException {
if (in == null) return new char[0];
reset();
char[] buf = new char[Math.max(16, in.length * 2 + 16)];
int converted = convert(in, 0, in.length, buf, 0, buf.length);
int flushed = flush(buf, converted, buf.length);
int total = converted + flushed;
char[] result = new char[total];
System.arraycopy(buf, 0, result, 0, total);
return result;
}
/**
* Convenience alias for hodConvertAll.
*/
public char[] convertAll(byte[] in) throws HODCharConversionException {
return hodConvertAll(in);
}
public void setSubstitutionMode(boolean mode) {
this.subMode = mode;
}
public boolean getSubstitutionMode() {
return this.subMode;
}
public void setSubstitutionChars(char[] subChars) {
if (subChars != null && subChars.length > 0) {
this.subChars = subChars;
}
}
public char[] getSubstitutionChars() {
return this.subChars;
}
public int getBadInputLength() {
return this.badInputLength;
}
public int nextByteIndex() {
return this.byteOff;
}
public int nextCharIndex() {
return this.charOff;
}
public CodePage getCodePage() {
return this.codePage;
}
public void setPreserveSOSI(boolean preserve) {
this.preserveSOSI = preserve;
}
public boolean isPreserveSOSI() {
return this.preserveSOSI;
}
public int getCurrentState() {
return this.currentState;
}
}
@@ -0,0 +1,20 @@
package haus.nightmare.lib3270j.converters;
import java.io.CharConversionException;
/**
* Exception thrown when character conversion fails during Host On-Demand converter processing.
* Conforms to com.ibm.eNetwork.HOD.common.HODCharConversionException.
*/
public class HODCharConversionException extends CharConversionException {
private static final long serialVersionUID = 1L;
public HODCharConversionException() {
super();
}
public HODCharConversionException(String message) {
super(message);
}
}
@@ -0,0 +1,169 @@
package haus.nightmare.lib3270j.converters;
import haus.nightmare.lib3270j.charset.CodePage;
import haus.nightmare.lib3270j.charset.CodePageRegistry;
import java.util.Objects;
/**
* High-performance adapter and bridge converting Unicode characters to byte streams
* (EBCDIC, ASCII, ISO, UTF) conforming to IBM Host On-Demand (HoD) converter specifications.
* <p>
* Supports dynamic factory resolution for all 275 HoD converter class names and transparent
* Shift-In (0x0F) / Shift-Out (0x0E) DBCS transitions.
*/
public abstract class HODCharToByteConverter {
public static final byte SO = 0x0E;
public static final byte SI = 0x0F;
protected int byteOff = 0;
protected int charOff = 0;
protected int badInputLength = 0;
protected boolean subMode = true;
protected byte[] subBytes = new byte[]{(byte) 0x6F}; // 0x6F '?' in EBCDIC (or safe fallback)
protected CodePage codePage;
// DBCS State
protected int currentState = 0; // 0 = SBCS, 1 = DBCS
public HODCharToByteConverter() {
}
public HODCharToByteConverter(CodePage codePage) {
this.codePage = Objects.requireNonNull(codePage, "codePage cannot be null");
}
/**
* Look up and instantiate a CharToByte converter matching the given encoding,
* codepage ID, alias, or HoD converter class name (e.g. "Cp037", "037", "CharToByteCp1047", "ConverterFT1047").
*
* @param encoding encoding identifier or class name
* @return initialized HODCharToByteConverter instance
* @throws HODUnsupportedCodepageException if the codepage cannot be resolved
*/
public static HODCharToByteConverter getHODConverter(String encoding) throws HODUnsupportedCodepageException {
if (encoding == null || encoding.trim().isEmpty()) {
throw new HODUnsupportedCodepageException("Encoding name cannot be null or empty");
}
CodePage cp = CodePageRegistry.resolveCodePage(encoding);
if (cp == null) {
throw new HODUnsupportedCodepageException("Unsupported codepage / converter: " + encoding);
}
if (cp.isDBCS()) {
return new CharToByteDBCS_EBCDIC(cp);
} else {
return new CharToByteSingleByte(cp);
}
}
/**
* Standard converter lookup alias conforming to Java/HoD converter factory patterns.
*/
public static HODCharToByteConverter getConverter(String encoding) throws HODUnsupportedCodepageException {
return getHODConverter(encoding);
}
/**
* Convert an array of characters into an array of bytes.
*
* @param in source char buffer
* @param inOff start offset in input buffer
* @param inEnd end offset in input buffer (exclusive)
* @param out destination byte buffer
* @param outOff start offset in output buffer
* @param outEnd end offset in output buffer (exclusive)
* @return number of bytes converted and written into out
* @throws HODCharConversionException if an unmappable char is encountered with substitution disabled,
* or if the output buffer overflows
*/
public abstract int convert(char[] in, int inOff, int inEnd, byte[] out, int outOff, int outEnd)
throws HODCharConversionException;
/**
* Flush any buffered / trailing shift state into the output byte buffer.
*
* @param out destination byte buffer
* @param outOff start offset
* @param outEnd end offset
* @return number of bytes flushed
* @throws HODCharConversionException if output buffer overflows
*/
public abstract int flush(byte[] out, int outOff, int outEnd) throws HODCharConversionException;
/**
* Reset converter state and offsets to defaults.
*/
public abstract void reset();
/**
* Get the canonical character encoding name (e.g. "Cp037", "Cp930").
*/
public abstract String getCharacterEncoding();
/**
* Convert an entire char array to a byte array matching IBM HoD's hodConvertAll API.
*/
public byte[] hodConvertAll(char[] in) throws HODCharConversionException {
if (in == null) return new byte[0];
reset();
byte[] buf = new byte[Math.max(16, in.length * 3 + 16)];
int converted = convert(in, 0, in.length, buf, 0, buf.length);
int flushed = flush(buf, converted, buf.length);
int total = converted + flushed;
byte[] result = new byte[total];
System.arraycopy(buf, 0, result, 0, total);
return result;
}
/**
* Convenience alias for hodConvertAll.
*/
public byte[] convertAll(char[] in) throws HODCharConversionException {
return hodConvertAll(in);
}
public void setSubstitutionMode(boolean mode) {
this.subMode = mode;
}
public boolean getSubstitutionMode() {
return this.subMode;
}
public void setSubstitutionBytes(byte[] subBytes) {
if (subBytes != null && subBytes.length > 0) {
this.subBytes = subBytes;
}
}
public byte[] getSubstitutionBytes() {
return this.subBytes;
}
public int getBadInputLength() {
return this.badInputLength;
}
public int nextByteIndex() {
return this.byteOff;
}
public int nextCharIndex() {
return this.charOff;
}
public int getMaxBytesPerChar() {
return (codePage != null && codePage.isDBCS()) ? 3 : 1; // At most 3 bytes (SO + 2-byte DBCS)
}
public CodePage getCodePage() {
return this.codePage;
}
public int getCurrentState() {
return this.currentState;
}
}
@@ -0,0 +1,20 @@
package haus.nightmare.lib3270j.converters;
import java.io.UnsupportedEncodingException;
/**
* Exception thrown when a requested character encoding or codepage identifier cannot be resolved.
* Conforms to com.ibm.eNetwork.HOD.common.HODUnsupportedCodepageException.
*/
public class HODUnsupportedCodepageException extends UnsupportedEncodingException {
private static final long serialVersionUID = 1L;
public HODUnsupportedCodepageException() {
super();
}
public HODUnsupportedCodepageException(String encoding) {
super(encoding);
}
}
@@ -63,6 +63,14 @@ public class DataStreamProcessor {
this.graphicsPlane.setProgramSymbolManager(programSymbolManager); this.graphicsPlane.setProgramSymbolManager(programSymbolManager);
} }
public ScreenBuffer getScreen() {
return screen;
}
public ScreenBuffer getScreenBuffer() {
return screen;
}
public QueryReplyBuilder getQueryReplyBuilder() { public QueryReplyBuilder getQueryReplyBuilder() {
return qrBuilder; return qrBuilder;
} }
@@ -81,6 +89,13 @@ public class DataStreamProcessor {
public void setOutputSender(OutputSender sender) { public void setOutputSender(OutputSender sender) {
this.outputSender = sender; this.outputSender = sender;
if (inputProcessor != null) {
inputProcessor.setOutputSender(sender);
}
}
public OutputSender getOutputSender() {
return outputSender;
} }
public void setFTDft(haus.nightmare.lib3270j.ft.FTDft ftDft) { public void setFTDft(haus.nightmare.lib3270j.ft.FTDft ftDft) {
@@ -99,6 +114,9 @@ public class DataStreamProcessor {
public void setInputProcessor(haus.nightmare.lib3270j.input.InputProcessor inputProcessor) { public void setInputProcessor(haus.nightmare.lib3270j.input.InputProcessor inputProcessor) {
this.inputProcessor = inputProcessor; this.inputProcessor = inputProcessor;
if (inputProcessor != null && outputSender != null) {
inputProcessor.setOutputSender(outputSender);
}
} }
public haus.nightmare.lib3270j.input.InputProcessor getInputProcessor() { public haus.nightmare.lib3270j.input.InputProcessor getInputProcessor() {
@@ -109,6 +127,10 @@ public class DataStreamProcessor {
screenListeners.add(l); screenListeners.add(l);
} }
public void removeScreenUpdateListener(ScreenUpdateListener l) {
screenListeners.remove(l);
}
/** /**
* Process a 3270 data stream record. * Process a 3270 data stream record.
* *
@@ -144,6 +166,9 @@ public class DataStreamProcessor {
int oldCols = screen.getCols(); int oldCols = screen.getCols();
screen.erase(false); screen.erase(false);
graphicsPlane.clear(); graphicsPlane.clear();
if (gocaDecoder != null) {
gocaDecoder.setGraphicsCursorActive(false);
}
processWrite(data, offset, length, true); processWrite(data, offset, length, true);
if (oldRows != screen.getRows() || oldCols != screen.getCols()) { if (oldRows != screen.getRows() || oldCols != screen.getCols()) {
notifyScreenSizeChanged(); notifyScreenSizeChanged();
@@ -161,6 +186,9 @@ public class DataStreamProcessor {
int oldCols = screen.getCols(); int oldCols = screen.getCols();
screen.erase(true); screen.erase(true);
graphicsPlane.clear(); graphicsPlane.clear();
if (gocaDecoder != null) {
gocaDecoder.setGraphicsCursorActive(false);
}
processWrite(data, offset, length, true); processWrite(data, offset, length, true);
if (oldRows != screen.getRows() || oldCols != screen.getCols()) { if (oldRows != screen.getRows() || oldCols != screen.getCols()) {
notifyScreenSizeChanged(); notifyScreenSizeChanged();
@@ -510,11 +538,14 @@ public class DataStreamProcessor {
// Handle GE (graphic escape) prefix // Handle GE (graphic escape) prefix
byte fillCs = currentCs; byte fillCs = currentCs;
char fillUcs4 = 0;
if (pos + 4 < end && fillChar == ORDER_GE) { if (pos + 4 < end && fillChar == ORDER_GE) {
fillChar = data[pos + 4] & 0xFF; fillChar = data[pos + 4] & 0xFF;
fillCs = CS_GE; fillCs = CS_GE;
fillUcs4 = (translator != null) ? translator.mapAPL(fillChar) : (char) fillChar;
pos += 5; pos += 5;
} else { } else {
fillUcs4 = (translator != null) ? translator.ebcdicToUnicode(fillChar) : (char) fillChar;
pos += 4; pos += 4;
} }
@@ -523,6 +554,7 @@ public class DataStreamProcessor {
ExtendedAttribute ea = screen.getCell(baddr); ExtendedAttribute ea = screen.getCell(baddr);
ea.fa = 0; // Destroy previous field attribute if any ea.fa = 0; // Destroy previous field attribute if any
ea.ec = (byte) fillChar; ea.ec = (byte) fillChar;
ea.ucs4 = fillUcs4;
ea.fg = currentFg; ea.fg = currentFg;
ea.bg = currentBg; ea.bg = currentBg;
ea.gr = (byte) currentGr; ea.gr = (byte) currentGr;
@@ -575,6 +607,7 @@ public class DataStreamProcessor {
ea.fa = 0; // Destroy previous field attribute if any ea.fa = 0; // Destroy previous field attribute if any
ea.ec = (byte) geChar; ea.ec = (byte) geChar;
ea.cs = CS_GE; ea.cs = CS_GE;
ea.ucs4 = (translator != null) ? translator.mapAPL(geChar) : (char) geChar;
ea.fg = currentFg; ea.fg = currentFg;
ea.bg = currentBg; ea.bg = currentBg;
ea.gr = (byte) currentGr; ea.gr = (byte) currentGr;
@@ -680,7 +713,7 @@ public class DataStreamProcessor {
// ========== Read Buffer ========== // ========== Read Buffer ==========
private void processReadBuffer() { public void processReadBuffer() {
outputPos = 0; outputPos = 0;
int size = screen.getRows() * screen.getCols(); int size = screen.getRows() * screen.getCols();
@@ -780,11 +813,21 @@ public class DataStreamProcessor {
// ========== Read Modified ========== // ========== Read Modified ==========
private void processReadModified(boolean all) { public void processReadModified(boolean all) {
if (ftDft != null && ftDft.readModified()) { if (ftDft != null && ftDft.readModified()) {
return; return;
} }
if (inputProcessor != null) {
int aid = (inputProcessor.getLastAid() != 0) ? inputProcessor.getLastAid() : AID_NO;
inputProcessor.setLastAid(AID_NO);
byte[] data = inputProcessor.buildReadModifiedInboundData(aid, all);
if (outputSender != null) {
outputSender.send3270Data(data);
}
return;
}
outputPos = 0; outputPos = 0;
int aid = (inputProcessor != null && inputProcessor.getLastAid() != 0) int aid = (inputProcessor != null && inputProcessor.getLastAid() != 0)
@@ -843,10 +886,11 @@ public class DataStreamProcessor {
sendOutput(); sendOutput();
} }
// ========== Write Structured Field ========== public void processWriteStructuredField(byte[] data, int offset, int length) {
if (data == null || length <= 0)
private void processWriteStructuredField(byte[] data, int offset, int length) { return;
int pos = offset + 1; // Skip WSF command byte int firstByte = data[offset] & 0xFF;
int pos = (firstByte == CMD_WSF || firstByte == SNA_CMD_WSF) ? offset + 1 : offset;
int end = offset + length; int end = offset + length;
while (pos < end) { while (pos < end) {
@@ -881,10 +925,19 @@ public class DataStreamProcessor {
case SF_ACTIVATE_PART: case SF_ACTIVATE_PART:
processActivatePartition(data, pos, fieldLen); processActivatePartition(data, pos, fieldLen);
break; break;
case SF_OUTBOUND_DS: case SF_SET_WINDOW: // 0x0F: Set Window / Modify Partition / 3270 Graphics Viewport
processSFSetWindow(data, pos, fieldLen);
break;
case SF_3270_GRAPHICS: // 0x20: 3270 Graphics / Object Control
processSFObjectControl(data, pos, fieldLen);
break;
case SF_DOCUMENT_DATA: // 0x24: Document Data / embedded SCS / Object Control
processSFDocumentData(data, pos, fieldLen);
break;
case SF_OUTBOUND_DS: // 0x40
processOutbound3270DS(data, pos, fieldLen); processOutbound3270DS(data, pos, fieldLen);
break; break;
case SF_TRANSFER_DATA: case SF_TRANSFER_DATA: // 0xD0
if (ftDft != null) { if (ftDft != null) {
ftDft.processStructuredField(data, pos, fieldLen); ftDft.processStructuredField(data, pos, fieldLen);
} else { } else {
@@ -898,95 +951,7 @@ public class DataStreamProcessor {
programSymbolManager.loadps(psData); programSymbolManager.loadps(psData);
} }
break; break;
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_LOADPS: { // 0x0F: 2-byte Structured Field prefix
if (fieldLen >= 4) {
int sfSubId = data[pos + 3] & 0xFF;
switch (sfSubId) {
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_LOADPS_SUB: // 0x06: Load Programmed Symbols
if (fieldLen > 4) {
byte[] psData = new byte[fieldLen - 4];
System.arraycopy(data, pos + 4, psData, 0, psData.length);
programSymbolManager.loadps(psData);
}
break;
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJDATA_SUB: { // 0x0F: Object Control / Data Unit
// Per IBM HOD processDataunit(), 0x0F activates graphic cursor and initializes data unit
log.info(String.format("SF 0x0F sub=0x0F (Data Unit Object Control len=%d): activating graphics cursor", fieldLen));
gocaDecoder.setGraphicsCursorActive(true);
notifyScreenUpdated();
break;
}
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJCNTL_SUB: // 0x11: Object Control (Procedure orders)
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJPICT_SUB: { // 0x10: Object Picture (Picture segments)
int flags = (fieldLen >= 6) ? (data[pos + 5] & 0xC0) : 0xC0;
int orderOffset = (fieldLen >= 7) ? (pos + 7) : (pos + 4);
int orderLen = Math.max(0, fieldLen - (orderOffset - pos));
StringBuilder hexDump = new StringBuilder();
for (int i = 0; i < Math.min(32, fieldLen); i++) {
hexDump.append(String.format("%02x ", data[pos + i] & 0xFF));
}
log.info(String.format("SF 0x0F sub=0x%02x len=%d flags=0x%02x orderOffset=+%d orderLen=%d bytes=[%s]",
sfSubId, fieldLen, flags, (orderOffset - pos), orderLen, hexDump.toString().trim()));
graphicsPlane.setScreenDimensions(screen.getCols(), screen.getRows());
int targetW = screen.getCols() * 9;
int targetH = screen.getRows() * 16;
if (graphicsPlane.getCanvasWidth() != targetW || graphicsPlane.getCanvasHeight() != targetH) {
graphicsPlane.resize(targetW, targetH);
}
if (flags == 0x80) { // SPAN_FIRST
gocaAccumulator.reset();
currentGocaSubtype = sfSubId;
if (orderLen > 0) {
gocaAccumulator.write(data, orderOffset, orderLen);
}
} else if (flags == 0x00) { // SPAN_MIDDLE
if (orderLen > 0) {
gocaAccumulator.write(data, orderOffset, orderLen);
}
} else if (flags == 0x40) { // SPAN_LAST
if (orderLen > 0) {
gocaAccumulator.write(data, orderOffset, orderLen);
}
byte[] fullStream = gocaAccumulator.toByteArray();
gocaAccumulator.reset();
log.info(String.format("GOCA stream SPAN_LAST assembled: %d bytes", fullStream.length));
if (currentGocaSubtype == haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJCNTL_SUB) {
gocaDecoder.processProcedureOrders(fullStream, 0, fullStream.length);
} else {
gocaDecoder.decodeStream(fullStream, 0, fullStream.length);
}
notifyScreenUpdated();
} else { // SPAN_ONLY (0xC0)
gocaAccumulator.reset();
log.info(String.format("GOCA stream SPAN_ONLY: %d bytes", orderLen));
if (sfSubId == haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJCNTL_SUB) {
gocaDecoder.processProcedureOrders(data, orderOffset, orderLen);
} else {
gocaDecoder.decodeStream(data, orderOffset, orderLen);
}
notifyScreenUpdated();
}
break;
}
default:
log.fine("Unknown SF 0x0F subtype: " + String.format("0x%02x", sfSubId));
break;
}
}
break;
}
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJCNTL: // 0x24: Object Control (Procedure orders)
if (fieldLen > 3) {
graphicsPlane.setScreenDimensions(screen.getCols(), screen.getRows());
gocaDecoder.processProcedureOrders(data, pos + 3, fieldLen - 3);
notifyScreenUpdated();
}
break;
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJDATA: // 0x85: Graphics Object Data / GOCA case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJDATA: // 0x85: Graphics Object Data / GOCA
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_3270_G: // 0x20: 3270 Graphics
if (fieldLen > 3) { if (fieldLen > 3) {
graphicsPlane.setScreenDimensions(screen.getCols(), screen.getRows()); graphicsPlane.setScreenDimensions(screen.getCols(), screen.getRows());
gocaDecoder.decodeStream(data, pos + 3, fieldLen - 3); gocaDecoder.decodeStream(data, pos + 3, fieldLen - 3);
@@ -1274,13 +1239,277 @@ public class DataStreamProcessor {
return pid >= 0 && pid <= 255; return pid >= 0 && pid <= 255;
} }
// ========== Missing Structured Field Handlers (Phase 2) ==========
public void processSFSetWindow(byte[] data, int offset, int fieldLen) {
if (fieldLen >= 4) {
int sfSubId = data[offset + 3] & 0xFF;
switch (sfSubId) {
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_LOADPS_SUB: // 0x06: Load Programmed Symbols
if (fieldLen > 4) {
byte[] psData = new byte[fieldLen - 4];
System.arraycopy(data, offset + 4, psData, 0, psData.length);
programSymbolManager.loadps(psData);
}
break;
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJDATA_SUB: { // 0x0F: Object Control / Data Unit
log.info(String.format("SF 0x0F sub=0x0F (Data Unit Object Control len=%d): activating graphics cursor", fieldLen));
gocaDecoder.setGraphicsCursorActive(true);
notifyScreenUpdated();
break;
}
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJCNTL_SUB: // 0x11: Object Control (Procedure orders)
case haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJPICT_SUB: { // 0x10: Object Picture (Picture segments)
int flags = (fieldLen >= 6) ? (data[offset + 5] & 0xC0) : 0xC0;
int orderOffset = (fieldLen >= 7) ? (offset + 7) : (offset + 4);
int orderLen = Math.max(0, fieldLen - (orderOffset - offset));
graphicsPlane.setScreenDimensions(screen.getCols(), screen.getRows());
int targetW = screen.getCols() * 9;
int targetH = screen.getRows() * 16;
if (graphicsPlane.getCanvasWidth() != targetW || graphicsPlane.getCanvasHeight() != targetH) {
graphicsPlane.resize(targetW, targetH);
}
if (flags == 0x80) { // SPAN_FIRST
gocaAccumulator.reset();
currentGocaSubtype = sfSubId;
if (orderLen > 0) {
gocaAccumulator.write(data, orderOffset, orderLen);
}
} else if (flags == 0x00) { // SPAN_MIDDLE
if (orderLen > 0) {
gocaAccumulator.write(data, orderOffset, orderLen);
}
} else if (flags == 0x40) { // SPAN_LAST
if (orderLen > 0) {
gocaAccumulator.write(data, orderOffset, orderLen);
}
byte[] fullStream = gocaAccumulator.toByteArray();
gocaAccumulator.reset();
log.info(String.format("GOCA stream SPAN_LAST assembled: %d bytes", fullStream.length));
if (currentGocaSubtype == haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJCNTL_SUB) {
gocaDecoder.processProcedureOrders(fullStream, 0, fullStream.length);
} else {
gocaDecoder.decodeStream(fullStream, 0, fullStream.length);
}
notifyScreenUpdated();
} else { // SPAN_ONLY (0xC0)
gocaAccumulator.reset();
log.info(String.format("GOCA stream SPAN_ONLY: %d bytes", orderLen));
if (sfSubId == haus.nightmare.lib3270j.graphics.GocaConstants.SF_OBJCNTL_SUB) {
gocaDecoder.processProcedureOrders(data, orderOffset, orderLen);
} else {
gocaDecoder.decodeStream(data, orderOffset, orderLen);
}
notifyScreenUpdated();
}
break;
}
default:
if (fieldLen >= 11) {
int xMin = ((data[offset + 3] & 0xFF) << 8) | (data[offset + 4] & 0xFF);
int yMin = ((data[offset + 5] & 0xFF) << 8) | (data[offset + 6] & 0xFF);
int xMax = ((data[offset + 7] & 0xFF) << 8) | (data[offset + 8] & 0xFF);
int yMax = ((data[offset + 9] & 0xFF) << 8) | (data[offset + 10] & 0xFF);
graphicsPlane.setViewingWindow(xMin, yMin, xMax, yMax);
}
log.fine("SF 0x0F Set Window processed (len=" + fieldLen + ")");
break;
}
}
}
public void processSFSetWindow(byte[] sf) {
if (sf != null && sf.length >= 3) {
int off = ((sf[0] & 0xFF) == CMD_WSF || (sf[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processSFSetWindow(sf, off, sf.length - off);
}
}
public void processSFObjectControl(byte[] data, int offset, int fieldLen) {
if (fieldLen > 3) {
graphicsPlane.setScreenDimensions(screen.getCols(), screen.getRows());
gocaDecoder.decodeStream(data, offset + 3, fieldLen - 3);
notifyScreenUpdated();
}
}
public void processSFObjectControl(byte[] sf) {
if (sf != null && sf.length >= 3) {
int off = ((sf[0] & 0xFF) == CMD_WSF || (sf[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processSFObjectControl(sf, off, sf.length - off);
}
}
public void processSFDocumentData(byte[] data, int offset, int fieldLen) {
if (fieldLen > 3) {
if (embeddedScsProcessor != null) {
embeddedScsProcessor.processHostData(data, offset + 3, fieldLen - 3);
}
graphicsPlane.setScreenDimensions(screen.getCols(), screen.getRows());
gocaDecoder.processProcedureOrders(data, offset + 3, fieldLen - 3);
notifyScreenUpdated();
}
}
public void processSFDocumentData(byte[] sf) {
if (sf != null && sf.length >= 3) {
int off = ((sf[0] & 0xFF) == CMD_WSF || (sf[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processSFDocumentData(sf, off, sf.length - off);
}
}
public void processOutbound3270DS(byte[] data, int offset, int fieldLen) { public void processOutbound3270DS(byte[] data, int offset, int fieldLen) {
if (fieldLen > 5) { if (fieldLen >= 4) {
int pid = data[offset + 3] & 0xFF; int pid = data[offset + 3] & 0xFF;
screen.setActivePartition(pid); screen.setActivePartition(pid);
if (fieldLen > 4) {
processRecord(data, offset + 4, fieldLen - 4, false); processRecord(data, offset + 4, fieldLen - 4, false);
} }
} }
}
public void processOutbound3270DS(byte[] sf) {
if (sf != null && sf.length >= 4) {
int off = ((sf[0] & 0xFF) == CMD_WSF || (sf[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processOutbound3270DS(sf, off, sf.length - off);
}
}
// ========== Convenience Overloads ==========
public void processRecord(byte[] data) {
if (data != null && data.length > 0) {
processRecord(data, 0, data.length, false);
}
}
public void processWrite(byte[] data) {
if (data != null && data.length > 0) {
processRecord(data, 0, data.length, false);
}
}
public void processEraseWrite(byte[] data) {
if (data != null && data.length > 0) {
int oldRows = screen.getRows();
int oldCols = screen.getCols();
screen.erase(false);
graphicsPlane.clear();
if (gocaDecoder != null) {
gocaDecoder.setGraphicsCursorActive(false);
}
processWrite(data, 0, data.length, true);
if (oldRows != screen.getRows() || oldCols != screen.getCols()) {
notifyScreenSizeChanged();
}
screen.translateToUnicode();
screen.markAllChanged();
screen.updateDisplaySnapshot();
}
}
public void processEraseWriteAlternate(byte[] data) {
if (data != null && data.length > 0) {
int oldRows = screen.getRows();
int oldCols = screen.getCols();
screen.erase(true);
graphicsPlane.clear();
if (gocaDecoder != null) {
gocaDecoder.setGraphicsCursorActive(false);
}
processWrite(data, 0, data.length, true);
if (oldRows != screen.getRows() || oldCols != screen.getCols()) {
notifyScreenSizeChanged();
}
screen.translateToUnicode();
screen.markAllChanged();
screen.updateDisplaySnapshot();
}
}
public void processEraseAllUnprotected() {
synchronized (screen.getRenderLock()) {
screen.eraseAllUnprotected();
}
}
public void processReadModified() {
processReadModified(false);
}
public void processReadModifiedAll() {
processReadModified(true);
}
public void processWriteStructuredField(byte[] data) {
if (data != null && data.length > 0) {
processWriteStructuredField(data, 0, data.length);
}
}
public void processSFReadPartition(byte[] data) {
if (data != null && data.length >= 3) {
int off = ((data[0] & 0xFF) == CMD_WSF || (data[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processSFReadPartition(data, off, data.length - off);
}
}
public void processSFReadPartitionQuery(byte[] data) {
sendAllQueryReplies();
}
public void processSFReadPartitionQueryList(byte[] data) {
if (data != null && data.length >= 6) {
int off = ((data[0] & 0xFF) == CMD_WSF || (data[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
int qlStart = off + 6;
if (data.length > qlStart) {
byte[] codes = new byte[data.length - qlStart];
System.arraycopy(data, qlStart, codes, 0, codes.length);
sendRequestedQueryReplies(codes);
} else {
sendAllQueryReplies();
}
} else {
sendAllQueryReplies();
}
}
public void processSetReplyMode(byte[] data) {
if (data != null && data.length >= 3) {
int off = ((data[0] & 0xFF) == CMD_WSF || (data[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processSetReplyMode(data, off, data.length - off);
}
}
public void processCreatePartition(byte[] data) {
if (data != null && data.length >= 3) {
int off = ((data[0] & 0xFF) == CMD_WSF || (data[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processCreatePartition(data, off, data.length - off);
}
}
public void processDestroyPartition(byte[] data) {
if (data != null && data.length >= 3) {
int off = ((data[0] & 0xFF) == CMD_WSF || (data[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processDestroyPartition(data, off, data.length - off);
}
}
public void processActivatePartition(byte[] data) {
if (data != null && data.length >= 3) {
int off = ((data[0] & 0xFF) == CMD_WSF || (data[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processActivatePartition(data, off, data.length - off);
}
}
public void processEraseReset(byte[] data) {
if (data != null && data.length >= 3) {
int off = ((data[0] & 0xFF) == CMD_WSF || (data[0] & 0xFF) == SNA_CMD_WSF) ? 1 : 0;
processEraseReset(data, off, data.length - off);
}
}
public void processQueryListOrder(byte[] data, int offset, int length) { public void processQueryListOrder(byte[] data, int offset, int length) {
processSFReadPartition(data, offset, length); processSFReadPartition(data, offset, length);
@@ -1305,4 +1534,233 @@ public class DataStreamProcessor {
public void processNullStructuredField() { public void processNullStructuredField() {
log.fine("Processed null structured field"); log.fine("Processed null structured field");
} }
// ========== Phase 3: HoD DS3270 Order & Data Stream Functions ==========
/** Process Write Control Character (WCC). */
public void processWCC(int wcc) {
boolean alarm = wccSoundAlarm(wcc);
boolean kbdRestore = wccKeyboardRestore(wcc);
boolean resetMdt = wccResetMDT(wcc);
log.fine("processWCC: " + String.format("0x%02x", wcc) +
" reset=" + wccReset(wcc) + " alarm=" + alarm + " kbdRestore=" + kbdRestore + " resetMdt=" + resetMdt);
if (kbdRestore && inputProcessor != null) {
inputProcessor.setKeyboardLocked(false);
}
if (resetMdt) {
resetAllMDT();
}
if (wccReset(wcc)) {
log.fine("WCC reset: clearing default attributes");
}
}
public void processWCC(short wcc) {
processWCC(wcc & 0xFFFF);
}
/** Process Set Buffer Address (SBA) order. */
public void processSBA(int baddr) {
int size = screen.getRows() * screen.getCols();
if (size > 0) {
screen.setBufferAddress(baddr % size);
}
}
public void processSBA(int b1, int b2) {
processSBA(decodeAddress(b1, b2));
}
public void processSBA() {
// No-op or maintains current buffer address
}
/** Process Start Field (SF) order. */
public void processSF(byte fa) {
int size = screen.getRows() * screen.getCols();
if (size <= 0) return;
int baddr = screen.getBufferAddress();
ExtendedAttribute ea = screen.getCell(baddr);
ea.clear();
ea.fa = (byte) (fa & FA_MASK);
ea.ec = 0;
ea.ucs4 = ' ';
screen.setFormatted(true);
screen.setBufferAddress((baddr + 1) % size);
}
public void processSF() {
processSF((byte) FA_PRINTABLE);
}
/** Process Start Field Extended (SFE) order. */
public void processSFE(byte[] pairs) {
int size = screen.getRows() * screen.getCols();
if (size <= 0) return;
int baddr = screen.getBufferAddress();
ExtendedAttribute ea = screen.getCell(baddr);
ea.clear();
ea.ec = 0;
ea.ucs4 = ' ';
if (pairs != null) {
for (int i = 0; i + 1 < pairs.length; i += 2) {
int attrType = pairs[i] & 0xFF;
int attrValue = pairs[i + 1] & 0xFF;
applyExtendedAttribute(ea, attrType, attrValue);
}
}
if (ea.fa == 0) {
ea.fa = (byte) FA_PRINTABLE;
}
screen.setFormatted(true);
screen.setBufferAddress((baddr + 1) % size);
}
public void processSFE() {
processSFE(new byte[0]);
}
/** Process Set Attribute (SA) order. */
public void processSA(int attrType, int attrValue) {
int baddr = screen.getBufferAddress();
ExtendedAttribute ea = screen.getCell(baddr);
applyExtendedAttribute(ea, attrType, attrValue);
}
public void processSA() {
// Default attributes
}
/** Process Modify Field (MF) order. */
public void processMF(byte[] pairs) {
int baddr = screen.getBufferAddress();
int faAddr = screen.findFieldAttribute(baddr);
if (faAddr >= 0 && pairs != null) {
ExtendedAttribute ea = screen.getCell(faAddr);
for (int i = 0; i + 1 < pairs.length; i += 2) {
int attrType = pairs[i] & 0xFF;
int attrValue = pairs[i + 1] & 0xFF;
applyExtendedAttribute(ea, attrType, attrValue);
}
}
}
public void processMF() {
processMF(new byte[0]);
}
/** Process Insert Cursor (IC) order. */
public void processIC() {
screen.setCursorAddress(screen.getBufferAddress());
}
/** Process Program Tab (PT) order. */
public void processPT() {
int baddr = screen.findNextUnprotected(screen.getBufferAddress());
screen.setBufferAddress(baddr);
}
/** Process Repeat to Address (RA) order. */
public void processRA(int toAddr, int fillChar) {
int size = screen.getRows() * screen.getCols();
if (size <= 0) return;
toAddr = ((toAddr % size) + size) % size;
int baddr = screen.getBufferAddress();
char ucs4 = (translator != null) ? translator.ebcdicToUnicode(fillChar & 0xFF) : (char) fillChar;
do {
ExtendedAttribute ea = screen.getCell(baddr);
ea.fa = 0;
ea.ec = (byte) fillChar;
ea.ucs4 = ucs4;
baddr = (baddr + 1) % size;
} while (baddr != toAddr);
screen.setBufferAddress(baddr);
}
public void processRA() {
processRA(0, 0);
}
/** Process Erase Unprotected to Address (EUA) order. */
public void processEUA(int toAddr) {
int size = screen.getRows() * screen.getCols();
if (size <= 0) return;
toAddr = ((toAddr % size) + size) % size;
int baddr = screen.getBufferAddress();
do {
ExtendedAttribute ea = screen.getCell(baddr);
if (!ea.isFieldAttribute()) {
int faAddr = screen.findFieldAttribute(baddr);
byte faVal = faAddr >= 0 ? screen.getCell(faAddr).fa : 0;
if (!faIsProtected(faVal & 0xFF)) {
ea.ec = 0;
ea.ucs4 = 0;
ea.fg = 0;
ea.bg = 0;
ea.gr = 0;
ea.cs = 0;
}
}
baddr = (baddr + 1) % size;
} while (baddr != toAddr);
screen.setBufferAddress(baddr);
}
public void processEUA() {
processEUA(0);
}
/** Process Graphic Escape (GE) order. */
public void processGE(int geChar) {
int size = screen.getRows() * screen.getCols();
if (size <= 0) return;
int baddr = screen.getBufferAddress();
ExtendedAttribute ea = screen.getCell(baddr);
ea.fa = 0;
ea.ec = (byte) geChar;
ea.cs = CS_GE;
ea.ucs4 = (translator != null) ? translator.mapAPL(geChar) : (char) geChar;
screen.setBufferAddress((baddr + 1) % size);
}
public void processGE() {
processGE(0);
}
/** Process Write Structured Field (WSF) from short buffer. */
public void processWSF(short[] data, int off, int len) {
if (data == null || len <= 0) return;
byte[] bdata = new byte[len];
for (int i = 0; i < len; i++) {
bdata[i] = (byte) (data[off + i] & 0xFF);
}
processWriteStructuredField(bdata, 0, len);
}
public void processWSF(byte[] data, int off, int len) {
processWriteStructuredField(data, off, len);
}
/** Process raw inbound data stream chunk (short[] representation). */
public void processData(short[] data, int off, int len) {
if (data == null || len <= 0) return;
byte[] bdata = new byte[len];
for (int i = 0; i < len; i++) {
bdata[i] = (byte) (data[off + i] & 0xFF);
}
processRecord(bdata, 0, len, true);
}
public void processData(byte[] data, int off, int len) {
processRecord(data, off, len, true);
}
/** Send AID key with explicit cursor address. */
public void sendAid(short aid, int cursorAddress) {
if (inputProcessor != null) {
inputProcessor.sendAid(aid & 0xFFFF, cursorAddress);
}
}
} }
@@ -294,7 +294,7 @@ public class QueryReplyBuilder {
out.write(data, 0, data.length); out.write(data, 0, data.length);
} }
private byte[] buildSummary() { public byte[] buildSummary() {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
int[] codes = graphicsMode.isVectorGraphicsEnabled() ? SUPPORTED_QR_VECTOR : SUPPORTED_QR_BASE; int[] codes = graphicsMode.isVectorGraphicsEnabled() ? SUPPORTED_QR_VECTOR : SUPPORTED_QR_BASE;
boolean isDbcs = (screen != null && screen.getTranslator() != null && screen.getTranslator().isDBCS()); boolean isDbcs = (screen != null && screen.getTranslator() != null && screen.getTranslator().isDBCS());
@@ -307,7 +307,13 @@ public class QueryReplyBuilder {
return out.toByteArray(); return out.toByteArray();
} }
private byte[] buildUsableArea(int maxCols, int maxRows, int bufferSize) { public byte[] buildUsableArea() {
int maxCols = (screen != null) ? screen.getMaxCols() : MODEL_2_COLS;
int maxRows = (screen != null) ? screen.getMaxRows() : MODEL_2_ROWS;
return buildUsableArea(maxCols, maxRows, maxCols * maxRows);
}
public byte[] buildUsableArea(int maxCols, int maxRows, int bufferSize) {
ByteArrayOutputStream out = new ByteArrayOutputStream(19); ByteArrayOutputStream out = new ByteArrayOutputStream(19);
out.write(graphicsMode.isVectorGraphicsEnabled() ? 0x03 : 0x01); // 12/14-bit addressing + graphics flag (matching HOD DS3270.java) out.write(graphicsMode.isVectorGraphicsEnabled() ? 0x03 : 0x01); // 12/14-bit addressing + graphics flag (matching HOD DS3270.java)
out.write(0x00); // no special character features out.write(0x00); // no special character features
@@ -316,12 +322,12 @@ public class QueryReplyBuilder {
out.write((maxRows >> 8) & 0xFF); // usable height high out.write((maxRows >> 8) & 0xFF); // usable height high
out.write(maxRows & 0xFF); // usable height low out.write(maxRows & 0xFF); // usable height low
out.write(0x00); // units (0x00 = inches, matching IBM Host On-Demand QR_USEAREA_STRING) out.write(0x00); // units (0x00 = inches, matching IBM Host On-Demand QR_USEAREA_STRING)
// Xr (4 bytes) - matching IBM Host On-Demand QR_USEAREA_STRING // Xr (4 bytes) - matching IBM Host On-Demand QR_USEAREA_STRING (96 DPI)
out.write((Xr_HOD >> 24) & 0xFF); out.write((Xr_HOD >> 24) & 0xFF);
out.write((Xr_HOD >> 16) & 0xFF); out.write((Xr_HOD >> 16) & 0xFF);
out.write((Xr_HOD >> 8) & 0xFF); out.write((Xr_HOD >> 8) & 0xFF);
out.write(Xr_HOD & 0xFF); out.write(Xr_HOD & 0xFF);
// Yr (4 bytes) - matching IBM Host On-Demand QR_USEAREA_STRING // Yr (4 bytes) - matching IBM Host On-Demand QR_USEAREA_STRING (96 DPI)
out.write((Yr_HOD >> 24) & 0xFF); out.write((Yr_HOD >> 24) & 0xFF);
out.write((Yr_HOD >> 16) & 0xFF); out.write((Yr_HOD >> 16) & 0xFF);
out.write((Yr_HOD >> 8) & 0xFF); out.write((Yr_HOD >> 8) & 0xFF);
@@ -359,8 +365,14 @@ public class QueryReplyBuilder {
return graphicsMode.isVectorGraphicsEnabled() ? 0x10 : SH_3279_2; return graphicsMode.isVectorGraphicsEnabled() ? 0x10 : SH_3279_2;
} }
private byte[] buildAlphaPartitions(int maxRows) { public byte[] buildAlphaPartitions() {
int bufSize = screen.getMaxCols() * screen.getMaxRows(); int maxRows = (screen != null) ? screen.getMaxRows() : MODEL_2_ROWS;
return buildAlphaPartitions(maxRows);
}
public byte[] buildAlphaPartitions(int maxRows) {
int maxCols = (screen != null) ? screen.getMaxCols() : MODEL_2_COLS;
int bufSize = maxCols * maxRows;
ByteArrayOutputStream out = new ByteArrayOutputStream(4); ByteArrayOutputStream out = new ByteArrayOutputStream(4);
out.write(0x00); // max partitions (1 byte: 0x00 = 1 partition) out.write(0x00); // max partitions (1 byte: 0x00 = 1 partition)
out.write((bufSize >> 8) & 0xFF); // total partition storage high out.write((bufSize >> 8) & 0xFF); // total partition storage high
@@ -369,7 +381,7 @@ public class QueryReplyBuilder {
return out.toByteArray(); return out.toByteArray();
} }
private byte[] buildCharsets() { public byte[] buildCharsets() {
int charW = getCharWidth(); int charW = getCharWidth();
int charH = getCharHeight(); int charH = getCharHeight();
@@ -429,7 +441,7 @@ public class QueryReplyBuilder {
return out.toByteArray(); return out.toByteArray();
} }
private byte[] buildColor() { public byte[] buildColor() {
// Alphanumeric Color (matches HOD: 8 pairs, F1..F7 + default F4 green, 18 bytes payload / 22 bytes total) // Alphanumeric Color (matches HOD: 8 pairs, F1..F7 + default F4 green, 18 bytes payload / 22 bytes total)
return new byte[] { return new byte[] {
0x00, 0x08, 0x00, (byte) 0xF4, 0x00, 0x08, 0x00, (byte) 0xF4,
@@ -443,7 +455,7 @@ public class QueryReplyBuilder {
}; };
} }
private byte[] buildHighlighting() { public byte[] buildHighlighting() {
// Highlighting (matches HOD: 4 pairs: default F0, Blink F1, Reverse F2, Underscore F4, 9 bytes payload / 13 bytes total) // Highlighting (matches HOD: 4 pairs: default F0, Blink F1, Reverse F2, Underscore F4, 9 bytes payload / 13 bytes total)
return new byte[] { return new byte[] {
0x04, 0x00, (byte) 0xF0, 0x04, 0x00, (byte) 0xF0,
@@ -453,11 +465,15 @@ public class QueryReplyBuilder {
}; };
} }
private byte[] buildReplyModes() { public byte[] buildReplyModes() {
return new byte[] { SF_SRM_FIELD, SF_SRM_XFIELD, SF_SRM_CHAR }; return new byte[] { SF_SRM_FIELD, SF_SRM_XFIELD, SF_SRM_CHAR };
} }
private byte[] buildDdm(int bufferSize) { public byte[] buildDdm() {
return buildDdm(4096);
}
public byte[] buildDdm(int bufferSize) {
ByteArrayOutputStream out = new ByteArrayOutputStream(8); ByteArrayOutputStream out = new ByteArrayOutputStream(8);
out.write(0x00); // reserved out.write(0x00); // reserved
out.write(0x00); // reserved out.write(0x00); // reserved
@@ -470,7 +486,13 @@ public class QueryReplyBuilder {
return out.toByteArray(); return out.toByteArray();
} }
private byte[] buildImplicitPartition(int maxCols, int maxRows) { public byte[] buildImplicitPartition() {
int maxCols = (screen != null) ? screen.getMaxCols() : MODEL_2_COLS;
int maxRows = (screen != null) ? screen.getMaxRows() : MODEL_2_ROWS;
return buildImplicitPartition(maxCols, maxRows);
}
public byte[] buildImplicitPartition(int maxCols, int maxRows) {
ByteArrayOutputStream out = new ByteArrayOutputStream(22); ByteArrayOutputStream out = new ByteArrayOutputStream(22);
// Implicit partition sizes, 2 self-defining parameters // Implicit partition sizes, 2 self-defining parameters
@@ -514,6 +536,12 @@ public class QueryReplyBuilder {
return new byte[]{ 0x02, 0x00, (byte) 0xF0, (byte) 0xFF, (byte) 0xFF }; return new byte[]{ 0x02, 0x00, (byte) 0xF0, (byte) 0xFF, (byte) 0xFF };
} }
public byte[] buildSegment() {
int maxCols = (screen != null) ? screen.getMaxCols() : MODEL_2_COLS;
int maxRows = (screen != null) ? screen.getMaxRows() : MODEL_2_ROWS;
return buildSegment(maxCols, maxRows);
}
public byte[] buildSegment(int maxCols, int maxRows) { public byte[] buildSegment(int maxCols, int maxRows) {
// HOD QueryReply3270Constants.java QR_SEGMENT_STRING ("\u0000\u000b\u0081\u00b0\u0080\u0002\u0000\u0000\u0000\u00fc\u0000") // HOD QueryReply3270Constants.java QR_SEGMENT_STRING ("\u0000\u000b\u0081\u00b0\u0080\u0002\u0000\u0000\u0000\u00fc\u0000")
return new byte[]{ return new byte[]{
@@ -524,10 +552,20 @@ public class QueryReplyBuilder {
}; };
} }
public byte[] buildGraphics() {
return buildSegment();
}
public byte[] buildGraphics(int maxCols, int maxRows) { public byte[] buildGraphics(int maxCols, int maxRows) {
return buildSegment(maxCols, maxRows); return buildSegment(maxCols, maxRows);
} }
public byte[] buildProcedure() {
int maxCols = (screen != null) ? screen.getMaxCols() : MODEL_2_COLS;
int maxRows = (screen != null) ? screen.getMaxRows() : MODEL_2_ROWS;
return buildProcedure(maxCols, maxRows);
}
public byte[] buildProcedure(int maxCols, int maxRows) { public byte[] buildProcedure(int maxCols, int maxRows) {
// HOD QueryReply3270Constants.java QR_PROCEDURE_STRING ("\u0000\u0015\u0081\u00b1\u0000\u0001\u0000\u0000\u0000\u00fc\u0000\u0006@\u0006@\u0006\u0001\u00ff\u00ff\u00ff\u00f0") // HOD QueryReply3270Constants.java QR_PROCEDURE_STRING ("\u0000\u0015\u0081\u00b1\u0000\u0001\u0000\u0000\u0000\u00fc\u0000\u0006@\u0006@\u0006\u0001\u00ff\u00ff\u00ff\u00f0")
return new byte[]{ return new byte[]{
@@ -540,6 +578,10 @@ public class QueryReplyBuilder {
}; };
} }
public byte[] buildGImage() {
return buildProcedure();
}
public byte[] buildGImage(int maxCols, int maxRows) { public byte[] buildGImage(int maxCols, int maxRows) {
return buildProcedure(maxCols, maxRows); return buildProcedure(maxCols, maxRows);
} }
@@ -581,6 +623,16 @@ public class QueryReplyBuilder {
appendPort(out); appendPort(out);
} }
public byte[] buildPort() {
ByteArrayOutputStream out = new ByteArrayOutputStream(70);
appendPort(out);
return out.toByteArray();
}
public byte[] buildOemFormat() {
return buildPort();
}
public byte[] buildGrColor() { public byte[] buildGrColor() {
// HOD QueryReply3270Constants.java QR_GRCOLOR_STRING (109 bytes total) // HOD QueryReply3270Constants.java QR_GRCOLOR_STRING (109 bytes total)
ByteArrayOutputStream out = new ByteArrayOutputStream(110); ByteArrayOutputStream out = new ByteArrayOutputStream(110);
@@ -602,6 +654,10 @@ public class QueryReplyBuilder {
return out.toByteArray(); return out.toByteArray();
} }
public byte[] buildGraphicColor() {
return buildGrColor();
}
public byte[] buildGColor() { public byte[] buildGColor() {
return buildGrColor(); return buildGrColor();
} }
@@ -0,0 +1,29 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
import haus.nightmare.lib3270j.Telnet3270Client;
/**
* IBM Host On-Demand ECLConnection drop-in compatibility class.
*/
public class ECLConnection extends haus.nightmare.lib3270j.ecl.ECLConnection {
public ECLConnection() {
super();
}
public ECLConnection(haus.nightmare.lib3270j.ecl.ECLSession session) {
super((haus.nightmare.lib3270j.ecl.ECLSession) session, session != null ? session.getClient() : null);
}
public ECLConnection(String host, int port) {
super(host, port);
}
public ECLConnection(java.util.Properties props) {
super(props);
}
public ECLConnection(haus.nightmare.lib3270j.ecl.ECLSession session, Telnet3270Client client) {
super(session, client);
}
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* IBM Host On-Demand ECLConstants compatibility interface.
*/
public interface ECLConstants extends haus.nightmare.lib3270j.ecl.ECLConstants {
}
@@ -0,0 +1,33 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLErr.
*/
public class ECLErr extends haus.nightmare.lib3270j.ecl.ECLErr {
private static final long serialVersionUID = 1L;
public ECLErr() {
super();
}
public ECLErr(String text) {
super(text);
}
public ECLErr(String tag, String id, String text) {
super(tag, id, text);
}
public ECLErr(String tag, String id, String text, String extra) {
super(tag, id, text, extra);
}
public ECLErr(Throwable cause) {
super(cause);
}
public ECLErr(String message, Throwable cause) {
super(message, cause);
}
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* IBM Host On-Demand ECLErrors compatibility interface.
*/
public interface ECLErrors extends haus.nightmare.lib3270j.ecl.ECLErrors {
}
@@ -0,0 +1,21 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* IBM Host On-Demand ECLException compatibility class.
*/
public class ECLException extends haus.nightmare.lib3270j.ecl.ECLException {
private static final long serialVersionUID = 1L;
public ECLException(int errorCode, String message) {
super(errorCode, message);
}
public ECLException(int errorCode, String message, Throwable cause) {
super(errorCode, message, cause);
}
public ECLException(String message) {
super(message);
}
}
@@ -0,0 +1,11 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* IBM Host On-Demand ECLField drop-in compatibility class.
*/
public class ECLField extends haus.nightmare.lib3270j.ecl.ECLField {
public ECLField(haus.nightmare.lib3270j.ecl.ECLPS ps, int startPos, int dataStart, int endPos, int length, byte attribute) {
super(ps, startPos, dataStart, endPos, length, attribute);
}
}
@@ -0,0 +1,13 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
import haus.nightmare.lib3270j.screen.ScreenBuffer;
/**
* IBM Host On-Demand ECLFieldList drop-in compatibility class.
*/
public class ECLFieldList extends haus.nightmare.lib3270j.ecl.ECLFieldList {
public ECLFieldList(haus.nightmare.lib3270j.ecl.ECLPS ps, ScreenBuffer screen) {
super(ps, screen);
}
}
@@ -0,0 +1,19 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
import haus.nightmare.lib3270j.input.InputProcessor;
import haus.nightmare.lib3270j.screen.ScreenBuffer;
import haus.nightmare.lib3270j.telnet.TelnetFSM;
/**
* IBM Host On-Demand ECLOIA drop-in compatibility class.
*/
public class ECLOIA extends haus.nightmare.lib3270j.ecl.ECLOIA {
public ECLOIA(ScreenBuffer screen, InputProcessor inputProcessor, TelnetFSM fsm) {
super(screen, inputProcessor, fsm);
}
public ECLOIA(haus.nightmare.lib3270j.eNetwork.ECL.ECLSession session) {
super(session);
}
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLOIANotify.
*/
public interface ECLOIANotify extends haus.nightmare.lib3270j.ecl.ECLOIANotify {
}
@@ -0,0 +1,19 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
import haus.nightmare.lib3270j.input.InputProcessor;
import haus.nightmare.lib3270j.screen.ScreenBuffer;
/**
* IBM Host On-Demand ECLPS drop-in compatibility class.
*/
public class ECLPS extends haus.nightmare.lib3270j.ecl.ECLPS {
public ECLPS(ScreenBuffer screen, InputProcessor inputProcessor, EbcdicTranslator translator) {
super(screen, inputProcessor, translator);
}
public ECLPS(haus.nightmare.lib3270j.eNetwork.ECL.ECLSession session) {
super(session);
}
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLPSBIDIServices.
*/
public interface ECLPSBIDIServices extends haus.nightmare.lib3270j.ecl.ECLPSBIDIServices {
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLPSGraphicsServices.
*/
public interface ECLPSGraphicsServices extends haus.nightmare.lib3270j.ecl.ECLPSGraphicsServices {
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLPSHindiServices.
*/
public interface ECLPSHindiServices extends haus.nightmare.lib3270j.ecl.ECLPSHindiServices {
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLPSTHAIServices.
*/
public interface ECLPSTHAIServices extends haus.nightmare.lib3270j.ecl.ECLPSTHAIServices {
}
@@ -0,0 +1,18 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLPSUpdate.
*/
public class ECLPSUpdate extends haus.nightmare.lib3270j.ecl.ECLPSUpdate {
private static final long serialVersionUID = 1L;
public ECLPSUpdate(haus.nightmare.lib3270j.ecl.ECLPS ps, int startRow, int startCol,
int endRow, int endCol, int start, int end, boolean fullUpdate, String text) {
super(ps, startRow, startCol, endRow, endCol, start, end, fullUpdate, text);
}
public ECLPSUpdate(int startRow, int startCol, int endRow, int endCol, boolean fullUpdate) {
super(startRow, startCol, endRow, endCol, fullUpdate);
}
}
@@ -0,0 +1,11 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* IBM Host On-Demand ECLScreenDesc drop-in compatibility class.
*/
public class ECLScreenDesc extends haus.nightmare.lib3270j.ecl.ECLScreenDesc {
public ECLScreenDesc() {
super();
}
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLScreenNotify.
*/
public interface ECLScreenNotify extends haus.nightmare.lib3270j.ecl.ECLScreenNotify {
}
@@ -0,0 +1,19 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLScreenReco.
*/
public class ECLScreenReco extends haus.nightmare.lib3270j.ecl.ECLScreenReco {
public ECLScreenReco() {
super();
}
public ECLScreenReco(haus.nightmare.lib3270j.ecl.ECLSession session) {
super(session);
}
public ECLScreenReco(haus.nightmare.lib3270j.ecl.ECLPS ps) {
super(ps);
}
}
@@ -0,0 +1,13 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLScreenRecoEvent.
*/
public class ECLScreenRecoEvent extends haus.nightmare.lib3270j.ecl.ECLScreenRecoEvent {
public ECLScreenRecoEvent(haus.nightmare.lib3270j.ecl.ECLScreenReco source,
haus.nightmare.lib3270j.ecl.ECLScreenDesc screenDesc,
haus.nightmare.lib3270j.ecl.ECLPS ps) {
super(source, screenDesc, ps);
}
}
@@ -0,0 +1,37 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
import haus.nightmare.lib3270j.ConnectionConfig;
import haus.nightmare.lib3270j.Telnet3270Client;
import haus.nightmare.lib3270j.TerminalModel;
import java.util.Properties;
/**
* IBM Host On-Demand ECLSession drop-in compatibility class.
*/
public class ECLSession extends haus.nightmare.lib3270j.ecl.ECLSession {
public ECLSession() {
super();
}
public ECLSession(ConnectionConfig config) {
super(config);
}
public ECLSession(String host, int port, TerminalModel model) {
super(host, port, model);
}
public ECLSession(String host, int port, TerminalModel model, boolean useTls) {
super(host, port, model, useTls);
}
public ECLSession(Properties props) {
super(props);
}
public ECLSession(Telnet3270Client client) {
super(client);
}
}
@@ -0,0 +1,16 @@
package haus.nightmare.lib3270j.eNetwork.ECL;
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
import haus.nightmare.lib3270j.datastream.DataStreamProcessor;
import haus.nightmare.lib3270j.input.InputProcessor;
import haus.nightmare.lib3270j.screen.ScreenBuffer;
/**
* IBM Host On-Demand ECLXfer drop-in compatibility class.
*/
public class ECLXfer extends haus.nightmare.lib3270j.ecl.ECLXfer {
public ECLXfer(ScreenBuffer screen, InputProcessor input, DataStreamProcessor dsProcessor, EbcdicTranslator translator) {
super(screen, input, dsProcessor, translator);
}
}
@@ -0,0 +1,15 @@
package haus.nightmare.lib3270j.eNetwork.ECL.bidi;
import haus.nightmare.lib3270j.input.InputProcessor;
import haus.nightmare.lib3270j.screen.ScreenBuffer;
import haus.nightmare.lib3270j.telnet.TelnetFSM;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLOIABIDI.
*/
public class ECLOIABIDI extends haus.nightmare.lib3270j.ecl.ECLOIABIDI {
public ECLOIABIDI(ScreenBuffer screen, InputProcessor inputProcessor, TelnetFSM fsm) {
super(screen, inputProcessor, fsm);
}
}
@@ -0,0 +1,16 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
import haus.nightmare.lib3270j.ConnectionState;
/**
* IBM Host On-Demand ECLCommEvent compatibility class.
*/
public class ECLCommEvent extends haus.nightmare.lib3270j.ecl.ECLCommEvent {
private static final long serialVersionUID = 1L;
public ECLCommEvent(Object source, int eventType, ConnectionState oldState, ConnectionState newState,
String message, String deviceType, String deviceName) {
super(source, eventType, oldState, newState, message, deviceType, deviceName);
}
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
/**
* IBM Host On-Demand ECLCommListener compatibility interface.
*/
public interface ECLCommListener extends haus.nightmare.lib3270j.ecl.ECLCommListener {
}
@@ -0,0 +1,8 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
/**
* IBM Host On-Demand ECLCommNotify compatibility interface.
*/
@FunctionalInterface
public interface ECLCommNotify extends haus.nightmare.lib3270j.ecl.ECLCommNotify {
}
@@ -0,0 +1,14 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
/**
* IBM Host On-Demand ECLOIAEvent compatibility class.
*/
public class ECLOIAEvent extends haus.nightmare.lib3270j.ecl.ECLOIAEvent {
private static final long serialVersionUID = 1L;
public ECLOIAEvent(Object source, int eventType, int inputInhibited, int alphanumericType,
boolean insertMode, String statusString) {
super(source, eventType, inputInhibited, alphanumericType, insertMode, statusString);
}
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
/**
* IBM Host On-Demand ECLOIAListener compatibility interface.
*/
public interface ECLOIAListener extends haus.nightmare.lib3270j.ecl.ECLOIAListener {
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLOIANotify in event package.
*/
public interface ECLOIANotify extends haus.nightmare.lib3270j.ecl.ECLOIANotify {
}
@@ -0,0 +1,29 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
import haus.nightmare.lib3270j.ecl.ECLPSUpdate;
/**
* IBM Host On-Demand ECLPSEvent compatibility class.
*/
public class ECLPSEvent extends haus.nightmare.lib3270j.ecl.ECLPSEvent {
private static final long serialVersionUID = 1L;
public ECLPSEvent(Object source, int eventType, int type, int startRow, int startCol,
int endRow, int endCol, int oldCursorAddress, int newCursorAddress,
int rows, int cols, boolean fullUpdate, boolean cursorVisible,
int ringCounter, boolean startPrinterBit, ECLPSUpdate psUpdate) {
super(source, eventType, type, startRow, startCol, endRow, endCol,
oldCursorAddress, newCursorAddress, rows, cols, fullUpdate,
cursorVisible, ringCounter, startPrinterBit, psUpdate);
}
public ECLPSEvent(Object source, int eventType, int startRow, int startCol, int endRow, int endCol,
int oldCursorAddress, int newCursorAddress, int rows, int cols, boolean fullUpdate) {
super(source, eventType, startRow, startCol, endRow, endCol, oldCursorAddress, newCursorAddress, rows, cols, fullUpdate);
}
public ECLPSEvent(Object source, int eventType) {
super(source, eventType);
}
}
@@ -0,0 +1,22 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
import java.awt.Image;
import java.awt.Rectangle;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLPSGraphicsEvent.
*/
public class ECLPSGraphicsEvent extends haus.nightmare.lib3270j.ecl.ECLPSGraphicsEvent {
public ECLPSGraphicsEvent(haus.nightmare.lib3270j.ecl.ECLPS source, int id) {
super(source, id);
}
public ECLPSGraphicsEvent(haus.nightmare.lib3270j.ecl.ECLPS source, int id, Image image) {
super(source, id, image);
}
public ECLPSGraphicsEvent(haus.nightmare.lib3270j.ecl.ECLPS source, int id, Image image, Rectangle rectangle) {
super(source, id, image, rectangle);
}
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLPSGraphicsListener.
*/
public interface ECLPSGraphicsListener extends haus.nightmare.lib3270j.ecl.ECLPSGraphicsListener {
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL.event;
/**
* IBM Host On-Demand ECLPSListener compatibility interface.
*/
public interface ECLPSListener extends haus.nightmare.lib3270j.ecl.ECLPSListener {
}
@@ -0,0 +1,15 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hindi;
import haus.nightmare.lib3270j.input.InputProcessor;
import haus.nightmare.lib3270j.screen.ScreenBuffer;
import haus.nightmare.lib3270j.telnet.TelnetFSM;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLOIAHindi.
*/
public class ECLOIAHindi extends haus.nightmare.lib3270j.ecl.ECLOIAHindi {
public ECLOIAHindi(ScreenBuffer screen, InputProcessor inputProcessor, TelnetFSM fsm) {
super(screen, inputProcessor, fsm);
}
}
@@ -0,0 +1,10 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
/**
* Drop-in IBM Host On-Demand compatible facade for Edge.
*/
public class Edge extends haus.nightmare.lib3270j.graphics.Edge {
public Edge(int x1, int y1, int x2, int y2) {
super(x1, y1, x2, y2);
}
}
@@ -0,0 +1,20 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
import java.awt.Color;
/**
* Drop-in IBM Host On-Demand compatible facade for FillArea.
*/
public class FillArea extends haus.nightmare.lib3270j.graphics.FillArea {
public FillArea() {
super();
}
public FillArea(int fillRule) {
super(fillRule);
}
public FillArea(int[] px, int[] py, int[] polyCounts, int numPolys, Color color) {
super(px, py, polyCounts, numPolys, color);
}
}
@@ -0,0 +1,10 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
/**
* Drop-in IBM Host On-Demand compatible facade for FilletPts.
*/
public class FilletPts extends haus.nightmare.lib3270j.graphics.FilletPts {
public FilletPts() {
super();
}
}
@@ -0,0 +1,12 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
import java.awt.Component;
/**
* Drop-in IBM Host On-Demand compatible facade for HODBitImage.
*/
public class HODBitImage extends haus.nightmare.lib3270j.graphics.HODBitImage {
public HODBitImage(Component comp, int width, int height, byte[] data, int baseColor, int depth, boolean useGraphicColors) {
super(comp, width, height, data, baseColor, depth, useGraphicColors);
}
}
@@ -0,0 +1,7 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
/**
* Drop-in IBM Host On-Demand compatible facade for HODBounds.
*/
public class HODBounds extends haus.nightmare.lib3270j.graphics.HODBounds {
}
@@ -0,0 +1,10 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
/**
* Drop-in IBM Host On-Demand compatible facade for HODColorChangeFilter.
*/
public class HODColorChangeFilter extends haus.nightmare.lib3270j.graphics.HODColorChangeFilter {
public HODColorChangeFilter(int color) {
super(color);
}
}
@@ -0,0 +1,20 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
import haus.nightmare.lib3270j.graphics.GraphicsPlane;
/**
* Drop-in IBM Host On-Demand compatible facade for HODGraphicsPlane.
*/
public class HODGraphicsPlane extends haus.nightmare.lib3270j.graphics.HODGraphicsPlane {
public HODGraphicsPlane() {
super();
}
public HODGraphicsPlane(int width, int height) {
super(width, height);
}
public HODGraphicsPlane(GraphicsPlane delegate) {
super(delegate);
}
}
@@ -0,0 +1,30 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
/**
* Drop-in IBM Host On-Demand compatible facade for HODPart.
*/
public class HODPart extends haus.nightmare.lib3270j.graphics.HODPart {
public HODPart() {
super();
}
public HODPart(Component component) {
super(component);
}
public HODPart(Component component, Dimension dimension) {
super(component, dimension);
}
public HODPart(Component component, Rectangle rectangle) {
super(component, rectangle);
}
public HODPart(HODPart hODPart) {
super(hODPart);
}
}
@@ -0,0 +1,16 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
import haus.nightmare.lib3270j.graphics.ProgramSymbolManager;
/**
* Drop-in IBM Host On-Demand compatible facade for HODProgramSymbolManager.
*/
public class HODProgramSymbolManager extends haus.nightmare.lib3270j.graphics.HODProgramSymbolManager {
public HODProgramSymbolManager() {
super();
}
public HODProgramSymbolManager(ProgramSymbolManager delegate) {
super(delegate);
}
}
@@ -0,0 +1,10 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
/**
* Drop-in IBM Host On-Demand compatible facade for HODTransform.
*/
public class HODTransform extends haus.nightmare.lib3270j.graphics.HODTransform {
public HODTransform(int charW, int charH, int defaultCharW, int defaultCharH) {
super(charW, charH, defaultCharW, defaultCharH);
}
}
@@ -0,0 +1,10 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
/**
* Drop-in IBM Host On-Demand compatible facade for HODTransparentColorFilter.
*/
public class HODTransparentColorFilter extends haus.nightmare.lib3270j.graphics.HODTransparentColorFilter {
public HODTransparentColorFilter(int transparentColor) {
super(transparentColor);
}
}
@@ -0,0 +1,20 @@
package haus.nightmare.lib3270j.eNetwork.ECL.hostgraphics;
import java.awt.Image;
/**
* Drop-in IBM Host On-Demand compatible facade for HODWallpaper.
*/
public class HODWallpaper extends haus.nightmare.lib3270j.graphics.HODWallpaper {
public HODWallpaper() {
super();
}
public HODWallpaper(int displayMode) {
super(displayMode);
}
public HODWallpaper(Image image, int displayMode) {
super(image, displayMode);
}
}
@@ -0,0 +1,15 @@
package haus.nightmare.lib3270j.eNetwork.ECL.thai;
import haus.nightmare.lib3270j.input.InputProcessor;
import haus.nightmare.lib3270j.screen.ScreenBuffer;
import haus.nightmare.lib3270j.telnet.TelnetFSM;
/**
* Drop-in IBM Host On-Demand compatible facade for ECLOIATHAI.
*/
public class ECLOIATHAI extends haus.nightmare.lib3270j.ecl.ECLOIATHAI {
public ECLOIATHAI(ScreenBuffer screen, InputProcessor inputProcessor, TelnetFSM fsm) {
super(screen, inputProcessor, fsm);
}
}
@@ -0,0 +1,29 @@
package haus.nightmare.lib3270j.eNetwork.ECL.tn3270;
import haus.nightmare.lib3270j.charset.EbcdicTranslator;
import haus.nightmare.lib3270j.datastream.DataStreamProcessor;
import haus.nightmare.lib3270j.ecl.ECLPS;
import haus.nightmare.lib3270j.ecl.ECLSession;
import haus.nightmare.lib3270j.screen.ScreenBuffer;
/**
* Drop-in IBM Host On-Demand compatible facade for com.ibm.eNetwork.ECL.tn3270.DS3270.
*/
public class DS3270 extends haus.nightmare.lib3270j.tn3270.DS3270 {
public DS3270() {
super();
}
public DS3270(ScreenBuffer screen, EbcdicTranslator translator) {
super(screen, translator);
}
public DS3270(DataStreamProcessor delegate) {
super(delegate);
}
public DS3270(ECLSession session, ECLPS ps) {
super(session, ps);
}
}

Some files were not shown because too many files have changed in this diff Show More