Whenever I click a row, I want to update the table with new information. For some reason when I click it is not doing anything and errors out. Any idea why I can't do this?
public HierarchyItemTreeCellCallback(TreeView<Requirement> treeView, DataModel dataModelIn)
{
super();
treeViewParent = treeView;
dataModel = dataModelIn;
}
@Override
public TreeCell<Requirement> call(TreeView<Requirement> param)
{
TreeCell<Requirement> cell = new HierarchyItemTreeCell();
cell.addEventFilter(MouseEvent.MOUSE_PRESSED,new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent event)
{
HierarchyTabController hierarchyTabController = new HierarchyTabController(dataModel);
Requirement req1 = new Requirement("ID", "21", 1, REQUIREMENT_TYPE.SOFTWARE);
hierarchyTabController.updateTableRow(req1);
}
});
return cell;
}
Here is the controller logic:
public void updateTableRow(Requirement r)
{
REQUIREMENT_TYPE reqType = REQUIREMENT_TYPE.SOFTWARE;
Requirement req1 = new Requirement("ID", "21", 1, reqType);
ObservableList<Requirement> list = FXCollections.observableArrayList(req1);
name.setCellValueFactory(new PropertyValueFactory<>("name"));
description.setCellValueFactory(new PropertyValueFactory<>("description"));
tableView.getItems().setAll(list);
tableView.setItems(list);
}
This works whenever I do not call the updateTableRow function from the MouseEvent. However, it is not working when I try to call the controller and update the values from the MouseEvent. Any idea what I am doing wrong?