auto-sync

This commit is contained in:
rusEfi 2016-01-19 23:02:48 -05:00
parent 17ac7d6c77
commit 0f8d0c47c5
2 changed files with 33 additions and 9 deletions

View File

@ -8,11 +8,26 @@ import java.util.List;
* 1/17/2016. * 1/17/2016.
*/ */
public class DialogModel { public class DialogModel {
private final String name; private final String key;
private final String uiName;
private final List<String> fields; private final List<String> fields;
public DialogModel(String name, List<String> fields) { public DialogModel(String key, String uiName, List<String> fields) {
this.name = name; this.key = key;
this.uiName = uiName;
this.fields = new ArrayList<>(fields); this.fields = new ArrayList<>(fields);
} }
public List<String> getFields() {
return fields;
}
@Override
public String toString() {
return "DialogModel{" +
"key='" + key + '\'' +
", uiName='" + uiName + '\'' +
", fields=" + fields.size() +
'}';
}
} }

View File

@ -12,12 +12,13 @@ public class IniFileModel {
private static final String FILENAME = "rusefi.ini"; private static final String FILENAME = "rusefi.ini";
private final static IniFileModel INSTANCE = new IniFileModel(); private final static IniFileModel INSTANCE = new IniFileModel();
private String dialogName; private String dialogId;
private String dialogUiName;
private List<String> fields = new ArrayList<>(); private List<String> fields = new ArrayList<>();
private List<DialogModel> dialogs = new ArrayList<>(); private Map<String, DialogModel> dialogs = new TreeMap<>();
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(IniFileModel.INSTANCE); System.out.println(IniFileModel.INSTANCE.dialogs);
} }
private IniFileModel() { private IniFileModel() {
@ -54,9 +55,9 @@ public class IniFileModel {
private void finishDialog() { private void finishDialog() {
if (fields.isEmpty()) if (fields.isEmpty())
return; return;
dialogs.add(new DialogModel(dialogName, fields)); dialogs.put(dialogUiName, new DialogModel(dialogId, dialogUiName, fields));
dialogName = null; dialogId = null;
fields.clear(); fields.clear();
} }
@ -102,7 +103,8 @@ public class IniFileModel {
// trim(list); // trim(list);
String name = list.isEmpty() ? null : list.removeFirst(); String name = list.isEmpty() ? null : list.removeFirst();
dialogName = keyword; dialogId = keyword;
dialogUiName = name;
System.out.println("Dialog key=" + keyword + ": name=[" + name + "]"); System.out.println("Dialog key=" + keyword + ": name=[" + name + "]");
} }
@ -142,4 +144,11 @@ public class IniFileModel {
return c == ' ' || c == '\t' || c == '=' || c == ','; return c == ' ' || c == '\t' || c == '=' || c == ',';
} }
public static IniFileModel getinstance() {
return INSTANCE;
}
public Map<String, DialogModel> getDialogs() {
return dialogs;
}
} }