auto-sync

This commit is contained in:
rusEfi 2016-12-20 19:03:24 -05:00
parent 68676da82f
commit 4f78de8c0b
6 changed files with 26 additions and 14 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

@ -38,7 +38,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see EngineSnifferPanel * @see EngineSnifferPanel
*/ */
public class Launcher { public class Launcher {
public static final int CONSOLE_VERSION = 20161202; public static final int CONSOLE_VERSION = 20161220;
public static final boolean SHOW_STIMULATOR = false; public static final boolean SHOW_STIMULATOR = false;
private static final String TAB_INDEX = "main_tab"; private static final String TAB_INDEX = "main_tab";
protected static final String PORT_KEY = "port"; protected static final String PORT_KEY = "port";
@ -88,7 +88,10 @@ public class Launcher {
private final LogDownloader logsManager = new LogDownloader(); private final LogDownloader logsManager = new LogDownloader();
private final FuelTunePane fuelTunePane; private final FuelTunePane fuelTunePane;
FrameHelper frame = new FrameHelper() { /**
* @see StartupFrame
*/
private FrameHelper mainFrame = new FrameHelper() {
@Override @Override
protected void onWindowOpened() { protected void onWindowOpened() {
super.onWindowOpened(); super.onWindowOpened();
@ -110,7 +113,7 @@ public class Launcher {
public Launcher(String port) { public Launcher(String port) {
this.port = port; this.port = port;
staticFrame = frame.getFrame(); staticFrame = mainFrame.getFrame();
FileLog.MAIN.logLine("Console " + CONSOLE_VERSION); FileLog.MAIN.logLine("Console " + CONSOLE_VERSION);
getConfig().getRoot().setProperty(PORT_KEY, port); getConfig().getRoot().setProperty(PORT_KEY, port);
@ -181,8 +184,8 @@ public class Launcher {
tabbedPane.setSelectedIndex(selectedIndex); tabbedPane.setSelectedIndex(selectedIndex);
} }
StartupFrame.setAppIcon(frame.getFrame()); StartupFrame.setAppIcon(mainFrame.getFrame());
frame.showFrame(tabbedPane); mainFrame.showFrame(tabbedPane);
} }
private void windowOpenedHandler() { private void windowOpenedHandler() {
@ -229,7 +232,7 @@ public class Launcher {
private void setTitle() { private void setTitle() {
String disconnected = ConnectionStatus.INSTANCE.isConnected() ? "" : "DISCONNECTED "; String disconnected = ConnectionStatus.INSTANCE.isConnected() ? "" : "DISCONNECTED ";
frame.getFrame().setTitle(disconnected + "Console " + CONSOLE_VERSION + "; firmware=" + Launcher.firmwareVersion.get() + "@" + port); mainFrame.getFrame().setTitle(disconnected + "Console " + CONSOLE_VERSION + "; firmware=" + Launcher.firmwareVersion.get() + "@" + port);
} }
private void windowClosedHandler() { private void windowClosedHandler() {

View File

@ -56,7 +56,7 @@ public class StartupFrame {
@NotNull @NotNull
private List<String> currentlyDisplayedPorts = new ArrayList<>(); private List<String> currentlyDisplayedPorts = new ArrayList<>();
private boolean isFirstTimeApplyingPorts = true; private boolean isFirstTimeApplyingPorts = true;
JPanel leftPanel; private JPanel leftPanel;
/** /**
* this flag tells us if we are closing the startup frame in order to proceed with console start or if we are * this flag tells us if we are closing the startup frame in order to proceed with console start or if we are
@ -71,8 +71,10 @@ public class StartupFrame {
frame.addWindowListener(new WindowAdapter() { frame.addWindowListener(new WindowAdapter() {
@Override @Override
public void windowClosed(WindowEvent ev) { public void windowClosed(WindowEvent ev) {
if (!isProceeding) if (!isProceeding) {
getConfig().save();
System.exit(0); System.exit(0);
}
} }
}); });
setAppIcon(frame); setAppIcon(frame);

View File

@ -14,6 +14,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static com.rusefi.Launcher.*; import static com.rusefi.Launcher.*;
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
/** /**
* This class checks the recommended versions numbers and compares them with current versions * This class checks the recommended versions numbers and compares them with current versions
@ -28,7 +29,6 @@ public class VersionChecker {
private static final VersionChecker instance = new VersionChecker(); private static final VersionChecker instance = new VersionChecker();
private final Map<String, String> map = new HashMap<>(); private final Map<String, String> map = new HashMap<>();
private int previousReportedVersion; private int previousReportedVersion;
@ -63,7 +63,6 @@ public class VersionChecker {
map.put(pair[0], pair[1]); map.put(pair[0], pair[1]);
} }
final Integer javaVersion = parseNotNull(map.get(JAVA_CONSOLE_TAG), "VC value"); final Integer javaVersion = parseNotNull(map.get(JAVA_CONSOLE_TAG), "VC value");
System.out.println("Server recommends java_console version " + javaVersion + " or newer"); System.out.println("Server recommends java_console version " + javaVersion + " or newer");
showUpdateWarningIfNeeded("dev console", javaVersion, CONSOLE_VERSION); showUpdateWarningIfNeeded("dev console", javaVersion, CONSOLE_VERSION);
@ -87,13 +86,21 @@ public class VersionChecker {
private static void showUpdateWarningIfNeeded(final String componentName, final Integer latestVersion, final int currentVersion) { private static void showUpdateWarningIfNeeded(final String componentName, final Integer latestVersion, final int currentVersion) {
if (latestVersion == null || currentVersion >= latestVersion) if (latestVersion == null || currentVersion >= latestVersion)
return; return;
if (getConfig().getRoot().getProperty(componentName).equals(Integer.toString(latestVersion)))
return; // warning was suppressed
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
String message = "It's time to update " + componentName + "!\r\n" + JPanel panel = new JPanel(new BorderLayout());
"Your version: " + currentVersion + "\r\n" + String message = "<html>It's time to update " + componentName + "!<br>" +
"Your version: " + currentVersion + "<br>" +
"Latest version: " + latestVersion; "Latest version: " + latestVersion;
JOptionPane.showMessageDialog(getPaneParent(), message, "Update", JOptionPane.WARNING_MESSAGE); panel.add(new JLabel(message), BorderLayout.NORTH);
JCheckBox doNotShowForThisVersion = new JCheckBox("Do not show for this version");
panel.add(doNotShowForThisVersion, BorderLayout.CENTER);
JOptionPane.showMessageDialog(getPaneParent(), panel, "Update", JOptionPane.WARNING_MESSAGE);
if (doNotShowForThisVersion.isSelected())
getConfig().getRoot().setProperty(componentName, latestVersion);
} }
}); });
} }

View File

@ -10,7 +10,7 @@ import java.util.Map;
public class PersistentConfiguration { public class PersistentConfiguration {
private static final PersistentConfiguration INSTANCE = new PersistentConfiguration(); private static final PersistentConfiguration INSTANCE = new PersistentConfiguration();
public static final String CONFIG_FILE_NAME = "rusefi_console_properties.xml"; private static final String CONFIG_FILE_NAME = "rusefi_console_properties.xml";
private Map<String, Object> config = new HashMap<>(); private Map<String, Object> config = new HashMap<>();