private void initializeWorkflowProcessesComboBox() {
    workflowProcessesComboBox.setEditable(false);
    workflowProcessesComboBox.setPromptText("Select Workflow Process");
    workflowProcessesComboBox.setCellFactory(
        (p) -> {
          final ListCell<WorkflowProcess> cell =
              new ListCell<WorkflowProcess>() {
                @Override
                protected void updateItem(WorkflowProcess a, boolean bln) {
                  super.updateItem(a, bln);

                  if (a != null) {
                    setText(a.getText());
                  } else {
                    setText(null);
                  }
                }
              };

          return cell;
        });

    workflowProcessesComboBox.setButtonCell(
        new ListCell<WorkflowProcess>() {
          @Override
          protected void updateItem(WorkflowProcess t, boolean bln) {
            super.updateItem(t, bln);
            if (bln) {
              setText("");
              initiateButton.setDisable(true);
            } else {
              setText(t.getText());
              initiateButton.setDisable(!isDataRequiredForInitiateOk());
            }
          }
        });
    workflowProcessesComboBox.setOnAction(
        (event) -> {
          LOG.trace(
              "workflowProcessesComboBox event (selected: "
                  + workflowProcessesComboBox.getSelectionModel().getSelectedItem()
                  + ")");

          initiateButton.setDisable(!isDataRequiredForInitiateOk());
        });
  }
  private void initializeAssignmentListViewAndFilters() {
    final ListBinding<PersonnelAssignment> filteredAssignementBinding =
        new ListBinding<PersonnelAssignment>() {
          final ObjectBinding<ObservableList<PersonnelAssignment>> internalBinding =
              Bindings.select(
                  assignmentsFilterComboBox.getSelectionModel().selectedItemProperty(),
                  "assignments");

          {
            bind(internalBinding);
          }

          @Override
          protected ObservableList<PersonnelAssignment> computeValue() {
            return internalBinding.get();
          }

          @Override
          public Spliterator<PersonnelAssignment> spliterator() {
            return super.spliterator();
          }
        };

    assigmentsListView.itemsProperty().bind(filteredAssignementBinding);
    assigmentsListView.setCellFactory(
        new PropertyListCellFactory<PersonnelAssignment>("name", null));

    assignmentsFilterComboBox.getItems().clear();
    assignmentsFilterComboBox.getItems().addAll(assignementFilters);
    assignmentsFilterComboBox.setCellFactory(
        new PropertyListCellFactory<AssignementFilter>("name", null));
    assignmentsFilterComboBox.setButtonCell(
        new ListCell<AssignementFilter>() {
          @Override
          protected void updateItem(AssignementFilter item, boolean empty) {
            super.updateItem(item, empty);
            if (textProperty().isBound()) {
              textProperty().unbind();
            }
            if (item != null || !empty) {
              textProperty().bind(item.nameProperty());
            }
          }
        });
  }
Пример #3
0
  private void initCombo() {

    List<ComboBox> superComboBoxes = Arrays.asList(parentCombo, searchCombo);
    parentCombo.setItems(superData);
    searchCombo.setItems(searchData);
    superComboBoxes
        .stream()
        .forEach(
            comboBox -> {
              comboBox.getSelectionModel().selectFirst();
              comboBox.setCellFactory(
                  param ->
                      new ListCell<ToolsTray>() {
                        @Override
                        protected void updateItem(ToolsTray toolsTray, boolean bln) {
                          super.updateItem(toolsTray, bln);
                          if (toolsTray != null) {
                            setText(toolsTray.getTrayName());
                          } else {
                            setText(null);
                          }
                        }
                      });
            });

    typeCombo.setItems(typeData);
    typeCombo.getSelectionModel().selectLast();
    typeCombo.setCellFactory(
        p ->
            new ListCell<ToolType>() {
              @Override
              protected void updateItem(ToolType toolType, boolean bln) {
                super.updateItem(toolType, bln);
                if (toolType != null) {
                  setText(toolType.getToolTypeName());
                } else {
                  setText(null);
                }
              }
            });
  }
  private void initializeSkillFilterTab() {
    skillFilterComboBox.getItems().addAll(skills);
    PropertyListCellFactory<Skill> propertyListCellFactory =
        new PropertyListCellFactory<>("name", null);
    skillFilterComboBox.setButtonCell(
        new ListCell<Skill>() {
          @Override
          protected void updateItem(Skill arg0, boolean arg1) {
            super.updateItem(arg0, arg1);
            if (arg1 || arg0 == null) {
              this.setText(null);
            } else {
              this.setText(arg0.getName());
            }
          }
        });
    skillFilterComboBox.setCellFactory(propertyListCellFactory);
    skillFiltersNameColumn.setCellValueFactory(
        new Callback<CellDataFeatures<SkillFilter, String>, ObservableValue<String>>() {
          @Override
          public ObservableValue<String> call(CellDataFeatures<SkillFilter, String> arg0) {
            return Bindings.selectString(arg0.getValue().skillProperty(), "name");
          }
        });

    skillFilterMinValueColumn.setCellValueFactory(
        new PropertyValueFactory<SkillFilter, Integer>("minValue"));
    skillFilterMaxValueColumn.setCellValueFactory(
        new PropertyValueFactory<SkillFilter, Integer>("maxValue"));
    skillFiltersTableView
        .getItems()
        .addListener(
            new ListChangeListener<SkillFilter>() {
              @Override
              public void onChanged(Change<? extends SkillFilter> arg0) {
                while (arg0.next()) {
                  for (SkillFilter skillFilter : arg0.getAddedSubList()) {
                    final Skill skill = skillFilter.getSkill();
                    TableColumn<Official, Number> skillColumn = new TableColumn<>(skill.getName());
                    skillColumn.setCellValueFactory(
                        new Callback<
                            CellDataFeatures<Official, Number>, ObservableValue<Number>>() {
                          @Override
                          public ObservableValue<Number> call(
                              CellDataFeatures<Official, Number> arg0) {
                            Official official = arg0.getValue();
                            IntegerBinding selectInteger =
                                Bindings.selectInteger(
                                    official.skillLevelsProperty().valueAt(skill), "level");
                            selectInteger.addListener(
                                new ChangeListener<Number>() {
                                  @Override
                                  public void changed(
                                      ObservableValue<? extends Number> arg0,
                                      Number arg1,
                                      Number arg2) {
                                    updateOfficialFiltersResult();
                                  }
                                });
                            return selectInteger;
                          }
                        });
                    officialsFilteredTableView.getColumns().add(skillColumn);
                    skillFiltersColumn.put(skill, skillColumn);
                  }

                  for (SkillFilter skillFilter : arg0.getRemoved()) {
                    final Skill skill = skillFilter.getSkill();
                    TableColumn<Official, Number> column = skillFiltersColumn.remove(skill);

                    if (column != null) {
                      officialsFilteredTableView.getColumns().remove(column);
                    }
                  }
                }
              }
            });
    Bindings.bindContent(skillFiltersMatcher.getMatchers(), skillFiltersTableView.getItems());
  }