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(); }
@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; }
/** build FILTER table */ private TableView<String> buildFilterTable() { final TableView<String> table=new TableView<>(); final TableColumn<String,String> scol = new TableColumn<>("Filter"); scol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<String,String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<String, String> param) { return new ReadOnlyObjectWrapper<String>(param.getValue()); } }); table.getColumns().add(scol); table.setPlaceholder(new Label("No Variant or Variant contains no Filter")); return table; }
@Override public ObservableValue<String> call(CellDataFeatures<EventInstance, String> p) { EventInstance event = p.getValue(); Object refValue = event.getParameters().get(reference); if (refValue != null) { String string = stringGetter.apply(refValue); ObservableValue<String> result = new ReadOnlyObjectWrapper<String>(string); return result; } return null; }
@Override public ObservableValue<String> call(CellDataFeatures<EventInstance, String> p) { EventInstance event = p.getValue(); Object refValue = event.getParameters().get(attribute); if (refValue != null) { ObservableValue<String> result = new ReadOnlyObjectWrapper<String>(refValue.toString()); return result; } return null; }
private void updateNameColumn(TableColumn<TableCreature, String> nameColumn) { nameColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<TableCreature, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<TableCreature, String> p) { return new SimpleStringProperty(p.getValue().name); } }); }
private void updateDnaSequenceColumn(TableColumn<TableCreature, String> dnaSequenceColumn) { dnaSequenceColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<TableCreature, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<TableCreature, String> p) { return new SimpleStringProperty(p.getValue().dnaSequence); } }); }
private void updateAmountColumn(TableColumn<TableCreature, String> amountColumn) { amountColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<TableCreature, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<TableCreature, String> p) { return new SimpleStringProperty(p.getValue().amount); } }); }
@Deprecated TableColumn<Map<String, Object>, Object> createColumn(String column) { TableColumn<Map<String, Object>, Object> tableColumn = new TableColumn<>(column); tableColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Map<String, Object>, Object>, ObservableValue<Object>>() { @Override public ObservableValue<Object> call(CellDataFeatures<Map<String, Object>, Object> param) { return new SimpleObjectProperty<>(param.getValue().get(column)); } }); return tableColumn; }
public static <D> Callback<CellDataFeatures<D,?>, ObservableValue<?>> getCellValueFactory(PropertyDescriptor pds) { return a -> { try { return ObservableConstant.of(pds.getReadMethod().invoke(a.getValue())); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new UndeclaredThrowableException(e); } }; }
/** * map indexs of the items to the items */ private void mapIndexesToCellValues() { mapCellValuesToRowIndexes.clear(); for (int i = 0; i < tableFilter.getUnfilteredItems().size(); i++) { S item = tableFilter.getUnfilteredItems().get(i); T cellValue = column.getCellValueFactory().call(new CellDataFeatures<>(tableFilter.getTableView(), column, item)).getValue(); List<Integer> indexes = mapCellValuesToRowIndexes.get(cellValue); if (indexes == null) { indexes = new ArrayList<>(); mapCellValuesToRowIndexes.put(cellValue, indexes); } indexes.add(i); } }
@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 ); }
/** * 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); }
private LinkedHashMap<String, TableColumn<TorrentView, ?>> buildColumnMappings() { final Callback<CellDataFeatures<TorrentView, String>, ObservableValue<String>> priorityValueFactory = tj -> tj.getValue().lifeCycleChangeProperty(); final Callback<CellDataFeatures<TorrentView, String>, ObservableValue<String>> nameValueFactory = tj -> new ReadOnlyObjectWrapper<>(tj.getValue().getFileName()); final Callback<CellDataFeatures<TorrentView, Number>, ObservableValue<Number>> sizeValueFactory = tj -> new ReadOnlyObjectWrapper<>(tj.getValue().getTotalLength()); final Callback<CellDataFeatures<TorrentView, Number>, ObservableValue<Number>> selectedSizeValueFactory = tj -> tj.getValue().selectedLengthProperty(); final Callback<CellDataFeatures<TorrentView, Number>, ObservableValue<Number>> addedValueFactory = tj -> new ReadOnlyObjectWrapper<>(tj.getValue().getAddedOnTime()); final Callback<CellDataFeatures<TorrentView, String>, ObservableValue<String>> trackerValueFactory = tj -> new ReadOnlyObjectWrapper<>(tj.getValue().getTrackerUrl()); final TableColumn<TorrentView, ?> priorityColumn = TableUtils.buildColumn(priorityValueFactory, val -> val.getLifeCycleChange(), GuiUtils.RIGHT_ALIGNED_COLUMN_HEADER_TYPE_NAME, PRIORITY_COLUMN_LABEL); torrentTable.getSortOrder().add(priorityColumn); final LinkedHashMap<String, TableColumn<TorrentView, ?>> columnMappings = new LinkedHashMap<>(); columnMappings.put(PRIORITY_COLUMN_LABEL, priorityColumn); columnMappings.put(NAME_COLUMN_LABEL, TableUtils.buildColumn(nameValueFactory, tj -> tj.getFileName(), GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME, NAME_COLUMN_LABEL)); columnMappings.put(SIZE_COLUMN_LABEL, TableUtils.buildColumn(sizeValueFactory, tj -> UnitConverter.formatByteCount(tj.getTotalLength()), GuiUtils.RIGHT_ALIGNED_COLUMN_HEADER_TYPE_NAME, SIZE_COLUMN_LABEL)); columnMappings.put(SELECTED_SIZE_COLUMN_LABEL, TableUtils.buildColumn(selectedSizeValueFactory, tj -> UnitConverter.formatByteCount(tj.getSelectedLength()), GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME, SELECTED_SIZE_COLUMN_LABEL)); columnMappings.put(ADDED_COLUMN_LABEL, TableUtils.buildColumn(addedValueFactory, tj -> UnitConverter.formatMillisToDate(tj.getAddedOnTime(), TimeZone.getDefault()), GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME, ADDED_COLUMN_LABEL)); columnMappings.put(TRACKER_COLUMN_LABEL, TableUtils.buildColumn(trackerValueFactory, tj -> tj.getTrackerUrl(), GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME, TRACKER_COLUMN_LABEL)); return columnMappings; }
@Override public ObservableValue<String> call(CellDataFeatures<EObject, String> p) { EObject object = p.getValue(); Object refValue = object.eGet(reference); if (refValue != null) { String string = stringGetter.apply(refValue); ObservableValue<String> result = new ReadOnlyObjectWrapper<String>(string); return result; } return null; }
public ObservableValue<String> call(CellDataFeatures<EntityType, String> features) { try { EntityType entity = features.getValue(); Method m = entity.getClass().getMethod(getterName); BigDecimal bigDecimal = (BigDecimal) m.invoke(entity); String formattedBigDecimal = formatter.format(bigDecimal); return new SimpleObservableValue<String>(formattedBigDecimal); } catch (Exception e) { e.printStackTrace(); } return null; }
public ObservableValue<String> call(CellDataFeatures<EntityType, String> features) { try { EntityType entity = features.getValue(); Method m = entity.getClass().getMethod(getterName); Date date = (Date) m.invoke(entity); String formattedDate = formatter.format(date); return new SimpleObservableValue<String>(formattedDate); } catch (Exception e) { e.printStackTrace(); } return null; }
private TableColumn<ReportLine, Number> toCurrencyColumn(String header, Callback<CellDataFeatures<ReportLine, Number>, ObservableValue<Number>> callback) { TableColumn<ReportLine, Number> tc = new TableColumn<>(); tc.setText(header); tc.setCellValueFactory(callback); tc.setCellFactory(p -> new CurrencyCell()); return tc; }
private Callback<CellDataFeatures<Object, String>, ObservableValue<String>> createCellValueFactoryForJavaTypeOrEnum( LanguageProvider languageProvider, Class<?> objectClass) { JavaFormatFactory formatFactory = new JavaFormatFactory(languageProvider); Format format = formatFactory.create(objectClass); return new Callback<CellDataFeatures<Object, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<Object, String> param) { String value = format.format(param); return new ReadOnlyObjectWrapper<String>(value); } }; }
/** * Adds a column for the specified property. * @param name the column name * @param property the property name * @param width the width */ public <T> void addColumn(String name, int width, Callback<CellDataFeatures<E,T>, ObservableValue<T>> callback) { //table column TableColumn<E, T> tableColumn = new TableColumn<E, T>(name); tableColumn.setPrefWidth(width); tableColumn.setCellValueFactory(callback); this.tableView.getColumns().add(tableColumn); }
/** * @return the cell value factory used to extract data from the data model */ default Callback<CellDataFeatures<SelectionTableRowData, T>, ObservableValue<T>> cellValueFactory() { return new Callback<CellDataFeatures<SelectionTableRowData, T>, ObservableValue<T>>() { @Override public ObservableValue<T> call(CellDataFeatures<SelectionTableRowData, T> param) { if (param.getValue() != null) { return getObservableValue(param.getValue()); } return null; } }; }
protected <T,R> TableColumn<T,R> makeColumn(final String tag,final Function<T,R> supplier) { final TableColumn<T,R> col = new TableColumn<>(tag); col.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<T,R>, ObservableValue<R>>() { @Override public ObservableValue<R> call(CellDataFeatures<T, R> param) { return new ReadOnlyObjectWrapper<R>(supplier.apply(param.getValue())); } }); return col; }
@Override public ObservableValue<Integer> call(CellDataFeatures<T, Integer> param) { return new ReadOnlyObjectWrapper<Integer>(items.indexOf(param.getValue()) + 1); }
public XmlAttributeTableView generate(NodeList list, List<String> columns) { XmlAttributeTableView view = new XmlAttributeTableView(); view.setEditable(true); ObservableList<TableColumn<Node, String>> tbColumns = FXCollections.observableArrayList(); for (String column : columns) { TableColumn<Node, String> tc = new TableColumn<Node, String>(); tc.setEditable(false); tc.setCellFactory(TextFieldTableCell.forTableColumn()); tc.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Node, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<Node, String> param) { NamedNodeMap attributes = param.getValue().getAttributes(); if (attributes != null) { Node namedItem = attributes.getNamedItem(column); if (namedItem != null) { SimpleStringProperty simpleStringProperty = new SimpleStringProperty(namedItem.getNodeValue()); simpleStringProperty.addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (newValue != null) { namedItem.setNodeValue(newValue); } } }); return simpleStringProperty; } } return new SimpleStringProperty(); } }); tc.setText(column); if (columnHandler != null) tc = columnHandler.apply(tc, column); tbColumns.add(tc); } view.getColumns().setAll(tbColumns); // view.getItems().addAll(list) int itemCount = list.getLength(); List<Node> arrayList = new ArrayList<Node>(); for (int i = 0; i < itemCount; i++) { Node item = list.item(i); arrayList.add(item); } view.getItems().addAll(arrayList); view.getSelectionModel().setCellSelectionEnabled(true); view.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); FxUtil.installClipboardKeyEvent(view); FxUtil.installFindKeyEvent(null, view); return view; }
@Override public ObservableValue<ValueExpression> call( CellDataFeatures<Map<ColumnExpression, ObjectProperty<ValueExpression>>, ValueExpression> param) { return param.getValue().get(columnName); }
@Override public void initialize(URL url, ResourceBundle rb) { studentsList = FXCollections.observableArrayList(); currentIndex = 0; studentsListView.setItems(studentsList); studentComboBox.setItems(studentsList); studentsTableView.setItems(studentsList); idColumn.setCellValueFactory( new Callback<CellDataFeatures<Student, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<Student, String> param) { return new SimpleStringProperty(param.getValue().getStudentId()); } }); nameColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getStudentName())); cgpaColumn.setCellValueFactory(param -> new SimpleDoubleProperty(param.getValue().getCgpa())); final String HOSTNAME = "172.17.0.134"; final String DBNAME = "studentinfodb"; final String USERNAME = "cse2015fall2016"; final String PASSWORD = "java"; final String DBURL = "jdbc:mysql://" + HOSTNAME + "/" + DBNAME; try { Connection connection = DriverManager.getConnection(DBURL, USERNAME, PASSWORD); System.out.println("Connected"); Statement statement = connection.createStatement(); String query = "select * from studentInfo;"; ResultSet resultSet = statement.executeQuery(query); while (resultSet.next()) { Student student = new Student(resultSet.getString("studentId"), resultSet.getString("studentName"), resultSet.getDouble("cgpa")); studentsList.add(student); } if (studentsList.size() > 0) { displayCurrentStudent(); } } catch (SQLException ex) { Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex); } }
private VBox getAddColumnForm() { final TextField tfColumnName = new TextField(); tfColumnName.setPromptText("new column name"); tfColumnName.setId(NEW_COLUMN_NAME_TEXTFIELD_ID); final TextField indexTf = new TextField(); indexTf.setPromptText("at index"); indexTf.setId(NEW_COLUMN_INDEX_TEXTFIELD_UD); final CheckBox addDataPropertiesTabToTab = new CheckBox("with properties table for data"); addDataPropertiesTabToTab.setId(NEW_COLUMN_GET_DATA_PROPERTIES_TAB_ID); final CheckBox addColumnPropertiesTableToTab = new CheckBox("with properties table for column"); addColumnPropertiesTableToTab.setId(NEW_COLUMN_GET_COLUMN_PROPERTIES_TAB_ID); Button button = new Button("Add"); button.setId(NEW_COLUMN_ADD_BUTTON_ID); button.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { final String name = tfColumnName.getText(); int index = Integer.parseInt(indexTf.getText()); TableColumn column = new TableColumn(name); column.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<DataItem, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<DataItem, String> p) { return p.getValue().get(name); } }); introduceColumn(name, column); if (addColumnPropertiesTableToTab.isSelected()) { tabPane.addPropertiesTable(name, NodeControllerFactory.createFullController(column, tabPane)); } testedTableView.getColumns().add(index, column); if (addDataPropertiesTabToTab.isSelected()) { final PropertiesTable forData = new PropertiesTable(null); for (DataItem item : allData) { forData.addStringLine(item.get(name), "new value"); } tabPane.addPropertiesTable(name + " data", forData.getVisualRepresentation()); } } }); HBox hb1 = new HBox(3); hb1.getChildren().addAll(new Label("With name"), tfColumnName); HBox hb2 = new HBox(3); hb2.getChildren().addAll(new Label("At index"), indexTf, button); VBox vb = new VBox(); vb.getChildren().addAll(hb1, addDataPropertiesTabToTab, addColumnPropertiesTableToTab, hb2); return vb; }
@Override public ObservableValue<Number> call(final CellDataFeatures<DateBean, Number> param) { return param.getValue().auslastungProperty(); }
@Override public void run() { if (dialog == null) { dialog = new Stage(); if (QuPathGUI.getInstance() != null) dialog.initOwner(QuPathGUI.getInstance().getStage()); dialog.setTitle("View tracker"); for (int i = 0; i < nCols(tracker); i++) { final int col = i; TableColumn<ViewRecordingFrame, Object> column = new TableColumn<>(getColumnName(col)); column.setCellValueFactory(new Callback<CellDataFeatures<ViewRecordingFrame, Object>, ObservableValue<Object>>() { @Override public ObservableValue<Object> call(CellDataFeatures<ViewRecordingFrame, Object> frame) { return new SimpleObjectProperty<>(getColumnValue(frame.getValue(), col)); } }); table.getColumns().add(column); } table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); table.getSelectionModel().selectedItemProperty().addListener((v, o, frame) -> { if (frame != null) ViewTrackerPlayback.setViewerForFrame(viewer, frame); }); refreshTracker(); Button btnImport = new Button("Import"); btnImport.setOnAction(e -> { if (handleImport(tracker)) { refreshTracker(); } }); Button btnExport = new Button("Export"); btnExport.setOnAction(e -> { handleExport(tracker); }); Button btnCopy = new Button("Copy to clipboard"); btnCopy.setOnAction(e -> { ClipboardContent content = new ClipboardContent(); content.putString(tracker.getSummaryString()); Clipboard clipboard = Clipboard.getSystemClipboard(); clipboard.setContent(content); }); GridPane panelButtons = PanelToolsFX.createColumnGridControls( btnImport, btnExport, btnCopy ); BorderPane pane = new BorderPane(); pane.setCenter(table); pane.setBottom(panelButtons); dialog.setScene(new Scene(pane)); } dialog.show(); dialog.toFront(); }
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); }
/** * Build a table column * * @param <T> Type of the view object stored in the table * @param <U> Type of data stored in the table cells * @param cellValueFactory How to set the cell values * @param valueConverter Function that converts T to string representation * @param alignmentStyle Column content alignment * @param columnName Column name displayed in the column header * @return Built column */ public static <T, U> TableColumn<T, U> buildColumn( final Callback<CellDataFeatures<T, U>, ObservableValue<U>> cellValueFactory, final Function<T, String> valueConverter, final String alignmentStyle, final String columnName) { final TableColumn<T, U> builtColumn = new TableColumn<>(columnName); builtColumn.setId(columnName); builtColumn.setGraphic(TableUtils.buildColumnHeader(builtColumn, alignmentStyle)); builtColumn.setCellValueFactory(cellValueFactory); builtColumn.setCellFactory(column -> new TableCell<T, U>() { final Label valueLabel = new Label(); @Override protected final void updateItem(final U value, final boolean empty) { super.updateItem(value, empty); if(empty) { setText(null); setGraphic(null); } else { if(this.getTableRow() == null) { return; } final T item = this.getTableView().getItems().get(this.getTableRow().getIndex()); valueLabel.setText(valueConverter.apply(item)); this.setGraphic(valueLabel); if(GuiUtils.RIGHT_ALIGNED_COLUMN_HEADER_TYPE_NAME.equals(alignmentStyle)) { this.setAlignment(Pos.BASELINE_RIGHT); super.setPadding(GuiUtils.rightPadding()); } else { this.setAlignment(Pos.BASELINE_LEFT); super.setPadding(GuiUtils.leftPadding()); } } } }); return builtColumn; }
private LinkedHashMap<String, TableColumn<TrackableView, ?>> buildColumnMappings() { final Function<TrackableView, String> updateInValueConverter = tv -> { if(!tv.isUserManaged() || tv.getTorrentView().getStatus() == TorrentStatus.STOPPED) { return ""; } final long nextUpdateValue = tv.getNextUpdate(); if(nextUpdateValue < 1000 || (nextUpdateValue > 0 && "".equals(tv.getStatus()))) { return Tracker.STATUS_UPDATING_MESSAGE; } else { return UnitConverter.formatMillisToTime(nextUpdateValue); } }; final Function<TrackableView, String> intervalValueConverter = tv -> { final long interval = tv.getInterval(); return (tv.isUserManaged() && tv.getTorrentView().getStatus() != TorrentStatus.STOPPED) && (interval > 0)? UnitConverter.formatMillisToTime(interval) : ""; }; final Function<TrackableView, String> minIntervalValueConverter = tv -> tv.isUserManaged() && tv.getTorrentView().getStatus() != TorrentStatus.STOPPED? UnitConverter.formatMillisToTime(tv.getMinInterval()) : ""; final Callback<CellDataFeatures<TrackableView, String>, ObservableValue<String>> nameValueFactory = tv -> new ReadOnlyObjectWrapper<>(tv.getValue().getName()); final Callback<CellDataFeatures<TrackableView, String>, ObservableValue<String>> statusValueFactory = tv -> tv.getValue().statusProperty(); final Callback<CellDataFeatures<TrackableView, Number>, ObservableValue<Number>> nextUpdateValueFactory = tv -> tv.getValue().nextUpdateProperty(); final Callback<CellDataFeatures<TrackableView, Number>, ObservableValue<Number>> intervalValueFactory = tv -> tv.getValue().intervalProperty(); final Callback<CellDataFeatures<TrackableView, Number>, ObservableValue<Number>> minIntervalValueFactory = tv -> tv.getValue().minIntervalProperty(); final Callback<CellDataFeatures<TrackableView, Number>, ObservableValue<Number>> seedsValueFactory = tv -> tv.getValue().seedsProperty(); final Callback<CellDataFeatures<TrackableView, Number>, ObservableValue<Number>> peersValueFactory = tv -> tv.getValue().leechersProperty(); final Callback<CellDataFeatures<TrackableView, Number>, ObservableValue<Number>> downloadedValueFactory = tv -> tv.getValue().downloadedProperty(); final TableColumn<TrackableView, String> nameColumn = TableUtils.buildColumn(nameValueFactory, TrackableView::getName, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME, NAME_COLUMN_NAME); trackerTable.getSortOrder().add(nameColumn); final LinkedHashMap<String, TableColumn<TrackableView, ?>> columnMappings = new LinkedHashMap<>(); columnMappings.put(NAME_COLUMN_NAME, nameColumn); columnMappings.put(STATUS_COLUMN_NAME, TableUtils.buildColumn(statusValueFactory, TrackableView::getStatus, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME, STATUS_COLUMN_NAME)); columnMappings.put(UPDATE_IN_COLUMN_NAME, TableUtils.buildColumn(nextUpdateValueFactory, updateInValueConverter, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME, UPDATE_IN_COLUMN_NAME)); columnMappings.put(INTERVAL_COLUMN_NAME, TableUtils.buildColumn(intervalValueFactory, intervalValueConverter, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME, INTERVAL_COLUMN_NAME)); columnMappings.put(MIN_INTERVAL_COLUMN_NAME, TableUtils.buildColumn(minIntervalValueFactory, minIntervalValueConverter, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME, MIN_INTERVAL_COLUMN_NAME)); columnMappings.put(SEEDS_COLUMN_NAME, TableUtils.buildColumn(seedsValueFactory, val -> String.valueOf(val.getSeeders()), GuiUtils.RIGHT_ALIGNED_COLUMN_HEADER_TYPE_NAME, SEEDS_COLUMN_NAME)); columnMappings.put(PEERS_COLUMN_NAME, TableUtils.buildColumn(peersValueFactory, val -> String.valueOf(val.getLeechers()), GuiUtils.RIGHT_ALIGNED_COLUMN_HEADER_TYPE_NAME, PEERS_COLUMN_NAME)); columnMappings.put(DOWNLOADED_COLUMN_NAME, TableUtils.buildColumn(downloadedValueFactory, val -> String.valueOf(val.getDownloaded()), GuiUtils.RIGHT_ALIGNED_COLUMN_HEADER_TYPE_NAME, DOWNLOADED_COLUMN_NAME)); return columnMappings; }
private TableColumn<ReportLine, String> toTableLineColumn(String header, Callback<CellDataFeatures<ReportLine, String>, ObservableValue<String>> callback) { TableColumn tc = new TableColumn(); tc.setText(header); tc.setCellValueFactory(callback); return tc; }
@Override public ObservableValue<SearchResultConcept> call(CellDataFeatures<SearchResultConcept, SearchResultConcept> param) { return new SimpleObjectProperty<SearchResultConcept>(param.getValue()); }
@Override public ObservableValue<MappingItem> call(CellDataFeatures<MappingItem, MappingItem> param) { return new SimpleObjectProperty<MappingItem>(param.getValue()); }
@Override public ObservableValue<MappingSet> call(CellDataFeatures<MappingSet, MappingSet> param) { return new SimpleObjectProperty<MappingSet>(param.getValue()); }
private void addTableColumns(RelationshipColumnType[] columns, boolean isStampColumnSet, Callback<TableColumn<RelationshipVersion, RelationshipVersion>, TableCell<RelationshipVersion, RelationshipVersion>> cellFactory) { TableColumn<RelationshipVersion, RelationshipVersion> nestingParent = null; if (isStampColumnSet) { nestingParent = new TableColumn<>("Stamp Fields"); relationshipsTable.getColumns().add(nestingParent); stampColumns.add(nestingParent); } for (RelationshipColumnType col : columns) { TableColumn<RelationshipVersion, RelationshipVersion> tc = new TableColumn<RelationshipVersion, RelationshipVersion>(col.toString()); tc.setUserData(col); tc.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<RelationshipVersion, RelationshipVersion>, ObservableValue<RelationshipVersion>>() { @Override public ObservableValue<RelationshipVersion> call(CellDataFeatures<RelationshipVersion, RelationshipVersion> param) { return new SimpleObjectProperty<RelationshipVersion>(param.getValue()); } }); tc.setCellFactory(cellFactory); //TODO Dan forgot to put comparators on these columns //off by default if (col == RelationshipColumnType.UUID || col == RelationshipColumnType.SOURCE) { tc.setVisible(false); } if (col == RelationshipColumnType.SOURCE) { sourceColumn = tc; } if (nestingParent == null) { relationshipsTable.getColumns().add(tc); } else { nestingParent.getColumns().add(tc); stampColumns.add(tc); } } }
private void addTableColumns(DescriptionColumnType[] columns, boolean isStampColumnSet, Callback<TableColumn<DescriptionVersion, DescriptionVersion>, TableCell<DescriptionVersion, DescriptionVersion>> cellFactory) { TableColumn<DescriptionVersion, DescriptionVersion> nestingParent = null; if (isStampColumnSet) { nestingParent = new TableColumn<>("Stamp Fields"); descriptionsTable.getColumns().add(nestingParent); stampColumns.add(nestingParent); } for (DescriptionColumnType col : columns) { TableColumn<DescriptionVersion, DescriptionVersion> tc = new TableColumn<DescriptionVersion, DescriptionVersion>(col.toString()); tc.setUserData(col); tc.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<DescriptionVersion, DescriptionVersion>, ObservableValue<DescriptionVersion>>() { @Override public ObservableValue<DescriptionVersion> call(CellDataFeatures<DescriptionVersion, DescriptionVersion> param) { return new SimpleObjectProperty<DescriptionVersion>(param.getValue()); } }); tc.setCellFactory(cellFactory); //TODO Dan forgot to put comparators on these columns //off by default if (col == DescriptionColumnType.UUID) { tc.setVisible(false); } if (nestingParent == null) { descriptionsTable.getColumns().add(tc); } else { nestingParent.getColumns().add(tc); stampColumns.add(tc); } } }
@Override public ObservableValue<T> call(CellDataFeatures<S, T> param) { return getCellDataReflectively(param.getValue()); }