@Override public TableCell<Anime, String> call(final TableColumn<Anime, String> arg0) { final ChoiceBoxTableCell<Anime, String> cellFactory = new ChoiceBoxTableCell<Anime, String>(new DefaultStringConverter()) { @Override public void updateItem(final String value, final boolean empty) { super.updateItem(value, empty); } }; cellFactory.getItems().clear(); for (final AnimeType element : AnimeType.values()) { cellFactory.getItems().add(element.getValue()); } return cellFactory; }
/** * Create a new SpecificationTableCell with a given validator. * @param validator The validator for this cell */ public SpecificationTableCell(ConstraintSpecificationValidator validator) { super(new DefaultStringConverter()); this.validator = validator; validator.problemsProperty().addListener(observable -> this.onProblemsChanged()); emptyProperty().addListener(observable -> this.onProblemsChanged()); getStyleClass().add("spec-cell"); ViewUtils.setupClass(this); onProblemsChanged(); }
private TableCell<FreeVariable, String> cellFactory( TableColumn<FreeVariable, String> tableColumn) { return new TextFieldTableCell<FreeVariable, String>(new DefaultStringConverter()) { { validator.problemsProperty().addListener((Observable o) -> onProblemsChanged()); getStyleClass().add("freevar"); onProblemsChanged(); } private void configureProblematic(String tooltip) { getStyleClass().remove("freevar-problem"); getStyleClass().add("freevar-problem"); setTooltip(new Tooltip(tooltip)); } private void configureUnproblematic() { getStyleClass().remove("freevar-problem"); setTooltip(null); } @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); onProblemsChanged(); } private void onProblemsChanged() { if (!isEmpty()) { List<FreeVariableProblem> problems = validator.problemsProperty().get() .getOrDefault(getTableRow().getItem(), Collections.emptyList()); if (problems.isEmpty()) { configureUnproblematic(); } else { configureProblematic(String.join("\n\n", problems.stream() .map(FreeVariableProblem::getGuiMessage).collect(Collectors.toList()))); } } } }; }
@Override public TableCell<Anime, String> call(final TableColumn<Anime, String> column) { return new TextFieldTableCell<Anime, String>(new DefaultStringConverter()) { @Override public void updateItem(final String value, final boolean empty) { super.updateItem(value, empty); } }; }
public ObjectCell(final OwnNoteEditor ownNoteEditor, final OwnNoteTableColumn ownNoteTableColumn, final boolean linkCursor, final EventHandler<MouseEvent> mouseEvent) { super(new DefaultStringConverter()); myOwnNoteEditor = ownNoteEditor; myOwnNoteTableColumn = ownNoteTableColumn; if (linkCursor) { this.setCursor(Cursor.HAND); } this.addEventFilter(MouseEvent.MOUSE_CLICKED, mouseEvent); }
@Override public TableCell<ObservableList<StringProperty>,String> call(TableColumn<ObservableList<StringProperty>,String> param) { return new TextFieldTableCell<ObservableList<StringProperty>, String>(( new DefaultStringConverter() )) { @Override public void updateItem(String s, boolean b) { super.updateItem(s, b); TableRow row = getTableRow(); if (row != null && (row.getIndex()+1 == this.getTableView().getItems().size()) || (cutoff && row != null && row.getIndex() == 0)) { setDisable(true); setEditable(false); this.setStyle("-fx-text-fill: grey"); } } }; }
private TextFieldTableCell<WarningCell, String> createTableCell(TableColumn<WarningCell, String> col) { TextFieldTableCell<WarningCell, String> cell = new TextFieldTableCell<WarningCell, String>(new DefaultStringConverter()) { @Override public void updateItem(String arg0, boolean empty) { this.setEditable( true ); super.updateItem(arg0, empty); if( !empty ) { this.setText( arg0 ); WarningCell warnableObject = (WarningCell) this.getTableRow().getItem(); if( warnableObject != null && warnableObject.displayWarning(colIndex) ) { this.setStyle(wrongStyle); } else { this.setStyle(normalStyle); } } else { this.setText( null ); // clear from recycled obj this.setStyle(normalStyle); } } }; return cell; }
@Override public FXFormNode call(Void param) { tableView.setEditable(true); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); return new FXFormNodeWrapper(new VBox(3, tableView, new HBox(5, addButton, removeButton)), tableView.itemsProperty()) { @Override public void init(Element element) { Class wrappedType = element.getWrappedType(); List<Field> fields = ReflectionUtils.listFields(wrappedType); for (Field field : fields) { TableColumn col = new TableColumn(field.getName()); col.setCellValueFactory(new PropertyValueFactory(field.getName())); col.setCellFactory(list -> new TextFieldTableCell(new DefaultStringConverter())); tableView.getColumns().add(col); } addButton.setOnAction(event -> { try { tableView.getItems().add(element.getWrappedType().newInstance()); tableView.edit(tableView.getItems().size() - 1, (TableColumn) tableView.getColumns().get(0)); } catch (Exception e) { e.printStackTrace(); } }); removeButton.setOnAction(event -> { tableView.getItems().removeAll(tableView.getSelectionModel().getSelectedItems()); }); } }; }
@Override public TableCell<T, String> call(TableColumn<T, String> param) { return new TextFieldTableCell<>(new DefaultStringConverter()); }
public static <S> Callback<TableColumn<S, String>, TableCell<S, String>> forTableColumn() { return forTableColumn(new DefaultStringConverter()); }
public AttributeItemCellFactory() { converter = new DefaultStringConverter(); }
public WrappingTextFieldTableCell() { super(new DefaultStringConverter()); this.cellText = createText(); }
public HighLightingTextCell() { super(new DefaultStringConverter()); defaultStyle = getStyle(); }
private StringCell() { super(new DefaultStringConverter()); }
public StringTextCell() { super(new DefaultStringConverter()); }
public static < S > Callback < TableColumn < S, String > , TableCell < S, String >> forTableColumn() { return forTableColumn(new DefaultStringConverter()); }
private void insertViewColumn(UserType col, int pos) { if (pos < 0) { pos = table.getColumns().size(); } TableColumn<Row, String> tableCol = new TableColumn<>(col.getName()); tableCol.setCellValueFactory((features) -> { String val = getValue(features.getValue().getOtherAttributes(), col.getName()); if (val == null) { val = ""; } return new SimpleObjectProperty(val); }); tableCol.setCellFactory((TableColumn<Row, String> param) -> { TextFieldTableCell<Row, String> myCell = new TextFieldTableCell<Row, String>(new DefaultStringConverter()) { @Override /** * Patch behavior so that any change is immediately persisted, * enter is not required. */ public void startEdit() { super.startEdit(); TextField textField = (TextField) getGraphic(); textField.textProperty().addListener((p, o, n) -> { setItem(n); int index = this.getTableRow().getIndex(); Row row = tableData.get(index); setValue(row.getOtherAttributes(), col.getName(), n); }); } }; return myCell; }); tableCol.setOnEditCommit((event) -> { table.requestFocus(); table.getSelectionModel().clearSelection(); }); tableCol.setEditable(true); tableCol.setContextMenu(new ContextMenu( createMenuItem("Rename Column", () -> renameColumn(col)), createMenuItem("Delete Column", () -> deleteColumnWithConfirmation(col)) )); table.getColumns().add(pos, tableCol); }
public ImprovedTableCell(Class<S> impl) { this(impl, (StringConverter<T>) new DefaultStringConverter()); }
@Override public void initialize(URL location, ResourceBundle resources) { // ルートの子要素を作成 TreeItem<String> item1 = new TreeItem<String>("Item 1"); TreeItem<String> item2 = new TreeItem<String>("Item 2"); TreeItem<String> item3 = new TreeItem<String>("Item 3"); TreeItem<String> item4 = new TreeItem<String>("Item 4"); // item4 の子要素 TreeItem<String> item41 = new TreeItem<String>("Item 4-1"); TreeItem<String> item42 = new TreeItem<String>("Item 4-2"); TreeItem<String> item43 = new TreeItem<String>("Item 4-3"); // item4 に子要素を追加する ObservableList<TreeItem<String>> image4tChildren = item4.getChildren(); image4tChildren.add(item41); image4tChildren.add(item42); image4tChildren.add(item43); TreeItem<String> root = new TreeItem<String>("root"); treeView.setRoot(root); // ルート要素に子要素を追加する ObservableList<TreeItem<String>> rootChildren = root.getChildren(); rootChildren.add(item1); rootChildren.add(item2); rootChildren.add(item3); rootChildren.add(item4); // 子を持つノードを開く root.setExpanded(true); item4.setExpanded(true); // 編集可能にする treeView.setEditable(true); treeView.setCellFactory( (TreeView<String> p) -> { TextFieldTreeCell<String> cell = new TextFieldTreeCell<String>(); // 編集した文字列を、 // セルが持つデータに反映させるロジックを指定。 // 今回はテキストフィールドに入力した文字列を // そのままセルが持つデータとして使うので、 // DefaultStringConverter を使用。 cell.setConverter(new DefaultStringConverter()); return cell; }); }
/** * Provides a {@link TextField} that allows editing of the cell content when * the cell is double-clicked, or when * {@link TableView#edit(int, javafx.scene.control.TableColumn)} is called. * This method will only work on {@link TableColumn} instances which are of * type String. * * @return A {@link Callback} that can be inserted into the * {@link TableColumn#cellFactoryProperty() cell factory property} of a * TableColumn, that enables textual editing of the content. */ public static <S> Callback<TableColumn<S, String>, TableCell<S, String>> forTableColumn() { return forTableColumn(new DefaultStringConverter()); }
/** * Provides a {@link TextField} that allows editing of the cell content when * the cell is double-clicked, or when * {@link TableView#edit(int, javafx.scene.control.TableColumn)} is called. * This method will only work on {@link TableColumn} instances which are of * type String. * * @return A {@link Callback} that can be inserted into the * {@link TableColumn#cellFactoryProperty() cell factory property} of a * TableColumn, that enables textual editing of the content. */ public static <S> Callback<TableColumn<S,String>, TableCell<S,String>> forTableColumn() { return forTableColumn(new DefaultStringConverter()); }