Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions resources/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ticker> 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
# -------------------
#
Expand Down
2 changes: 2 additions & 0 deletions src/ibcalpha/ibc/IbcTws.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ private static List<WindowHandler> 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());

Expand Down
51 changes: 51 additions & 0 deletions src/ibcalpha/ibc/MustEnterValidPriceDialogHandler.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

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);

}
}

61 changes: 61 additions & 0 deletions src/ibcalpha/ibc/NavigatingAwayDialogHandler.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

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);
}
}