REO progress
This commit is contained in:
parent
8f05d735db
commit
673738e5d2
|
@ -2,6 +2,7 @@ package com.rusefi.tools;
|
||||||
|
|
||||||
import com.rusefi.server.SessionDetails;
|
import com.rusefi.server.SessionDetails;
|
||||||
import com.rusefi.ui.storage.Node;
|
import com.rusefi.ui.storage.Node;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
|
|
||||||
|
@ -11,9 +12,15 @@ public class VehicleToken {
|
||||||
public static int getOrCreate() {
|
public static int getOrCreate() {
|
||||||
String value = getConfig().getRoot().getProperty(VEHICLE_TOKEN, null);
|
String value = getConfig().getRoot().getProperty(VEHICLE_TOKEN, null);
|
||||||
if (value == null || !Node.isNumeric(value)) {
|
if (value == null || !Node.isNumeric(value)) {
|
||||||
value = Integer.toString(SessionDetails.createOneTimeCode());
|
value = refresh();
|
||||||
getConfig().getRoot().setProperty(VEHICLE_TOKEN, value);
|
|
||||||
}
|
}
|
||||||
return Integer.parseInt(value);
|
return Integer.parseInt(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static String refresh() {
|
||||||
|
String value = Integer.toString(SessionDetails.createOneTimeCode());
|
||||||
|
getConfig().getRoot().setProperty(VEHICLE_TOKEN, value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,16 @@ import com.rusefi.autodetect.PortDetector;
|
||||||
import com.rusefi.autoupdate.AutoupdateUtil;
|
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||||
import com.rusefi.proxy.NetworkConnector;
|
import com.rusefi.proxy.NetworkConnector;
|
||||||
import com.rusefi.proxy.NetworkConnectorContext;
|
import com.rusefi.proxy.NetworkConnectorContext;
|
||||||
|
import com.rusefi.tools.VehicleToken;
|
||||||
import com.rusefi.ui.AuthTokenPanel;
|
import com.rusefi.ui.AuthTokenPanel;
|
||||||
import com.rusefi.ui.util.URLLabel;
|
import com.rusefi.ui.util.URLLabel;
|
||||||
|
import com.sun.naming.internal.VersionHelper;
|
||||||
import org.putgemin.VerticalFlowLayout;
|
import org.putgemin.VerticalFlowLayout;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.datatransfer.Clipboard;
|
||||||
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
@ -20,7 +25,7 @@ public class BroadcastTab {
|
||||||
private final JComponent content = new JPanel(new VerticalFlowLayout());
|
private final JComponent content = new JPanel(new VerticalFlowLayout());
|
||||||
|
|
||||||
private final JLabel status = new JLabel();
|
private final JLabel status = new JLabel();
|
||||||
private final JButton disconnect = new JButton("Disconnect");
|
private final JButton disconnect = new JButton("Stop Broadcasting");
|
||||||
private NetworkConnector networkConnector;
|
private NetworkConnector networkConnector;
|
||||||
|
|
||||||
public BroadcastTab() {
|
public BroadcastTab() {
|
||||||
|
@ -51,6 +56,8 @@ public class BroadcastTab {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
content.add(createVehicleTokenPanel());
|
||||||
|
|
||||||
content.add(broadcast);
|
content.add(broadcast);
|
||||||
content.add(status);
|
content.add(status);
|
||||||
content.add(disconnect);
|
content.add(disconnect);
|
||||||
|
@ -60,6 +67,40 @@ public class BroadcastTab {
|
||||||
AutoupdateUtil.trueLayout(content);
|
AutoupdateUtil.trueLayout(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Component createVehicleTokenPanel() {
|
||||||
|
JLabel label = new JLabel();
|
||||||
|
updateVehicleTokenLabel(label);
|
||||||
|
|
||||||
|
JButton copy = new JButton("Copy to clipboard");
|
||||||
|
copy.addActionListener(new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
StringSelection stringSelection = new StringSelection("" + VehicleToken.getOrCreate());
|
||||||
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
clipboard.setContents(stringSelection, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JButton reset = new JButton("Reset");
|
||||||
|
reset.addActionListener(new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
VehicleToken.refresh();
|
||||||
|
updateVehicleTokenLabel(label);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JPanel panel = new JPanel(new FlowLayout());
|
||||||
|
panel.add(label);
|
||||||
|
panel.add(copy);
|
||||||
|
panel.add(reset);
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateVehicleTokenLabel(JLabel label) {
|
||||||
|
label.setText("Vehicle access token: " + VehicleToken.getOrCreate());
|
||||||
|
}
|
||||||
|
|
||||||
private void startBroadcasting(String authToken, String autoDetectedPort) {
|
private void startBroadcasting(String authToken, String autoDetectedPort) {
|
||||||
if (autoDetectedPort == null) {
|
if (autoDetectedPort == null) {
|
||||||
status.setText("<html>rusEFI ECU not detected.<br/>Please make sure that TunerStudio is currently not connected to ECU.</html>");
|
status.setText("<html>rusEFI ECU not detected.<br/>Please make sure that TunerStudio is currently not connected to ECU.</html>");
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="mockito-all-1.10.19">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/../../java_console/lib/mockito-all-1.10.19.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/../../java_console/lib/mockito-all-1.10.19.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
Loading…
Reference in New Issue