auto-sync

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

View File

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

View File

@ -56,7 +56,7 @@ public class StartupFrame {
@NotNull
private List<String> currentlyDisplayedPorts = new ArrayList<>();
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
@ -71,8 +71,10 @@ public class StartupFrame {
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent ev) {
if (!isProceeding)
if (!isProceeding) {
getConfig().save();
System.exit(0);
}
}
});
setAppIcon(frame);

View File

@ -14,6 +14,7 @@ import java.util.HashMap;
import java.util.Map;
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
@ -28,7 +29,6 @@ public class VersionChecker {
private static final VersionChecker instance = new VersionChecker();
private final Map<String, String> map = new HashMap<>();
private int previousReportedVersion;
@ -63,7 +63,6 @@ public class VersionChecker {
map.put(pair[0], pair[1]);
}
final Integer javaVersion = parseNotNull(map.get(JAVA_CONSOLE_TAG), "VC value");
System.out.println("Server recommends java_console version " + javaVersion + " or newer");
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) {
if (latestVersion == null || currentVersion >= latestVersion)
return;
if (getConfig().getRoot().getProperty(componentName).equals(Integer.toString(latestVersion)))
return; // warning was suppressed
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String message = "It's time to update " + componentName + "!\r\n" +
"Your version: " + currentVersion + "\r\n" +
JPanel panel = new JPanel(new BorderLayout());
String message = "<html>It's time to update " + componentName + "!<br>" +
"Your version: " + currentVersion + "<br>" +
"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 {
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<>();