diff --git a/resources/config.ini b/resources/config.ini index f502fe1..b0c08d1 100644 --- a/resources/config.ini +++ b/resources/config.ini @@ -533,6 +533,28 @@ ClosedownAt= AcceptIncomingConnectionAction=manual +# Suppress Navigating Away Warning +# -------------------------------- +# +# If you change Order Type, Quantity or other fields in Order Entry +# dialog and switch to a different ticker in a linked window, +# TWS displays dialog box with a warning: +# +# "Navigating away from will reset the order entry." +# +# TWS doesn't have built-in option to disable this warning. +# +# yes means the dialog is dismissed as though the user had +# clicked the 'Continue' button: this means that you accept +# Order Entry fields are reset to default values while +# switching to different ticker. +# +# no means the dialog remains on display and must be +# handled by the user. + +SuppressNavigatingAwayWarning=no + + # Allow Blind Trading # ------------------- # diff --git a/src/ibcalpha/ibc/IbcTws.java b/src/ibcalpha/ibc/IbcTws.java index 1848029..05f68a1 100644 --- a/src/ibcalpha/ibc/IbcTws.java +++ b/src/ibcalpha/ibc/IbcTws.java @@ -337,6 +337,8 @@ private static List createWindowHandlers() { windowHandlers.add(new ShutdownProgressDialogHandler()); windowHandlers.add(new BidAskLastSizeDisplayUpdateDialogHandler()); windowHandlers.add(new LoginErrorDialogHandler()); + windowHandlers.add(new NavigatingAwayDialogHandler()); + windowHandlers.add(new MustEnterValidPriceDialogHandler()); windowHandlers.add(new CryptoOrderConfirmationDialogHandler()); windowHandlers.add(new AutoRestartConfirmationDialog()); diff --git a/src/ibcalpha/ibc/MustEnterValidPriceDialogHandler.java b/src/ibcalpha/ibc/MustEnterValidPriceDialogHandler.java new file mode 100644 index 0000000..3ae49a7 --- /dev/null +++ b/src/ibcalpha/ibc/MustEnterValidPriceDialogHandler.java @@ -0,0 +1,51 @@ +// This file is part of IBC. +// Copyright (C) 2004 Steven M. Kearns (skearns23@yahoo.com ) +// Copyright (C) 2004 - 2018 Richard L King (rlking@aultan.com) +// For conditions of distribution and use, see copyright notice in COPYING.txt + +// IBC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// IBC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with IBC. If not, see . + +package ibcalpha.ibc; + +import java.awt.Window; +import java.awt.event.WindowEvent; +import javax.swing.JDialog; + +class MustEnterValidPriceDialogHandler implements WindowHandler { + public boolean filterEvent(Window window, int eventId) { + switch (eventId) { + case WindowEvent.WINDOW_OPENED: + return true; + default: + return false; + } + } + + public void handleWindow(Window window, int eventID) { + if (! Settings.settings().getBoolean("SuppressYouMustEnterValidPriceWarning", false)) return; + + if (SwingUtils.clickButton(window, "OK")) { + } else { + Utils.logError("can't close 'You must enter a valid price' window: 'OK' button not found"); + } + } + + public boolean recogniseWindow(Window window) { + if (! (window instanceof JDialog)) return false; + + return (SwingUtils.findTextPane(window, "You must enter a valid price") != null); + + } +} + diff --git a/src/ibcalpha/ibc/NavigatingAwayDialogHandler.java b/src/ibcalpha/ibc/NavigatingAwayDialogHandler.java new file mode 100644 index 0000000..3f49864 --- /dev/null +++ b/src/ibcalpha/ibc/NavigatingAwayDialogHandler.java @@ -0,0 +1,61 @@ +// This file is part of IBC. +// Copyright (C) 2004 Steven M. Kearns (skearns23@yahoo.com ) +// Copyright (C) 2004 - 2018 Richard L King (rlking@aultan.com) +// For conditions of distribution and use, see copyright notice in COPYING.txt + +// IBC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// IBC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with IBC. If not, see . + +package ibcalpha.ibc; + +import java.awt.Window; +import java.awt.event.WindowEvent; +import javax.swing.JDialog; +import javax.swing.JOptionPane; + +class NavigatingAwayDialogHandler implements WindowHandler { + public boolean filterEvent(Window window, int eventId) { + switch (eventId) { + case WindowEvent.WINDOW_OPENED: + return true; + default: + return false; + } + } + + public void handleWindow(Window window, int eventID) { + if (! Settings.settings().getBoolean("SuppressNavigatingAwayWarning", false)) return; + + if (SwingUtils.clickButton(window, "Continue")) { + } else { + Utils.logError("can't close 'Navigating away' window: 'Continue' button not found"); + } + } + + public boolean recogniseWindow(Window window) { + if (! (window instanceof JDialog)) return false; + + JOptionPane optionsPane = SwingUtils.findOptionPane(window); + + if (optionsPane == null) return false; + + String label = optionsPane.getMessage().toString(); + + if (label.contains("Navigating away from") && label.contains("will reset the order entry.")) + return true; + + return (SwingUtils.findLabel(window, "Navigating away from") != null) && + (SwingUtils.findLabel(window, "will reset the order entry.") != null); + } +} +