mirror of https://github.com/rusefi/RomRaider.git
Warnings load from user profile.
Warning set by clicking on gauge face instead of inputting directly into a form on the gauge face. TODO: Transmit warning settings back to user profile when saving. git-svn-id: https://svn2.assembla.com/svn/romraider/branches/thegris@134 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
parent
993ed52228
commit
0e44b763d1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,57 @@
|
|||
package com.romraider.logger.ecu.definition;
|
||||
|
||||
import com.romraider.logger.ecu.definition.EcuParameterWarningType;
|
||||
|
||||
public class EcuParameterWarning {
|
||||
private EcuParameterWarningType warningType;
|
||||
private double warningValue;
|
||||
private boolean audible;
|
||||
private boolean visible;
|
||||
|
||||
public EcuParameterWarning() {
|
||||
warningType = EcuParameterWarningType.WARN_NONE;
|
||||
warningValue = 0.0;
|
||||
audible = false;
|
||||
visible = false;
|
||||
}
|
||||
|
||||
public EcuParameterWarning(EcuParameterWarningType warningType, double warningValue, boolean audible, boolean visible) {
|
||||
this.warningType = warningType;
|
||||
this.warningValue = warningValue;
|
||||
this.audible = audible;
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public EcuParameterWarningType getWarningType() {
|
||||
return warningType;
|
||||
}
|
||||
|
||||
public void setWarningType(EcuParameterWarningType warningType) {
|
||||
this.warningType = warningType;
|
||||
}
|
||||
|
||||
public double getWarningValue() {
|
||||
return warningValue;
|
||||
}
|
||||
|
||||
public void setWarningValue(double warningValue) {
|
||||
this.warningValue = warningValue;
|
||||
}
|
||||
|
||||
public boolean isAudible() {
|
||||
return audible;
|
||||
}
|
||||
|
||||
public void setAudible(boolean audible) {
|
||||
this.audible = audible;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.romraider.logger.ecu.definition;
|
||||
|
||||
public enum EcuParameterWarningType {
|
||||
WARN_NONE,
|
||||
WARN_ABOVE,
|
||||
WARN_BELOW
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.romraider.swing;
|
||||
|
||||
import com.romraider.logger.ecu.definition.EcuParameterWarning;
|
||||
import com.romraider.logger.ecu.definition.EcuParameterWarningType;
|
||||
|
||||
import javax.swing.JDialog;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class GaugeWarningSettingsDialog extends JDialog implements ActionListener {
|
||||
|
||||
EcuParameterWarning warningSettings;
|
||||
|
||||
private static final String IGNORE = "ignore warnings";
|
||||
private static final String ABOVE = "warn above";
|
||||
private static final String BELOW = "warn below";
|
||||
private static final String OK = "OK";
|
||||
private static final String CANCEL = "Cancel";
|
||||
|
||||
private javax.swing.JButton btnCancel;
|
||||
private javax.swing.JButton btnOk;
|
||||
private javax.swing.JTextField warningValue;
|
||||
private javax.swing.JComboBox warningType;
|
||||
|
||||
public GaugeWarningSettingsDialog(EcuParameterWarning warningSettings) {
|
||||
this.warningSettings = warningSettings;
|
||||
|
||||
setTitle("Warning Settings");
|
||||
setSize(300, 75);
|
||||
|
||||
btnCancel = new javax.swing.JButton();
|
||||
btnOk = new javax.swing.JButton();
|
||||
if(warningSettings != null)
|
||||
{
|
||||
warningValue = new javax.swing.JTextField(String.valueOf(warningSettings.getWarningValue()));
|
||||
}
|
||||
else
|
||||
{
|
||||
warningValue = new javax.swing.JTextField("0.0");
|
||||
}
|
||||
warningType = new javax.swing.JComboBox(new Object[]{IGNORE, ABOVE, BELOW});
|
||||
|
||||
warningValue.setSize(new Dimension(40, 40));
|
||||
if(warningSettings != null)
|
||||
{
|
||||
if(warningSettings.getWarningType() == EcuParameterWarningType.WARN_NONE){
|
||||
warningType.setSelectedItem(IGNORE);
|
||||
}else if(warningSettings.getWarningType() == EcuParameterWarningType.WARN_ABOVE){
|
||||
warningType.setSelectedItem(ABOVE);
|
||||
}else if(warningSettings.getWarningType() == EcuParameterWarningType.WARN_BELOW) {
|
||||
warningType.setSelectedItem(BELOW);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
warningSettings = new EcuParameterWarning();
|
||||
warningType.setSelectedItem(IGNORE);
|
||||
}
|
||||
|
||||
btnCancel.setMnemonic('C');
|
||||
btnCancel.setText("Cancel");
|
||||
btnCancel.addActionListener(this);
|
||||
|
||||
btnOk.setMnemonic('O');
|
||||
btnOk.setText("OK");
|
||||
btnOk.addActionListener(this);
|
||||
|
||||
getContentPane().setLayout(new FlowLayout());
|
||||
|
||||
add(warningType);
|
||||
add(warningValue);
|
||||
add(btnOk);
|
||||
add(btnCancel);
|
||||
}
|
||||
|
||||
public EcuParameterWarning getWarningSettings() {
|
||||
return warningSettings;
|
||||
}
|
||||
|
||||
public void saveSettings() {
|
||||
if(warningSettings == null){
|
||||
warningSettings = new EcuParameterWarning();
|
||||
}
|
||||
|
||||
if(warningType.getSelectedItem() == IGNORE){
|
||||
warningSettings.setWarningType(EcuParameterWarningType.WARN_NONE);
|
||||
}else if(warningType.getSelectedItem() == ABOVE){
|
||||
warningSettings.setWarningType(EcuParameterWarningType.WARN_ABOVE);
|
||||
}else if(warningType.getSelectedItem() == BELOW) {
|
||||
warningSettings.setWarningType(EcuParameterWarningType.WARN_BELOW);
|
||||
}
|
||||
|
||||
warningSettings.setWarningValue(Double.valueOf(warningValue.getText()));
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(e.getActionCommand() == OK)
|
||||
{
|
||||
saveSettings();
|
||||
setVisible(false);
|
||||
}
|
||||
else if(e.getActionCommand() == CANCEL)
|
||||
{
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue