@Override
    public void handleWindow(final Window window, int eventID) {
        if (!firstTradesWindowOpened) {
            showAllTrades = Settings.settings().getBoolean("ShowAllTrades", false);
        }
        if (!showAllTrades) {
            firstTradesWindowOpened = true;
            return;
        }
        if (eventID == WindowEvent.WINDOW_OPENED) {
            if (findCheckBox(window, "Sun") != null) {
                Utils.logToConsole("Setting trades log to show all trades");
                // TWS versions before 955
                SwingUtils.setCheckBoxSelected(window, "Sun", true);
                SwingUtils.setCheckBoxSelected(window, "Mon", true);
                SwingUtils.setCheckBoxSelected(window, "Tue", true);
                SwingUtils.setCheckBoxSelected(window, "Wed", true);
                SwingUtils.setCheckBoxSelected(window, "Thu", true);
                SwingUtils.setCheckBoxSelected(window, "Fri", true);
                SwingUtils.setCheckBoxSelected(window, "Sat", true);
                SwingUtils.setCheckBoxSelected(window, "All", true);

                monitorAllTradesCheckbox(window, "All");

                if (! firstTradesWindowOpened) {
                    if (Settings.settings().getBoolean("MinimizeMainWindow", false)) {
                        ((JFrame) window).setExtendedState(java.awt.Frame.ICONIFIED);
                    }
                }
            } else {
                Utils.logToConsole("Can't set trades log to show all trades with this TWS version: user must do this");
                /*
                 * For TWS 955 onwards, IB have replaced the row of daily 
                 * checkboxes with what appears visually to be a combo box:
                 * it is indeed derived from a JComboBox, but setting the
                 * selected item to 'Last 7 Days' doesn't have the desired
                 * effect.
                 * 
                 * At present I don't see a way of getting round this, but 
                 * the setting chosen by the user can now be persisted
                 * between sessions, so there is really no longer a need for
                 * 'ShowAllTrades'.
                 * 
                 */
                
                showAllTrades = false;
                ((JFrame) window).dispose();
            }

            firstTradesWindowOpened = true;

        } else if (eventID == WindowEvent.WINDOW_CLOSING) {
            Utils.logToConsole("User closing trades log");
        } else if (eventID == WindowEvent.WINDOW_CLOSED) {
            if (showAllTrades) {
                Utils.logToConsole("Trades log closed by user - recreating");
                Utils.showTradesLogWindow();
            }
        }

    }