Support logging to text area without breaking line (#6699)
This commit is contained in:
parent
4687802890
commit
ace2c67e5a
|
@ -23,9 +23,9 @@ public class DfuHelper {
|
|||
try {
|
||||
stream.sendPacket(command);
|
||||
stream.close();
|
||||
callbacks.log(String.format("Reboot command [%s] sent into %s!\n", cmd, stream));
|
||||
callbacks.log(String.format("Reboot command [%s] sent into %s!\n", cmd, stream), true);
|
||||
} catch (IOException e) {
|
||||
callbacks.log("Error " + e);
|
||||
callbacks.log("Error " + e, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.rusefi.io;
|
||||
|
||||
public interface UpdateOperationCallbacks {
|
||||
void log(String message);
|
||||
void log(String message, boolean breakLineOnTextArea);
|
||||
|
||||
default void append(String message) {
|
||||
log(message);
|
||||
default void append(final String message, final boolean breakLineOnTextArea) {
|
||||
log(message, breakLineOnTextArea);
|
||||
}
|
||||
|
||||
void done();
|
||||
|
@ -12,7 +12,7 @@ public interface UpdateOperationCallbacks {
|
|||
|
||||
class UpdateOperationDummy implements UpdateOperationCallbacks {
|
||||
@Override
|
||||
public void log(String message) {
|
||||
public void log(final String message, final boolean breakLineOnTextArea) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,17 +48,19 @@ public class PCanIoStream extends AbstractIoStream {
|
|||
|
||||
@Nullable
|
||||
public static PCanIoStream createStream() {
|
||||
return createStream(message -> log.info(message));
|
||||
return createStream((message, breakLineOnTextArea) -> {
|
||||
log.info(message);
|
||||
});
|
||||
}
|
||||
|
||||
public static PCanIoStream createStream(StatusConsumer statusListener) {
|
||||
PCANBasic can = PCanHelper.create();
|
||||
TPCANStatus status = PCanHelper.init(can);
|
||||
if (status != TPCANStatus.PCAN_ERROR_OK) {
|
||||
statusListener.append("Error initializing PCAN: " + status);
|
||||
statusListener.append("Error initializing PCAN: " + status, true);
|
||||
return null;
|
||||
}
|
||||
statusListener.append("Creating PCAN stream...");
|
||||
statusListener.append("Creating PCAN stream...", true);
|
||||
return new PCanIoStream(can, statusListener);
|
||||
}
|
||||
|
||||
|
@ -71,7 +73,7 @@ public class PCanIoStream extends AbstractIoStream {
|
|||
|
||||
TPCANStatus status = PCanHelper.send(can, isoTpConnector.canId(), payLoad);
|
||||
if (status != TPCANStatus.PCAN_ERROR_OK) {
|
||||
statusListener.append("Unable to write the CAN message: " + status);
|
||||
statusListener.append("Unable to write the CAN message: " + status, true);
|
||||
System.exit(0);
|
||||
}
|
||||
// log.info("Send OK! length=" + payLoad.length);
|
||||
|
|
|
@ -44,7 +44,7 @@ public class BinaryProtocolProxy {
|
|||
clientStream = new TcpIoStream("[[proxy]] ", clientSocket);
|
||||
runProxy(targetEcuSocket, clientStream, clientApplicationActivityListener, USER_IO_TIMEOUT);
|
||||
} catch (IOException e) {
|
||||
statusConsumer.append("ERROR BinaryProtocolProxy::run " + e);
|
||||
statusConsumer.append("ERROR BinaryProtocolProxy::run " + e, true);
|
||||
close(clientStream);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -96,7 +96,7 @@ public class BinaryProtocolServer {
|
|||
public static ServerSocketReference tcpServerSocket(int port, String threadName, CompatibleFunction<Socket, Runnable> socketRunnableFactory, Listener serverSocketCreationCallback, StatusConsumer statusConsumer) throws IOException {
|
||||
return tcpServerSocket(socketRunnableFactory, port, threadName, serverSocketCreationCallback, p -> {
|
||||
ServerSocket serverSocket = new ServerSocket(p);
|
||||
statusConsumer.append("ServerSocket " + p + " created. Feel free to point TS at IP Address 'localhost' port " + p);
|
||||
statusConsumer.append("ServerSocket " + p + " created. Feel free to point TS at IP Address 'localhost' port " + p, true);
|
||||
return serverSocket;
|
||||
});
|
||||
}
|
||||
|
@ -367,4 +367,4 @@ public class BinaryProtocolServer {
|
|||
return Timeouts.BINARY_IO_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@ import static com.devexperts.logging.Logging.getLogging;
|
|||
public interface StatusConsumer {
|
||||
Logging log = getLogging(StatusConsumer.class);
|
||||
|
||||
StatusConsumer ANONYMOUS = log::info;
|
||||
StatusConsumer VOID = s -> {
|
||||
StatusConsumer ANONYMOUS = (status, breakLineOnTextArea) -> {
|
||||
log.info(status);
|
||||
};
|
||||
StatusConsumer VOID = (status, breakLineOnTextArea) -> {
|
||||
};
|
||||
|
||||
void append(String status);
|
||||
void append(String status, boolean breakLineOnTextArea);
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public class DfuFlasher {
|
|||
return;
|
||||
if (isSignatureValidated.get()) {
|
||||
if (!FileLog.isWindows()) {
|
||||
callbacks.append("Switched to DFU mode!");
|
||||
callbacks.append("rusEFI console can only program on Windows");
|
||||
callbacks.append("Switched to DFU mode!", true);
|
||||
callbacks.append("rusEFI console can only program on Windows", true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class DfuFlasher {
|
|||
executeDFU(callbacks, FindFileHelper.FIRMWARE_BIN_FILE);
|
||||
});
|
||||
} else {
|
||||
callbacks.log("Please use manual DFU to change bundle type.");
|
||||
callbacks.log("Please use manual DFU to change bundle type.", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class DfuFlasher {
|
|||
public static AtomicBoolean rebootToDfu(JComponent parent, String port, UpdateOperationCallbacks callbacks, String command) {
|
||||
AtomicBoolean isSignatureValidated = new AtomicBoolean(true);
|
||||
if (!PortDetector.isAutoPort(port)) {
|
||||
callbacks.log("Using selected " + port + "\n");
|
||||
callbacks.log("Using selected " + port + "\n", true);
|
||||
IoStream stream = BufferedSerialIoStream.openPort(port);
|
||||
AtomicReference<String> signature = new AtomicReference<>();
|
||||
new SerialAutoChecker(PortDetector.DetectorMode.DETECT_TS, port, new CountDownLatch(1)).checkResponse(stream, new Function<SerialAutoChecker.CallbackContext, Void>() {
|
||||
|
@ -84,22 +84,22 @@ public class DfuFlasher {
|
|||
}
|
||||
});
|
||||
if (signature.get() == null) {
|
||||
callbacks.append("");
|
||||
callbacks.append("");
|
||||
callbacks.append("");
|
||||
callbacks.append("Make sure TUNERSTUDIO IS DISCONNECTED FROM ECU");
|
||||
callbacks.append("");
|
||||
callbacks.append("");
|
||||
callbacks.append("");
|
||||
callbacks.append("", true);
|
||||
callbacks.append("", true);
|
||||
callbacks.append("", true);
|
||||
callbacks.append("Make sure TUNERSTUDIO IS DISCONNECTED FROM ECU", true);
|
||||
callbacks.append("", true);
|
||||
callbacks.append("", true);
|
||||
callbacks.append("", true);
|
||||
callbacks.append("*** ERROR *** rusEFI has not responded on selected " + port + "\n" +
|
||||
"Maybe try automatic serial port detection?");
|
||||
"Maybe try automatic serial port detection?", true);
|
||||
callbacks.error();
|
||||
return null;
|
||||
}
|
||||
boolean isSignatureValidatedLocal = DfuHelper.sendDfuRebootCommand(parent, signature.get(), stream, callbacks, command);
|
||||
isSignatureValidated.set(isSignatureValidatedLocal);
|
||||
} else {
|
||||
callbacks.log("Auto-detecting port...\n");
|
||||
callbacks.log("Auto-detecting port...\n", true);
|
||||
// instead of opening the just-detected port we execute the command using the same stream we used to discover port
|
||||
// it's more reliable this way
|
||||
// ISSUE: that's blocking stuff on UI thread at the moment, TODO smarter threading!
|
||||
|
@ -109,11 +109,11 @@ public class DfuFlasher {
|
|||
return null;
|
||||
}).getSerialPort();
|
||||
if (port == null) {
|
||||
callbacks.append("*** ERROR *** rusEFI serial port not detected");
|
||||
callbacks.append("*** ERROR *** rusEFI serial port not detected", true);
|
||||
callbacks.error();
|
||||
return null;
|
||||
} else {
|
||||
callbacks.append("Detected rusEFI on " + port + "\n");
|
||||
callbacks.append("Detected rusEFI on " + port + "\n", true);
|
||||
}
|
||||
}
|
||||
return isSignatureValidated;
|
||||
|
@ -133,7 +133,7 @@ public class DfuFlasher {
|
|||
getDfuEraseCommand(),
|
||||
DFU_CMD_TOOL, callbacks);
|
||||
} catch (FileNotFoundException e) {
|
||||
callbacks.log(e.toString());
|
||||
callbacks.log(e.toString(), true);
|
||||
callbacks.error();
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class DfuFlasher {
|
|||
private static void executeDFU(UpdateOperationCallbacks callbacks, String firmwareBinFile) {
|
||||
boolean driverIsHappy = detectSTM32BootloaderDriverState(callbacks);
|
||||
if (!driverIsHappy) {
|
||||
callbacks.append("*** DRIVER ERROR? *** Did you have a chance to try 'Install Drivers' button on top of rusEFI console start screen?");
|
||||
callbacks.append("*** DRIVER ERROR? *** Did you have a chance to try 'Install Drivers' button on top of rusEFI console start screen?", true);
|
||||
callbacks.error();
|
||||
return;
|
||||
}
|
||||
|
@ -161,27 +161,27 @@ public class DfuFlasher {
|
|||
getDfuWriteCommand(firmwareBinFile),
|
||||
DFU_CMD_TOOL, callbacks, stdout);
|
||||
} catch (FileNotFoundException e) {
|
||||
callbacks.log("ERROR: " + e);
|
||||
callbacks.log("ERROR: " + e, true);
|
||||
callbacks.error();
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout.toString().contains("Download verified successfully")) {
|
||||
// looks like sometimes we are not catching the last line of the response? 'Upgrade' happens before 'Verify'
|
||||
callbacks.log("SUCCESS!");
|
||||
callbacks.log("Please power cycle device to exit DFU mode");
|
||||
callbacks.log("SUCCESS!", true);
|
||||
callbacks.log("Please power cycle device to exit DFU mode", true);
|
||||
callbacks.done();
|
||||
} else if (stdout.toString().contains("Target device not found")) {
|
||||
callbacks.append("ERROR: Device not connected or STM32 Bootloader driver not installed?");
|
||||
callbacks.append("ERROR: Device not connected or STM32 Bootloader driver not installed?", true);
|
||||
appendWindowsVersion(callbacks);
|
||||
callbacks.append("ERROR: Please try installing drivers using 'Install Drivers' button on rusEFI splash screen");
|
||||
callbacks.append("ERROR: Alternatively please install drivers using Device Manager pointing at 'drivers/silent_st_drivers/DFU_Driver' folder");
|
||||
callbacks.append("ERROR: Please try installing drivers using 'Install Drivers' button on rusEFI splash screen", true);
|
||||
callbacks.append("ERROR: Alternatively please install drivers using Device Manager pointing at 'drivers/silent_st_drivers/DFU_Driver' folder", true);
|
||||
appendDeviceReport(callbacks);
|
||||
callbacks.error();
|
||||
} else {
|
||||
appendWindowsVersion(callbacks);
|
||||
appendDeviceReport(callbacks);
|
||||
callbacks.log(stdout.length() + " / " + errorResponse.length());
|
||||
callbacks.log(stdout.length() + " / " + errorResponse.length(), true);
|
||||
callbacks.error();
|
||||
}
|
||||
}
|
||||
|
@ -191,22 +191,22 @@ public class DfuFlasher {
|
|||
}
|
||||
|
||||
private static void appendWindowsVersion(UpdateOperationCallbacks callbacks) {
|
||||
callbacks.log("ERROR: does not look like DFU has worked!");
|
||||
callbacks.log("ERROR: does not look like DFU has worked!", true);
|
||||
}
|
||||
|
||||
private static void appendDeviceReport(UpdateOperationCallbacks callbacks) {
|
||||
for (String line : getDevicesReport()) {
|
||||
if (line.contains("STM Device in DFU Mode")) {
|
||||
callbacks.log(" ******************************************************************");
|
||||
callbacks.log(" ************* YOU NEED TO REMOVE LEGACY DFU DRIVER ***************");
|
||||
callbacks.log(" ******************************************************************");
|
||||
callbacks.log(" ******************************************************************", true);
|
||||
callbacks.log(" ************* YOU NEED TO REMOVE LEGACY DFU DRIVER ***************", true);
|
||||
callbacks.log(" ******************************************************************", true);
|
||||
}
|
||||
callbacks.log("Devices: " + line);
|
||||
callbacks.log("Devices: " + line, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static void timeForDfuSwitch(UpdateOperationCallbacks callbacks) {
|
||||
callbacks.log("Giving time for USB enumeration...");
|
||||
callbacks.log("Giving time for USB enumeration...", true);
|
||||
try {
|
||||
// two seconds not enough on my Windows 10
|
||||
Thread.sleep(3 * Timeouts.SECOND);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class DriverInstall {
|
|||
FileLog.MAIN.logLine("IsWindows=" + FileLog.isWindows());
|
||||
if (!new File(FOLDER).exists()) {
|
||||
String message = FOLDER + " not found";
|
||||
wnd.append(message);
|
||||
wnd.append(message, true);
|
||||
FileLog.MAIN.logLine(message);
|
||||
return;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class DriverInstall {
|
|||
String batch = isWindows7orBelow() ? WINDOWS7_BATCH : WINDOWS8_BATCH;
|
||||
ExecHelper.executeCommand(UNPACKED_FOLDER, ExecHelper.getBatchCommand(batch), batch, wnd);
|
||||
} catch (FileNotFoundException e) {
|
||||
wnd.append(e.toString());
|
||||
wnd.append(e.toString(), true);
|
||||
wnd.error();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@ public class ExecHelper {
|
|||
String line = bis.readLine();
|
||||
if (line == null)
|
||||
break;
|
||||
callbacks.log(line);
|
||||
callbacks.log(line, true);
|
||||
buffer.append(line);
|
||||
wasRunningTime = System.currentTimeMillis();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
callbacks.log("Stream " + e);
|
||||
callbacks.log("Stream " + e, true);
|
||||
callbacks.error();
|
||||
}
|
||||
});
|
||||
|
@ -65,7 +65,7 @@ public class ExecHelper {
|
|||
StringBuffer error = new StringBuffer();
|
||||
String binaryFullName = workingDirPath + File.separator + binaryRelativeName;
|
||||
if (!new File(binaryFullName).exists()) {
|
||||
callbacks.log(binaryFullName + " not found :(");
|
||||
callbacks.log(binaryFullName + " not found :(", true);
|
||||
throw new FileNotFoundException(binaryFullName);
|
||||
}
|
||||
|
||||
|
@ -75,17 +75,17 @@ public class ExecHelper {
|
|||
|
||||
@NotNull
|
||||
public static String executeCommand(String command, UpdateOperationCallbacks callbacks, StringBuffer output, StringBuffer error, File workingDir) {
|
||||
callbacks.log("Executing " + command);
|
||||
callbacks.log("Executing " + command, true);
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command, null, workingDir);
|
||||
startStreamThread(p, p.getInputStream(), output, callbacks);
|
||||
startStreamThread(p, p.getErrorStream(), error, callbacks);
|
||||
p.waitFor(3, TimeUnit.MINUTES);
|
||||
} catch (IOException e) {
|
||||
callbacks.log("IOError: " + e);
|
||||
callbacks.log("IOError: " + e, true);
|
||||
callbacks.error();
|
||||
} catch (InterruptedException e) {
|
||||
callbacks.log("WaitError: " + e);
|
||||
callbacks.log("WaitError: " + e, true);
|
||||
callbacks.error();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ public class MaintenanceUtil {
|
|||
StringBuffer output = new StringBuffer();
|
||||
StringBuffer error = new StringBuffer();
|
||||
ExecHelper.executeCommand(queryCommand, callbacks, output, error, null);
|
||||
callbacks.log(output.toString());
|
||||
callbacks.log(error.toString());
|
||||
callbacks.log(output.toString(), true);
|
||||
callbacks.log(error.toString(), true);
|
||||
// long cost = System.currentTimeMillis() - now;
|
||||
// System.out.println("DFU lookup cost " + cost + "ms");
|
||||
return output.toString().contains(pattern);
|
||||
|
|
|
@ -156,10 +156,10 @@ public class ProgramSelector {
|
|||
try {
|
||||
OpenbltJni.flashCan(FindFileHelper.findSrecFile(), cb);
|
||||
|
||||
callbacks.log("Update completed successfully!");
|
||||
callbacks.log("Update completed successfully!", true);
|
||||
callbacks.done();
|
||||
} catch (Throwable e) {
|
||||
callbacks.log("Error: " + e);
|
||||
callbacks.log("Error: " + e, true);
|
||||
callbacks.error();
|
||||
} finally {
|
||||
OpenbltJni.stop(cb);
|
||||
|
@ -178,10 +178,10 @@ public class ProgramSelector {
|
|||
|
||||
// Check that the ECU disappeared from the "after" list
|
||||
if (!PortDetector.AUTO.equals(ecuPort) && Arrays.stream(portsAfter).anyMatch(ecuPort::equals)) {
|
||||
callbacks.log("Looks like your ECU didn't reboot to OpenBLT fast enough");
|
||||
callbacks.log("");
|
||||
callbacks.log("Try closing and opening console again");
|
||||
callbacks.log("");
|
||||
callbacks.log("Looks like your ECU didn't reboot to OpenBLT fast enough", true);
|
||||
callbacks.log("", true);
|
||||
callbacks.log("Try closing and opening console again", true);
|
||||
callbacks.log("", true);
|
||||
callbacks.error();
|
||||
return;
|
||||
}
|
||||
|
@ -196,21 +196,21 @@ public class ProgramSelector {
|
|||
}
|
||||
|
||||
if (newItems.isEmpty()) {
|
||||
callbacks.log("Looks like your ECU disappeared during the update process. Please try again.");
|
||||
callbacks.log("Looks like your ECU disappeared during the update process. Please try again.", true);
|
||||
callbacks.error();
|
||||
return;
|
||||
}
|
||||
|
||||
if (newItems.size() > 1) {
|
||||
// More than one port appeared? whattt?
|
||||
callbacks.log("Unable to find ECU after reboot as multiple serial ports appeared. Before: " + portsBefore.length + " After: " + portsAfter.length);
|
||||
callbacks.log("Unable to find ECU after reboot as multiple serial ports appeared. Before: " + portsBefore.length + " After: " + portsAfter.length, true);
|
||||
callbacks.error();
|
||||
return;
|
||||
}
|
||||
|
||||
String openbltPort = newItems.get(0);
|
||||
|
||||
callbacks.log("Serial port " + openbltPort + " appeared, programming firmware...");
|
||||
callbacks.log("Serial port " + openbltPort + " appeared, programming firmware...", true);
|
||||
|
||||
flashOpenbltSerialJni(parent, openbltPort, callbacks);
|
||||
}
|
||||
|
@ -219,12 +219,12 @@ public class ProgramSelector {
|
|||
return new OpenbltJni.OpenbltCallbacks() {
|
||||
@Override
|
||||
public void log(String line) {
|
||||
callbacks.log(line);
|
||||
callbacks.log(line, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(int percent) {
|
||||
callbacks.log("Progress: " + percent + "%");
|
||||
callbacks.log("Progress: " + percent + "%", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -234,7 +234,7 @@ public class ProgramSelector {
|
|||
|
||||
@Override
|
||||
public void setPhase(String title, boolean hasProgress) {
|
||||
callbacks.log("Phase: " + title);
|
||||
callbacks.log("Phase: " + title, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -254,13 +254,13 @@ public class ProgramSelector {
|
|||
|
||||
try {
|
||||
String fileName = FindFileHelper.findSrecFile();
|
||||
callbacks.log("flashSerial " + fileName);
|
||||
callbacks.log("flashSerial " + fileName, true);
|
||||
OpenbltJni.flashSerial(fileName, port, cb);
|
||||
|
||||
callbacks.log("Update completed successfully!");
|
||||
callbacks.log("Update completed successfully!", true);
|
||||
callbacks.done();
|
||||
} catch (Throwable e) {
|
||||
callbacks.log("Error: " + e.toString());
|
||||
callbacks.log("Error: " + e.toString(), true);
|
||||
callbacks.error();
|
||||
} finally {
|
||||
OpenbltJni.stop(cb);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class StLinkFlasher {
|
|||
|
||||
private static void doFlashFirmware(StatusWindow wnd, String fileName) {
|
||||
if (!new File(fileName).exists()) {
|
||||
wnd.append(fileName + " not found, cannot proceed !!!");
|
||||
wnd.append(fileName + " not found, cannot proceed !!!", true);
|
||||
wnd.setStatus("ERROR");
|
||||
return;
|
||||
}
|
||||
|
@ -76,18 +76,18 @@ public class StLinkFlasher {
|
|||
fileName +
|
||||
" verify reset exit 0x08000000\"", wnd);
|
||||
} catch (FileNotFoundException e) {
|
||||
wnd.append(e.toString());
|
||||
wnd.append(e.toString(), true);
|
||||
wnd.error();
|
||||
return;
|
||||
}
|
||||
if (error.contains(SUCCESS_MESSAGE_TAG) && !error.toLowerCase().contains(FAILED_MESSAGE_TAG)) {
|
||||
wnd.append("Flashing looks good!");
|
||||
wnd.append("Flashing looks good!", true);
|
||||
sa.stop();
|
||||
wnd.setStatus(DONE);
|
||||
wnd.setSuccessState();
|
||||
} else {
|
||||
wnd.setErrorState();
|
||||
wnd.append("!!! FIRMWARE FLASH: DOES NOT LOOK RIGHT !!!");
|
||||
wnd.append("!!! FIRMWARE FLASH: DOES NOT LOOK RIGHT !!!", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ public class UpdateStatusWindow extends StatusWindow implements UpdateOperationC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
append(message);
|
||||
public void log(final String message, final boolean breakLineOnTextArea) {
|
||||
append(message, breakLineOnTextArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,9 +15,9 @@ public class CANConnectorStartup {
|
|||
|
||||
String signature = BinaryProtocol.getSignature(tsStream);
|
||||
if (signature == null) {
|
||||
statusListener.append("Error: no ECU signature from " + tsStream);
|
||||
statusListener.append("Error: no ECU signature from " + tsStream, true);
|
||||
} else {
|
||||
statusListener.append("Got [" + signature + "] ECU signature via " + tsStream);
|
||||
statusListener.append("Got [" + signature + "] ECU signature via " + tsStream, true);
|
||||
}
|
||||
BinaryProtocolProxy.createProxy(tsStream, TcpConnector.DEFAULT_PORT, BinaryProtocolProxy.ClientApplicationActivityListener.VOID, statusListener);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ConsoleTools {
|
|||
private static final StatusConsumer statusListener = new StatusConsumer() {
|
||||
final Logging log = getLogging(CANConnectorStartup.class);
|
||||
@Override
|
||||
public void append(String message) {
|
||||
public void append(final String message, final boolean breakLineOnTextArea) {
|
||||
log.info(message);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -24,9 +24,13 @@ public class PcanConnectorUI {
|
|||
JTextArea logTextArea = new JTextArea();
|
||||
panel.add(logTextArea, BorderLayout.CENTER);
|
||||
|
||||
StatusConsumer statusConsumer = string -> SwingUtilities.invokeLater(() -> {
|
||||
StatusConsumer statusConsumer = (string, breakLineOnTextArea) -> SwingUtilities.invokeLater(() -> {
|
||||
log.info(string);
|
||||
logTextArea.append(string + "\r\n");
|
||||
String stringForTextArea = string;
|
||||
if (breakLineOnTextArea) {
|
||||
stringForTextArea += "\r\n";
|
||||
}
|
||||
logTextArea.append(stringForTextArea);
|
||||
UiUtils.trueLayout(logTextArea);
|
||||
});
|
||||
|
||||
|
@ -36,7 +40,7 @@ public class PcanConnectorUI {
|
|||
if (stream != null)
|
||||
CANConnectorStartup.start(stream, statusConsumer);
|
||||
} catch (IOException e) {
|
||||
statusConsumer.append("Error " + e);
|
||||
statusConsumer.append("Error " + e, true);
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ public class StatusWindow implements StatusConsumer, UpdateOperationCallbacks {
|
|||
content.add(messagesScroll, BorderLayout.CENTER);
|
||||
content.add(bottomStatusLabel, BorderLayout.SOUTH);
|
||||
|
||||
append("Console version " + rusEFIVersion.CONSOLE_VERSION);
|
||||
append("Windows " + System.getProperty("os.version"));
|
||||
append("Bundle " + BundleUtil.readBundleFullNameNotNull());
|
||||
append("Console version " + rusEFIVersion.CONSOLE_VERSION, true);
|
||||
append("Windows " + System.getProperty("os.version"), true);
|
||||
append("Bundle " + BundleUtil.readBundleFullNameNotNull(), true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -62,9 +62,8 @@ public class StatusWindow implements StatusConsumer, UpdateOperationCallbacks {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
append(message);
|
||||
|
||||
public void log(final String message, final boolean breakLineOnTextArea) {
|
||||
append(message, breakLineOnTextArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,12 +93,16 @@ public class StatusWindow implements StatusConsumer, UpdateOperationCallbacks {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void append(final String string) {
|
||||
public void append(final String string, final boolean breakLineOnTextArea) {
|
||||
// todo: check if AWT thread and do not invokeLater if already on AWT thread
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
String s = string.replaceAll(Character.toString((char) 219), "");
|
||||
log.info(s);
|
||||
logTextArea.append(s + "\r\n");
|
||||
String stringForTestArea = s;
|
||||
if (breakLineOnTextArea) {
|
||||
stringForTestArea += "\r\n";
|
||||
}
|
||||
logTextArea.append(stringForTestArea);
|
||||
UiUtils.trueLayout(logTextArea);
|
||||
});
|
||||
}
|
||||
|
@ -110,7 +113,7 @@ public class StatusWindow implements StatusConsumer, UpdateOperationCallbacks {
|
|||
SwingUtilities.invokeLater(() -> Toolkit.getDefaultToolkit().getSystemClipboard()
|
||||
.setContents(new StringSelection(logTextArea.getText()), null));
|
||||
|
||||
append("hint: error state is already in your clipboard, please use PASTE or Ctrl-V while reporting issues");
|
||||
append("hint: error state is already in your clipboard, please use PASTE or Ctrl-V while reporting issues", true);
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
|
|
Loading…
Reference in New Issue