@FXML
  private void initialize() {
    deleteButton.setDisable(true);
    reconcileButton.setDisable(true);

    initializeTreeTableView();

    Platform.runLater(this::loadAccountTree);

    MessageBus.getInstance()
        .registerListener(
            this, MessageChannel.SYSTEM, MessageChannel.ACCOUNT, MessageChannel.TRANSACTION);

    // Register invalidation listeners to force a reload
    typeFilter.addListener(observable -> reload());

    selectedAccountProperty.addListener(
        (observable, oldValue, newValue) -> {
          updateButtonStates();
        });

    modifyButton.disableProperty().bind(selectedAccountProperty.isNull());

    AccountBalanceDisplayManager.getAccountBalanceDisplayModeProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              treeTableView.refresh();
            });
  }
  private void initBindings() {
    // zorgen dat de content van de scrollpane de juiste brete aanhoud
    quizPane.prefWidthProperty().bind(questionScroll.widthProperty().add(-5));
    // wrappings zetten
    openQuestionText.wrappingWidthProperty().bind(openQuestionVbox.widthProperty().add(-20));
    multipleChoiceText.wrappingWidthProperty().bind(multipleChoiseVbox.widthProperty().add(-20));
    imageQuestionText.wrappingWidthProperty().bind(imageQuestionVbox.widthProperty().add(-20));

    questionListener =
        new ListChangeListener<QuestionSubmit>() {
          @Override
          public void onChanged(
              javafx.collections.ListChangeListener.Change<? extends QuestionSubmit> c) {
            for (QuestionSubmit s : c.getList()) {
              if (!questionForPane.values().contains(s)) {
                TitledPane p = new TitledPane(s.getQuestion(), new AnchorPane());
                questionAccordion.getPanes().add(p);
                questionForPane.put(p, s);
              }
            }
          }
        };

    questionAccordion
        .expandedPaneProperty()
        .addListener(
            new ChangeListener<TitledPane>() {
              @Override
              public void changed(
                  ObservableValue<? extends TitledPane> observable,
                  TitledPane oldValue,
                  TitledPane newValue) {
                if (oldValue != null) {
                  ((AnchorPane) oldValue.getContent()).getChildren().clear();
                }
                if (newValue != null) {
                  createQuestionFor(newValue);
                }
              }
            });

    currentPlayingRound.addListener(
        new ChangeListener<RoundSubmit>() {
          @Override
          public void changed(
              ObservableValue<? extends RoundSubmit> observable,
              RoundSubmit oldValue,
              RoundSubmit newValue) {
            removeRound(oldValue);
            setRound(newValue);
          }
        });

    quizPane.visibleProperty().bind(currentPlayingRound.isNotNull());
  }
  @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);
                          }
                        });
              }
            });
  }
  private void installListeners() {
    treeTableView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue != null) {
                selectedAccountProperty.setValue(newValue.getValue());
              } else {
                selectedAccountProperty.setValue(null);
              }
            });

    for (final TreeTableColumn<?, ?> treeTableColumn : treeTableView.getColumns()) {
      treeTableColumn
          .visibleProperty()
          .addListener((observable, oldValue, newValue) -> saveColumnVisibility());
    }
  }
  @FXML
  void showFileChooser() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialFileName("export");
    fileChooser.setSelectedExtensionFilter(
        new FileChooser.ExtensionFilter("export to excel", ".xlsx"));

    File file = fileChooser.showOpenDialog(exportBtn.getScene().getWindow());
    exportFile.set(file);
  }
  @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);
          }
        });
  }
Exemple #8
0
  static {
    preferences = Preferences.userNodeForPackage(ThemeManager.class);

    final StringProperty _baseColorProperty = new SimpleStringProperty();

    // restore the old value
    fontScaleProperty.set(preferences.getDouble(FONT_SIZE, 1));

    // Save the value when it changes
    fontScaleProperty.addListener(
        (observable, oldValue, newValue) -> {
          if (newValue != null) {
            preferences.putDouble(FONT_SIZE, newValue.doubleValue());
          }
        });

    baseColorProperty.setValue(Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR)));

    // restore the old base color value
    switch (preferences.get(LAST, Application.STYLESHEET_MODENA)) {
      case Application.STYLESHEET_CASPIAN:
        baseColorProperty.setValue(
            Color.web(preferences.get(BASE_COLOR, DEFAULT_CASPIAN_BASE_COLOR)));
        break;
      case Application.STYLESHEET_MODENA:
        baseColorProperty.setValue(
            Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR)));
        break;
      default:
        baseColorProperty.setValue(
            Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR)));
    }

    _baseColorProperty.setValue(colorToHex(baseColorProperty.getValue()));

    // Save the value when it changes
    baseColorProperty.addListener(
        (observable, oldValue, newValue) -> {
          if (newValue != null) {
            preferences.put(BASE_COLOR, colorToHex(newValue));
            _baseColorProperty.setValue(colorToHex(newValue));
          }
        });

    // Create the binding format for the style / font size
    styleProperty =
        Bindings.format(
            "-fx-font-size: %1$.6fem; -fx-base:%2$s", fontScaleProperty, _baseColorProperty);
  }
 @FXML
 private void handleZoomAccountAction() {
   RegisterStage.getRegisterStage(selectedAccountProperty.get()).show();
 }
 private void update(Wallet wallet) {
   balance.set(wallet.getBalance());
   address.set(wallet.currentReceiveAddress());
 }