public static void estimateKeyDerivationTime() {
   // This is run in the background after startup. If we haven't recorded it before, do a key
   // derivation to see
   // how long it takes. This helps us produce better progress feedback, as on Windows we don't
   // currently have a
   // native Scrypt impl and the Java version is ~3 times slower, plus it depends a lot on CPU
   // speed.
   checkGuiThread();
   estimatedKeyDerivationTime = Main.instance.prefs.getExpectedKeyDerivationTime();
   if (estimatedKeyDerivationTime == null) {
     new Thread(
             () -> {
               log.info("Doing background test key derivation");
               KeyCrypterScrypt scrypt = new KeyCrypterScrypt(SCRYPT_PARAMETERS);
               long start = System.currentTimeMillis();
               scrypt.deriveKey("test password");
               long msec = System.currentTimeMillis() - start;
               log.info("Background test key derivation took {}msec", msec);
               Platform.runLater(
                   () -> {
                     estimatedKeyDerivationTime = Duration.ofMillis(msec);
                     Main.instance.prefs.setExpectedKeyDerivationTime(estimatedKeyDerivationTime);
                   });
             })
         .start();
   }
 }
Esempio n. 2
0
  public static void showError(String message, Throwable t) {
    LOG.log(Level.SEVERE, "Сообщение: " + message, t);

    StringBuilder s = new StringBuilder(message).append('\n');
    s.append(t.getClass().getName()).append(": ").append(t.getLocalizedMessage());
    for (StackTraceElement e : t.getStackTrace()) {
      String line = e.toString();
      if (line.startsWith("my")) {
        s.append("\n    ").append(line);
      }
    }
    Alert alert = new Alert(Alert.AlertType.ERROR, s.toString(), ButtonType.OK);
    alert.showAndWait();
  }
Esempio n. 3
0
  @Override
  public void start(Stage primaryStage) {
    try {
      TabPane page = (TabPane) FXMLLoader.load(Main.class.getResource("simple.fxml"));
      Scene scene = new Scene(page);
      primaryStage.setScene(scene);
      primaryStage.setTitle("Hotels");
      primaryStage.show();

      textf = (TextField) scene.lookup("#HotelNameTextb");
      Button create = (Button) scene.lookup("#CreateButton");
      create.setOnAction(this::handleButtonAction);

    } catch (Exception ex) {
      Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Esempio n. 4
0
/** @author Sergey Stishenko <*****@*****.**> */
public class MainFX extends Application {

  private static final Logger LOG = Logger.getLogger(MainFX.class.getName());

  @Override
  public void start(Stage stage) {
    stage.setScene(new MainScene(stage));
    stage.setTitle("Мой бюджет");
    stage.show();
  }

  public static void showMessage(String message) {
    LOG.log(Level.SEVERE, "Сообщение: {0}", message);

    Alert alert = new Alert(Alert.AlertType.INFORMATION, message, ButtonType.OK);
    alert.showAndWait();
  }

  public static void showError(String message, Throwable t) {
    LOG.log(Level.SEVERE, "Сообщение: " + message, t);

    StringBuilder s = new StringBuilder(message).append('\n');
    s.append(t.getClass().getName()).append(": ").append(t.getLocalizedMessage());
    for (StackTraceElement e : t.getStackTrace()) {
      String line = e.toString();
      if (line.startsWith("my")) {
        s.append("\n    ").append(line);
      }
    }
    Alert alert = new Alert(Alert.AlertType.ERROR, s.toString(), ButtonType.OK);
    alert.showAndWait();
  }

  public static void main(String[] args) {
    Application.launch(MainFX.class, args);
  }
}
Esempio n. 5
0
  public static void showMessage(String message) {
    LOG.log(Level.SEVERE, "Сообщение: {0}", message);

    Alert alert = new Alert(Alert.AlertType.INFORMATION, message, ButtonType.OK);
    alert.showAndWait();
  }