List of usage examples for javafx.beans.property ReadOnlyStringWrapper ReadOnlyStringWrapper
public ReadOnlyStringWrapper(String initialValue)
From source file:com.ggvaidya.scinames.ui.DatasetDiffController.java
@FXML private void displayComparisonStats(ActionEvent e) { Dataset ds1 = dataset1ComboBox.getValue(); Dataset ds2 = dataset2ComboBox.getValue(); Table<String, Dataset, String> precalc = getComparisonStats(ds1, ds2); ObservableList<TableColumn> cols = comparisonTableView.getColumns(); cols.clear();/*from w ww .j ava 2 s .c o m*/ TableColumn<String, String> rowName = new TableColumn<>(""); rowName.setCellValueFactory(cvf -> new ReadOnlyStringWrapper(cvf.getValue())); cols.add(rowName); for (Dataset ds : Arrays.asList(ds1, ds2)) { TableColumn<String, String> datasetCol = new TableColumn<>(ds.getName()); datasetCol.setCellValueFactory(cvf -> new ReadOnlyStringWrapper(precalc.get(cvf.getValue(), ds))); cols.add(datasetCol); } // The "items" here are just the rows we've calculated. comparisonTableView.setItems(getComparisonStatRowHeaders()); }
From source file:com.ggvaidya.scinames.ui.DatasetDiffController.java
private TableColumn<DatasetRow, String> createTableColumnForDatasetRow(String colName, Function<DatasetRow, String> func) { TableColumn<DatasetRow, String> col = new TableColumn<>(colName); col.setCellValueFactory(cvf -> new ReadOnlyStringWrapper(func.apply(cvf.getValue()))); return col;//from w w w. ja v a 2s . c om }
From source file:jduagui.Controller.java
private TreeTableColumn setNameColumn() { TreeTableColumn<File, String> col = new TreeTableColumn<>("Name"); col.setCellValueFactory((CellDataFeatures<File, String> p) -> { File f = p.getValue().getValue(); if (f.getPath().equals(rootPath)) return new ReadOnlyStringWrapper(f.getPath()); else/*from w ww. j a va 2s .c o m*/ return new ReadOnlyStringWrapper(f.getName()); }); return col; }
From source file:jduagui.Controller.java
private TreeTableColumn setSizeColumn() { TreeTableColumn<File, String> col = new TreeTableColumn<>("Size"); col.setCellValueFactory((CellDataFeatures<File, String> p) -> { ReadOnlyStringWrapper wrap;//from w w w . j a v a 2s. c o m File file = p.getValue().getValue(); String curPath = file.getPath(); long size = file.length(); if (file.isDirectory()) { if (storageCache.containsKey(curPath)) { wrap = new ReadOnlyStringWrapper(getByteSize(storageCache.get(curPath))); } else { try { size = FileItem.getSize(curPath, subDirs, subFiles); storageCache.put(curPath, size); wrap = new ReadOnlyStringWrapper(getByteSize(size)); } catch (IOException e) { storageCache.put(curPath, new Long(0)); wrap = new ReadOnlyStringWrapper(getByteSize(0)); } } } else if (file.isFile()) { storageCache.put(curPath, size); wrap = new ReadOnlyStringWrapper(getByteSize(size)); } else { storageCache.put(curPath, new Long(0)); wrap = new ReadOnlyStringWrapper(getByteSize(0)); } return wrap; }); col.setComparator(new sizeComparator()); return col; }
From source file:jduagui.Controller.java
private TreeTableColumn setPercentColumn() { TreeTableColumn<File, String> col = new TreeTableColumn<>("~Percent"); col.setCellValueFactory((CellDataFeatures<File, String> p) -> { ReadOnlyStringWrapper wrap;/* w w w .j av a 2 s . c o m*/ File file = p.getValue().getValue(); String curPath = file.getPath(); if (curPath.equals(rootPath)) { wrap = new ReadOnlyStringWrapper("100.00 %"); } else { if ((storageCache.get(curPath) != null) && (storageCache.get(curPath) > 0)) { double percentage = (double) storageCache.get(curPath); percentage /= storageCache.get(file.getParent()); if (percentage == 1.0) wrap = new ReadOnlyStringWrapper("100.00 %"); else { percentage *= 100.0; wrap = new ReadOnlyStringWrapper(twoDecimals(new BigDecimal(percentage), " %")); } } else { wrap = new ReadOnlyStringWrapper("0.00 %"); } } return wrap; }); col.setComparator(new percentComparator()); return col; }
From source file:com.ggvaidya.scinames.complexquery.ComplexQueryViewController.java
private TableColumn<NameCluster, String> createColumnFromPrecalc(String colName, Table<NameCluster, String, Set<String>> precalc) { TableColumn<NameCluster, String> column = new TableColumn<>(colName); column.cellValueFactoryProperty().set((TableColumn.CellDataFeatures<NameCluster, String> cdf) -> { NameCluster nc = cdf.getValue(); // There might be columns found in some dataset but not in others // so we detect those cases here and put in "NA"s instead. String output = "NA"; if (precalc.contains(nc, colName)) output = precalc.get(nc, colName).stream().collect(Collectors.joining("; ")); return new ReadOnlyStringWrapper(output); });//from w w w. ja v a 2s . c o m column.setPrefWidth(100.0); column.setEditable(false); return column; }
From source file:jduagui.Controller.java
private TreeTableColumn setItemColumn() { TreeTableColumn<File, String> col = new TreeTableColumn<>("Items"); col.setCellValueFactory((CellDataFeatures<File, String> p) -> { File file = p.getValue().getValue(); String curPath = file.getPath(); if (file.isDirectory()) { return new ReadOnlyStringWrapper("" + (subDirs.get(curPath) + subFiles.get(curPath))); } else//from w w w .j av a2 s. c o m return new ReadOnlyStringWrapper(""); }); col.setComparator(new longComparator()); return col; }
From source file:jduagui.Controller.java
private TreeTableColumn setDirColumn() { TreeTableColumn<File, String> col = new TreeTableColumn<>("Subdirectories"); col.setCellValueFactory((CellDataFeatures<File, String> p) -> { File file = p.getValue().getValue(); String curPath = file.getPath(); if (file.isDirectory()) { return new ReadOnlyStringWrapper("" + subDirs.get(curPath)); } else//from w ww.j a va2s . com return new ReadOnlyStringWrapper(""); }); col.setComparator(new longComparator()); return col; }
From source file:jduagui.Controller.java
private TreeTableColumn setFileColumn() { TreeTableColumn<File, String> col = new TreeTableColumn<>("Files"); col.setCellValueFactory((CellDataFeatures<File, String> p) -> { File file = p.getValue().getValue(); String curPath = file.getPath(); if (file.isDirectory()) { return new ReadOnlyStringWrapper("" + subFiles.get(curPath)); } else// w w w . j a v a2 s. co m return new ReadOnlyStringWrapper(""); }); col.setComparator(new longComparator()); return col; }
From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java
private void fillTableViewWithDatasetRows(TableView<DatasetRow> tableView) { // We need to precalculate. ObservableList<DatasetRow> rows = dataset.rowsProperty(); // Setup table. tableView.editableProperty().set(false); ObservableList<TableColumn<DatasetRow, ?>> cols = tableView.getColumns(); cols.clear();//from www . ja v a2 s . co m // Set up columns. TableColumn<DatasetRow, String> colRowName = new TableColumn<>("Name"); colRowName.setCellValueFactory((TableColumn.CellDataFeatures<DatasetRow, String> features) -> { DatasetRow row = features.getValue(); Set<Name> names = dataset.getNamesInRow(row); if (names.isEmpty()) { return new ReadOnlyStringWrapper("(None)"); } else { return new ReadOnlyStringWrapper( names.stream().map(n -> n.getFullName()).collect(Collectors.joining("; "))); } }); colRowName.setPrefWidth(100.0); cols.add(colRowName); // Create a column for every column here. dataset.getColumns().forEach((DatasetColumn col) -> { String colName = col.getName(); TableColumn<DatasetRow, String> colColumn = new TableColumn<>(colName); colColumn.setCellValueFactory((TableColumn.CellDataFeatures<DatasetRow, String> features) -> { DatasetRow row = features.getValue(); String val = row.get(colName); return new ReadOnlyStringWrapper(val == null ? "" : val); }); colColumn.setPrefWidth(100.0); cols.add(colColumn); }); // Set table items. tableView.itemsProperty().set(rows); // What if it's empty? tableView.setPlaceholder(new Label("No data contained in this dataset.")); }