live data: use human readable settings names fix #909
This commit is contained in:
parent
de173e9325
commit
726734ef74
|
@ -3,6 +3,7 @@
|
||||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
||||||
<module name="ui" />
|
<module name="ui" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="auto" />
|
<option name="PROGRAM_PARAMETERS" value="auto" />
|
||||||
|
<option name="VM_PARAMETERS" value="-Dinput_files_path=../firmware/tunerstudio" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.ui.config;
|
||||||
|
|
||||||
import com.opensr5.io.IniFileReader;
|
import com.opensr5.io.IniFileReader;
|
||||||
import com.opensr5.io.RawIniFile;
|
import com.opensr5.io.RawIniFile;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -20,8 +21,10 @@ public class IniFileModel {
|
||||||
private final static IniFileModel INSTANCE = new IniFileModel();
|
private final static IniFileModel INSTANCE = new IniFileModel();
|
||||||
private String dialogId;
|
private String dialogId;
|
||||||
private String dialogUiName;
|
private String dialogUiName;
|
||||||
private List<DialogModel.Field> fields = new ArrayList<>();
|
|
||||||
private Map<String, DialogModel> dialogs = new TreeMap<>();
|
private Map<String, DialogModel> dialogs = new TreeMap<>();
|
||||||
|
private Map<String, DialogModel.Field> allFields = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
// this is only used while reading model - TODO extract reader
|
||||||
|
private List<DialogModel.Field> fieldsOfCurrentDialog = new ArrayList<>();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(IniFileModel.INSTANCE.dialogs);
|
System.out.println(IniFileModel.INSTANCE.dialogs);
|
||||||
|
@ -49,14 +52,14 @@ public class IniFileModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishDialog() {
|
private void finishDialog() {
|
||||||
if (fields.isEmpty())
|
if (fieldsOfCurrentDialog.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (dialogUiName == null)
|
if (dialogUiName == null)
|
||||||
dialogUiName = dialogId;
|
dialogUiName = dialogId;
|
||||||
dialogs.put(dialogUiName, new DialogModel(dialogId, dialogUiName, fields));
|
dialogs.put(dialogUiName, new DialogModel(dialogId, dialogUiName, fieldsOfCurrentDialog));
|
||||||
|
|
||||||
dialogId = null;
|
dialogId = null;
|
||||||
fields.clear();
|
fieldsOfCurrentDialog.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleLine(RawIniFile.Line line) {
|
private void handleLine(RawIniFile.Line line) {
|
||||||
|
@ -83,12 +86,23 @@ public class IniFileModel {
|
||||||
private void handleField(LinkedList<String> list) {
|
private void handleField(LinkedList<String> list) {
|
||||||
list.removeFirst(); // "field"
|
list.removeFirst(); // "field"
|
||||||
|
|
||||||
String uiLabel = list.isEmpty() ? "" : list.removeFirst();
|
String uiFieldName = list.isEmpty() ? "" : list.removeFirst();
|
||||||
|
|
||||||
String key = list.isEmpty() ? null : list.removeFirst();
|
String key = list.isEmpty() ? null : list.removeFirst();
|
||||||
|
|
||||||
fields.add(new DialogModel.Field(key, uiLabel));
|
DialogModel.Field field = new DialogModel.Field(key, uiFieldName);
|
||||||
System.out.println("IniFileModel: Field label=[" + uiLabel + "] : key=[" + key + "]");
|
if (key != null) {
|
||||||
|
// UI labels do not have 'key'
|
||||||
|
allFields.put(key, field);
|
||||||
|
}
|
||||||
|
fieldsOfCurrentDialog.add(field);
|
||||||
|
System.out.println("IniFileModel: Field label=[" + uiFieldName + "] : key=[" + key + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public DialogModel.Field getField(String key) {
|
||||||
|
DialogModel.Field field = allFields.get(key);
|
||||||
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDialog(LinkedList<String> list) {
|
private void handleDialog(LinkedList<String> list) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.rusefi.ui.livedocs;
|
package com.rusefi.ui.livedocs;
|
||||||
|
|
||||||
import com.opensr5.ConfigurationImage;
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.rusefi.FileLog;
|
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
import com.rusefi.config.Field;
|
import com.rusefi.config.Field;
|
||||||
import com.rusefi.config.generated.EngineState;
|
import com.rusefi.config.generated.EngineState;
|
||||||
|
@ -12,6 +11,8 @@ import com.rusefi.core.Sensor;
|
||||||
import com.rusefi.core.SensorCentral;
|
import com.rusefi.core.SensorCentral;
|
||||||
import com.rusefi.ldmp.*;
|
import com.rusefi.ldmp.*;
|
||||||
import com.rusefi.ldmp.generated.*;
|
import com.rusefi.ldmp.generated.*;
|
||||||
|
import com.rusefi.ui.config.DialogModel;
|
||||||
|
import com.rusefi.ui.config.IniFileModel;
|
||||||
import com.rusefi.ui.livedocs.controls.Toolbox;
|
import com.rusefi.ui.livedocs.controls.Toolbox;
|
||||||
import com.rusefi.ui.util.UiUtils;
|
import com.rusefi.ui.util.UiUtils;
|
||||||
import com.rusefi.ui.widgets.DetachedSensor;
|
import com.rusefi.ui.widgets.DetachedSensor;
|
||||||
|
@ -90,7 +91,7 @@ public class LiveDocPanel {
|
||||||
|
|
||||||
JLabel label = new JLabel("*");
|
JLabel label = new JLabel("*");
|
||||||
label.setIcon(UiUtils.loadIcon("livedocs/setting.png"));
|
label.setIcon(UiUtils.loadIcon("livedocs/setting.png"));
|
||||||
label.setToolTipText("Configuration " + field.getName());
|
label.setToolTipText(getTooltipText(field.getName()));
|
||||||
result.actionsList.add(new RefreshActions() {
|
result.actionsList.add(new RefreshActions() {
|
||||||
@Override
|
@Override
|
||||||
public void refresh(BinaryProtocol bp, byte[] response) {
|
public void refresh(BinaryProtocol bp, byte[] response) {
|
||||||
|
@ -137,6 +138,14 @@ public class LiveDocPanel {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getTooltipText(String configurationFieldName) {
|
||||||
|
DialogModel.Field dialogField = IniFileModel.getInstance().getField(configurationFieldName);
|
||||||
|
if (dialogField == null) {
|
||||||
|
return "Configuration " + configurationFieldName;
|
||||||
|
}
|
||||||
|
return "Configuration " + dialogField.getUiName() + " (" + configurationFieldName + ")";
|
||||||
|
}
|
||||||
|
|
||||||
private static ActionPanel createIfRequestPanel(IfRequest request, Field[] values) {
|
private static ActionPanel createIfRequestPanel(IfRequest request, Field[] values) {
|
||||||
|
|
||||||
Field conditionField = Field.findField(values, "", request.getVariable());
|
Field conditionField = Field.findField(values, "", request.getVariable());
|
||||||
|
|
Loading…
Reference in New Issue