/*
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
*/
|
package com.megatim.fdxgenerator;
|
|
/**
|
* https://github.com/vinumeris/updatefx
|
* @author STEPHANIE
|
*/
|
public class AppUpdate {
|
//
|
// private static java.util.logging.Logger logger;
|
// private static final Logger log = LoggerFactory.getLogger(App.class);
|
// public static int VERSION = 1;
|
// private static final String APP_NAME = "generateur";
|
//
|
// @Override
|
// public void start(Stage primaryStage) throws FileNotFoundException, MalformedURLException, IOException {
|
// // For some reason the JavaFX launch process results in us losing the thread context class loader: reset it.
|
// Thread.currentThread().setContextClassLoader(App.class.getClassLoader());
|
// // Must be done twice for the times when we come here via realMain.
|
// AppDirectory.initAppDir(APP_NAME);
|
//
|
// log.info("Hello World! This is version " + VERSION);
|
//
|
// // ProgressIndicator indicator = showGiantProgressWheel(primaryStage);
|
//
|
// List<ECPoint> pubkeys = Crypto.decode();
|
//
|
// Updater updater = new Updater(URI.create("http://localhost:8080/generateur-updates/index"), "generation-typefichier-" + VERSION,
|
// AppDirectory.dir(), UpdateFX.findCodePath(App.class), pubkeys, 0) {
|
// @Override
|
// protected void updateProgress(long workDone, long max) {
|
// super.updateProgress(workDone, max);
|
// // Give UI a chance to show.
|
// Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
|
// }
|
// };
|
//
|
// FXMLLoader loader = new FXMLLoader();
|
// loader.setLocation(MainController.class.getResource("main.fxml"));
|
// Parent root = loader.load();
|
// MainController controller = loader.getController();
|
//
|
// ProgressIndicator indicator = controller.getIndicator();
|
// indicator.progressProperty().bind(updater.progressProperty());
|
// Label label = controller.getLabelVersion();
|
//
|
//
|
// log.info("Checking for updates!");
|
// updater.setOnRunning(event -> {
|
// label.setText("Mise à jour en cours");
|
// });
|
// updater.setOnSucceeded(event -> {
|
// try {
|
// UpdateSummary summary = updater.get();
|
// Updates updates = summary.updates;
|
// int count = updates.getUpdatesCount();
|
//
|
// if (!summary.descriptions.isEmpty()) {
|
// log.info("One liner: {}", summary.descriptions.get(0).getOneLiner());
|
// log.info("{}", summary.descriptions.get(0).getDescription());
|
// }
|
// if (summary.highestVersion > VERSION) {
|
// int nb = summary.highestVersion - VERSION;
|
// log.info("Restarting to get version " + summary.highestVersion);
|
// label.setText("Nombre de mise à jour trouvé : " + nb);
|
// if (UpdateFX.getVersionPin(AppDirectory.dir()) == 0) {
|
// log.info("before restartApp()");
|
// UpdateFX.restartApp();
|
// }
|
// } else {
|
// label.setVisible(false);
|
// indicator.setVisible(false);
|
// }
|
// } catch (Throwable e) {
|
// log.error("oops", e);
|
// }
|
// });
|
// updater.setOnFailed(event -> {
|
// label.setVisible(false);
|
// indicator.setVisible(false);
|
//
|
// log.error("Update error: {}", updater.getException());
|
// updater.getException().getMessage();
|
// updater.getException().printStackTrace();
|
// });
|
//
|
// indicator.setOnMouseClicked(ev -> UpdateFX.restartApp());
|
//
|
// new Thread(updater, "UpdateFX Thread").start();
|
//
|
// AbstractViewContext.getInstance().setAbstractEditDialogControllerURL(App.class.getResource("/generation/validateur/typefichier/abstracts/AbstractEditDialog.fxml"));
|
//
|
//
|
//
|
// Scene scene = new Scene(root, 1100, 600);
|
//
|
// primaryStage.setTitle("Générateur de fichiers de validation");
|
// primaryStage.getIcons().add(new Image("images/icone_ins.png"));
|
// primaryStage.setScene(scene);
|
// primaryStage.setOnCloseRequest(e -> {
|
// HibernateUtil.shutdown();
|
// System.exit(0);
|
// });
|
// primaryStage.show();
|
// }
|
//
|
// /**
|
// * @param args the command line arguments
|
// */
|
// public static void main(String[] args) throws IOException {
|
// // We want to store updates in our app dir so must init that here.
|
// AppDirectory.initAppDir(APP_NAME);
|
// setupLogging();
|
// // re-enter at realMain, but possibly running a newer version of the software i.e. after this point the
|
// // rest of this code may be ignored.
|
// UpdateFX.bootstrap(App.class, AppDirectory.dir(), args);
|
//
|
// String appId = "generation.validateur.typefichier.App";
|
// boolean alreadyRunning;
|
// try {
|
// JUnique.acquireLock(appId);
|
// alreadyRunning = false;
|
// } catch (AlreadyLockedException e) {
|
// alreadyRunning = true;
|
// }
|
// if (!alreadyRunning) {
|
// launch(args);
|
// } else {
|
// System.exit(1);
|
// }
|
// }
|
//
|
// public static void realMain(String[] args) {
|
// launch(args);
|
// }
|
//
|
// private static void setupLogging() throws IOException {
|
// logger = java.util.logging.Logger.getLogger("");
|
// logger.getHandlers()[0].setFormatter(new BriefLogFormatter());
|
// FileHandler handler = new FileHandler(AppDirectory.dir().resolve("log.txt").toString(), true);
|
// handler.setFormatter(new BriefLogFormatter());
|
// logger.addHandler(handler);
|
// }
|
//
|
// private ProgressIndicator showGiantProgressWheel(Stage stage) {
|
// ProgressIndicator indicator = new ProgressIndicator();
|
// BorderPane borderPane = new BorderPane(indicator);
|
// borderPane.setMinWidth(640);
|
// borderPane.setMinHeight(480);
|
// Button pinButton = new Button();
|
// pinButton.setText("Pin to version "+VERSION);
|
// pinButton.setOnAction(event -> {
|
// UpdateFX.pinToVersion(AppDirectory.dir(), VERSION);
|
// UpdateFX.restartApp();
|
// });
|
// HBox box = new HBox(new Label("Version " + VERSION), pinButton);
|
// box.setSpacing(10);
|
// box.setAlignment(Pos.CENTER_LEFT);
|
// box.setPadding(new Insets(10));
|
// borderPane.setTop(box);
|
// Scene scene = new Scene(borderPane);
|
// stage.setScene(scene);
|
//
|
// return indicator;
|
// }
|
//
|
// private ProgressIndicator showGiantProgressWheel(MainController controller) {
|
// ProgressIndicator indicator = controller.getIndicator();
|
//
|
// Label label = controller.getLabelVersion();
|
// label.setText("Version "+VERSION);
|
//
|
// return indicator;
|
// }
|
}
|