@Override
public void start(final Stage stage) throws Exception {
try {
log.debug("Starting GUI...");
RS.img(stage);
notifyPreloader(new ProgressNotification(0.1d));
stage.setTitle(RS.rbLabel(KEY.APP_TITLE));
log.debug("Iniitializing Services...");
notifyPreloader(new ProgressNotification(0.2d));
initServices();
if (initErrors != null && initErrors.length() > 0) {
final TextArea errorDetails = TextAreaBuilder.create().text(initErrors.toString()).wrapText(true
).focusTraversable(false).editable(false).opacity(0.7d).build();
if (initErrorHeader == null) {
initErrorHeader = RS.rbLabel(KEY.APP_TITLE_ERROR);
}
final GuiUtil.DialogService dialogService = GuiUtil.dialogService(stage, KEY.APP_TITLE, initErrorHeader,
KEY.CLOSE, 550d, 300d, new Service<Void>() {
@Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
// if the dialog shouldn't be closed call super.cancel()
return null;
}
};
}
}, null, errorDetails);
dialogService.getStage().addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>() {
@Override
public void handle(final WindowEvent event) {
notifyPreloader(new ProgressNotification(1d));
dialogService.getStage().removeEventHandler(WindowEvent.WINDOW_SHOWN, this);
}
});
notifyPreloader(new ProgressNotification(0.5d));
dialogService.start();
notifyPreloader(new StateChangeNotification(
StateChangeNotification.Type.BEFORE_START));
notifyPreloader(new ProgressNotification(0.75d));
} else {
// start the main GUI
primaryStageStart(stage);
}