diff --git a/java_console/inifile/inifile.iml b/java_console/inifile/inifile.iml
index aaf201b070..a91a847c47 100644
--- a/java_console/inifile/inifile.iml
+++ b/java_console/inifile/inifile.iml
@@ -17,5 +17,15 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/java_tools/ts_screenshots/.idea/modules.xml b/java_tools/ts_screenshots/.idea/modules.xml
index 6692425d9b..6b7c1a6d04 100644
--- a/java_tools/ts_screenshots/.idea/modules.xml
+++ b/java_tools/ts_screenshots/.idea/modules.xml
@@ -2,6 +2,7 @@
+
diff --git a/java_tools/ts_screenshots/screen/screen.iml b/java_tools/ts_screenshots/screen/screen.iml
index 31e3a4c653..348f236b51 100644
--- a/java_tools/ts_screenshots/screen/screen.iml
+++ b/java_tools/ts_screenshots/screen/screen.iml
@@ -10,5 +10,6 @@
+
\ No newline at end of file
diff --git a/java_tools/ts_screenshots/screen/src/ScreenCaptureLauncher.java b/java_tools/ts_screenshots/screen/src/ScreenCaptureLauncher.java
new file mode 100644
index 0000000000..39f13c0e74
--- /dev/null
+++ b/java_tools/ts_screenshots/screen/src/ScreenCaptureLauncher.java
@@ -0,0 +1,23 @@
+import com.rusefi.ScreenGenerator;
+
+public class ScreenCaptureLauncher {
+ public static void main(String[] args) throws Exception {
+ startTunerStudio(args);
+ ScreenGenerator.main(args);
+ }
+
+ private static void startTunerStudio(String[] args) {
+ Thread t = new Thread(() -> {
+ try {
+ TunerStudio.main(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new IllegalStateException(e);
+ }
+ });
+
+ t.setDaemon(false);
+ t.start();
+ }
+
+}
diff --git a/java_tools/ts_screenshots/screen/src/com/rusefi/Content.java b/java_tools/ts_screenshots/screen/src/com/rusefi/Content.java
new file mode 100644
index 0000000000..6c36282a36
--- /dev/null
+++ b/java_tools/ts_screenshots/screen/src/com/rusefi/Content.java
@@ -0,0 +1,18 @@
+package com.rusefi;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlRootElement
+public class Content {
+ private List menus = new ArrayList<>();
+
+ @XmlElementWrapper
+ @XmlElement(name = "keyword")
+ public List getTopLevelMenus() {
+ return menus;
+ }
+}
diff --git a/java_tools/ts_screenshots/screen/src/ScreenGenerator.java b/java_tools/ts_screenshots/screen/src/com/rusefi/ScreenGenerator.java
similarity index 88%
rename from java_tools/ts_screenshots/screen/src/ScreenGenerator.java
rename to java_tools/ts_screenshots/screen/src/com/rusefi/ScreenGenerator.java
index aae945b09b..455fe38b84 100644
--- a/java_tools/ts_screenshots/screen/src/ScreenGenerator.java
+++ b/java_tools/ts_screenshots/screen/src/com/rusefi/ScreenGenerator.java
@@ -1,13 +1,18 @@
+package com.rusefi;
+
+import com.opensr5.ini.IniFileModel;
import javax.imageio.ImageIO;
import javax.swing.*;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.RasterFormatException;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
+import java.io.*;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.*;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@@ -21,15 +26,14 @@ public class ScreenGenerator {
private static final String DESTINATION = "images" + File.separator;
- public static void main(String[] args) throws InterruptedException, InvocationTargetException, IOException, AWTException {
+ static Content content = new Content();
+
+ public static void main(String[] args) throws Exception {
+ IniFileModel iniFileModel = new IniFileModel();
+ iniFileModel.readIniFile("../../firmware/tunerstudio");
+
new File(DESTINATION).mkdirs();
- Thread t = new Thread(() -> TunerStudio.main(args));
-
- t.setDaemon(false);
- t.start();
-
-
Frame mainFrame = findMainFrame();
while (topLevelButtons.isEmpty()) {
@@ -48,9 +52,22 @@ public class ScreenGenerator {
System.out.println("Done discovering buttons, " + topLevelButtons.size());
- doJob(mainFrame);
+ handleTopLevelButtons(mainFrame, topLevelButtons);
}
+ private static void writeXml(Content content) throws JAXBException, IOException {
+ JAXBContext jaxbContext = JAXBContext.newInstance(Content.class);
+
+ Marshaller marshaller = jaxbContext.createMarshaller();
+
+ StringWriter xmlWriter = new StringWriter();
+ marshaller.marshal(content, xmlWriter);
+ System.out.println(xmlWriter.toString());
+
+ marshaller.marshal(content, new FileWriter("output.xml"));
+ }
+
+
private static Frame findMainFrame() throws InterruptedException {
while (true) {
Frame[] all = JFrame.getFrames();
@@ -108,19 +125,23 @@ public class ScreenGenerator {
return component instanceof bi.b;
}
- private static void doJob(Frame frame) throws InterruptedException, InvocationTargetException, IOException, AWTException {
+ private static void handleTopLevelButtons(Frame frame, ArrayList topLevelButtons) throws Exception {
printAllDialogs("Dialogs before clicking ", JDialog.getWindows());
-
for (AbstractButton topLevel : topLevelButtons) {
handleTopLevelButton(frame, topLevel);
}
}
- private static void handleTopLevelButton(Frame frame, AbstractButton topLevel) throws InterruptedException, InvocationTargetException, IOException {
+ private static void handleTopLevelButton(Frame frame, AbstractButton topLevel) throws Exception {
SwingUtilities.invokeAndWait(topLevel::doClick);
Thread.sleep(TOP_MENU_CLICK_DELAY);
+ content.getTopLevelMenus().add(new TopLevelMenu(topLevel.getText()));
+
+ writeXml(content);
+
+
ImageIO.write(
getScreenShot(frame),
"png",
@@ -134,20 +155,13 @@ public class ScreenGenerator {
}
private static void handleMenuItem(JMenuItem menuItem) throws InterruptedException, InvocationTargetException {
- SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- menuItem.doClick();
- }
- });
+ SwingUtilities.invokeAndWait(menuItem::doClick);
Thread.sleep(MENU_CLICK_DELAY);
AtomicReference ref = new AtomicReference<>();
- SwingUtilities.invokeAndWait(() -> {
- ref.set(findDynamicDialog());
- });
+ SwingUtilities.invokeAndWait(() -> ref.set(findDynamicDialog()));
// let's give it time to appear on the screen
Thread.sleep(MENU_CLICK_DELAY);
JDialog dialog = ref.get();
diff --git a/java_tools/ts_screenshots/screen/src/com/rusefi/TopLevelMenu.java b/java_tools/ts_screenshots/screen/src/com/rusefi/TopLevelMenu.java
new file mode 100644
index 0000000000..1e3b79bf27
--- /dev/null
+++ b/java_tools/ts_screenshots/screen/src/com/rusefi/TopLevelMenu.java
@@ -0,0 +1,30 @@
+package com.rusefi;
+
+import com.opensr5.ini.DialogModel;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TopLevelMenu {
+ private final String title;
+
+ @XmlElementWrapper
+ @XmlElement(name = "dialog")
+ private List dialogs = new ArrayList<>();
+
+ public TopLevelMenu(String title) {
+ this.title = title;
+ }
+
+ @XmlAttribute
+ public String getTitle() {
+ return title;
+ }
+
+ public List getDialogs() {
+ return dialogs;
+ }
+}