diff --git a/src/ibcalpha/ibc/AbstractLoginHandler.java b/src/ibcalpha/ibc/AbstractLoginHandler.java index 4da2e6b..27b54de 100644 --- a/src/ibcalpha/ibc/AbstractLoginHandler.java +++ b/src/ibcalpha/ibc/AbstractLoginHandler.java @@ -25,6 +25,7 @@ import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; +import javax.swing.JToggleButton; public abstract class AbstractLoginHandler implements WindowHandler { @@ -157,6 +158,7 @@ private JButton findLoginButton(final Window window) { JButton b = SwingUtils.findButton(window, "Login"); if (b == null) b = SwingUtils.findButton(window, "Log In"); if (b == null) b = SwingUtils.findButton(window, "Paper Log In"); + if (b == null) b = SwingUtils.findButton(window, "Paper-Login"); // Gateway 1037+ (hyphenated) return b; } @@ -174,14 +176,18 @@ protected final void setCredential(final Window window, protected final boolean setTradingMode(final Window window) { String tradingMode = TradingModeManager.tradingModeManager().getTradingMode(); - if (SwingUtils.findToggleButton(window, "Live Trading") != null && - SwingUtils.findToggleButton(window, "Paper Trading") != null) { + // Gateway 1037+ uses hyphenated names; older Gateway/TWS uses space-separated. + JToggleButton liveBtn = SwingUtils.findToggleButton(window, "Live Trading"); + if (liveBtn == null) liveBtn = SwingUtils.findToggleButton(window, "Live-Trading"); + JToggleButton paperBtn = SwingUtils.findToggleButton(window, "Paper Trading"); + if (paperBtn == null) paperBtn = SwingUtils.findToggleButton(window, "Paper-Trading"); + if (liveBtn != null && paperBtn != null) { // TWS 974 onwards uses toggle buttons rather than a combo box Utils.logToConsole("Setting Trading mode = " + tradingMode); if (tradingMode.equalsIgnoreCase(TradingModeManager.TRADING_MODE_LIVE)) { - SwingUtils.findToggleButton(window, "Live Trading").doClick(); + liveBtn.doClick(); } else { - SwingUtils.findToggleButton(window, "Paper Trading").doClick(); + paperBtn.doClick(); } return true; } else { diff --git a/src/ibcalpha/ibc/GatewayLoginFrameHandler.java b/src/ibcalpha/ibc/GatewayLoginFrameHandler.java index d182973..9ca2793 100644 --- a/src/ibcalpha/ibc/GatewayLoginFrameHandler.java +++ b/src/ibcalpha/ibc/GatewayLoginFrameHandler.java @@ -30,11 +30,13 @@ public boolean recogniseWindow(Window window) { if (! (window instanceof JFrame)) return false; return ((SwingUtils.titleContains(window, "IBKR Gateway") || - SwingUtils.titleContains(window, "IB Gateway") || + SwingUtils.titleContains(window, "IBKR-Gateway") || // Gateway 1037+ + SwingUtils.titleContains(window, "IB Gateway") || SwingUtils.titleContains(window, "Interactive Brokers Gateway")) && (SwingUtils.findButton(window, "Login") != null || SwingUtils.findButton(window, "Log In") != null || // TWS 974+ - SwingUtils.findButton(window, "Paper Log In") != null)); // TWS 974+ + SwingUtils.findButton(window, "Paper Log In") != null || // TWS 974+ + SwingUtils.findButton(window, "Paper-Login") != null)); // Gateway 1037+ (hyphenated) } @Override @@ -119,6 +121,7 @@ private void selectGatewayMode(Window window) throws IbcException { private void switchToFIX(Window window) throws IbcException { JToggleButton button = SwingUtils.findToggleButton(window, "FIX CTCI"); + if (button == null) button = SwingUtils.findToggleButton(window, "FIX-CTCI"); // Gateway 1037+ if (button == null) throw new IbcException("FIX CTCI selector"); if (! button.isSelected()) { diff --git a/src/ibcalpha/ibc/ReconnectDataOrAccountConfirmationDialogHandler.java b/src/ibcalpha/ibc/ReconnectDataOrAccountConfirmationDialogHandler.java index cd1a334..b4b5acf 100644 --- a/src/ibcalpha/ibc/ReconnectDataOrAccountConfirmationDialogHandler.java +++ b/src/ibcalpha/ibc/ReconnectDataOrAccountConfirmationDialogHandler.java @@ -46,10 +46,12 @@ public void handleWindow(Window window, int eventID) { public boolean recogniseWindow(Window window) { if (! (window instanceof JDialog)) return false; - return ((SwingUtils.titleContains(window, "IBKR Trader Workstation") + return ((SwingUtils.titleContains(window, "IBKR Trader Workstation") || - SwingUtils.titleContains(window, "IBKR Gateway")) - && + SwingUtils.titleContains(window, "IBKR Gateway") + || + SwingUtils.titleContains(window, "IBKR-Gateway")) // Gateway 1037+ + && (SwingUtils.findLabel(window, "Are you sure you want to execute \"simulate") != null) ); }