mirror of https://github.com/rusefi/RomRaider.git
started adding config item for logger def location
git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@169 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
parent
f36f2b159c
commit
de2c387fc1
|
@ -69,7 +69,7 @@ public class Settings implements Serializable {
|
||||||
private String loggerPort = "";
|
private String loggerPort = "";
|
||||||
private String loggerPortDefault = "";
|
private String loggerPortDefault = "";
|
||||||
private String loggerProtocol = "SSM";
|
private String loggerProtocol = "SSM";
|
||||||
private String loggerConfigFilePath = "logger.xml";
|
private String loggerDefinitionFilePath = "logger.xml";
|
||||||
private String loggerProfileFilePath = "";
|
private String loggerProfileFilePath = "";
|
||||||
private String loggerOutputDirPath = System.getProperty("user.home");
|
private String loggerOutputDirPath = System.getProperty("user.home");
|
||||||
private String fileLoggingControllerSwitchId = "S20"; // defogger switch by default
|
private String fileLoggingControllerSwitchId = "S20"; // defogger switch by default
|
||||||
|
@ -329,8 +329,12 @@ public class Settings implements Serializable {
|
||||||
return loggerProtocol;
|
return loggerProtocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLoggerConfigFilePath() {
|
public String getLoggerDefinitionFilePath() {
|
||||||
return loggerConfigFilePath;
|
return loggerDefinitionFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoggerDefinitionFilePath(String loggerDefinitionFilePath) {
|
||||||
|
this.loggerDefinitionFilePath = loggerDefinitionFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLoggerOutputDirPath() {
|
public String getLoggerOutputDirPath() {
|
||||||
|
|
|
@ -310,7 +310,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
||||||
dashboardTabExternalListTableModel = new ParameterListTableModel(dashboardTabBroker, HEADING_EXTERNAL);
|
dashboardTabExternalListTableModel = new ParameterListTableModel(dashboardTabBroker, HEADING_EXTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadLoggerParams() {
|
public void loadLoggerParams() {
|
||||||
loadLoggerConfig();
|
loadLoggerConfig();
|
||||||
loadFromExternalDataSources();
|
loadFromExternalDataSources();
|
||||||
}
|
}
|
||||||
|
@ -370,7 +370,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
||||||
private void loadLoggerConfig() {
|
private void loadLoggerConfig() {
|
||||||
try {
|
try {
|
||||||
EcuDataLoader dataLoader = new EcuDataLoaderImpl();
|
EcuDataLoader dataLoader = new EcuDataLoaderImpl();
|
||||||
dataLoader.loadConfigFromXml(settings.getLoggerConfigFilePath(), settings.getLoggerProtocol(),
|
dataLoader.loadConfigFromXml(settings.getLoggerDefinitionFilePath(), settings.getLoggerProtocol(),
|
||||||
settings.getFileLoggingControllerSwitchId(), ecuInit);
|
settings.getFileLoggingControllerSwitchId(), ecuInit);
|
||||||
List<EcuParameter> ecuParams = dataLoader.getEcuParameters();
|
List<EcuParameter> ecuParams = dataLoader.getEcuParameters();
|
||||||
addConvertorUpdateListeners(ecuParams);
|
addConvertorUpdateListeners(ecuParams);
|
||||||
|
|
|
@ -31,6 +31,7 @@ import com.romraider.logger.ecu.ui.swing.menubar.action.LoadProfileAction;
|
||||||
import com.romraider.logger.ecu.ui.swing.menubar.action.LogFileAbsoluteTimestampAction;
|
import com.romraider.logger.ecu.ui.swing.menubar.action.LogFileAbsoluteTimestampAction;
|
||||||
import com.romraider.logger.ecu.ui.swing.menubar.action.LogFileControllerSwitchAction;
|
import com.romraider.logger.ecu.ui.swing.menubar.action.LogFileControllerSwitchAction;
|
||||||
import com.romraider.logger.ecu.ui.swing.menubar.action.LogFileLocationAction;
|
import com.romraider.logger.ecu.ui.swing.menubar.action.LogFileLocationAction;
|
||||||
|
import com.romraider.logger.ecu.ui.swing.menubar.action.LoggerDefinitionLocationAction;
|
||||||
import com.romraider.logger.ecu.ui.swing.menubar.action.ReloadProfileAction;
|
import com.romraider.logger.ecu.ui.swing.menubar.action.ReloadProfileAction;
|
||||||
import com.romraider.logger.ecu.ui.swing.menubar.action.ResetConnectionAction;
|
import com.romraider.logger.ecu.ui.swing.menubar.action.ResetConnectionAction;
|
||||||
import com.romraider.logger.ecu.ui.swing.menubar.action.ResetEcuAction;
|
import com.romraider.logger.ecu.ui.swing.menubar.action.ResetEcuAction;
|
||||||
|
@ -76,6 +77,7 @@ public class EcuLoggerMenuBar extends JMenuBar {
|
||||||
|
|
||||||
// settings menu items
|
// settings menu items
|
||||||
JMenu settingsMenu = new EcuLoggerMenu("Settings", VK_S);
|
JMenu settingsMenu = new EcuLoggerMenu("Settings", VK_S);
|
||||||
|
settingsMenu.add(new EcuLoggerMenuItem("Logger Definition Location...", new LoggerDefinitionLocationAction(logger), VK_D, getKeyStroke(VK_D, CTRL_MASK)));
|
||||||
settingsMenu.add(new EcuLoggerMenuItem("Log File Output Location...", new LogFileLocationAction(logger), VK_O, getKeyStroke(VK_O, CTRL_MASK)));
|
settingsMenu.add(new EcuLoggerMenuItem("Log File Output Location...", new LogFileLocationAction(logger), VK_O, getKeyStroke(VK_O, CTRL_MASK)));
|
||||||
settingsMenu.add(new JSeparator());
|
settingsMenu.add(new JSeparator());
|
||||||
settingsMenu.add(new EcuLoggerRadioButtonMenuItem("Control File Logging With Defogger Switch", VK_C, getKeyStroke(VK_C, CTRL_MASK), new LogFileControllerSwitchAction(logger), logger.getSettings().isFileLoggingControllerSwitchActive()));
|
settingsMenu.add(new EcuLoggerRadioButtonMenuItem("Control File Logging With Defogger Switch", VK_C, getKeyStroke(VK_C, CTRL_MASK), new LogFileControllerSwitchAction(logger), logger.getSettings().isFileLoggingControllerSwitchActive()));
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||||
|
* Copyright (C) 2006-2008 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 static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getDefinitionFileChooser;
|
||||||
|
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getFile;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import static javax.swing.JFileChooser.APPROVE_OPTION;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public final class LoggerDefinitionLocationAction extends AbstractAction {
|
||||||
|
|
||||||
|
public LoggerDefinitionLocationAction(EcuLogger logger) {
|
||||||
|
super(logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
|
try {
|
||||||
|
setDefinitionLocationDialog();
|
||||||
|
logger.loadLoggerParams();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.reportError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDefinitionLocationDialog() throws Exception {
|
||||||
|
File lastConfigPath = getFile(logger.getSettings().getLoggerDefinitionFilePath());
|
||||||
|
JFileChooser fc = getDefinitionFileChooser(lastConfigPath);
|
||||||
|
if (fc.showOpenDialog(logger) == APPROVE_OPTION) {
|
||||||
|
String path = fc.getSelectedFile().getAbsolutePath();
|
||||||
|
logger.getSettings().setLoggerDefinitionFilePath(path);
|
||||||
|
logger.reportMessage("Logger definition location successfully updated: " + path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,7 @@
|
||||||
package com.romraider.logger.ecu.ui.swing.menubar.util;
|
package com.romraider.logger.ecu.ui.swing.menubar.util;
|
||||||
|
|
||||||
import com.romraider.logger.ecu.profile.UserProfile;
|
import com.romraider.logger.ecu.profile.UserProfile;
|
||||||
|
import com.romraider.swing.GenericFileFilter;
|
||||||
import static com.romraider.util.ParamChecker.isNullOrEmpty;
|
import static com.romraider.util.ParamChecker.isNullOrEmpty;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import static javax.swing.JFileChooser.DIRECTORIES_ONLY;
|
import static javax.swing.JFileChooser.DIRECTORIES_ONLY;
|
||||||
|
@ -41,14 +42,11 @@ public final class FileHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JFileChooser getProfileFileChooser(File lastProfileFile) {
|
public static JFileChooser getProfileFileChooser(File lastProfileFile) {
|
||||||
JFileChooser fc;
|
return getFileChooser(lastProfileFile, "ECU Logger User Profiles", "xml");
|
||||||
if (lastProfileFile.exists() && lastProfileFile.isFile() && lastProfileFile.getParentFile() != null) {
|
}
|
||||||
fc = new JFileChooser(lastProfileFile.getParentFile().getAbsolutePath());
|
|
||||||
} else {
|
public static JFileChooser getDefinitionFileChooser(File lastDefFile) {
|
||||||
fc = new JFileChooser();
|
return getFileChooser(lastDefFile, "ECU Logger Definitions", "xml");
|
||||||
}
|
|
||||||
fc.setFileFilter(new UserProfileFileFilter());
|
|
||||||
return fc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String saveProfileToFile(UserProfile profile, File destinationFile) throws IOException {
|
public static String saveProfileToFile(UserProfile profile, File destinationFile) throws IOException {
|
||||||
|
@ -76,4 +74,17 @@ public final class FileHelper {
|
||||||
fc.setFileSelectionMode(DIRECTORIES_ONLY);
|
fc.setFileSelectionMode(DIRECTORIES_ONLY);
|
||||||
return fc;
|
return fc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static JFileChooser getFileChooser(File file, String description, String... extensions) {
|
||||||
|
JFileChooser fc = getFileChooser(file);
|
||||||
|
fc.setFileFilter(new GenericFileFilter(description, extensions));
|
||||||
|
return fc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JFileChooser getFileChooser(File file) {
|
||||||
|
if (file.exists() && file.isFile() && file.getParentFile() != null) {
|
||||||
|
return new JFileChooser(file.getParentFile().getAbsolutePath());
|
||||||
|
}
|
||||||
|
return new JFileChooser();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
|
||||||
* Copyright (C) 2006-2008 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.util;
|
|
||||||
|
|
||||||
import com.romraider.swing.GenericFileFilter;
|
|
||||||
import javax.swing.filechooser.FileFilter;
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public final class UserProfileFileFilter extends FileFilter {
|
|
||||||
private final FileFilter filter = new GenericFileFilter("ECU Logger User Profiles", "xml");
|
|
||||||
|
|
||||||
public boolean accept(File file) {
|
|
||||||
return filter.accept(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return filter.getDescription();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -260,6 +260,11 @@ public final class DOMSettingsBuilder {
|
||||||
tabs.setAttribute("selected", String.valueOf(settings.getLoggerSelectedTabIndex()));
|
tabs.setAttribute("selected", String.valueOf(settings.getLoggerSelectedTabIndex()));
|
||||||
loggerSettings.appendChild(tabs);
|
loggerSettings.appendChild(tabs);
|
||||||
|
|
||||||
|
// definition path
|
||||||
|
IIOMetadataNode definition = new IIOMetadataNode("definition");
|
||||||
|
definition.setAttribute("path", settings.getLoggerDefinitionFilePath());
|
||||||
|
loggerSettings.appendChild(definition);
|
||||||
|
|
||||||
// profile path
|
// profile path
|
||||||
IIOMetadataNode profile = new IIOMetadataNode("profile");
|
IIOMetadataNode profile = new IIOMetadataNode("profile");
|
||||||
profile.setAttribute("path", settings.getLoggerProfileFilePath());
|
profile.setAttribute("path", settings.getLoggerProfileFilePath());
|
||||||
|
|
|
@ -230,6 +230,9 @@ public final class DOMSettingsUnmarshaller {
|
||||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("tabs")) {
|
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("tabs")) {
|
||||||
settings.setLoggerSelectedTabIndex(unmarshallAttribute(n, "selected", 0));
|
settings.setLoggerSelectedTabIndex(unmarshallAttribute(n, "selected", 0));
|
||||||
|
|
||||||
|
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("definition")) {
|
||||||
|
settings.setLoggerDefinitionFilePath(unmarshallAttribute(n, "path", settings.getLoggerDefinitionFilePath()));
|
||||||
|
|
||||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("profile")) {
|
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("profile")) {
|
||||||
settings.setLoggerProfileFilePath(unmarshallAttribute(n, "path", ""));
|
settings.setLoggerProfileFilePath(unmarshallAttribute(n, "path", ""));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue