diff --git a/java_console/.idea/modules.xml b/java_console/.idea/modules.xml index 0ee521d085..d870adaa1b 100644 --- a/java_console/.idea/modules.xml +++ b/java_console/.idea/modules.xml @@ -5,6 +5,7 @@ + diff --git a/java_console/.idea/runConfigurations/IniFileModel.xml b/java_console/.idea/runConfigurations/IniFileModel.xml index 975077309a..ab35129570 100644 --- a/java_console/.idea/runConfigurations/IniFileModel.xml +++ b/java_console/.idea/runConfigurations/IniFileModel.xml @@ -1,22 +1,16 @@ - + \ No newline at end of file diff --git a/java_console/build.xml b/java_console/build.xml index 56d015cf44..56134288eb 100644 --- a/java_console/build.xml +++ b/java_console/build.xml @@ -19,6 +19,7 @@ + diff --git a/java_console/inifile/inifile.iml b/java_console/inifile/inifile.iml new file mode 100644 index 0000000000..aaf201b070 --- /dev/null +++ b/java_console/inifile/inifile.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java_console/ui/src/com/rusefi/ui/config/DialogModel.java b/java_console/inifile/src/com/opensr5/ini/DialogModel.java similarity index 97% rename from java_console/ui/src/com/rusefi/ui/config/DialogModel.java rename to java_console/inifile/src/com/opensr5/ini/DialogModel.java index d7ffad0a76..a3c1ef7b2f 100644 --- a/java_console/ui/src/com/rusefi/ui/config/DialogModel.java +++ b/java_console/inifile/src/com/opensr5/ini/DialogModel.java @@ -1,4 +1,4 @@ -package com.rusefi.ui.config; +package com.opensr5.ini; import java.util.ArrayList; import java.util.List; diff --git a/java_console/opensr5/src/com/opensr5/io/IniFileMetaInfo.java b/java_console/inifile/src/com/opensr5/ini/IniFileMetaInfo.java similarity index 98% rename from java_console/opensr5/src/com/opensr5/io/IniFileMetaInfo.java rename to java_console/inifile/src/com/opensr5/ini/IniFileMetaInfo.java index e5fc0ba611..943a55491c 100644 --- a/java_console/opensr5/src/com/opensr5/io/IniFileMetaInfo.java +++ b/java_console/inifile/src/com/opensr5/ini/IniFileMetaInfo.java @@ -1,4 +1,4 @@ -package com.opensr5.io; +package com.opensr5.ini; import java.util.ArrayList; import java.util.List; diff --git a/java_console/ui/src/com/rusefi/ui/config/IniFileModel.java b/java_console/inifile/src/com/opensr5/ini/IniFileModel.java similarity index 86% rename from java_console/ui/src/com/rusefi/ui/config/IniFileModel.java rename to java_console/inifile/src/com/opensr5/ini/IniFileModel.java index 31c253556a..75f3e8fdcc 100644 --- a/java_console/ui/src/com/rusefi/ui/config/IniFileModel.java +++ b/java_console/inifile/src/com/opensr5/ini/IniFileModel.java @@ -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 dialogs = new TreeMap<>(); @@ -26,15 +22,11 @@ public class IniFileModel { private List 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; } diff --git a/java_console/opensr5/src/com/opensr5/io/IniFileReader.java b/java_console/inifile/src/com/opensr5/ini/IniFileReader.java similarity index 98% rename from java_console/opensr5/src/com/opensr5/io/IniFileReader.java rename to java_console/inifile/src/com/opensr5/ini/IniFileReader.java index 45d8417edf..fc74ff070a 100644 --- a/java_console/opensr5/src/com/opensr5/io/IniFileReader.java +++ b/java_console/inifile/src/com/opensr5/ini/IniFileReader.java @@ -1,4 +1,4 @@ -package com.opensr5.io; +package com.opensr5.ini; import java.io.*; import java.util.ArrayList; diff --git a/java_console/opensr5/src/com/opensr5/io/RawIniFile.java b/java_console/inifile/src/com/opensr5/ini/RawIniFile.java similarity index 98% rename from java_console/opensr5/src/com/opensr5/io/RawIniFile.java rename to java_console/inifile/src/com/opensr5/ini/RawIniFile.java index 2d2a52b103..03e60ab87d 100644 --- a/java_console/opensr5/src/com/opensr5/io/RawIniFile.java +++ b/java_console/inifile/src/com/opensr5/ini/RawIniFile.java @@ -1,4 +1,4 @@ -package com.opensr5.io; +package com.opensr5.ini; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/java_console/opensr5/src/com/opensr5/io/test/IniFileReaderTest.java b/java_console/inifile/src/com/opensr5/ini/test/IniFileReaderTest.java similarity index 94% rename from java_console/opensr5/src/com/opensr5/io/test/IniFileReaderTest.java rename to java_console/inifile/src/com/opensr5/ini/test/IniFileReaderTest.java index b836cab735..ff00949964 100644 --- a/java_console/opensr5/src/com/opensr5/io/test/IniFileReaderTest.java +++ b/java_console/inifile/src/com/opensr5/ini/test/IniFileReaderTest.java @@ -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; diff --git a/java_console/opensr5/opensr5.iml b/java_console/opensr5/opensr5.iml index a797b96e7c..4dc12e2190 100644 --- a/java_console/opensr5/opensr5.iml +++ b/java_console/opensr5/opensr5.iml @@ -10,5 +10,6 @@ + \ No newline at end of file diff --git a/java_console/opensr5/src/com/opensr5/Main.java b/java_console/opensr5/src/com/opensr5/Main.java index 0886be4fcf..9236fdc104 100644 --- a/java_console/opensr5/src/com/opensr5/Main.java +++ b/java_console/opensr5/src/com/opensr5/Main.java @@ -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; diff --git a/java_console/ui/src/com/rusefi/ui/SettingsTab.java b/java_console/ui/src/com/rusefi/ui/SettingsTab.java index 807e30bbe7..48d4a1cbf1 100644 --- a/java_console/ui/src/com/rusefi/ui/SettingsTab.java +++ b/java_console/ui/src/com/rusefi/ui/SettingsTab.java @@ -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 dialogs = IniFileModel.getInstance().getDialogs(); + final Map 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)); diff --git a/java_console/ui/src/com/rusefi/ui/livedocs/LiveDocPanel.java b/java_console/ui/src/com/rusefi/ui/livedocs/LiveDocPanel.java index 8bc1fe56d1..977394929e 100644 --- a/java_console/ui/src/com/rusefi/ui/livedocs/LiveDocPanel.java +++ b/java_console/ui/src/com/rusefi/ui/livedocs/LiveDocPanel.java @@ -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; } diff --git a/java_console/ui/ui.iml b/java_console/ui/ui.iml index 91616b7195..1244b95131 100644 --- a/java_console/ui/ui.iml +++ b/java_console/ui/ui.iml @@ -21,5 +21,6 @@ + \ No newline at end of file