public List<InteractionClassFDD> getInteractions() {
   return interactions
       .stream()
       .filter(a -> a.isOn())
       .map(a -> a.interaction)
       .collect(Collectors.toList());
 }
 @FXML
 public void ok() {
   ObservableList<UITableColumnVO> items = columnListView.getItems();
   if (items != null && items.size() > 0) {
     List<IgnoredColumn> ignoredColumns = new ArrayList<>();
     List<ColumnOverride> columnOverrides = new ArrayList<>();
     items
         .stream()
         .forEach(
             item -> {
               if (!item.getChecked()) {
                 IgnoredColumn ignoredColumn = new IgnoredColumn(item.getColumnName());
                 ignoredColumns.add(ignoredColumn);
               } else if (item.getTypeHandle() != null
                   || item.getJavaType() != null
                   || item.getPropertyName() != null) { // unchecked and have typeHandler value
                 ColumnOverride columnOverride = new ColumnOverride(item.getColumnName());
                 columnOverride.setTypeHandler(item.getTypeHandle());
                 columnOverride.setJavaProperty(item.getPropertyName());
                 columnOverride.setJavaType(item.getJavaType());
                 columnOverrides.add(columnOverride);
               }
             });
     mainUIController.setIgnoredColumns(ignoredColumns);
     mainUIController.setColumnOverrides(columnOverrides);
   }
   getDialogStage().close();
 }
  private void updateSelection() {
    setItems();

    if (updating) return;
    updating = true;

    List<T> availableChoices = items.stream().collect(Collectors.toList());
    for (ChoiceBox<T> comboBox : comboBoxList) {
      if (comboBox.getValue() != null) {
        availableChoices.remove(comboBox.getValue());
      }
    }

    for (ChoiceBox<T> comboBox : comboBoxList) {
      T selectedValue = comboBox.getValue();
      ObservableList<T> items = comboBox.getItems();
      items.setAll(availableChoices);

      if (selectedValue != null) {
        items.add(selectedValue);
        comboBox.setValue(selectedValue);
      }
    }

    updating = false;
  }
Exemplo n.º 4
0
 private ComboBox<String> generateVariableSelector() {
   Set vars = new TreeSet<>();
   actions.stream().map(Action::getVariableNames).forEach(vars::addAll);
   ComboBox<String> box = new ComboBox<>();
   vars.add(DONT_USE);
   box.getItems().addAll(vars);
   return box;
 }
Exemplo n.º 5
0
  @Override
  public void addCommand(FilterInteraction interaction, IUserCommand command) {

    if (interaction == FilterInteraction.UPDATE) {
      interactionMap.put(interaction, command);
      data.stream().forEach(this::notifyUpdateCommand);
    } else {
      interactionMap.put(interaction, command);
    }
  }
  public void setFddObjectModel(FddObjectModel fddObjectModel) {
    logger.entry();
    if (fddObjectModel != null) {
      fddObjectModel
          .getInteractionClasses()
          .values()
          .stream()
          .forEach(
              (value) -> {
                interactions.add(new InteractionState(value));
              });
      InteractionTableView.setItems(interactions);
      interactions.forEach(
          (interaction) -> {
            interaction
                .onProperty()
                .addListener(
                    (observable, oldValue, newValue) -> {
                      if (!newValue) {
                        cb.setSelected(false);
                      } else if (interactions.stream().allMatch(a -> a.isOn())) {
                        cb.setSelected(true);
                      }
                    });
          });
      InteractionTableColumn.setCellValueFactory(new PropertyValueFactory<>("interactionName"));
      CheckTableColumn.setCellValueFactory(
          new Callback<
              TableColumn.CellDataFeatures<InteractionState, Boolean>, ObservableValue<Boolean>>() {
            @Override
            public ObservableValue<Boolean> call(
                TableColumn.CellDataFeatures<InteractionState, Boolean> param) {
              return param.getValue().onProperty();
            }
          });

      CheckTableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(CheckTableColumn));
      cb.setUserData(CheckTableColumn);
      cb.setOnAction(
          (ActionEvent event) -> {
            CheckBox cb1 = (CheckBox) event.getSource();
            TableColumn tc = (TableColumn) cb1.getUserData();
            InteractionTableView.getItems()
                .stream()
                .forEach(
                    (item) -> {
                      item.setOn(cb1.isSelected());
                    });
          });
      CheckTableColumn.setGraphic(cb);
    }
    logger.exit();
  }
 /** Creates and returns data for StackedBarChart from the given pieData. */
 @SuppressWarnings("unchecked")
 private ObservableList<Series<String, Number>> createBarData(ObservableList<Data> pieChartData) {
   ObservableList<Series<String, Number>> data =
       pieChartData
           .stream()
           .map(p -> new XYChart.Data<>("none", (Number) p.getPieValue(), p.getName()))
           .map(
               xy ->
                   new Series<>(
                       (String) xy.getExtraValue(), FXCollections.observableArrayList(xy)))
           .collect(toObservableList())
       //            .collect(Collectors.collectingAndThen(Collectors.toList(),
       // FXCollections::observableArrayList));
       ;
   return data;
 }
Exemplo n.º 8
0
  @FXML
  public void btnSaveOnAction() {
    GuiMain.getWithdrawalsControl()
        .addWithdrawals(
            withdrawals
                .stream()
                .map(
                    with ->
                        new Withdraw(
                            with.getDetails(),
                            with.getValue(),
                            LocalDate.parse(with.getDate()),
                            GuiMain.getAccountControl()
                                .getAccountId(LocalDate.parse(with.getDate()))))
                .collect(Collectors.toList()));

    try {
      GuiMain.getWithdrawalsControl().saveChanges();
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      GuiMain.getAddWithdrawalsWindow().close();
    }
  }
 /**
  * Creates and returns a list of items acceptable by the treeItem. For each item in other we
  * create a TreeItem with that item as value and add the treeItem to the returned list.
  *
  * @param other a list of elements (of arbitrary type)
  * @return a list of TreeItems with their value set to the raw item.
  */
 protected ObservableList<TreeItem> createTreeItems(ObservableList other) {
   ObservableList items = FXCollections.observableArrayList();
   other.stream().forEach(value -> items.add(createItem(value)));
   return items;
 }
Exemplo n.º 10
0
 public static List<Meal> filterMeals(
     ObservableList<Meal> mealActions, Predicate<Meal> predicate) {
   return mealActions.stream().filter(predicate).collect(Collectors.<Meal>toList());
 }
Exemplo n.º 11
0
  public void buildForm() {
    try {
      URL location = getClass().getResource("/com/webfront/app/fxml/LedgerEntryForm.fxml");
      ResourceBundle resources = ResourceBundle.getBundle("com.webfront.app.bank");
      FXMLLoader loader = new FXMLLoader(location, resources);

      btnOk.setDefaultButton(true);
      btnCancel.setCancelButton(true);

      stage = new Stage();
      scene = new Scene(this);
      stage.setScene(scene);
      stage.setTitle("Item Detail");

      loader.setRoot(this);
      loader.setController(this);
      loader.load();

      ObservableList<Category> cList = view.getCategoryManager().getCategories();

      ObservableList<Account> accountList =
          javafx.collections.FXCollections.observableArrayList(Bank.accountList);
      accountList
          .stream()
          .forEach(
              (acct) -> {
                accountNum.getItems().add(acct.getId());
              });

      for (Category c : cList) {
        // Category parent = c.getParent();
        Integer parent = c.getParent();
        categoryMap.put(c.getDescription(), c);
        if (parent == 0) {
          primaryCat.getItems().add(c.getDescription());
        } else if (oldItem != null) {
          if (oldItem.getPrimaryCat() != null) {
            if (parent == oldItem.getPrimaryCat().getId()) {
              subCat.getItems().add(c.getDescription());
            }
          }
        }
      }

      if (oldItem != null) {
        if (oldItem.getSubCat() != null) {
          Category c = oldItem.getSubCat();
          if (c != null) {
            String desc = c.getDescription();
            if (!subCat.getItems().contains(desc)) {
              subCat.getItems().add(desc);
            }
            subCat.setValue(c.getDescription());
          }
        }
      }

      primaryCat
          .getSelectionModel()
          .selectedItemProperty()
          .addListener(
              new ChangeListener() {
                @Override
                public void changed(ObservableValue observable, Object oldValue, Object newValue) {
                  String newCat = newValue.toString();
                  if (categoryMap.containsKey(newCat)) {
                    if (oldItem.getId() != null) {
                      Category c = categoryMap.get(newCat);
                      String sqlStmt =
                          "SELECT * FROM categories WHERE parent = " + Integer.toString(c.getId());
                      sqlStmt += " order by description";
                      ObservableList<Category> subCatList =
                          view.getCategoryManager().getCategories(sqlStmt);
                      subCat.getItems().clear();
                      subCatMap.clear();
                      for (Category cat2 : subCatList) {
                        subCatMap.put(cat2.getDescription(), cat2);
                      }
                      subCat.getItems().addAll(subCatMap.keySet());
                      if (oldItem.getPrimaryCat() == null) {
                        oldItem.setPrimaryCat(c);
                        btnOk.setDisable(false);
                      }
                      if (!oldItem.getPrimaryCat().getDescription().equals(primaryCat.getValue())) {
                        oldItem.setPrimaryCat(c);
                        btnOk.setDisable(false);
                      }
                    }
                  }
                }
              });

      subCat
          .getSelectionModel()
          .selectedItemProperty()
          .addListener(
              new ChangeListener() {
                @Override
                public void changed(ObservableValue observable, Object oldValue, Object newValue) {
                  if (newValue != null) {
                    String newCat = newValue.toString();
                    if (subCatMap.containsKey(newCat)) {
                      if (oldItem != null) {
                        oldItem.setSubCat(subCatMap.get(newCat));
                        btnOk.setDisable(false);
                      }
                    }
                  }
                }
              });

      transDescription.setOnKeyPressed(
          new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent event) {
              if (!transDescription.getText().equals(oldItem.getTransDesc())) {
                oldItem.setTransDesc(transDescription.getText());
                btnOk.setDisable(false);
              }
            }
          });

      transDescription
          .textProperty()
          .addListener(
              new ChangeListener() {
                @Override
                public void changed(ObservableValue observable, Object oldValue, Object newValue) {
                  if (!oldValue.equals(newValue)) {
                    btnOk.setDisable(false);
                  }
                }
              });

      checkNum.setOnKeyPressed(
          new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent event) {
              if (event.getCode() == KeyCode.TAB) {
                if (!checkNum.getText().equals(oldItem.getCheckNum())) {
                  oldItem.setCheckNum(checkNum.getText());
                  btnOk.setDisable(false);
                }
              }
            }
          });

      transAmt
          .textProperty()
          .addListener(
              new ChangeListener() {
                @Override
                public void changed(ObservableValue observable, Object oldValue, Object newValue) {
                  if (!oldValue.equals(newValue)) {
                    btnOk.setDisable(false);
                  }
                }
              });

      distView.setPrefSize(857.0, 175.0);
      paymentDetail.setPrefSize(857.0, 175.0);
      distView.getChildren().add(paymentDetail);
      stage.show();

    } catch (IOException ex) {
      Logger.getLogger(LedgerForm.class.getName()).log(Level.SEVERE, null, ex);
    }
  }