Launcher splash screen is freezy fix #2560
This commit is contained in:
parent
2b24045584
commit
e5a2b58edf
|
@ -28,6 +28,8 @@ All notable user-facing or behavior-altering changes will be documented in this
|
||||||
## Month 202x Release - "Release Name"
|
## Month 202x Release - "Release Name"
|
||||||
### Fixed
|
### Fixed
|
||||||
- SD card logs bugfix #2556
|
- SD card logs bugfix #2556
|
||||||
|
- Too many small logs are zero size #2553
|
||||||
|
- Launcher splash screen is freezy #2560
|
||||||
|
|
||||||
## April 2021 Release "Be Kind to Lawyers Day"
|
## April 2021 Release "Be Kind to Lawyers Day"
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.net.URL;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class rusEFIVersion {
|
public class rusEFIVersion {
|
||||||
public static final int CONSOLE_VERSION = 20210413;
|
public static final int CONSOLE_VERSION = 20210415;
|
||||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||||
|
|
||||||
public static long classBuildTimeMillis() {
|
public static long classBuildTimeMillis() {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.io.tcp.TcpConnector;
|
import com.rusefi.io.tcp.TcpConnector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -16,19 +15,17 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
public enum SerialPortScanner {
|
public enum SerialPortScanner {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
private volatile boolean isRunning = true;
|
||||||
|
|
||||||
static final String AUTO_SERIAL = "Auto Serial";
|
static final String AUTO_SERIAL = "Auto Serial";
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<String> knownPorts = new ArrayList<>();
|
private final List<String> knownPorts = new ArrayList<>();
|
||||||
|
|
||||||
public List<Listener> listeners = new CopyOnWriteArrayList<>();
|
public List<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
private final Timer scanPortsTimer = new Timer(1000, e -> findAllAvailablePorts());
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all available serial ports and checks if simulator local TCP port is available
|
* Find all available serial ports and checks if simulator local TCP port is available
|
||||||
*/
|
*/
|
||||||
@NotNull
|
|
||||||
void findAllAvailablePorts() {
|
void findAllAvailablePorts() {
|
||||||
List<String> ports = new ArrayList<>();
|
List<String> ports = new ArrayList<>();
|
||||||
String[] serialPorts = LinkManager.getCommPorts();
|
String[] serialPorts = LinkManager.getCommPorts();
|
||||||
|
@ -57,11 +54,23 @@ public enum SerialPortScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startTimer() {
|
public void startTimer() {
|
||||||
scanPortsTimer.start();
|
Thread portsScanner = new Thread(() -> {
|
||||||
|
while (isRunning) {
|
||||||
|
findAllAvailablePorts();
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, "Ports Scanner");
|
||||||
|
portsScanner.setDaemon(true);
|
||||||
|
portsScanner.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer() {
|
public void stopTimer() {
|
||||||
scanPortsTimer.stop();
|
isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.List;
|
||||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
import static com.rusefi.ui.util.UiUtils.getAllComponents;
|
import static com.rusefi.ui.util.UiUtils.getAllComponents;
|
||||||
import static com.rusefi.ui.util.UiUtils.setToolTip;
|
import static com.rusefi.ui.util.UiUtils.setToolTip;
|
||||||
import static java.awt.image.ImageObserver.ABORT;
|
|
||||||
import static javax.swing.JOptionPane.YES_NO_OPTION;
|
import static javax.swing.JOptionPane.YES_NO_OPTION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,10 +49,10 @@ 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;
|
||||||
private JPanel leftPanel = new JPanel(new VerticalFlowLayout());
|
private final JPanel leftPanel = new JPanel(new VerticalFlowLayout());
|
||||||
|
|
||||||
private JPanel realHardwarePanel = new JPanel(new MigLayout());
|
private final JPanel realHardwarePanel = new JPanel(new MigLayout());
|
||||||
private JPanel miscPanel = new JPanel(new MigLayout()) {
|
private final JPanel miscPanel = new JPanel(new MigLayout()) {
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize() {
|
public Dimension getPreferredSize() {
|
||||||
// want miscPanel and realHardwarePanel to be the same width
|
// want miscPanel and realHardwarePanel to be the same width
|
||||||
|
@ -66,7 +65,7 @@ public class StartupFrame {
|
||||||
* closing the application.
|
* closing the application.
|
||||||
*/
|
*/
|
||||||
private boolean isProceeding;
|
private boolean isProceeding;
|
||||||
private JLabel noPortsMessage = new JLabel("No ports found!");
|
private final JLabel noPortsMessage = new JLabel("No ports found!");
|
||||||
|
|
||||||
public StartupFrame() {
|
public StartupFrame() {
|
||||||
// AudioPlayback.start();
|
// AudioPlayback.start();
|
||||||
|
@ -152,28 +151,25 @@ public class StartupFrame {
|
||||||
realHardwarePanel.add(new EraseChip().getButton(), "right, wrap");
|
realHardwarePanel.add(new EraseChip().getButton(), "right, wrap");
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialPortScanner.INSTANCE.listeners.add(new SerialPortScanner.Listener() {
|
SerialPortScanner.INSTANCE.listeners.add(() -> SwingUtilities.invokeLater(() -> {
|
||||||
@Override
|
List<String> ports = SerialPortScanner.INSTANCE.getKnownPorts();
|
||||||
public void onChange() {
|
if (!currentlyDisplayedPorts.equals(ports) || isFirstTimeApplyingPorts) {
|
||||||
List<String> ports = SerialPortScanner.INSTANCE.getKnownPorts();
|
FileLog.MAIN.logLine("Available ports " + ports);
|
||||||
if (!currentlyDisplayedPorts.equals(ports) || isFirstTimeApplyingPorts) {
|
isFirstTimeApplyingPorts = false;
|
||||||
FileLog.MAIN.logLine("Available ports " + ports);
|
connectPanel.setVisible(!ports.isEmpty());
|
||||||
isFirstTimeApplyingPorts = false;
|
noPortsMessage.setVisible(ports.isEmpty());
|
||||||
connectPanel.setVisible(!ports.isEmpty());
|
|
||||||
noPortsMessage.setVisible(ports.isEmpty());
|
|
||||||
// panel.add(comboSpeeds); // todo: finish speed selector UI component
|
// panel.add(comboSpeeds); // todo: finish speed selector UI component
|
||||||
// horizontalLine.setVisible(!ports.isEmpty());
|
// horizontalLine.setVisible(!ports.isEmpty());
|
||||||
|
|
||||||
applyPortSelectionToUIcontrol(ports);
|
applyPortSelectionToUIcontrol(ports);
|
||||||
currentlyDisplayedPorts = ports;
|
currentlyDisplayedPorts = ports;
|
||||||
UiUtils.trueLayout(connectPanel);
|
UiUtils.trueLayout(connectPanel);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
// todo: invoke this NOT on AWT thread?
|
||||||
SerialPortScanner.INSTANCE.findAllAvailablePorts();
|
SerialPortScanner.INSTANCE.findAllAvailablePorts();
|
||||||
|
|
||||||
final JButton buttonLogViewer = new JButton();
|
final JButton buttonLogViewer = new JButton();
|
||||||
|
|
Loading…
Reference in New Issue