@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void select() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { Point2D point = getPoint(tableView, 2, 1); ComboBoxTableCell cell = (ComboBoxTableCell) getCellAt(tableView, 1, 2); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); cell.startEdit(); tableView.edit(1, (TableColumn) tableView.getColumns().get(2)); Person person = (Person) tableView.getItems().get(1); person.setLastName("Jones"); cell.commitEdit("Jones"); rfxTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("Jones", recording.getParameters()[0]); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void selectEditable() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { Point2D point = getPoint(tableView, 2, 1); ComboBoxTableCell cell = (ComboBoxTableCell) getCellAt(tableView, 1, 2); cell.setEditable(true); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); cell.startEdit(); tableView.edit(1, (TableColumn) tableView.getColumns().get(2)); Person person = (Person) tableView.getItems().get(1); person.setLastName("Jones"); cell.commitEdit("Jones"); rfxTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("Jones", recording.getParameters()[0]); }
private void setComboboxCellEditor(boolean isCustom) { for (int i = 0; i < testedTableView.getColumns().size(); i++) { TableColumn col = testedTableView.getColumns().get(i); String colName = col.getText(); final ObservableList<String> items = FXCollections.observableArrayList(); for (DataItem dataItem : allData) { items.add(dataItem.get(colName).get()); } if (!isCustom) { col.setCellFactory(ComboBoxTableCell.forTableColumn(items)); } else { col.setCellFactory(new Callback() { public Object call(Object p) { return new EditingComboBoxCell(items); } }); } } }
private void selectedTaskObserver(ObservableValue<? extends ITask> observableValue, ITask oldTask, ITask newTask) { if (newTask != null) { module.setItems(newTask.getParentTasks()); module.getParentTaskNameColumn().setCellValueFactory(cellData -> cellData.getValue().getTask().nameProperty()); module.getParentTaskDependencyTypeColumn().setCellValueFactory(cellData -> cellData.getValue().dependenceTypeProperty()); // Добавляем возможность изменять тип связи в таблице module.setEditable(true); // TODO: 18.04.2016 Сделать изменение строки через команды module.getParentTaskDependencyTypeColumn().setCellFactory(ComboBoxTableCell.forTableColumn(TaskDependencyType.values())); // Контекстное меню ParentTaskContextMenu parentTaskContextMenu = new ParentTaskContextMenu(); parentTaskContextMenu.initMenus(controller.getProject(), newTask); module.setContextMenu(parentTaskContextMenu); } }
private ComboBoxTableCell<ParkingTableViewRow, Class<? extends ParkingSpot>> parkingSpotClassComboBoxTableCell() { ComboBoxTableCell<ParkingTableViewRow, Class<? extends ParkingSpot>> field = new ComboBoxTableCell<>(); field.getItems().addAll(MainApplication.ParkingSpotTypes); field.setConverter(new StringConverter<Class<? extends ParkingSpot>>() { @Override public String toString(Class<? extends ParkingSpot> object) { return object.getSimpleName().replace("ParkingSpot", ""); } @Override public Class<? extends ParkingSpot> fromString(String string) { try { Class type = Class.forName(string + "ParkingSpot"); if (ParkingSpot.class.isAssignableFrom(type)) return Utils.<Class<? extends ParkingSpot>>uncheckedCast(type); } catch (ClassNotFoundException e) { field.cancelEdit(); } return null; } }); return field; }
private void initTownNameCol() { townName.setCellValueFactory(p -> p.getValue().townProperty()); townName.setCellFactory(ComboBoxTableCell.<Person, Town> forTableColumn(new StringConverter<Town>() { @Override public String toString(Town object) { if (object == null) { return DEFAULT_FILL; } return object.getName(); } @Override public Town fromString(String string) { return townService.getTownForName(string); } }, townService.getTowns().getValue())); }
public static void reset() { add(Node.class, JavaFXElement.class); add(TextInputControl.class, JavaFXTextInputControlElement.class); add(HTMLEditor.class, JavaFXHTMLEditor.class); add(CheckBox.class, JavaFXCheckBoxElement.class); add(ToggleButton.class, JavaFXToggleButtonElement.class); add(Slider.class, JavaFXSliderElement.class); add(Spinner.class, JavaFXSpinnerElement.class); add(SplitPane.class, JavaFXSplitPaneElement.class); add(ProgressBar.class, JavaFXProgressBarElement.class); add(ChoiceBox.class, JavaFXChoiceBoxElement.class); add(ColorPicker.class, JavaFXColorPickerElement.class); add(ComboBox.class, JavaFXComboBoxElement.class); add(DatePicker.class, JavaFXDatePickerElement.class); add(TabPane.class, JavaFXTabPaneElement.class); add(ListView.class, JavaFXListViewElement.class); add(TreeView.class, JavaFXTreeViewElement.class); add(TableView.class, JavaFXTableViewElement.class); add(TreeTableView.class, JavaFXTreeTableViewElement.class); add(CheckBoxListCell.class, JavaFXCheckBoxListCellElement.class); add(ChoiceBoxListCell.class, JavaFXChoiceBoxListCellElement.class); add(ComboBoxListCell.class, JavaFXComboBoxListCellElemnt.class); add(CheckBoxTreeCell.class, JavaFXCheckBoxTreeCellElement.class); add(ChoiceBoxTreeCell.class, JavaFXChoiceBoxTreeCellElement.class); add(ComboBoxTreeCell.class, JavaFXComboBoxTreeCellElement.class); add(TableCell.class, JavaFXTableViewCellElement.class); add(CheckBoxTableCell.class, JavaFXCheckBoxTableCellElement.class); add(ChoiceBoxTableCell.class, JavaFXChoiceBoxTableCellElement.class); add(ComboBoxTableCell.class, JavaFXComboBoxTableCellElemnt.class); add(TreeTableCell.class, JavaFXTreeTableCellElement.class); add(CheckBoxTreeTableCell.class, JavaFXCheckBoxTreeTableCell.class); add(ChoiceBoxTreeTableCell.class, JavaFXChoiceBoxTreeTableCell.class); add(ComboBoxTreeTableCell.class, JavaFXComboBoxTreeTableCell.class); }
/** * Inicializuje tabulku pro přidávání konstant k hodu kostkou */ private void initTable() { columnAdditionType.setCellValueFactory(new PropertyValueFactory<>("additionType")); columnAdditionType.setCellFactory(ComboBoxTableCell .forTableColumn(StringConvertors.forAdditionType(translator), AdditionType.values())); columnAdditionType.setOnEditCommit( event -> tableAdditions.getItems().get(event.getTablePosition().getRow()) .setAdditionType(event.getNewValue())); columnUseRepair.setCellValueFactory(new PropertyValueFactory<>("useRepair")); columnUseRepair.setCellFactory(CheckBoxTableCell.forTableColumn(columnUseRepair)); columnUseRepair.setOnEditCommit( event -> tableAdditions.getItems().get(event.getTablePosition().getRow()) .setUseRepair(event.getNewValue())); columnUseSubtract.setCellValueFactory(new PropertyValueFactory<>("useSubtract")); columnUseSubtract.setCellFactory(CheckBoxTableCell.forTableColumn(columnUseSubtract)); columnUseSubtract.setOnEditCommit( event -> tableAdditions.getItems().get(event.getTablePosition().getRow()) .setUseSubtract(event.getNewValue())); }
private TableColumn processComboBoxColumnName(String name, JsonArray items){ TableColumn column = new TableColumn(name); column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name)); ObservableList list = FXCollections.observableArrayList(); if(items!=null) list.addAll(items.getList()); column.setCellFactory(ComboBoxTableCell.forTableColumn(list)); column.setOnEditCommit( t -> { int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow(); Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index); item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue()); }); columnMap.put(name, column); return column; }
@FXML public void initialize() { colCommbo.setCellFactory(param -> { ComboBoxTableCell<SampleVO, String> comboBoxTableCell = new ComboBoxTableCell<>("Hi", "My", "Name", "Is", "Kim"); comboBoxTableCell.setPickOnBounds(true); comboBoxTableCell.updateSelected(true); return comboBoxTableCell; }); colCommbo.setCellValueFactory(v -> v.getValue().nameProperty()); tbSample.getItems().add(new SampleVO("Hi")); tbSample.getItems().add(new SampleVO("My")); tbSample.getItems().add(new SampleVO("Name")); tbSample.getItems().add(new SampleVO("Is")); }
@Test public void testGetComboBoxTableCellAdjuster() { Adjuster adjuster = Adjuster.getAdjuster(ComboBoxTableCell.class); assertThat(adjuster, is(instanceOf(ControlAdjuster.class))); assertThat(adjuster.getNodeClass(), is(sameInstance(Control.class))); }
private void configureTasksTable() { taskNameColumn.setCellValueFactory(new PropertyValueFactory<>("name")); taskDescriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description")); taskStatusColumn.setCellValueFactory(new PropertyValueFactory<>("status")); taskStatusColumn.setCellFactory(ComboBoxTableCell.forTableColumn(Task.Status.values())); taskStatusColumn.setOnEditCommit(edit -> { edit.getRowValue().setStatus(edit.getNewValue()); projectTrackingService.save(edit.getRowValue()); }); }
@SuppressWarnings("unchecked") @Override public String _getValue() { @SuppressWarnings("rawtypes") ComboBoxTableCell cell = (ComboBoxTableCell) node; return cell.getConverter().toString(cell.getItem()); }
@Override public void initialize(URL location, ResourceBundle resources) { if (prefs.get(PreferencesKeys.SAVE_PATH.toString(), null) != null) { try { userAppList.loadFromXml(new File(prefs.get(PreferencesKeys.SAVE_PATH.toString(), null))); } catch (JAXBException | SteamApiException e) { e.printStackTrace(); } } currentAppList = userAppList.getAppList(); updateListApp(); /* Define the Table View */ key.setCellValueFactory(new PropertyValueFactory<>("key")); key.setCellFactory(TextFieldTableCell.forTableColumn()); state.setCellValueFactory(new PropertyValueFactory<>("state")); state.setCellFactory(ComboBoxTableCell.forTableColumn(KeyState.values())); currentUse.setCellValueFactory(new PropertyValueFactory<>("currentUse")); currentUse.setCellFactory(ComboBoxTableCell.forTableColumn(KeyCurrentUse.values())); used.setCellValueFactory(new PropertyValueFactory<>("used")); used.setCellFactory(CheckBoxTableCell.forTableColumn(used)); dateAdded.setCellValueFactory(new PropertyValueFactory<>("dateAdded")); dateAdded.setCellFactory(TextFieldTableCell.forTableColumn()); /*Change listener for table view */ ChangeListener<Object> listener = (obs, oldValue, newValue) -> modified = true; keyList.focusedProperty().addListener(listener); keyList.getSelectionModel().selectedItemProperty().addListener(listener); /* Context Menu for the filter button */ ContextMenu contextMenu = new ContextMenu(); MenuItem showAll = new MenuItem(); MenuItem showUsed = new MenuItem(); showAll.setText(I18n.getMessage("allGame")); showUsed.setText(I18n.getMessage("gameWithUsedKey")); showAll.setOnAction(event -> { currentAppList = userAppList.getAppList(); updateListApp(); filterMode = false; }); showUsed.setOnAction(event -> { currentAppList = userAppList.getGamesWithUsedKey(); updateListApp(); filterMode = true; }); contextMenu.getItems().addAll(showAll,showUsed); filterButton.setContextMenu(contextMenu); imageCacheHandler.loadImageCache(); }
@SuppressWarnings("restriction") public void init() { TableColumn<SettlementBase, String> nameCol = new TableColumn<>(headers[0]); nameCol.setCellValueFactory(cellData -> cellData.getValue().nameProperty()); //nameCol.setCellFactory(TextFieldTableCell.forTableColumn()); nameCol = setCellFactory(nameCol); nameCol.setMinWidth(150); templateCol = new TableColumn<>(headers[1]); templateCol.setCellValueFactory(cellData -> cellData.getValue().templateProperty()); templateCol.setCellFactory(ComboBoxTableCell.forTableColumn( templates.get(0).getTemplateName(), templates.get(1).getTemplateName(), templates.get(2).getTemplateName(), templates.get(3).getTemplateName(), templates.get(4).getTemplateName(), templates.get(5).getTemplateName())); templateCol.setMinWidth(250); settlerCol = new TableColumn<>(headers[2]); settlerCol.setCellValueFactory(cellData -> cellData.getValue().settlerProperty()); //settlerCol.setCellFactory(TextFieldTableCell.forTableColumn()); settlerCol = setCellFactory(settlerCol); settlerCol.setMinWidth(50); //private ValidationSupport validationSupport = new ValidationSupport(); //validationSupport.registerValidator(TextField, Validator.createEmptyValidator("Text is required")); botCol = new TableColumn<>(headers[3]); botCol.setCellValueFactory(cellData -> cellData.getValue().botProperty()); //botCol.setCellFactory(TextFieldTableCell.forTableColumn()); botCol = setCellFactory(botCol); botCol.setMinWidth(50); TableColumn<SettlementBase, String> sponsorCol = new TableColumn<>(headers[4]); sponsorCol.setCellValueFactory(cellData -> cellData.getValue().sponsorProperty()); sponsorCol.setCellFactory(ComboBoxTableCell.forTableColumn( SPONSORS[0].toString(), SPONSORS[1].toString(), SPONSORS[2].toString(), SPONSORS[3].toString(), SPONSORS[4].toString(), SPONSORS[5].toString(), SPONSORS[6].toString(), SPONSORS[7].toString())); sponsorCol.setMinWidth(250); latCol = new TableColumn<>(headers[5]); latCol.setCellValueFactory(cellData -> cellData.getValue().latitudeProperty()); //latCol.setCellFactory(TextFieldTableCell.forTableColumn()); latCol = setCellFactory(latCol); latCol.setMinWidth(70); longCol = new TableColumn<>(headers[6]); longCol.setCellValueFactory(cellData -> cellData.getValue().longitudeProperty()); //longCol.setCellFactory(TextFieldTableCell.forTableColumn()); longCol = setCellFactory(longCol); longCol.setMinWidth(70); table_view.getColumns().addAll(nameCol,templateCol,settlerCol,botCol,sponsorCol,latCol, longCol); table_view.getItems().addAll(generateDataInMap()); }