Update HelpTab.java
This commit is contained in:
parent
f16d2991df
commit
5c89e9e1bc
|
@ -1,7 +1,6 @@
|
||||||
package ctbrec.ui.tabs;
|
package ctbrec.ui.tabs;
|
||||||
|
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.OS;
|
|
||||||
import ctbrec.docs.DocServer;
|
import ctbrec.docs.DocServer;
|
||||||
import ctbrec.ui.DesktopIntegration;
|
import ctbrec.ui.DesktopIntegration;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
@ -32,7 +31,6 @@ public class HelpTab extends Tab {
|
||||||
Button openCfg = new Button("Open config dir");
|
Button openCfg = new Button("Open config dir");
|
||||||
openHelp.setPadding(new Insets(20));
|
openHelp.setPadding(new Insets(20));
|
||||||
openLog.setPadding(new Insets(20));
|
openLog.setPadding(new Insets(20));
|
||||||
Label logFilePathLabel = new Label("Log: " + new File("ctbrec.log").getAbsolutePath());
|
|
||||||
openCfg.setPadding(new Insets(20));
|
openCfg.setPadding(new Insets(20));
|
||||||
Label logFilePathLabel = new Label("Log file: " + new File("ctbrec.log").getAbsolutePath());
|
Label logFilePathLabel = new Label("Log file: " + new File("ctbrec.log").getAbsolutePath());
|
||||||
File cfgDir = Config.getInstance().getConfigDir();
|
File cfgDir = Config.getInstance().getConfigDir();
|
||||||
|
@ -81,30 +79,30 @@ public class HelpTab extends Tab {
|
||||||
log.warn("Log file doesn't exist: {}", logFile.getAbsolutePath());
|
log.warn("Log file doesn't exist: {}", logFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
openCfg.setOnAction(e -> {
|
openCfg.setOnAction(e -> {
|
||||||
File configDir = Config.getInstance().getConfigDir();
|
File configDir = Config.getInstance().getConfigDir();
|
||||||
if (configDir.exists()) {
|
if (configDir.exists()) {
|
||||||
try {
|
try {
|
||||||
// Use Runtime.getRuntime().exec() to open the file in a separate process
|
// Use Runtime.getRuntime().exec() to open the file in a separate process
|
||||||
String osName = System.getProperty("os.name").toLowerCase();
|
String osName = System.getProperty("os.name").toLowerCase();
|
||||||
ProcessBuilder pb = null;
|
ProcessBuilder pb = null;
|
||||||
if (osName.contains("mac")) {
|
if (osName.contains("mac")) {
|
||||||
pb = new ProcessBuilder("open", configDir.getAbsolutePath());
|
pb = new ProcessBuilder("open", configDir.getAbsolutePath());
|
||||||
} else if (osName.contains("win")) {
|
} else if (osName.contains("win")) {
|
||||||
pb = new ProcessBuilder("explorer.exe", configDir.getAbsolutePath());
|
pb = new ProcessBuilder("explorer.exe", configDir.getAbsolutePath());
|
||||||
} else { // Assume it's a Unix/Linux system
|
} else { // Assume it's a Unix/Linux system
|
||||||
pb = new ProcessBuilder("xdg-open", configDir.getAbsolutePath());
|
pb = new ProcessBuilder("xdg-open", configDir.getAbsolutePath());
|
||||||
|
}
|
||||||
|
pb.start();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
log.error("Couldn't open config dir", ex);
|
||||||
}
|
}
|
||||||
pb.start();
|
} else {
|
||||||
} catch (IOException ex) {
|
log.warn("Config dir doesn't exist: {}", configDir.getAbsolutePath());
|
||||||
log.error("Couldn't open config dir", ex);
|
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
log.warn("Config dir doesn't exist: {}", configDir.getAbsolutePath());
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
private void startDocumentationServer() {
|
private void startDocumentationServer() {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
|
Loading…
Reference in New Issue