diff --git a/java_tools/ts_screenshots/screen/src/com/rusefi/MdGenerator.java b/java_tools/ts_screenshots/screen/src/com/rusefi/MdGenerator.java new file mode 100644 index 0000000000..407020d7fd --- /dev/null +++ b/java_tools/ts_screenshots/screen/src/com/rusefi/MdGenerator.java @@ -0,0 +1,60 @@ +package com.rusefi; + +import com.rusefi.xml.*; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.Date; + +public class MdGenerator { + static String FOLDER; + + private static final String EOL = "\r\n"; + + public static void main(String[] args) throws Exception { +// FOLDER = "images/"; + FOLDER = "overview/TS_generated/"; + + ContentModel contentModel = XmlUtil.readModel(); + + FileWriter md = new FileWriter("rusEFI_project.md"); + + for (TopLevelMenuModel topLevelMenuModel : contentModel.getTopLevelMenus()) { + md.append("# " + topLevelMenuModel.getTitle() + EOL); + md.append(getImageTag(topLevelMenuModel.getImageName())); + md.append(EOL); + } + + for (TopLevelMenuModel topLevelMenuModel : contentModel.getTopLevelMenus()) { + + md.append("# " + topLevelMenuModel.getTitle() + EOL); + + for (DialogModel dialogModel : topLevelMenuModel.getDialogs()) { + appendDialog(md, dialogModel); + } + } + + md.write(EOL); + md.write("generated by " + MdGenerator.class + " on " + new Date()); + md.write(EOL); + md.close(); + } + + private static void appendDialog(FileWriter md, DialogModel dialogModel) throws IOException { + md.append(getImageTag(dialogModel.getImageName())); + for (FieldModel fieldModel : dialogModel.fields) { + String tooltip = fieldModel.getTooltip(); + + if (tooltip.length() > 0) { + md.append(fieldModel.getUiName() + ": " + tooltip + EOL + EOL); + } + } + } + + private static String getImageTag(String imageName) { + String IMG_SUFFIX = ")" + EOL; + String IMG_PREFIX = "![x]("; + + return IMG_PREFIX + FOLDER + imageName + IMG_SUFFIX; + } +} diff --git a/java_tools/ts_screenshots/screen/src/com/rusefi/ScreenGenerator.java b/java_tools/ts_screenshots/screen/src/com/rusefi/ScreenGenerator.java index 79144c82a3..42f7a11d05 100644 --- a/java_tools/ts_screenshots/screen/src/com/rusefi/ScreenGenerator.java +++ b/java_tools/ts_screenshots/screen/src/com/rusefi/ScreenGenerator.java @@ -57,6 +57,8 @@ public class ScreenGenerator { System.out.println("Done discovering buttons, " + topLevelButtons.size()); + Thread.sleep(2 * WAITING_FOR_FRAME_PERIOD); // we have this sleep to avoid an artifact on first screenshot + handleTopLevelButtons(mainFrame, topLevelButtons); XmlUtil.writeXml(contentModel); diff --git a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/ContentModel.java b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/ContentModel.java index b6dd923368..b5da19e66c 100644 --- a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/ContentModel.java +++ b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/ContentModel.java @@ -24,4 +24,11 @@ public class ContentModel { public String getVersion() { return "Generated by " + ScreenGenerator.class + " on " + new Date(); } + + @Override + public String toString() { + return "ContentModel{" + + "menus=" + menus + + '}'; + } } diff --git a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/DialogModel.java b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/DialogModel.java index 060c9196f1..e0f5e8abc3 100644 --- a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/DialogModel.java +++ b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/DialogModel.java @@ -7,12 +7,15 @@ import java.util.ArrayList; import java.util.List; public class DialogModel { - private final String dialogTitle; - private final String imageName; + private String dialogTitle; + private String imageName; @XmlElementWrapper @XmlElement(name = "field") public List fields = new ArrayList<>(); + public DialogModel() { + } + public DialogModel(String dialogTitle, String imageName) { this.dialogTitle = dialogTitle; this.imageName = imageName; @@ -23,8 +26,25 @@ public class DialogModel { return imageName; } + public void setImageName(String imageName) { + this.imageName = imageName; + } + @XmlAttribute public String getDialogTitle() { return dialogTitle; } + + public void setDialogTitle(String dialogTitle) { + this.dialogTitle = dialogTitle; + } + + @Override + public String toString() { + return "DialogModel{" + + "dialogTitle='" + dialogTitle + '\'' + + ", imageName='" + imageName + '\'' + + ", fields=" + fields + + '}'; + } } diff --git a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/FieldModel.java b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/FieldModel.java index abdd1aa81f..66d2d3cd3f 100644 --- a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/FieldModel.java +++ b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/FieldModel.java @@ -4,10 +4,13 @@ import javax.xml.bind.annotation.XmlAttribute; public class FieldModel { - private final String uiName; - private final String fieldName; - private final String imageName; - private final String tooltip; + private String uiName; + private String fieldName; + private String imageName; + private String tooltip; + + public FieldModel() { + } public FieldModel(String uiName, String fieldName, String fileName, String tooltip) { this.uiName = uiName; @@ -21,18 +24,44 @@ public class FieldModel { return uiName; } + public void setUiName(String uiName) { + this.uiName = uiName; + } + @XmlAttribute public String getFieldName() { return fieldName; } + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + @XmlAttribute public String getImageName() { return imageName; } + public void setImageName(String imageName) { + this.imageName = imageName; + } + @XmlAttribute public String getTooltip() { return tooltip; } + + public void setTooltip(String tooltip) { + this.tooltip = tooltip; + } + + @Override + public String toString() { + return "FieldModel{" + + "uiName='" + uiName + '\'' + + ", fieldName='" + fieldName + '\'' + + ", imageName='" + imageName + '\'' + + ", tooltip='" + tooltip + '\'' + + '}'; + } } diff --git a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/TopLevelMenuModel.java b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/TopLevelMenuModel.java index b0752e9107..13fc95a221 100644 --- a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/TopLevelMenuModel.java +++ b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/TopLevelMenuModel.java @@ -7,13 +7,16 @@ import java.util.ArrayList; import java.util.List; public class TopLevelMenuModel { - private final String title; - private final String imageName; + private String title; + private String imageName; @XmlElementWrapper @XmlElement(name = "dialog") private List dialogs = new ArrayList<>(); + public TopLevelMenuModel() { + } + public TopLevelMenuModel(String title, String imageName) { this.title = title; this.imageName = imageName; @@ -24,12 +27,29 @@ public class TopLevelMenuModel { return title; } + public void setTitle(String title) { + this.title = title; + } + @XmlAttribute public String getImageName() { return imageName; } + public void setImageName(String imageName) { + this.imageName = imageName; + } + public List getDialogs() { return dialogs; } + + @Override + public String toString() { + return "TopLevelMenuModel{" + + "title='" + title + '\'' + + ", imageName='" + imageName + '\'' + + ", dialogs=" + dialogs + + '}'; + } } diff --git a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/XmlUtil.java b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/XmlUtil.java index 54931894d0..7b0dfd7dab 100644 --- a/java_tools/ts_screenshots/screen/src/com/rusefi/xml/XmlUtil.java +++ b/java_tools/ts_screenshots/screen/src/com/rusefi/xml/XmlUtil.java @@ -3,6 +3,8 @@ package com.rusefi.xml; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.StringWriter; @@ -24,4 +26,12 @@ public class XmlUtil { marshaller.marshal(contentModel, new FileWriter(FILE_NAME)); System.out.println("Done " + FILE_NAME); } + + public static ContentModel readModel() throws Exception { + File xmlFile = new File(FILE_NAME); + JAXBContext jaxbContext; + jaxbContext = JAXBContext.newInstance(ContentModel.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); + return (ContentModel) jaxbUnmarshaller.unmarshal(xmlFile); + } }