From db5be7743901cafd76bb4212a0e9e97afd7cdfe2 Mon Sep 17 00:00:00 2001 From: Dale Schultz Date: Wed, 5 Oct 2011 03:31:57 +0000 Subject: [PATCH] Moved COM port Auto Refresh to Settings menu to free up more control bar space. git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@356 38686702-15cf-42e4-a595-3071df8bf5ea --- release_notes.txt | 1 + src/com/romraider/logger/ecu/EcuLogger.java | 14 +------ .../ecu/comms/manager/QueryManagerImpl.java | 37 +++++++++--------- .../ui/swing/menubar/EcuLoggerMenuBar.java | 6 +++ .../action/ComPortAutoRefreshAction.java | 39 +++++++++++++++++++ 5 files changed, 67 insertions(+), 30 deletions(-) create mode 100644 src/com/romraider/logger/ecu/ui/swing/menubar/action/ComPortAutoRefreshAction.java diff --git a/release_notes.txt b/release_notes.txt index 901e1a38..0f1bda58 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -78,6 +78,7 @@ This is the first beta release of the upcoming official 0.5.4b release. - Added a Debugging Level selection option to the Help menu. The setting is saved and restored between sessions. INFO should be the normal state to keep the rr_system.log file in-check. +- Moved the COM port Auto Refresh checkbox to the Settings menu. --- Editor --- - Set JInternalFrame.isPalette in TableFarme.java so table titles are visible on Mac OS. diff --git a/src/com/romraider/logger/ecu/EcuLogger.java b/src/com/romraider/logger/ecu/EcuLogger.java index b87bc07e..43290f93 100644 --- a/src/com/romraider/logger/ecu/EcuLogger.java +++ b/src/com/romraider/logger/ecu/EcuLogger.java @@ -215,7 +215,6 @@ public final class EcuLogger extends AbstractFrame implements MessageListener { private JLabel statsLabel; private JTabbedPane tabbedPane; private SerialPortComboBox portsComboBox; - private JCheckBox portRefresh; private DataUpdateHandlerManager dataHandlerManager; private DataRegistrationBroker dataTabBroker; private ParameterListTableModel dataTabParamListTableModel; @@ -1065,15 +1064,6 @@ public final class EcuLogger extends AbstractFrame implements MessageListener { JPanel comboBoxPanel = new JPanel(new FlowLayout()); comboBoxPanel.add(new JLabel("COM Port:")); comboBoxPanel.add(portsComboBox); - portRefresh = new JCheckBox("Auto Refresh"); - portRefresh.setToolTipText("Check to enable automatic COM port refreshing"); - portRefresh.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - refresher.setRefreshMode(portRefresh.isSelected()); - settings.setRefreshMode(portRefresh.isSelected()); - } - }); - comboBoxPanel.add(portRefresh); final JCheckBox ecuCheckBox = new JCheckBox("ECU"); final JCheckBox tcuCheckBox = new JCheckBox("TCU"); @@ -1456,8 +1446,8 @@ public final class EcuLogger extends AbstractFrame implements MessageListener { } } - private void setRefreshMode(boolean refreshMode) { - portRefresh.setSelected(refreshMode); + public void setRefreshMode(boolean refreshMode) { + settings.setRefreshMode(refreshMode); refresher.setRefreshMode(refreshMode); } } diff --git a/src/com/romraider/logger/ecu/comms/manager/QueryManagerImpl.java b/src/com/romraider/logger/ecu/comms/manager/QueryManagerImpl.java index f96e4119..5b7ab074 100644 --- a/src/com/romraider/logger/ecu/comms/manager/QueryManagerImpl.java +++ b/src/com/romraider/logger/ecu/comms/manager/QueryManagerImpl.java @@ -19,10 +19,26 @@ package com.romraider.logger.ecu.comms.manager; -import com.romraider.Settings; -import com.romraider.logger.ecu.comms.manager.PollingState; -import com.romraider.logger.ecu.comms.io.connection.LoggerConnection; import static com.romraider.logger.ecu.comms.io.connection.LoggerConnectionFactory.getConnection; +import static com.romraider.logger.ecu.definition.EcuDataType.EXTERNAL; +import static com.romraider.util.ParamChecker.checkNotNull; +import static com.romraider.util.ThreadUtil.runAsDaemon; +import static com.romraider.util.ThreadUtil.sleep; +import static java.util.Collections.synchronizedList; +import static java.util.Collections.synchronizedMap; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.SwingUtilities; + +import org.apache.log4j.Logger; + +import com.romraider.Settings; +import com.romraider.logger.ecu.comms.io.connection.LoggerConnection; import com.romraider.logger.ecu.comms.query.EcuInitCallback; import com.romraider.logger.ecu.comms.query.EcuQuery; import com.romraider.logger.ecu.comms.query.EcuQueryImpl; @@ -32,30 +48,15 @@ import com.romraider.logger.ecu.comms.query.Query; import com.romraider.logger.ecu.comms.query.Response; import com.romraider.logger.ecu.comms.query.ResponseImpl; import com.romraider.logger.ecu.definition.EcuData; -import static com.romraider.logger.ecu.definition.EcuDataType.EXTERNAL; import com.romraider.logger.ecu.definition.ExternalData; import com.romraider.logger.ecu.definition.LoggerData; import com.romraider.logger.ecu.ui.MessageListener; import com.romraider.logger.ecu.ui.StatusChangeListener; import com.romraider.logger.ecu.ui.handler.DataUpdateHandler; import com.romraider.logger.ecu.ui.handler.file.FileLoggerControllerSwitchMonitor; -import static com.romraider.util.ParamChecker.checkNotNull; -import static com.romraider.util.ThreadUtil.runAsDaemon; -import static com.romraider.util.ThreadUtil.sleep; -import static java.util.Collections.synchronizedList; -import static java.util.Collections.synchronizedMap; -import org.apache.log4j.Logger; -import javax.swing.SwingUtilities; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; public final class QueryManagerImpl implements QueryManager { private static final Logger LOGGER = Logger.getLogger(QueryManagerImpl.class); - private final DecimalFormat format = new DecimalFormat("0.00"); private final List listeners = synchronizedList(new ArrayList()); private final Map queryMap = synchronizedMap(new HashMap()); private final Map addList = new HashMap(); diff --git a/src/com/romraider/logger/ecu/ui/swing/menubar/EcuLoggerMenuBar.java b/src/com/romraider/logger/ecu/ui/swing/menubar/EcuLoggerMenuBar.java index 9b4d2009..1369cd49 100644 --- a/src/com/romraider/logger/ecu/ui/swing/menubar/EcuLoggerMenuBar.java +++ b/src/com/romraider/logger/ecu/ui/swing/menubar/EcuLoggerMenuBar.java @@ -25,6 +25,7 @@ import static java.awt.event.InputEvent.SHIFT_MASK; import static java.awt.event.KeyEvent.VK_A; import static java.awt.event.KeyEvent.VK_C; import static java.awt.event.KeyEvent.VK_D; +import static java.awt.event.KeyEvent.VK_E; import static java.awt.event.KeyEvent.VK_F; import static java.awt.event.KeyEvent.VK_F7; import static java.awt.event.KeyEvent.VK_H; @@ -49,6 +50,7 @@ import javax.swing.JMenuBar; import javax.swing.JSeparator; import com.romraider.logger.ecu.EcuLogger; +import com.romraider.logger.ecu.ui.swing.menubar.action.ComPortAutoRefreshAction; import com.romraider.logger.ecu.ui.swing.menubar.action.DisconnectAction; import com.romraider.logger.ecu.ui.swing.menubar.action.ExitAction; import com.romraider.logger.ecu.ui.swing.menubar.action.FastPollModeAction; @@ -92,9 +94,13 @@ public class EcuLoggerMenuBar extends JMenuBar { settingsMenu.add(new MenuItem("Log File Output Location...", new LogFileLocationAction(logger), VK_O, getKeyStroke(VK_O, CTRL_MASK))); settingsMenu.add(new JSeparator()); settingsMenu.add(new RadioButtonMenuItem("Control File Logging With Defogger Switch", VK_C, getKeyStroke(VK_C, CTRL_MASK), new LogFileControllerSwitchAction(logger), logger.getSettings().isFileLoggingControllerSwitchActive())); + RadioButtonMenuItem autoRefresh = new RadioButtonMenuItem("Enable COM port Auto Refresh", VK_E, getKeyStroke(VK_E, CTRL_MASK), new ComPortAutoRefreshAction(logger), logger.getSettings().getRefreshMode()); + autoRefresh.setToolTipText("Select to enable automatic COM port refreshing"); + settingsMenu.add(autoRefresh); RadioButtonMenuItem fastPoll = new RadioButtonMenuItem("Enable Fast Polling Mode", VK_M, getKeyStroke(VK_M, CTRL_MASK), new FastPollModeAction(logger), logger.getSettings().isFastPoll()); fastPoll.setToolTipText("Select to enable faster polling of the ECU"); settingsMenu.add(fastPoll); + settingsMenu.add(new JSeparator()); settingsMenu.add(new RadioButtonMenuItem("Use Absolute Timestamp In Log File", VK_T, getKeyStroke(VK_T, CTRL_MASK), new LogFileAbsoluteTimestampAction(logger), logger.getSettings().isFileLoggingAbsoluteTimestamp())); add(settingsMenu); diff --git a/src/com/romraider/logger/ecu/ui/swing/menubar/action/ComPortAutoRefreshAction.java b/src/com/romraider/logger/ecu/ui/swing/menubar/action/ComPortAutoRefreshAction.java new file mode 100644 index 00000000..343b7c28 --- /dev/null +++ b/src/com/romraider/logger/ecu/ui/swing/menubar/action/ComPortAutoRefreshAction.java @@ -0,0 +1,39 @@ +/* + * RomRaider Open-Source Tuning, Logging and Reflashing + * Copyright (C) 2006-2010 RomRaider.com + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package com.romraider.logger.ecu.ui.swing.menubar.action; + +import com.romraider.logger.ecu.EcuLogger; +import com.romraider.swing.menubar.action.AbstractAction; +import java.awt.event.ActionEvent; + +public final class ComPortAutoRefreshAction extends AbstractAction { + + public ComPortAutoRefreshAction(EcuLogger logger) { + super(logger); + } + + public void actionPerformed(ActionEvent actionEvent) { + try { + logger.setRefreshMode((Boolean) getValue(SELECTED_KEY)); + } catch (Exception e) { + logger.reportError(e); + } + } +}