javafx.scene.control.TableColumn.CellDataFeatures Java Examples
The following examples show how to use
javafx.scene.control.TableColumn.CellDataFeatures.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReverseColumn.java From pdfsam with GNU Affero General Public License v3.0 | 6 votes |
@Override public TableColumn<SelectionTableRowData, Boolean> getTableColumn() { TableColumn<SelectionTableRowData, Boolean> tableColumn = new TableColumn<>(getColumnTitle()); tableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(tableColumn)); tableColumn.setCellValueFactory( new Callback<CellDataFeatures<SelectionTableRowData, Boolean>, ObservableValue<Boolean>>() { @Override public ObservableValue<Boolean> call(CellDataFeatures<SelectionTableRowData, Boolean> param) { if (param.getValue() != null) { return param.getValue().reverse; } return null; } }); return tableColumn; }
Example #2
Source File: CTimePeriodField.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
@Override public ObservableValue<TimePeriod> call(CellDataFeatures<ObjectTableRow, TimePeriod> p) { try { ObjectTableRow line = p.getValue(); String fieldname = thistimeperiodfield.getFieldname(); SimpleDataElt lineelement = line.getFieldDataEltClone(fieldname); if (lineelement == null) { return null; } TimePeriod period = null; if (lineelement instanceof TextDataElt) { TextDataElt textelement = (TextDataElt) lineelement; period = TimePeriod.generateFromString(textelement.getPayload()); } if (lineelement instanceof TimePeriodDataElt) { TimePeriodDataElt timeperiodelement = (TimePeriodDataElt) lineelement; period = timeperiodelement.getPayload(); } return new SimpleObjectProperty<TimePeriod>(period); } catch (RuntimeException e) { ExceptionLogger.setInLogs(e, logger); return null; } }
Example #3
Source File: TableController.java From zest-writer with GNU General Public License v3.0 | 6 votes |
private void addCol() { TableColumn tc = new TableColumn(); tc.setEditable(true); tc.setCellValueFactory(param -> { CellDataFeatures<ZRow, String> dtf = (CellDataFeatures<ZRow, String>) param; return new SimpleStringProperty(dtf.getValue().getRow().get(0)); }); tc.setCellFactory(TextFieldTableCell.forTableColumn()); tc.setOnEditCommit(t -> { CellEditEvent<ZRow, String> evt = (CellEditEvent<ZRow, String>) t; List<String> row = evt.getTableView().getItems().get(evt.getTablePosition().getRow()).getRow(); row.set(evt.getTablePosition().getColumn(), evt.getNewValue()); }); tc.setPrefWidth(150); TextField txf = new TextField(); txf.setPrefWidth(150); txf.setPromptText(Configuration.getBundle().getString("ui.dialog.table_editor.colon") + (tableView.getColumns().size()+1)); tc.setGraphic(txf); tableView.getColumns().addAll(tc); postAddColumn(); }
Example #4
Source File: OverdueNotificationController.java From Library-Assistant with Apache License 2.0 | 5 votes |
@Override public ObservableValue<JFXCheckBox> call(TableColumn.CellDataFeatures<NotificationItem, JFXCheckBox> param) { NotificationItem item = param.getValue(); JFXCheckBox checkBox = new JFXCheckBox(); checkBox.selectedProperty().setValue(item.getNotify()); checkBox.selectedProperty().addListener((ov, old_val, new_val) -> { item.setNotify(new_val); }); return new SimpleObjectProperty<>(checkBox); }
Example #5
Source File: SelectionTableColumn.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
/** * @return the cell value factory used to extract data from the data model */ default Callback<CellDataFeatures<SelectionTableRowData, T>, ObservableValue<T>> cellValueFactory() { return new Callback<>() { @Override public ObservableValue<T> call(CellDataFeatures<SelectionTableRowData, T> param) { if (param.getValue() != null) { return getObservableValue(param.getValue()); } return null; } }; }
Example #6
Source File: TrainingExerciseBase.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
/** * Adds a column to the shot timer table. The <tt>name</tt> is used to * reference this column for the purposes of setting text and cleaning up. * * @param name * both the text that will appear for name of the column and the * name used to reference this column whenever it needs to be * looked up * @param width * the width of the new column * * @since 1.3 */ public void addShotTimerColumn(String name, int width) { final TableColumn<ShotEntry, String> newCol = new TableColumn<>(name); newCol.setPrefWidth(width); newCol.setCellValueFactory(new Callback<CellDataFeatures<ShotEntry, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<ShotEntry, String> p) { return new SimpleStringProperty(p.getValue().getExerciseValue(name)); } }); exerciseColumns.put(name, newCol); shotTimerTable.getColumns().add(newCol); }
Example #7
Source File: BigTableController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void initialize() { btnSave.disableProperty().bind( dirtyFlag.not() ); // id is read-only /* tcId.setCellValueFactory(new PropertyValueFactory<MyObject,Number>("id") { @Override public ObservableValue<Number> call(CellDataFeatures<MyObject, Number> param) { return new ReadOnlyObjectWrapper<Number>(param.getValue().getId()); } }); */ tcId.setCellValueFactory(new PropertyValueFactory<MyObject,Number>("id")); tcData.setCellValueFactory(new PropertyValueFactory<MyObject,String>("data"){ @Override public ObservableValue<String> call(CellDataFeatures<MyObject, String> param) { System.out.println("pvCounter=" + pvCounter++); return new ReadOnlyObjectWrapper<String>(param.getValue().getData()); } }); tcData.setCellFactory(TextFieldTableCell.forTableColumn()); tcData.setOnEditCommit( dataEditCommitHandler ); }
Example #8
Source File: JFXTableCellValueFactory.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public ObservableValue<JFXTableCellValue<T>> call(CellDataFeatures<UITableItem<T>, JFXTableCellValue<T>> cdf) { int index = cdf.getTableView().getColumns().indexOf(cdf.getTableColumn()); if( index >= 0 ) { return new ReadOnlyObjectWrapper<JFXTableCellValue<T>>(this.findOrCreateCell(cdf.getValue(), index)); } return new ReadOnlyObjectWrapper<JFXTableCellValue<T>>(null); }
Example #9
Source File: CChoiceField.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
@Override public ObservableValue<CChoiceFieldValue> call(CellDataFeatures<ObjectTableRow, CChoiceFieldValue> p) { try { ObjectTableRow line = p.getValue(); String fieldname = thischoicefield.getFieldname(); SimpleDataElt lineelement = line.getFieldDataEltClone(fieldname); if (lineelement == null) { return null; } String code = lineelement.defaultTextRepresentation(); CChoiceFieldValue displayvalue = thischoicefield.valuesbycode.get(code); // try to get display value ArrayList<String> restrictionsonupdate = line.hasFieldRestriction(fieldname); if (displayvalue == null) { displayvalue = thischoicefield.getBlankChoiceField(); if (code!=null) if (code.length()>0) { displayvalue = thischoicefield.generateInvalidValue(code); } } if (displayvalue != null) displayvalue.setRestrictionsOnNextValues(restrictionsonupdate); if (line.isRowFrozen()) displayvalue = displayvalue.duplicateAsFrozen(); return new SimpleObjectProperty<CChoiceFieldValue>(displayvalue); } catch (RuntimeException e) { ExceptionLogger.setInLogs(e, logger); return null; } }
Example #10
Source File: CIntegerField.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
@Override public TreeTableColumn<ObjectDataElt, Integer> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn< ObjectDataElt, Integer> thiscolumn = new TreeTableColumn<ObjectDataElt, Integer>(this.getLabel()); if (actionkeyforupdate != null) thiscolumn.setEditable(true); int length = 110; thiscolumn.setMinWidth(length); CIntegerField thisdecimalfield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, Integer>, ObservableValue<Integer>>() { @Override public ObservableValue<Integer> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, Integer> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thisdecimalfield.getFieldname(); if (line == null) return new SimpleObjectProperty<Integer>(null); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) return new SimpleObjectProperty<Integer>(null); if (!(lineelement instanceof IntegerDataElt)) return new SimpleObjectProperty<Integer>(null); IntegerDataElt linedataelt = (IntegerDataElt) lineelement; return new SimpleObjectProperty<Integer>(linedataelt.getPayload()); } }); return thiscolumn; }
Example #11
Source File: CDateField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, Date> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, Date> thiscolumn = new TreeTableColumn<ObjectDataElt, Date>(this.getLabel()); thiscolumn.setEditable(true); int length = 110; thiscolumn.setMinWidth(length); thiscolumn.setCellFactory(column -> { return new TreeTableCell<ObjectDataElt, Date>() { @Override protected void updateItem(Date date, boolean empty) { super.updateItem(date, empty); if (date == null || empty) { setText(null); } else { setText(dateformat.format(date)); this.setTooltip(new Tooltip(fulldateformat.format(date))); } } }; }); CDateField thisdatefield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, Date>, ObservableValue<Date>>() { @Override public ObservableValue<Date> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, Date> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thisdatefield.getFieldname(); if (line == null) return new SimpleObjectProperty<Date>(null); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) return new SimpleObjectProperty<Date>(null); if (!(lineelement instanceof DateDataElt)) return new SimpleObjectProperty<Date>(null); DateDataElt linedataelt = (DateDataElt) lineelement; return new SimpleObjectProperty<Date>(linedataelt.getPayload()); } }); return thiscolumn; }
Example #12
Source File: CTextField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, ?> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, String> thiscolumn = new TreeTableColumn<ObjectDataElt, String>(this.getLabel()); if (actionkeyforupdate != null) thiscolumn.setEditable(true); int length = 20 + this.maxlength * 6; if (length > 150) length = 150; if (this.prefereddisplaysizeintable >= 0) { logger.severe( "dirty log: prefereddisplayintable " + this.prefereddisplaysizeintable + "," + this.getLabel()); length = this.prefereddisplaysizeintable * 5; } if (length > MAXROWWIDTH) { length = MAXROWWIDTH; LOGGER.finer("for column " + this.getFieldname() + ", reduced max row width to " + length); } thiscolumn.setMinWidth(length); thiscolumn.setPrefWidth(length); CTextField thistextfield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<ObjectDataElt, String> p) { try { ObjectDataElt line = p.getValue().getValue(); String fieldname = thistextfield.getFieldname(); if (line == null) return new SimpleStringProperty(""); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) return new SimpleStringProperty("Field Not found !" + fieldname); if (!richtextedit) return new SimpleStringProperty(lineelement.defaultTextRepresentation()); String text = lineelement.defaultTextRepresentation(); RichText richtext = new RichText(text); return new SimpleStringProperty(richtext.generatePlainString()); } catch (Exception e) { logger.warning("Exception while building observable value " + e.getMessage()); for (int i = 0; i < e.getStackTrace().length; i++) logger.warning(" " + e.getStackTrace()[i]); pageactionmanager.getClientSession().getActiveClientDisplay() .updateStatusBar("Error in building cell value " + e.getMessage(), true); return new SimpleStringProperty("ERROR"); } } }); return thiscolumn; }
Example #13
Source File: CChoiceField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, String> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, String> thiscolumn = new TreeTableColumn<ObjectDataElt, String>(this.getLabel()); thiscolumn.setEditable(true); int length = (this.maxcharlength * 7); if (length > 300) length = 300; if (this.prefereddisplaysizeintable >= 0) { length = this.prefereddisplaysizeintable * 7; } logger.fine(" --**-- length for field" + this.getLabel() + " maxcharlength:" + maxcharlength + " pref display in table " + this.prefereddisplaysizeintable + " final length = " + length); thiscolumn.setMinWidth(length); thiscolumn.setPrefWidth(length); CChoiceField thischoicefield = this; thiscolumn.setCellValueFactory( new Callback<TreeTableColumn.CellDataFeatures<ObjectDataElt, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, String> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thischoicefield.getFieldname(); if (line == null) return new SimpleStringProperty(""); SimpleDataElt lineelement = line.lookupEltByName(fieldname); if (lineelement == null) { return new SimpleStringProperty("Field Not found !" + fieldname); } String code = lineelement.defaultTextRepresentation(); String displaystring = "Invalid code: " + code; // by default code is invalid if (code.length() == 0) displaystring = ""; // or empty CChoiceFieldValue displayvalue = valuesbycode.get(code); // try to get display value if (displayvalue != null) displaystring = displayvalue.getDisplayvalue(); return new SimpleStringProperty(displaystring); } }); return thiscolumn; }
Example #14
Source File: FilterGridController.java From VocabHunter with Apache License 2.0 | 4 votes |
private ObservableValue<GridCell> extractValue(final CellDataFeatures<GridLine, GridCell> features, final int index) { List<GridCell> cells = features.getValue().getCells(); GridCell cell = getCell(cells, index); return cellCache.computeIfAbsent(cell, ReadOnlyObjectWrapper::new); }
Example #15
Source File: CIntegerField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TableColumn<ObjectTableRow, Integer> getTableColumn( PageActionManager pageactionmanager, boolean largedisplay, int preferedrowheight, String actionkeyforupdate) { TableColumn<ObjectTableRow, Integer> thiscolumn = new TableColumn<ObjectTableRow, Integer>(this.getLabel()); if (actionkeyforupdate != null) { thiscolumn.setEditable(true); } else { thiscolumn.setEditable(false); } int length = 110; thiscolumn.setMinWidth(length); CIntegerField thisintegerfield = this; thiscolumn.setCellFactory(column -> { return new TableCell<ObjectTableRow, Integer>() { @Override protected void updateItem(Integer integer, boolean empty) { super.updateItem(integer, empty); if (integer == null || empty) { setText("0"); } else { setText(integer.toString()); } } }; }); thiscolumn.setCellValueFactory( new Callback<CellDataFeatures<ObjectTableRow, Integer>, ObservableValue<Integer>>() { @Override public ObservableValue<Integer> call(CellDataFeatures<ObjectTableRow, Integer> p) { try { ObjectTableRow line = p.getValue(); String fieldname = thisintegerfield.getFieldname(); SimpleDataElt lineelement = line.getFieldDataEltClone(fieldname); if (lineelement == null) return new SimpleObjectProperty<Integer>(null); if (!(lineelement instanceof IntegerDataElt)) return new SimpleObjectProperty<Integer>(null); IntegerDataElt linedataelt = (IntegerDataElt) lineelement; return new SimpleObjectProperty<Integer>(linedataelt.getPayload()); } catch (RuntimeException e) { ExceptionLogger.setInLogs(e, logger); return null; } } }); return thiscolumn; }
Example #16
Source File: ScheduleGui.java From Strata with Apache License 2.0 | 4 votes |
@Override public ObservableValue<T> call(CellDataFeatures<S, T> param) { return getCellDataReflectively(param.getValue()); }
Example #17
Source File: ScheduleGui.java From Strata with Apache License 2.0 | 4 votes |
public static <S, T> Callback<CellDataFeatures<S, T>, ObservableValue<T>> of(ReadOnlyCallback<S, T> underlying) { return underlying; }
Example #18
Source File: ScheduleGui.java From Strata with Apache License 2.0 | 4 votes |
@Override public default ObservableValue<T> call(CellDataFeatures<S, T> param) { return new ReadOnlyObjectWrapper<T>(callValue(param.getValue())); }
Example #19
Source File: CDecimalField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, LockableBigDecimal> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn< ObjectDataElt, LockableBigDecimal> thiscolumn = new TreeTableColumn<ObjectDataElt, LockableBigDecimal>( this.getLabel()); thiscolumn.setEditable(true); thiscolumn.setStyle("-fx-alignment: CENTER-RIGHT;"); int length = 110; thiscolumn.setMinWidth(length); CDecimalField thisdecimalfield = this; BigDecimalFormatValidator validator = new BigDecimalFormatValidator(precision, scale); // big display disabled as hardcoded thiscolumn.setCellFactory(column -> { return new LargeTextTreeTableCell<ObjectDataElt, LockableBigDecimal>( new NiceLockableBigDecimalStringConverter(precision, scale), validator, this.decimalformatter, false, true,1) { @Override public void updateItem(LockableBigDecimal decimal, boolean empty) { logger.fine("Updating field for decimal = " + decimal + " empty = " + empty); super.updateItem(decimal, empty); super.setMaxHeight(12); super.setPrefHeight(12); super.setMinHeight(12); if (decimal != null) { if (decimal.isLocked()) { logger.fine("set to lock"); super.setEditable(false); } else { logger.fine("set to unlock"); super.setEditable(true); } } } }; }); thiscolumn.setCellValueFactory(new Callback< TreeTableColumn.CellDataFeatures<ObjectDataElt, LockableBigDecimal>, ObservableValue<LockableBigDecimal>>() { @Override public ObservableValue<LockableBigDecimal> call( TreeTableColumn.CellDataFeatures<ObjectDataElt, LockableBigDecimal> p) { SimpleDataElt lineelement = p.getValue().getValue().lookupEltByName(thisdecimalfield.getFieldname()); if (lineelement == null) return new SimpleObjectProperty<LockableBigDecimal>(null); if (!(lineelement instanceof DecimalDataElt)) return new SimpleObjectProperty<LockableBigDecimal>(null); DecimalDataElt linedataelt = (DecimalDataElt) lineelement; boolean locked = true; logger.finest(" *-*-*-* processing DecimalDataElt " + Integer.toHexString(linedataelt.hashCode()) + " locked = " + linedataelt.islocked() + ", payload = " + linedataelt.getPayload() + " name = " + linedataelt.getName()); return new SimpleObjectProperty<LockableBigDecimal>( new LockableBigDecimal(locked, linedataelt.getPayload())); } }); return thiscolumn; }
Example #20
Source File: CTimePeriodField.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public TreeTableColumn<ObjectDataElt, ?> getTreeTableColumn( PageActionManager pageactionmanager, String actionkeyforupdate) { TreeTableColumn<ObjectDataElt, String> thiscolumn = new TreeTableColumn<ObjectDataElt, String>(this.getLabel()); thiscolumn.setEditable(true); int length = 20 * 7; if (this.prefereddisplayintable >= 0) { length = this.prefereddisplayintable * 7; } thiscolumn.setMinWidth(length); thiscolumn.setPrefWidth(length); CTimePeriodField thistimeperiodfield = this; thiscolumn.setCellValueFactory(new javafx.util.Callback< TreeTableColumn.CellDataFeatures<ObjectDataElt, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( javafx.scene.control.TreeTableColumn.CellDataFeatures<ObjectDataElt, String> p) { ObjectDataElt line = p.getValue().getValue(); String fieldname = thistimeperiodfield.getFieldname(); if (line == null) return new SimpleStringProperty(""); SimpleDataElt lineelement = line.lookupEltByName(fieldname); String displayasstring = "Field Not found or bad type: " + fieldname + "/" + (lineelement != null ? lineelement.getClass() : "NULL"); if (lineelement != null) if (lineelement instanceof TimePeriodDataElt) { TimePeriodDataElt tpelement = (TimePeriodDataElt) lineelement; return new SimpleStringProperty( tpelement.getPayload() != null ? tpelement.getPayload().toString() : ""); } if (lineelement != null) if (lineelement instanceof TextDataElt) { TextDataElt text = (TextDataElt) lineelement; TimePeriod tp = TimePeriod.generateFromString(text.getPayload()); return new SimpleStringProperty(tp != null ? tp.toString() : ""); } return new SimpleStringProperty(displayasstring); } }); return thiscolumn; }