diff --git a/java_console/shared_ui/src/com/rusefi/tools/online/Online.java b/java_console/shared_ui/src/com/rusefi/tools/online/Online.java
index 0e7090680c..6617ab2bb9 100644
--- a/java_console/shared_ui/src/com/rusefi/tools/online/Online.java
+++ b/java_console/shared_ui/src/com/rusefi/tools/online/Online.java
@@ -14,9 +14,8 @@ import org.apache.http.util.EntityUtils;
import javax.swing.*;
import javax.xml.bind.JAXBException;
-import java.io.*;
-
-import static com.rusefi.ui.AuthTokenPanel.TOKEN_WARNING;
+import java.io.File;
+import java.io.IOException;
public class Online {
private static final String url = "https://rusefi.com/online/upload.php";
@@ -43,8 +42,8 @@ public class Online {
public static void uploadTune(Msq tune, AuthTokenPanel authTokenPanel, JComponent parent) {
String authToken = authTokenPanel.getToken();
- if (authToken.contains(TOKEN_WARNING)) {
- JOptionPane.showMessageDialog(parent, "Does not work without auth token");
+ if (!authTokenPanel.hasToken()) {
+ authTokenPanel.showError(parent);
return;
}
new Thread(() -> doUpload(authToken, tune)).start();
diff --git a/java_console/shared_ui/src/com/rusefi/ui/AuthTokenPanel.java b/java_console/shared_ui/src/com/rusefi/ui/AuthTokenPanel.java
index a2425eb44b..2b4dc6e0a1 100644
--- a/java_console/shared_ui/src/com/rusefi/ui/AuthTokenPanel.java
+++ b/java_console/shared_ui/src/com/rusefi/ui/AuthTokenPanel.java
@@ -11,14 +11,20 @@ import java.awt.event.ActionEvent;
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
public class AuthTokenPanel {
- public static final String TOKEN_WARNING = "Please copy token from your forum profile";
+ private static final String TOKEN_WARNING = "Please copy token from your forum profile";
+ private static final String TOKEN_SUBSTRING = "token";
private static final String AUTH_TOKEN = "auth_token";
private static final String TOKEN_PROFILE_URL = "https://rusefi.com/forum/ucp.php?i=254";
- private JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ private JPanel content = new JPanel(new BorderLayout());
private JTextField textField = new JTextField();
public AuthTokenPanel() {
+
+ JPanel top = new JPanel(new FlowLayout(FlowLayout.LEFT));
+
+ content.setBorder(BorderFactory.createTitledBorder("rusEFI Online Authentication Token"));
+
textField.setPreferredSize(new Dimension(200, 24));
String authToken = getAuthToken();
@@ -33,12 +39,13 @@ public class AuthTokenPanel {
}
});
- content.add(textField);
- content.add(save);
+ top.add(textField);
+ top.add(save);
+ content.add(top);
if (authToken.trim().isEmpty()) {
authToken = TOKEN_WARNING;
- content.add(new URLLabel("Get it here", TOKEN_PROFILE_URL));
+ content.add(new URLLabel("Get your token here", TOKEN_PROFILE_URL), BorderLayout.SOUTH);
}
textField.setText(authToken);
}
@@ -56,7 +63,15 @@ public class AuthTokenPanel {
return content;
}
+ public boolean hasToken() {
+ return textField.getText().trim().length() > 0 && !textField.getText().contains(TOKEN_SUBSTRING);
+ }
+
public String getToken() {
return textField.getText();
}
+
+ public void showError(JComponent parent) {
+ JOptionPane.showMessageDialog(parent, "Does not work without auth token, see below.");
+ }
}
diff --git a/java_tools/ts_plugin/build.xml b/java_tools/ts_plugin/build.xml
index faffb95faa..b729364348 100644
--- a/java_tools/ts_plugin/build.xml
+++ b/java_tools/ts_plugin/build.xml
@@ -30,6 +30,10 @@
+
+
+
+
diff --git a/java_tools/ts_plugin/src/com/rusefi/ts_plugin/PluginBodySandbox.java b/java_tools/ts_plugin/src/com/rusefi/ts_plugin/PluginBodySandbox.java
new file mode 100644
index 0000000000..a402f4ebcb
--- /dev/null
+++ b/java_tools/ts_plugin/src/com/rusefi/ts_plugin/PluginBodySandbox.java
@@ -0,0 +1,12 @@
+package com.rusefi.ts_plugin;
+
+import com.rusefi.ui.util.FrameHelper;
+
+/**
+ * @see PluginLauncherSandbox
+ */
+public class PluginBodySandbox {
+ public static void main(String[] args) {
+ new FrameHelper().showFrame(new PluginEntry().getContent());
+ }
+}
diff --git a/java_tools/ts_plugin/src/com/rusefi/ts_plugin/PluginEntry.java b/java_tools/ts_plugin/src/com/rusefi/ts_plugin/PluginEntry.java
index 871665ee2e..fdbfd271c4 100644
--- a/java_tools/ts_plugin/src/com/rusefi/ts_plugin/PluginEntry.java
+++ b/java_tools/ts_plugin/src/com/rusefi/ts_plugin/PluginEntry.java
@@ -10,12 +10,12 @@ import com.rusefi.tune.xml.Constant;
import com.rusefi.tune.xml.Msq;
import com.rusefi.ui.AuthTokenPanel;
import com.rusefi.ui.storage.PersistentConfiguration;
+import org.putgemin.VerticalFlowLayout;
import javax.swing.*;
import javax.xml.bind.JAXBException;
import java.awt.event.ActionEvent;
import java.io.IOException;
-import java.io.InputStream;
import java.net.URL;
import java.util.Map;
import java.util.TreeMap;
@@ -28,20 +28,26 @@ import java.util.jar.Manifest;
public class PluginEntry implements TsPluginBody {
public static final String BUILT_DATE = "Built-Date";
private final AuthTokenPanel tokenPanel = new AuthTokenPanel();
- private final JComponent content = new JPanel();
+ private final JComponent content = new JPanel(new VerticalFlowLayout());
public PluginEntry() {
- content.add(tokenPanel.getContent());
- JButton upload = new JButton("Upload Tune");
+ JButton upload = new JButton("Upload Current Tune");
upload.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
+ if (!tokenPanel.hasToken()) {
+ tokenPanel.showError(content);
+ return;
+ }
Msq tune = writeCurrentTune(ControllerAccess.getInstance());
Online.uploadTune(tune, tokenPanel, content);
}
});
+
content.add(upload);
+ content.add(new JLabel(Updater.LOGO));
+ content.add(tokenPanel.getContent());
}
@Override
@@ -75,7 +81,12 @@ public class PluginEntry implements TsPluginBody {
}
public static String getConfigurationName() {
- return ControllerAccess.getInstance().getEcuConfigurationNames()[0];
+ ControllerAccess controllerAccess = ControllerAccess.getInstance();
+ if (controllerAccess == null) {
+ System.out.println("No ControllerAccess");
+ return null;
+ }
+ return controllerAccess.getEcuConfigurationNames()[0];
}
private static String toString(double scalarValue, int decimalPlaces) {
diff --git a/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Sandbox.java b/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/PluginLauncherSandbox.java
similarity index 90%
rename from java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Sandbox.java
rename to java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/PluginLauncherSandbox.java
index 73a206e42a..7805fbca63 100644
--- a/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Sandbox.java
+++ b/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/PluginLauncherSandbox.java
@@ -2,7 +2,7 @@ package com.rusefi.ts_plugin;
import javax.swing.*;
-public class Sandbox {
+public class PluginLauncherSandbox {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(800, 500);
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 2c9ab5318a..cab286eacd 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
@@ -11,6 +11,7 @@ import javax.swing.*;
*/
public class TsPluginLauncher implements ApplicationPlugin {
static final String VERSION = "alpha2020";
+ private static final String HELP_URL = "https://github.com/rusefi/rusefi/wiki/TS-Plugin";
private final JPanel content = new JPanel(new VerticalFlowLayout());
@@ -70,7 +71,7 @@ public class TsPluginLauncher implements ApplicationPlugin {
@Override
public String getHelpUrl() {
- return "https://rusefi.com";
+ return HELP_URL;
}
@Override
diff --git a/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Updater.java b/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Updater.java
index bf4b55be99..644b258395 100644
--- a/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Updater.java
+++ b/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Updater.java
@@ -22,13 +22,12 @@ public class Updater {
private static final String TITLE = "rusEFI plugin installer " + VERSION;
private final JPanel content = new JPanel(new VerticalFlowLayout());
+ public static final ImageIcon LOGO = AutoupdateUtil.loadIcon("/rusefi_online_color_300.png");
public Updater() {
content.add(new JLabel("" + VERSION));
- ImageIcon logo = AutoupdateUtil.loadIcon("/rusefi_online_color_300.png");
-
- content.add(new JLabel(logo));
+ content.add(new JLabel(LOGO));
String version = null;
File localFile = new File(LOCAL_JAR_FILE_NAME);
@@ -140,6 +139,7 @@ public class Updater {
content.add(instance.getContent());
AutoupdateUtil.trueLayout(content.getParent());
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(content);
+ AutoupdateUtil.trueLayout(topFrame);
topFrame.pack();
AutoupdateUtil.trueLayout(topFrame);
}