private void initializeFilteredPersonnelTableView() { personnelNameColumn.setCellValueFactory(new PropertyValueFactory<Official, String>("name")); personnelRankColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<Official, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<Official, String> arg0) { final Official official = arg0.getValue(); final StringExpression concat = Bindings.selectString(official.rankProperty(), "designation"); return concat; } }); Bindings.bindContent(officialsFilteredTableView.getItems(), officialFilteredList); gameData .getOfficials() .addListener( new ListChangeListener<Official>() { @Override public void onChanged(Change<? extends Official> arg0) { updateOfficialFiltersResult(); } }); // TODO initialize assignOfficialMenuItem to be sure that it's not // enable if not correct values are selected }
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(); }
private void setupTracksView() { TableColumn titleColumn = new TableColumn("Title"); titleColumn.setSortable(false); titleColumn.setMinWidth(USE_COMPUTED_SIZE); titleColumn.setCellValueFactory(new PropertyValueFactory<>("title")); TableColumn durationColumn = new TableColumn("Duration"); durationColumn.setMinWidth(60); durationColumn.setMaxWidth(60); durationColumn.setSortable(false); durationColumn.setCellValueFactory(new PropertyValueFactory<>("durationFormatted")); durationColumn.getStyleClass().add("text-layout-center"); tracksView.getColumns().clear(); tracksView.getColumns().addAll(titleColumn, durationColumn); tracksView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); }
/** * Create the priority column, which holds the priority of a filter and also creates a callback to * the integer property behind it. */ private void setUpPriorityColumn(TableView<FilterInput> tableView) { // Set up priority column final TableColumn<FilterInput, Integer> priorityColumn = new TableColumn<>("Priority"); priorityColumn.setMinWidth(50); priorityColumn.setPrefWidth(50); tableView.getColumns().add(priorityColumn); priorityColumn.setCellValueFactory(p -> p.getValue().getPriorityProperty().asObject()); }
/** * Create the legalality column, which holds the legality of a filter and also creates a callback * to the string property behind it. */ private void setUpLegalityColumn(TableView<FilterInput> tableView) { // Set up priority column final TableColumn<FilterInput, Boolean> legalColumn = new TableColumn<>("Authorized"); legalColumn.setMinWidth(70); legalColumn.setPrefWidth(70); tableView.getColumns().add(legalColumn); legalColumn.setCellValueFactory(p -> p.getValue().getLegalProperty()); }
/** * Create the origin column, which holds the type of the origin and also creates a callback to the * string property behind it. */ private void setUpOriginColumn(TableView<FilterInput> tableView) { // Set up origin column final TableColumn<FilterInput, String> originColumn = new TableColumn<>("Filtered By"); originColumn.setMinWidth(90); originColumn.setPrefWidth(90); tableView.getColumns().add(originColumn); originColumn.setCellValueFactory(p -> p.getValue().getFilterTypeProperty()); }
/** * Create the type column, which holds the type of the filter and also creates a callback to the * string property behind it. */ private void setUpTypeColumn(TableView<FilterInput> tableView) { // Set up type column final TableColumn<FilterInput, String> typeColumn = new TableColumn<>("Selection Model"); typeColumn.setMinWidth(90); typeColumn.setPrefWidth(90); tableView.getColumns().add(typeColumn); typeColumn.setCellValueFactory(p -> p.getValue().getSelectionModelProperty()); }
/** * Create the filter column, which holds the name of the filter and also creates a callback to the * string property behind it. */ private void setUpFilterColumn(TableView<FilterInput> tableView) { // Set up filter column final TableColumn<FilterInput, String> filterColumn = new TableColumn<>("Filter"); filterColumn.setMinWidth(120); filterColumn.setPrefWidth(120); tableView.getColumns().add(filterColumn); filterColumn.setCellValueFactory(p -> p.getValue().getNameProperty()); }
private void setupPlaylistsView() { TableColumn titleColumn = new TableColumn("Title"); titleColumn.setMinWidth(USE_COMPUTED_SIZE); titleColumn.setSortable(false); titleColumn.setCellValueFactory(new PropertyValueFactory<>("title")); TableColumn countColumn = new TableColumn("Tracks"); countColumn.setMinWidth(60); countColumn.setMaxWidth(60); countColumn.setSortable(false); countColumn.setCellValueFactory(new PropertyValueFactory<>("count")); countColumn.getStyleClass().add("text-layout-right"); playlistsView.getColumns().clear(); playlistsView.getColumns().addAll(titleColumn, countColumn); playlistsView.setContextMenu(playlistsContextMenu); playlistsView.setPlaceholder(playlistPlaceholder); playlistsView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); }
/** * Create the color column, which holds the color and also creates a callback to the string * property behind it. */ private void setUpColorColumn(TableView<FilterInput> tableView) { final TableColumn<FilterInput, Color> colorColumn = new TableColumn<>("Color"); colorColumn.setMinWidth(50); colorColumn.setPrefWidth(50); colorColumn.setSortable(false); tableView.getColumns().add(colorColumn); // Set the cell value factory for the color colorColumn.setCellValueFactory(p -> p.getValue().getColorProperty()); // Set the cell factory for the color colorColumn.setCellFactory( param -> new TableCell<FilterInput, Color>() { final Rectangle rectangle = new Rectangle(); @Override public void updateItem(Color item, boolean empty) { // Add the color to the row if (item != null) { HBox hBox = new HBox(); hBox.getChildren().add(rectangle); rectangle.setHeight(20); rectangle.setWidth(30); hBox.setAlignment(Pos.CENTER); rectangle.setFill(item); setGraphic(hBox); } // Remove the color if the row has been removed if (empty) { setGraphic(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()); }
@Override // This method is called by the FXMLLoader when initialization is complete public void initialize(URL fxmlFileLocation, ResourceBundle resources) { assert civilianAdministratorCheckBox != null : "fx:id=\"civilianAdministratorCheckBox\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert officialsFilteredTableView != null : "fx:id=\"filteredPersonnelTableView\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert groundOfficerFilterCheckBox != null : "fx:id=\"groundOfficerFilterCheckBox\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert navalOfficerFilterCheckBox != null : "fx:id=\"navalOfficerFilterCheckBox\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert personnelNameColumn != null : "fx:id=\"personnelNameColumn\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert personnelRankColumn != null : "fx:id=\"personnelRankColumn\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert scientistFilterCheckBox != null : "fx:id=\"scientistFilterCheckBox\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert skillFilterComboBox != null : "fx:id=\"skillFilterComboBox\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert skillFilterMaxValueColumn != null : "fx:id=\"skillFilterMaxValueColumn\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert skillFilterMaxValueComponent != null : "fx:id=\"skillFilterMaxValueComponent\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert skillFilterMinValueColumn != null : "fx:id=\"skillFilterMinValueColumn\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert skillFilterMinValueComponent != null : "fx:id=\"skillFilterMinValueComponent\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert skillFiltersNameColumn != null : "fx:id=\"skillFiltersNameColumn\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert skillFiltersTableView != null : "fx:id=\"skillFiltersTableView\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert assignmentsFilterComboBox != null; assert assigmentsListView != null; assert createTeamMenuItem != null : "fx:id=\"createTeamMenuItem\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert assignOfficialMenuItem != null; assert skillsTableView != null : "fx:id=\"skillsTableView\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert skillColumn != null : "fx:id=\"skillColumn\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; assert levelColumn != null : "fx:id=\"levelColumn\" was not injected: check your FXML file 'PersonnelManagementScreen.fxml'."; // initialize your logic here: all @FXML variables will have been // injected initializeCompositeMatcher(); initializeFilteredPersonnelTableView(); initializeSkillFilterTab(); initializeAssignmentListViewAndFilters(); createTeamMenuItem .disableProperty() .bind( Bindings.select(officialsFilteredTableView.selectionModelProperty(), "selectedItem") .isNull()); final ObjectBinding<Official> selectedPersonnel = Bindings.select(officialsFilteredTableView.selectionModelProperty(), "selectedItem"); detailsPaneController .officialProperty() .bind(officialsFilteredTableView.getSelectionModel().selectedItemProperty()); skillColumn.setCellValueFactory( new Callback<CellDataFeatures<SkillLevel, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<SkillLevel, String> p) { SkillLevel value = p.getValue(); return Bindings.selectString(value, "skill", "name"); } }); levelColumn.setCellValueFactory(new PropertyValueFactory<SkillLevel, Integer>("level")); selectedPersonnel.addListener( new ChangeListener<Official>() { @Override public void changed( ObservableValue<? extends Official> arg0, Official arg1, Official arg2) { updateSkills(); } }); updateOfficialFiltersResult(); }