Esempio n. 1
0
  @Override
  public void duringSave(Void model) {
    List<EntityExportSource<? extends AbstractPersistentObject>> entityExportSources =
        PersistentWork.read(
            em -> {
              @SuppressWarnings("unchecked")
              List<Class<? extends AbstractPersistentObject>> entityClasses =
                  em.getEntityManagerFactory()
                      .getMetamodel()
                      .getEntities()
                      .stream()
                      .map(e -> (Class<? extends AbstractPersistentObject>) e.getJavaType())
                      .collect(Collectors.toList());
              List<EntityExportSource<? extends AbstractPersistentObject>> exportSources =
                  entityClasses
                      .stream()
                      .map(c -> new EntityExportSource<>(PersistentWork.idsFrom(c), c))
                      .collect(Collectors.toList());
              return exportSources;
            });

    XlsxExporter exporter = new XlsxExporter(controller.getExecutorService());

    File file = exportFile.get();
    try {
      if (file.exists()) {
        log.info("Deleting existing file {}", file);
        file.delete();
      }
      Files.createDirectories(file.toPath());
      file.createNewFile();
    } catch (IOException e) {
      log.error("Could not create file {}", file, e);
    }
    List<EntityExportSource<?>> bla = entityExportSources;
    exporter.export(file, bla);

    controller
        .getJavaFXExecutor()
        .submit(
            () -> {
              Dialogs.create()
                  .message(Localized.get("export.successfully", file))
                  .showInformation();
              if (openAfterExport.isSelected()) {
                controller
                    .getExecutorService()
                    .submit(
                        () -> {
                          try {
                            desktop.edit(file);
                          } catch (IOException e) {
                            log.error("Could not open {}", file, e);
                          }
                        });
              }
            });
  }
  @FXML
  private void sendRound() {
    if (answerForQuestion.size() != currentPlayingRound.get().getAmountOfQuestions()) {
      messageMaker.showWarning("niet alle vragen zijn ingevuld");
      return;
    }

    send(questionsForRound.get(currentPlayingRound.get()));

    // de huidige ronde verwijderen
    questionsForRound.remove(currentPlayingRound.get());
    if (questionsForRound.isEmpty()) {
      currentPlayingRound.set(null);
    } else {
      for (RoundSubmit s : questionsForRound.keySet()) {
        currentPlayingRound.set(s);
        break;
      }
    }
  }
  private void updateButtonStates() {
    Platform.runLater(
        () -> {
          final Account account = selectedAccountProperty.get();

          if (account != null) {
            final int count = account.getTransactionCount();

            deleteButton.setDisable(count > 0 || account.getChildCount() > 0);
            reconcileButton.setDisable(count <= 0);
            zoomButton.setDisable(account.isPlaceHolder());
          } else {
            deleteButton.setDisable(true);
            reconcileButton.setDisable(true);
            zoomButton.setDisable(true);
          }
        });
  }
 @FXML
 private void handleZoomAccountAction() {
   RegisterStage.getRegisterStage(selectedAccountProperty.get()).show();
 }