refactoring: screen generator integration with ini files

This commit is contained in:
rusefi 2020-04-25 22:56:47 -04:00
parent c2645e390f
commit 8e21951fd4
15 changed files with 68 additions and 50 deletions

View File

@ -5,6 +5,7 @@
<module fileurl="file://$PROJECT_DIR$/autotest/autotest.iml" filepath="$PROJECT_DIR$/autotest/autotest.iml" />
<module fileurl="file://$PROJECT_DIR$/../java_tools/configuration_definition/configuration_definition.iml" filepath="$PROJECT_DIR$/../java_tools/configuration_definition/configuration_definition.iml" />
<module fileurl="file://$PROJECT_DIR$/../java_tools/enum_to_string/enum_to_string.iml" filepath="$PROJECT_DIR$/../java_tools/enum_to_string/enum_to_string.iml" />
<module fileurl="file://$PROJECT_DIR$/inifile/inifile.iml" filepath="$PROJECT_DIR$/inifile/inifile.iml" />
<module fileurl="file://$PROJECT_DIR$/io/io.iml" filepath="$PROJECT_DIR$/io/io.iml" />
<module fileurl="file://$PROJECT_DIR$/logging/logging.iml" filepath="$PROJECT_DIR$/logging/logging.iml" />
<module fileurl="file://$PROJECT_DIR$/models/models.iml" filepath="$PROJECT_DIR$/models/models.iml" />

View File

@ -1,22 +1,16 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="IniFileModel" type="Application" factoryName="Application" nameIsGenerated="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<option name="MAIN_CLASS_NAME" value="com.opensr5.ini.IniFileModel" />
<module name="ui" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.rusefi.ui.config.*" />
<option name="PATTERN" value="com.opensr5.ini.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="MAIN_CLASS_NAME" value="com.rusefi.ui.config.IniFileModel" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="ui" />
<envs />
<method />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@ -19,6 +19,7 @@
<src path="../java_tools/enum_to_string/src"/>
<src path="io/src"/>
<src path="models/src"/>
<src path="inifile/src"/>
<src path="ui/src"/>
<src path="romraider/src"/>
<src path="opensr5/src"/>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/annotations/18.0.0/annotations-18.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="junit" level="project" />
</component>
</module>

View File

@ -1,4 +1,4 @@
package com.rusefi.ui.config;
package com.opensr5.ini;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.opensr5.io;
package com.opensr5.ini;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,14 +1,10 @@
package com.rusefi.ui.config;
package com.opensr5.ini;
import com.opensr5.io.IniFileReader;
import com.opensr5.io.RawIniFile;
import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.util.*;
import static com.rusefi.Launcher.INI_FILE_PATH;
/**
* (c) Andrey Belomutskiy
* 12/23/2015.
@ -17,7 +13,7 @@ public class IniFileModel {
public static final String RUSEFI_INI_PREFIX = "rusefi";
public static final String RUSEFI_INI_SUFFIX = ".ini";
private final static IniFileModel INSTANCE = new IniFileModel();
private static IniFileModel INSTANCE;
private String dialogId;
private String dialogUiName;
private Map<String, DialogModel> dialogs = new TreeMap<>();
@ -26,15 +22,11 @@ public class IniFileModel {
private List<DialogModel.Field> fieldsOfCurrentDialog = new ArrayList<>();
public static void main(String[] args) {
System.out.println(IniFileModel.INSTANCE.dialogs);
System.out.println(IniFileModel.getInstance("..").dialogs);
}
private IniFileModel() {
readIniFile();
}
private void readIniFile() {
String fileName = findMetaInfoFile();
public void readIniFile(String iniFilePath) {
String fileName = findMetaInfoFile(iniFilePath);
File input = null;
if (fileName != null)
input = new File(fileName);
@ -53,13 +45,13 @@ public class IniFileModel {
finishDialog();
}
private String findMetaInfoFile() {
File dir = new File(INI_FILE_PATH);
private String findMetaInfoFile(String iniFilePath) {
File dir = new File(iniFilePath);
if (!dir.isDirectory())
return null;
for (String file : dir.list()) {
if (file.startsWith(RUSEFI_INI_PREFIX) && file.endsWith(RUSEFI_INI_SUFFIX))
return INI_FILE_PATH + File.separator + file;
return iniFilePath + File.separator + file;
}
return null;
}
@ -143,8 +135,11 @@ public class IniFileModel {
DIALOG
}
public static IniFileModel getInstance() {
public static synchronized IniFileModel getInstance(String iniFilePath) {
if (INSTANCE == null) {
INSTANCE = new IniFileModel();
INSTANCE.readIniFile(iniFilePath);
}
return INSTANCE;
}

View File

@ -1,4 +1,4 @@
package com.opensr5.io;
package com.opensr5.ini;
import java.io.*;
import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package com.opensr5.io;
package com.opensr5.ini;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@ -1,8 +1,8 @@
package com.opensr5.io.test;
package com.opensr5.ini.test;
import com.opensr5.io.IniFileMetaInfo;
import com.opensr5.io.IniFileReader;
import com.opensr5.io.RawIniFile;
import com.opensr5.ini.IniFileMetaInfo;
import com.opensr5.ini.IniFileReader;
import com.opensr5.ini.RawIniFile;
import org.junit.Test;
import java.io.ByteArrayInputStream;

View File

@ -10,5 +10,6 @@
<orderEntry type="library" name="annotations" level="project" />
<orderEntry type="library" name="jssc" level="project" />
<orderEntry type="library" name="junit" level="project" />
<orderEntry type="module" module-name="inifile" />
</component>
</module>

View File

@ -1,8 +1,8 @@
package com.opensr5;
import com.opensr5.io.IniFileMetaInfo;
import com.opensr5.io.IniFileReader;
import com.opensr5.io.RawIniFile;
import com.opensr5.ini.IniFileMetaInfo;
import com.opensr5.ini.IniFileReader;
import com.opensr5.ini.RawIniFile;
import java.io.File;

View File

@ -1,5 +1,8 @@
package com.rusefi.ui;
import com.opensr5.ini.DialogModel;
import com.opensr5.ini.IniFileModel;
import com.rusefi.Launcher;
import com.rusefi.config.Field;
import com.rusefi.config.FieldType;
import com.rusefi.config.FieldsMap;
@ -15,8 +18,8 @@ import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.rusefi.ui.config.IniFileModel.RUSEFI_INI_PREFIX;
import static com.rusefi.ui.config.IniFileModel.RUSEFI_INI_SUFFIX;
import static com.opensr5.ini.IniFileModel.RUSEFI_INI_PREFIX;
import static com.opensr5.ini.IniFileModel.RUSEFI_INI_SUFFIX;
/**
* @see EnumConfigField
@ -36,7 +39,7 @@ public class SettingsTab {
}
public void showContent() {
final Map<String, DialogModel> dialogs = IniFileModel.getInstance().getDialogs();
final Map<String, DialogModel> dialogs = IniFileModel.getInstance(Launcher.INI_FILE_PATH).getDialogs();
if (dialogs.isEmpty()) {
content.removeAll();
content.add(new JLabel("Meta data not found: " + RUSEFI_INI_PREFIX + "*" + RUSEFI_INI_SUFFIX));
@ -128,7 +131,7 @@ public class SettingsTab {
dialog.setText(name);
dialogBody.removeAll();
DialogModel m = IniFileModel.getInstance().getDialogs().get(name);
DialogModel m = IniFileModel.getInstance(Launcher.INI_FILE_PATH).getDialogs().get(name);
dialogBody.setLayout(new GridLayout(m.getFields().size(), 1));

View File

@ -1,6 +1,7 @@
package com.rusefi.ui.livedocs;
import com.opensr5.ConfigurationImage;
import com.rusefi.Launcher;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.Field;
import com.rusefi.config.generated.Fields;
@ -8,8 +9,8 @@ import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import com.rusefi.ldmp.*;
import com.rusefi.ldmp.generated.*;
import com.rusefi.ui.config.DialogModel;
import com.rusefi.ui.config.IniFileModel;
import com.opensr5.ini.DialogModel;
import com.opensr5.ini.IniFileModel;
import com.rusefi.ui.livedocs.controls.Toolbox;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.DetachedSensor;
@ -162,7 +163,7 @@ public class LiveDocPanel {
}
private static String getTooltipText(String configurationFieldName) {
DialogModel.Field dialogField = IniFileModel.getInstance().getField(configurationFieldName);
DialogModel.Field dialogField = IniFileModel.getInstance(Launcher.INI_FILE_PATH).getField(configurationFieldName);
if (dialogField == null) {
return "Configuration " + configurationFieldName;
}

View File

@ -21,5 +21,6 @@
<orderEntry type="module" module-name="romraider" />
<orderEntry type="library" name="jlatexmath" level="project" />
<orderEntry type="module" module-name="configuration_definition" />
<orderEntry type="module" module-name="inifile" />
</component>
</module>