javafx.scene.control.TreeTableColumn Java Examples
The following examples show how to use
javafx.scene.control.TreeTableColumn.
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: ResizableJfxTreeTableView.java From milkman with MIT License | 6 votes |
public void resizeColumns() { try { Method method = getClass().getClassLoader() .loadClass("javafx.scene.control.skin.TableSkinUtils") .getMethod("resizeColumnToFitContent", TableViewSkinBase.class, TableColumnBase.class, int.class); method.setAccessible(true); for (TreeTableColumn<R, ?> column : this.getColumns()) { method.invoke(null, getSkin(), column, -1); } } catch (Throwable t) { //for some reason, a NPE will be thrown now and then, some racing condition? log.warn("Failed to resize columns"); } // TableSkinUtils.resizeColumnToFitContent((TableViewSkinBase<?, ?, ?, ?, ?>) getSkin(), getTreeColumn(), -1); // ((ResizableJfxTreeTableViewSkin<R>)getSkin()).resizeAllColumns(); }
Example #2
Source File: DoubleRenderer.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) { return new TreeTableCell<FeatureTableRow, Object>() { @Override public void updateItem(Object object, boolean empty) { super.updateItem(object, empty); setStyle("-fx-alignment: CENTER;" + "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;"); if (object == null) { setText(null); } else { // Default format to two decimals NumberFormat formatter = new DecimalFormat("#0.00"); Double doubleValue = Double.parseDouble(object.toString()); setText(formatter.format(doubleValue)); } } }; }
Example #3
Source File: RtRenderer.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) { return new TreeTableCell<FeatureTableRow, Object>() { @Override public void updateItem(Object object, boolean empty) { super.updateItem(object, empty); setStyle("-fx-alignment: CENTER;" + "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;"); if (object == null) { setText(null); } else { NumberFormat formatter = MZmineCore.getConfiguration().getRTFormat(); Float floatValue = Float.parseFloat(object.toString()); setText(formatter.format(floatValue)); } } }; }
Example #4
Source File: IntensityRenderer.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) { return new TreeTableCell<FeatureTableRow, Object>() { @Override public void updateItem(Object object, boolean empty) { super.updateItem(object, empty); setStyle("-fx-alignment: CENTER;" + "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;"); if (object == null) { setText(null); } else { Double doubleValue = Double.parseDouble(object.toString()); NumberFormat formatter = MZmineCore.getConfiguration().getIntensityFormat(); setText(formatter.format(doubleValue)); } } }; }
Example #5
Source File: RtRangeRenderer.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) { return new TreeTableCell<FeatureTableRow, Object>() { @Override public void updateItem(Object object, boolean empty) { super.updateItem(object, empty); setStyle("-fx-alignment: CENTER;" + "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;"); if (object == null) { setText(null); } else { Range rangeValue = (Range) object; NumberFormat formatter = MZmineCore.getConfiguration().getMZFormat(); String value = formatter.format(rangeValue.lowerEndpoint()) + " - " + formatter.format(rangeValue.upperEndpoint()); setText(value); } } }; }
Example #6
Source File: EditableTreeTable.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
/** * @return the elements corresponding to the active cell */ public List<E> getSelectedElements() { ObservableList<TreeTablePosition<EditableTreeTableLineItem<Wrapper<E>>, ?>> selectedcells = treetableview .getSelectionModel().getSelectedCells(); if (selectedcells.size() == 1) { TreeTablePosition<EditableTreeTableLineItem<Wrapper<E>>, ?> selectedposition = selectedcells.get(0); TreeTableColumn<EditableTreeTableLineItem<Wrapper<E>>, ?> tablecolumn = selectedposition.getTableColumn(); if (tablecolumn instanceof EditableTreeTableValueColumn) { @SuppressWarnings({ "unchecked", "rawtypes" }) EditableTreeTableValueColumn<E, ?, ?> tablecolumnparsed = (EditableTreeTableValueColumn) tablecolumn; TreeItem<EditableTreeTableLineItem<Wrapper<E>>> treeitem = selectedposition.getTreeItem(); EditableTreeTableLineItem<Wrapper<E>> rowdata = treeitem.getValue(); ArrayList<Wrapper<E>> filteredvalues = tablecolumnparsed.columngrouping.filterItems(rowdata, tablecolumnparsed.titlekey); ArrayList<E> returnedvalues = new ArrayList<E>(); for (int i = 0; i < filteredvalues.size(); i++) { returnedvalues.add(filteredvalues.get(i).getPayload()); } return returnedvalues; } } return new ArrayList<E>(); }
Example #7
Source File: RFXTreeTableViewTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void selectACell() { TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { TreeTableViewSelectionModel<?> selectionModel = treeTableView.getSelectionModel(); selectionModel.setCellSelectionEnabled(true); Point2D point = getPoint(treeTableView, 1, 0); RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, point, lr); rfxTreeTableView.focusGained(null); @SuppressWarnings("rawtypes") TreeTableColumn column = getTreeTableColumnAt(treeTableView, 0); selectionModel.select(1, column); rfxTreeTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("{\"cells\":[[\"/Sales Department/Ethan Williams\",\"Employee\"]]}", recording.getParameters()[0]); }
Example #8
Source File: SnapshotTreeTable.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** * Update the table column titles, by putting an asterisk to non saved snapshots or remove asterisk from saved * snapshots. */ private void updateTableColumnTitles() { // add the * to the title of the column if the snapshot is not saved if (uiSnapshots.size() == 1) { ((TooltipTreeTableColumn<?>) getColumns().get(6)).setSaved(true); //uiSnapshots.get(0).isSaved()); } else { TreeTableColumn<TreeTableEntry, ?> column = getColumns().get(4); for (int i = 0; i < uiSnapshots.size(); i++) { TreeTableColumn tableColumn = column.getColumns().get(i); if(tableColumn instanceof DividerTreeTableColumn){ continue; } ((TooltipTreeTableColumn<?>) tableColumn).setSaved(true); //uiSnapshots.get(i).isSaved()); } } }
Example #9
Source File: EditableTreeTable.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
/** * generates the root column showing label of line elements */ private void generateRootColumn() { TreeTableColumn< EditableTreeTableLineItem<Wrapper<E>>, String> rootcolumn = new TreeTableColumn<EditableTreeTableLineItem<Wrapper<E>>, String>("Item"); rootcolumn.setCellValueFactory(new Callback< CellDataFeatures<EditableTreeTableLineItem<Wrapper<E>>, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<EditableTreeTableLineItem<Wrapper<E>>, String> param) { return new SimpleStringProperty(param.getValue().getValue().getLabel()); } }); treetableview.getColumns().add(rootcolumn); }
Example #10
Source File: IntegerRenderer.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) { return new TreeTableCell<FeatureTableRow, Object>() { @Override public void updateItem(Object object, boolean empty) { super.updateItem(object, empty); setStyle("-fx-alignment: CENTER;" + "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;"); if (object == null) { setText(null); } else { Integer integerValue = Integer.parseInt(object.toString()); setText(integerValue.toString()); } } }; }
Example #11
Source File: RFXTreeTableViewTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void selectMultipleCells() { TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { TreeTableViewSelectionModel<?> selectionModel = treeTableView.getSelectionModel(); selectionModel.setCellSelectionEnabled(true); selectionModel.setSelectionMode(SelectionMode.MULTIPLE); Point2D point = getPoint(treeTableView, 1, 0); RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, point, lr); rfxTreeTableView.focusGained(null); @SuppressWarnings("rawtypes") TreeTableColumn column = getTreeTableColumnAt(treeTableView, 0); selectionModel.select(1, column); selectionModel.select(3, getTreeTableColumnAt(treeTableView, 1)); rfxTreeTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals( "{\"cells\":[[\"/Sales Department/Ethan Williams\",\"Employee\"],[\"/Sales Department/Michael Brown\",\"Email\"]]}", recording.getParameters()[0]); }
Example #12
Source File: DefaultRenderer.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) { return new TreeTableCell<FeatureTableRow, Object>() { @Override public void updateItem(Object object, boolean empty) { super.updateItem(object, empty); setStyle("-fx-alignment: CENTER;" + "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;"); if (object == null) { setText(null); } else { try { NumberFormat formatter = new DecimalFormat("#0.00"); Double doubleValue = Double.parseDouble(object.toString()); setText(formatter.format(doubleValue)); } catch (NumberFormatException e) { setText(object.toString()); } } } }; }
Example #13
Source File: NumberRangeType.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override @Nonnull public List<TreeTableColumn<ModularFeatureListRow, Object>> createSubColumns( @Nullable RawDataFile raw) { List<TreeTableColumn<ModularFeatureListRow, Object>> cols = new ArrayList<>(); // create column per name TreeTableColumn<ModularFeatureListRow, Object> min = new TreeTableColumn<>("min"); DataTypeCellValueFactory cvFactoryMin = new DataTypeCellValueFactory(raw, this); min.setCellValueFactory(cvFactoryMin); min.setCellFactory(new DataTypeCellFactory(raw, this, 0)); TreeTableColumn<ModularFeatureListRow, Object> max = new TreeTableColumn<>("max"); DataTypeCellValueFactory cvFactoryMax = new DataTypeCellValueFactory(raw, this); max.setCellValueFactory(cvFactoryMax); max.setCellFactory(new DataTypeCellFactory(raw, this, 1)); // add all cols.add(min); cols.add(max); return cols; }
Example #14
Source File: MzRenderer.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) { return new TreeTableCell<FeatureTableRow, Object>() { @Override public void updateItem(Object object, boolean empty) { super.updateItem(object, empty); setStyle("-fx-alignment: CENTER;" + "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;"); if (object == null) { setText(null); } else { NumberFormat formatter = MZmineCore.getConfiguration().getMZFormat(); Double doubleValue = Double.parseDouble(object.toString()); setText(formatter.format(doubleValue)); } } }; }
Example #15
Source File: TreeTableFileSizeCell.java From MyBox with Apache License 2.0 | 6 votes |
@Override public TreeTableCell<T, Long> call(TreeTableColumn<T, Long> param) { TreeTableCell<T, Long> cell = new TreeTableCell<T, Long>() { private final Text text = new Text(); @Override protected void updateItem(final Long item, boolean empty) { super.updateItem(item, empty); if (empty || item == null || (long) item <= 0) { setText(null); setGraphic(null); return; } text.setText(FileTools.showFileSize((long) item)); setGraphic(text); } }; return cell; }
Example #16
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 5 votes |
protected int getTreeTableColumnIndex(TreeTableView<?> treeTableView, String columnName) { ObservableList<?> columns = treeTableView.getColumns(); int ncolumns = columns.size(); for (int i = 0; i < ncolumns; i++) { @SuppressWarnings("rawtypes") String column = ((TreeTableColumn) columns.get(i)).getText(); if (columnName.equals(escapeSpecialCharacters(column))) { return i; } } throw new RuntimeException("Could not find column " + columnName + " in tree table"); }
Example #17
Source File: JFXTreeTableView.java From JFoenix with Apache License 2.0 | 5 votes |
public void reGroup() { if (!groupOrder.isEmpty()) { ArrayList<TreeTableColumn<S, ?>> tempGroups = new ArrayList<>(groupOrder); groupOrder.clear(); group(tempGroups.toArray(new TreeTableColumn[0])); } }
Example #18
Source File: FormulaFunctionViewer.java From diirt with MIT License | 5 votes |
public FormulaFunctionViewer() { FXMLLoader fxmlLoader = new FXMLLoader( getClass().getResource("FormulaFunctionViewer.fxml")); fxmlLoader.setRoot(this); fxmlLoader.setController(this); try { fxmlLoader.load(); } catch (IOException exception) { throw new RuntimeException(exception); } // functionsTreeTable = new TreeTableView<>(); // setHgrow(functionsTreeTable, Priority.ALWAYS); TreeItem<BrowserItem> root = new TreeBrowserItem(new FormulaFunctionRootBrowserItem()); root.setExpanded(true); functionsTreeTable.setRoot(root); functionsTreeTable.setShowRoot(false); functionsTreeTable.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY); TreeTableColumn<BrowserItem,String> nameCol = new TreeTableColumn<>("Name"); TreeTableColumn<BrowserItem,String> descriptionCol = new TreeTableColumn<>("Description"); functionsTreeTable.getColumns().setAll(nameCol, descriptionCol); nameCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("name")); descriptionCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("description")); }
Example #19
Source File: IonAnnotationRenderer.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) { return new TreeTableCell<FeatureTableRow, Object>() { @Override public void updateItem(Object object, boolean empty) { super.updateItem(object, empty); setStyle("-fx-alignment: CENTER-LEFT;" + "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;"); if (object == null) { setText(null); } else { List<IonAnnotation> ionAnnotations = (List<IonAnnotation>) object; String value = ""; for (IonAnnotation ionAnnotation : ionAnnotations) { if (value != "") value = value + "\n"; if (ionAnnotation.getDescription() != null) value = value + ionAnnotation.getDescription(); else value = value + ionAnnotation.getAnnotationId(); } setText(value); } } }; }
Example #20
Source File: ChoiceBoxTreeTableSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private void updateObservableListProperties(TreeTableColumn<Employee, String> empColumn) { empColumn.setOnEditCommit(new EventHandler<TreeTableColumn.CellEditEvent<Employee, String>>() { @Override public void handle(CellEditEvent<Employee, String> t) { TreeItem<Employee> treeItem = t.getTreeTableView().getTreeItem(t.getTreeTablePosition().getRow()); treeItem.getValue().setName(t.getNewValue()); } }); }
Example #21
Source File: FxTreeTable.java From FxDock with Apache License 2.0 | 5 votes |
private Callback createCellFactory() { return new Callback<TreeTableColumn<T,?>,TreeTableCell<T,?>>() { @Override public TreeTableCell<T,?> call(TreeTableColumn<T,?> column) { return new TreeTableCell() { @Override protected void updateItem(Object item, boolean empty) { if(item == getItem()) { return; } super.updateItem(item, empty); if(item == null) { super.setText(null); super.setGraphic(null); } else if(item instanceof Node) { super.setText(null); super.setGraphic((Node)item); } else { super.setText(item.toString()); super.setGraphic(null); } } }; } }; }
Example #22
Source File: FxTreeTableColumn.java From FxDock with Apache License 2.0 | 5 votes |
private TreeTableCell<T,Object> getCellFactory(TreeTableColumn<T,Object> tc) { return new TreeTableCell<T,Object>() { @Override protected void updateItem(Object item, boolean empty) { super.updateItem(item, empty); if(empty) { setText(null); setGraphic(null); } else { if(renderer == null) { String text = formatter.toString(item); setText(text); setGraphic(null); setAlignment(alignment); } else { Node n = renderer.apply(item); setText(null); setGraphic(n); } } } }; }
Example #23
Source File: TextFieldTreeTableSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private void updateObservableListProperties(TreeTableColumn<Employee, String> empColumn) { empColumn.setOnEditCommit(new EventHandler<TreeTableColumn.CellEditEvent<Employee, String>>() { @Override public void handle(CellEditEvent<Employee, String> t) { TreeItem<Employee> treeItem = t.getTreeTableView().getTreeItem(t.getTreeTablePosition().getRow()); treeItem.getValue().setName(t.getNewValue()); } }); }
Example #24
Source File: FileBrowser.java From phoebus with Eclipse Public License 1.0 | 5 votes |
@Override public void restore(final Memento memento) { memento.getString(DIRECTORY).ifPresent(dir -> controller.setRoot(new File(dir))); int i = 0; for (TreeTableColumn<?,?> col : controller.getView().getColumns()) { if (! memento.getBoolean(SHOW_COLUMN+i).orElse(true)) col.setVisible(false); memento.getNumber(WIDTH+i).ifPresent(width -> col.setPrefWidth(width.doubleValue())); ++i; } }
Example #25
Source File: GenericEditableTreeTableCell.java From JFoenix with Apache License 2.0 | 5 votes |
private List<TreeTableColumn<S, ?>> getLeaves(TreeTableColumn<S, ?> root) { List<TreeTableColumn<S, ?>> columns = new ArrayList<>(); if (root.getColumns().isEmpty()) { //We only want the leaves that are editable. if (root.isEditable()) { columns.add(root); } return columns; } else { for (TreeTableColumn<S, ?> column : root.getColumns()) { columns.addAll(getLeaves(column)); } return columns; } }
Example #26
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") public TreeTableCell getVisibleCellAt(TreeTableView<?> treeTableView, int row, int column) { Set<Node> lookupAll = getTreeTableCells(treeTableView); TreeTableCell cell = null; for (Node node : lookupAll) { TreeTableCell<?, ?> cell1 = (TreeTableCell<?, ?>) node; TreeTableRow<?> tableRow = cell1.getTreeTableRow(); TreeTableColumn<?, ?> tableColumn = cell1.getTableColumn(); if (tableRow.getIndex() == row && tableColumn == treeTableView.getColumns().get(column)) { cell = cell1; break; } } return cell; }
Example #27
Source File: FileBrowser.java From phoebus with Eclipse Public License 1.0 | 5 votes |
@Override public void save(final Memento memento) { if (controller == null) return; memento.setString(DIRECTORY, controller.getRoot().toString()); int i = 0; for (TreeTableColumn<?,?> col : controller.getView().getColumns()) { if (! col.isVisible()) memento.setBoolean(SHOW_COLUMN+i, false); memento.setNumber(WIDTH+i, col.getWidth()); ++i; } }
Example #28
Source File: DefaultTreeTable.java From xframium-java with GNU General Public License v3.0 | 5 votes |
protected void addColumnString (String heading, int width, Justification justification, String propertyName) { TreeTableColumn<T, String> column = new TreeTableColumn<> (heading); column.setPrefWidth (width); column .setCellValueFactory (new TreeItemPropertyValueFactory<T, String> (propertyName)); getColumns ().add (column); if (justification == Justification.CENTER) column.setStyle ("-fx-alignment: CENTER;"); }
Example #29
Source File: DefaultTreeTable.java From dm3270 with Apache License 2.0 | 5 votes |
protected void addColumnNumber (String heading, int width, String propertyName) { TreeTableColumn<T, Number> column = new TreeTableColumn<> (heading); column.setPrefWidth (width); column .setCellValueFactory (new TreeItemPropertyValueFactory<T, Number> (propertyName)); getColumns ().add (column); column.setStyle ("-fx-alignment: CENTER-RIGHT;"); }
Example #30
Source File: DefaultTreeTable.java From xframium-java with GNU General Public License v3.0 | 5 votes |
protected void addColumnNumber (String heading, int width, String propertyName) { TreeTableColumn<T, Number> column = new TreeTableColumn<> (heading); column.setPrefWidth (width); column .setCellValueFactory (new TreeItemPropertyValueFactory<T, Number> (propertyName)); getColumns ().add (column); column.setStyle ("-fx-alignment: CENTER-RIGHT;"); }