/** * Adding a table cell to the grid * @param grid grid pant to which to add. * @param rowNum row index * @param row table row * @param col column index * @param cell the node is pased on * @param hAlignment horizontal alignment * @param textStyleClass style class for the text */ public void addCellToGridPane(GridPane grid, int rowNum, TableRow row, int col, ITableCell cell, HPos hAlignment, String textStyleClass) { if (cell instanceof StaticTextTableCell) { Text text = new Text(((StaticTextTableCell)cell).getValue()); text.getStyleClass().add(textStyleClass); addCellToGridPane(rowNum, row, col, cell, text, grid, hAlignment); } else if (cell instanceof DynamicTextTableCell) { DynamicTextTableCell dynCell = (DynamicTextTableCell) cell; Text text = new Text(); text.textProperty().bind(dynCell.valueProperty()); text.getStyleClass().add(textStyleClass); addCellToGridPane(rowNum, row, col, cell, text, grid, hAlignment); } else if (cell instanceof ControlTableCell) { final Node control = ((ControlTableCell) cell).getControl(); addCellToGridPane(rowNum, row, col, cell, control, grid, hAlignment); } else { throw new RuntimeException("Not implemented"); } } /**
DynamicTextTableCell shipAmount = new DynamicTextTableCell(); IntegerBinding shipAmountBinding = shipAmount(weapon, ship); shipAmount.valueProperty().bind(shipAmountBinding.asString()); row.add(new ControlTableCell(toOffice)); // to office DynamicTextTableCell officeAmount = new DynamicTextTableCell(); officeAmount.valueProperty().bind(storageAmount(weapon).asString()); row.add(officeAmount); model.add(row);
row.add(new ControlTableCell(imgView)); DynamicTextTableCell weaponAmountInArmory = new DynamicTextTableCell(); weaponAmountInArmory.valueProperty().bind(getAmountInArmoryAsStringBinding(weapon)); row.add(weaponAmountInArmory); IntegerBinding weaponPrice = buyPriceBinding(weapon); weaponsInStorage.valueProperty().bind(weaponStorage.getWeaponProperty(weapon).asString()); row.add(weaponsInStorage); return row;
row.add(new ControlTableCell(imgView)); DynamicTextTableCell weaponAmountInArmory = new DynamicTextTableCell(); weaponAmountInArmory.valueProperty().bind(getAmountInArmoryAsStringBinding(weapon)); row.add(weaponAmountInArmory); weaponsInStorage.valueProperty().bind(weaponStorage.getWeaponProperty(weapon).asString()); row.add(weaponsInStorage); return row;