mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Add setupStage and setDatabaseCorruptionHandler methods
This commit is contained in:
parent
8a266b16bb
commit
101365aef6
1 changed files with 56 additions and 46 deletions
|
@ -175,55 +175,12 @@ public class BisqApp extends Application {
|
|||
if (Utilities.isLinux())
|
||||
System.setProperty("prism.lcdtext", "false");
|
||||
|
||||
Storage.setDatabaseCorruptionHandler((String fileName) -> {
|
||||
corruptedDatabaseFiles.add(fileName);
|
||||
if (mainView != null)
|
||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||
});
|
||||
setupStage();
|
||||
|
||||
// load the main view and create the main scene
|
||||
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
|
||||
mainView = (MainView) viewLoader.load(MainView.class);
|
||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||
|
||||
scene = new Scene(mainView.getRoot(), INITIAL_SCENE_WIDTH, INITIAL_SCENE_HEIGHT);
|
||||
|
||||
scene.getStylesheets().setAll(
|
||||
"/bisq/desktop/bisq.css",
|
||||
"/bisq/desktop/images.css",
|
||||
"/bisq/desktop/CandleStickChart.css");
|
||||
|
||||
// configure the system tray
|
||||
SystemTray.create(primaryStage, shutDownHandler);
|
||||
|
||||
primaryStage.setOnCloseRequest(event -> {
|
||||
event.consume();
|
||||
stop();
|
||||
});
|
||||
addSceneKeyEventHandler();
|
||||
|
||||
// configure the primary stage
|
||||
primaryStage.setTitle(bisqEnvironment.getRequiredProperty(AppOptionKeys.APP_NAME_KEY));
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setMinWidth(1020);
|
||||
primaryStage.setMinHeight(620);
|
||||
|
||||
// on windows the title icon is also used as task bar icon in a larger size
|
||||
// on Linux no title icon is supported but also a large task bar icon is derived from that title icon
|
||||
String iconPath;
|
||||
if (Utilities.isOSX())
|
||||
iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png";
|
||||
else if (Utilities.isWindows())
|
||||
iconPath = "/images/task_bar_icon_windows.png";
|
||||
else
|
||||
iconPath = "/images/task_bar_icon_linux.png";
|
||||
|
||||
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));
|
||||
|
||||
// make the UI visible
|
||||
primaryStage.show();
|
||||
setDatabaseCorruptionHandler(mainView);
|
||||
|
||||
checkForCorrectOSArchitecture();
|
||||
|
||||
UserThread.runPeriodically(() -> Profiler.printSystemLoad(log), LOG_MEMORY_PERIOD_MIN, TimeUnit.MINUTES);
|
||||
} catch (Throwable throwable) {
|
||||
log.error("Error during app init", throwable);
|
||||
|
@ -231,6 +188,59 @@ public class BisqApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
private void setupStage() {
|
||||
// load the main view and create the main scene
|
||||
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
|
||||
mainView = (MainView) viewLoader.load(MainView.class);
|
||||
|
||||
|
||||
scene = new Scene(mainView.getRoot(), INITIAL_SCENE_WIDTH, INITIAL_SCENE_HEIGHT);
|
||||
|
||||
scene.getStylesheets().setAll(
|
||||
"/bisq/desktop/bisq.css",
|
||||
"/bisq/desktop/images.css",
|
||||
"/bisq/desktop/CandleStickChart.css");
|
||||
|
||||
// configure the system tray
|
||||
SystemTray.create(primaryStage, shutDownHandler);
|
||||
|
||||
primaryStage.setOnCloseRequest(event -> {
|
||||
event.consume();
|
||||
stop();
|
||||
});
|
||||
addSceneKeyEventHandler();
|
||||
|
||||
// configure the primary stage
|
||||
primaryStage.setTitle(bisqEnvironment.getRequiredProperty(AppOptionKeys.APP_NAME_KEY));
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setMinWidth(1020);
|
||||
primaryStage.setMinHeight(620);
|
||||
|
||||
// on windows the title icon is also used as task bar icon in a larger size
|
||||
// on Linux no title icon is supported but also a large task bar icon is derived from that title icon
|
||||
String iconPath;
|
||||
if (Utilities.isOSX())
|
||||
iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png";
|
||||
else if (Utilities.isWindows())
|
||||
iconPath = "/images/task_bar_icon_windows.png";
|
||||
else
|
||||
iconPath = "/images/task_bar_icon_linux.png";
|
||||
|
||||
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));
|
||||
|
||||
// make the UI visible
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
private void setDatabaseCorruptionHandler(MainView mainView) {
|
||||
Storage.setDatabaseCorruptionHandler((String fileName) -> {
|
||||
corruptedDatabaseFiles.add(fileName);
|
||||
if (mainView != null)
|
||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||
});
|
||||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||
}
|
||||
|
||||
|
||||
private void addSceneKeyEventHandler() {
|
||||
scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> {
|
||||
|
|
Loading…
Add table
Reference in a new issue