use of se.light.assembly64.Support.UpgradeOptions in project assembly64fx by freabemania.
the class Main method start.
@Override
public void start(Stage splashStage) {
GlobalRepoService.getInstance().put("main", this);
try {
PlatformInfo platformInfo = platformInfoService.getPlatformInfo(platformInfoService.getPlaformPrefix());
if (platformInfo.isNewerAvailable(version)) {
try {
UpgradeController upgradeDialog = GuiUtils.noShowDialog("upgrade.fxml", true, true, "New version available", splashStage, platformInfo);
upgradeDialog.getStage().showAndWait();
UpgradeOptions upgradeChoice = upgradeDialog.getUpgradeChoice();
if (upgradeChoice == UpgradeOptions.DOWNLOAD) {
this.getHostServices().showDocument("http://hackerswithstyle.ddns.net/assembly/download.html");
ReturningTask<Void> exitWithDelay = () -> {
try {
Thread.sleep(500);
System.exit(1);
} catch (Exception e) {
}
return null;
};
ExecutorUtil.executeAsyncWithRetry(exitWithDelay);
} else if (upgradeChoice == UpgradeOptions.UPGRADE) {
Autoupgrade.getInstance().doUpgrade();
return;
}
} catch (Exception e) {
LOGGER.info("Unable to startup", e);
}
}
} catch (Exception e) {
OfflineController offlineController = (OfflineController) GuiUtils.showDialogBare("assemblyOffline.fxml", "Ooops :-/", new Object[] {});
if (offlineController.openSidify()) {
GuiUtils.showDialog("sidifyMain.fxml", true, "Sidify Heroium", new Object[] { Boolean.FALSE });
return;
} else {
System.exit(1);
}
}
GuiUtils.showDialog("authLogin.fxml", "Login to Assembly", new Object[] {});
List<String> inputParams = getParameters().getRaw();
if (platformInfoService.isWin() && inputParams.size() == 1) {
File f = new File(inputParams.get(0));
if (f.exists()) {
launchViceOrImageView(f);
System.exit(1);
}
}
final Rectangle2D bounds = Screen.getPrimary().getBounds();
maxHeight = bounds.getHeight() - 150;
if (maxHeight > 700) {
maxHeight = 700;
}
try {
// Utils.getInstance().assertFolders();
if (isAppActive()) {
GenericMessageDialogController.withErrorProps("Another instance of", "Assembly64 is already active!").withExitAfterOk().showAndWait();
}
if (localDbService.getLocalDB().containsKey("uid")) {
Analytics.sendEvent("application", "startup_existing_user_" + platformInfoService.getPlaformPrefix());
} else {
Analytics.sendEvent("application", "startup_new_user_" + platformInfoService.getPlaformPrefix());
}
ImageView splash = new ImageView(new Image(getClass().getResourceAsStream("image-assemblysplash.png")));
splashLayout = new VBox();
splashLayout.getChildren().addAll(splash);
Scene splashScene = new Scene(splashLayout, Color.TRANSPARENT);
splashStage.setScene(splashScene);
splashStage.setX(bounds.getMinX() + bounds.getWidth() / 2 - SPLASH_WIDTH / 2);
splashStage.setY(bounds.getMinY() + bounds.getHeight() / 2 - SPLASH_HEIGHT / 2);
splashStage.initStyle(StageStyle.TRANSPARENT);
splashStage.setAlwaysOnTop(true);
splashStage.show();
ExecutorUtil.executeAsyncWithRetry(() -> {
try {
artifactsService.updateChecksumInPrivateFolder();
} catch (Exception e) {
LOGGER.error("Unable to update checksum", e);
}
return null;
}, 5);
ExecutorUtil.executeAsyncWithRetry(() -> {
try {
artifactsService.getArtifactsDb();
refreshedArtifacts.set(true);
} catch (Exception e) {
LOGGER.error("Unable to get artifacts", e);
Thread.sleep(1000);
throw e;
}
return null;
}, 5);
ReturningTask<Void> continueTask = () -> {
int retries = 0;
while (retries < 5) {
Thread.sleep(2000);
if (refreshedArtifacts.get() == Boolean.TRUE) {
LOGGER.info("Got artifacts from server, ok to start");
break;
}
retries++;
}
if (refreshedArtifacts.get() == Boolean.FALSE) {
Platform.runLater(() -> {
splashStage.close();
});
Platform.runLater(() -> {
GuiUtils.showDialog("assemblyOffline.fxml", "Ooops :-/", new Object[] {});
try {
Thread.sleep(10000);
} catch (Exception e) {
// TODO Auto-generated catch block
}
});
} else {
FadeTransition fadeSplash2 = new FadeTransition(Duration.seconds(0.7), splashLayout);
fadeSplash2.setFromValue(1.0);
fadeSplash2.setToValue(0.0);
fadeSplash2.setOnFinished(actionEvent -> {
splashStage.hide();
viewPrimary();
});
fadeSplash2.play();
// }
}
return null;
};
ExecutorUtil.executeAsyncWithRetry(continueTask);
} catch (Exception e) {
GenericMessageDialogController.withErrorProps("Error", "Error when starting Assembly").withExitAfterOk().showAndWait();
}
}
Aggregations