diff --git a/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/PluginEntry.java b/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/PluginEntry.java index c002038a25..523f560175 100644 --- a/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/PluginEntry.java +++ b/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/PluginEntry.java @@ -5,12 +5,15 @@ import com.rusefi.ts_plugin.util.ManifestHelper; import com.rusefi.tune.xml.Constant; import javax.swing.*; +import java.awt.*; +import java.lang.reflect.Field; import java.util.function.Supplier; /** * TsPlugin launcher creates an instance of this class via reflection. */ public class PluginEntry implements TsPluginBody { + private final JPanel content = new JPanel(new BorderLayout()); private final JTabbedPane tabbedPane = new JTabbedPane(); /** @@ -23,6 +26,11 @@ public class PluginEntry implements TsPluginBody { public PluginEntry(Supplier controllerAccessSupplier) { System.out.println("PluginEntry init " + this); + if (isLauncherTooOld()) { + content.add(new JLabel("Please manually install latest plugin version")); + return; + } + UploadTab uploadTab = new UploadTab(controllerAccessSupplier); BroadcastTab broadcastTab = new BroadcastTab(); RemoteTab remoteTab = new RemoteTab(); @@ -30,6 +38,19 @@ public class PluginEntry implements TsPluginBody { tabbedPane.addTab("Upload", uploadTab.getContent()); tabbedPane.addTab("Broadcast", broadcastTab.getContent()); tabbedPane.addTab("Remote ECU", remoteTab.getContent()); + content.add(tabbedPane); + } + + private boolean isLauncherTooOld() { + try { + // at some point we did not have this field so using reflection for the next couple of months + Field field = TsPluginLauncher.class.getField("BUILD_VERSION"); + int launcherVersion = (int) field.get(null); + System.out.println("Launcher version " + launcherVersion + " detected"); + return false; + } catch (NoSuchFieldException | IllegalAccessException e) { + return true; + } } public static boolean isEmpty(Constant constant) { @@ -44,7 +65,7 @@ public class PluginEntry implements TsPluginBody { @Override public JComponent getContent() { - return tabbedPane; + return content; } /* public void close() { diff --git a/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/TsPluginLauncher.java b/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/TsPluginLauncher.java index 59f72a5d8f..ab4e3a5ee1 100644 --- a/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/TsPluginLauncher.java +++ b/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/TsPluginLauncher.java @@ -10,7 +10,8 @@ import javax.swing.*; * by the way TS installs stuff into %user%\.efianalytics\TunerStudio\plugins folder */ public class TsPluginLauncher implements ApplicationPlugin { - static final String VERSION = "alpha4_2020"; + public static final int BUILD_VERSION = 3; + static final String VERSION = "2020.alpha." + BUILD_VERSION; private static final String HELP_URL = "https://github.com/rusefi/rusefi/wiki/TS-Plugin"; private final JPanel content = new JPanel(new VerticalFlowLayout());