getting SOOOOOOOOOO close

This commit is contained in:
rusefi 2020-07-24 14:41:50 -04:00
parent accf9c9341
commit 469ba453c1
2 changed files with 24 additions and 2 deletions

View File

@ -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<ControllerAccess> 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() {

View File

@ -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());