use of javafx.scene.control.TreeTableColumn in project JFoenix by jfoenixadmin.
the class TreeTableViewController method init.
@PostConstruct
public void init() throws FlowException, VetoException {
String[] names = { "Morley", "Scott", "Kruger", "Lain", "Kennedy", "Gawron", "Han", "Hall", "Aydogdu", "Grace", "Spiers", "Perera", "Smith", "Connoly", "Sokolowski", "Chaow", "James", "June" };
Random random = new Random();
firstNameColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<Person, String> param) -> {
if (firstNameColumn.validateValue(param))
return param.getValue().getValue().firstName;
else
return firstNameColumn.getComputedValue(param);
});
lastNameColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<Person, String> param) -> {
if (lastNameColumn.validateValue(param))
return param.getValue().getValue().lastName;
else
return lastNameColumn.getComputedValue(param);
});
ageColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<Person, Integer> param) -> {
if (ageColumn.validateValue(param))
return param.getValue().getValue().age.asObject();
else
return ageColumn.getComputedValue(param);
});
ObservableList<Person> people = FXCollections.observableArrayList();
for (int i = 0; i < 100; i++) people.add(new Person(names[random.nextInt(names.length)], names[random.nextInt(names.length)], random.nextInt(100)));
treeTableView.setRoot(new RecursiveTreeItem<Person>(people, RecursiveTreeObject::getChildren));
treeTableView.setShowRoot(false);
treeTableViewCount.textProperty().bind(Bindings.createStringBinding(() -> "( " + treeTableView.getCurrentItemsCount() + " )", treeTableView.currentItemsCountProperty()));
treeTableViewAdd.disableProperty().bind(Bindings.notEqual(-1, treeTableView.getSelectionModel().selectedIndexProperty()));
treeTableViewRemove.disableProperty().bind(Bindings.equal(-1, treeTableView.getSelectionModel().selectedIndexProperty()));
treeTableViewAdd.setOnMouseClicked((e) -> {
people.add(new Person(names[random.nextInt(names.length)], names[random.nextInt(names.length)], random.nextInt(100)));
treeTableView.currentItemsCountProperty().set(treeTableView.currentItemsCountProperty().get() + 1);
});
treeTableViewRemove.setOnMouseClicked((e) -> {
people.remove(treeTableView.getSelectionModel().selectedItemProperty().get().getValue());
treeTableView.currentItemsCountProperty().set(treeTableView.currentItemsCountProperty().get() - 1);
});
searchField.textProperty().addListener((o, oldVal, newVal) -> {
treeTableView.setPredicate(person -> person.getValue().firstName.get().contains(newVal) || person.getValue().lastName.get().contains(newVal) || (person.getValue().age.get() + "").contains(newVal));
});
firstNameEditableColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<Person, String> param) -> {
if (firstNameEditableColumn.validateValue(param))
return param.getValue().getValue().firstName;
else
return firstNameEditableColumn.getComputedValue(param);
});
lastNameEditableColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<Person, String> param) -> {
if (lastNameEditableColumn.validateValue(param))
return param.getValue().getValue().lastName;
else
return lastNameEditableColumn.getComputedValue(param);
});
ageEditableColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<Person, Integer> param) -> {
if (ageEditableColumn.validateValue(param))
return param.getValue().getValue().age.asObject();
else
return ageEditableColumn.getComputedValue(param);
});
// add editors
firstNameEditableColumn.setCellFactory((TreeTableColumn<Person, String> param) -> new GenericEditableTreeTableCell<Person, String>(new TextFieldEditorBuilder()));
firstNameEditableColumn.setOnEditCommit((CellEditEvent<Person, String> t) -> {
((Person) t.getTreeTableView().getTreeItem(t.getTreeTablePosition().getRow()).getValue()).firstName.set(t.getNewValue());
});
lastNameEditableColumn.setCellFactory((TreeTableColumn<Person, String> param) -> new GenericEditableTreeTableCell<Person, String>(new TextFieldEditorBuilder()));
lastNameEditableColumn.setOnEditCommit((CellEditEvent<Person, String> t) -> {
((Person) t.getTreeTableView().getTreeItem(t.getTreeTablePosition().getRow()).getValue()).lastName.set(t.getNewValue());
});
ageEditableColumn.setCellFactory((TreeTableColumn<Person, Integer> param) -> new GenericEditableTreeTableCell<Person, Integer>(new IntegerTextFieldEditorBuilder()));
ageEditableColumn.setOnEditCommit((CellEditEvent<Person, Integer> t) -> {
((Person) t.getTreeTableView().getTreeItem(t.getTreeTablePosition().getRow()).getValue()).age.set(t.getNewValue());
});
ObservableList<Person> people2 = FXCollections.observableArrayList();
for (int i = 0; i < 200; i++) people2.add(new Person(names[random.nextInt(names.length)], names[random.nextInt(names.length)], random.nextInt(100)));
editableTreeTableView.setRoot(new RecursiveTreeItem<Person>(people2, RecursiveTreeObject::getChildren));
editableTreeTableView.setShowRoot(false);
editableTreeTableView.setEditable(true);
editableTreeTableViewCount.textProperty().bind(Bindings.createStringBinding(() -> "( " + editableTreeTableView.getCurrentItemsCount() + " )", editableTreeTableView.currentItemsCountProperty()));
searchField2.textProperty().addListener((o, oldVal, newVal) -> {
editableTreeTableView.setPredicate(person -> person.getValue().firstName.get().contains(newVal) || person.getValue().lastName.get().contains(newVal) || (person.getValue().age.get() + "").contains(newVal));
});
}
use of javafx.scene.control.TreeTableColumn in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketHex method buildPacketView.
/**
* Build packet view
*
* @param packet
* @return
*/
private VBox buildPacketView() {
VBox insidePane = new VBox();
TreeTableColumn<HexData, String> c0 = new TreeTableColumn<>("offst");
c0.setCellValueFactory((TreeTableColumn.CellDataFeatures<HexData, String> param) -> new ReadOnlyStringWrapper(param.getValue().getValue().getOffset()));
c0.setSortable(false);
c0.setPrefWidth(120);
TreeTableColumn<HexData, String> c1 = new TreeTableColumn<>("Hex");
c1.setCellValueFactory((TreeTableColumn.CellDataFeatures<HexData, String> param) -> new ReadOnlyStringWrapper(param.getValue().getValue().getHex()));
c1.setSortable(false);
c1.setPrefWidth(375);
c1.setCellFactory(new TextFieldCellFactory());
TreeTableColumn<HexData, String> c2 = new TreeTableColumn<>("Payload");
c2.setCellValueFactory((TreeTableColumn.CellDataFeatures<HexData, String> param) -> new ReadOnlyStringWrapper(param.getValue().getValue().getPayLoad()));
c2.setSortable(false);
c2.setPrefWidth(130);
hexTable = new TreeTableView<>();
hexTable.getStyleClass().add("treeTable");
hexTable.getColumns().addAll(c0, c1, c2);
hexTable.setPrefSize(630, 510);
insidePane.getChildren().add(hexTable);
return insidePane;
}
Aggregations