/** * 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"); } } /**
TableRow row = new TableRow(); row.add(new StaticTextTableCell(translator.getLocalDisplayName(weapon))); DynamicTextTableCell shipAmount = new DynamicTextTableCell(); IntegerBinding shipAmountBinding = shipAmount(weapon, ship); shipAmount.valueProperty().bind(shipAmountBinding.asString()); toOffice.disableProperty().bind(shipAmountBinding.lessThan(1)); row.add(new ControlTableCell(toOffice)); // to office DynamicTextTableCell officeAmount = new DynamicTextTableCell(); officeAmount.valueProperty().bind(storageAmount(weapon).asString()); row.add(officeAmount); model.add(row);
ImageView imgView = new ImageView(img); row.add(new ControlTableCell(imgView)); DynamicTextTableCell weaponAmountInArmory = new DynamicTextTableCell(); weaponAmountInArmory.valueProperty().bind(getAmountInArmoryAsStringBinding(weapon)); row.add(weaponAmountInArmory); IntegerBinding weaponPrice = buyPriceBinding(weapon); row.add(new ControlTableCell(prioView)); DynamicTextTableCell weaponsInStorage = new DynamicTextTableCell(); weaponsInStorage.valueProperty().bind(weaponStorage.getWeaponProperty(weapon).asString()); row.add(weaponsInStorage); return row;
ImageView imgView = new ImageView(img); row.add(new ControlTableCell(imgView)); DynamicTextTableCell weaponAmountInArmory = new DynamicTextTableCell(); weaponAmountInArmory.valueProperty().bind(getAmountInArmoryAsStringBinding(weapon)); row.add(weaponAmountInArmory); DynamicTextTableCell weaponsInStorage = new DynamicTextTableCell(); weaponsInStorage.valueProperty().bind(weaponStorage.getWeaponProperty(weapon).asString()); row.add(weaponsInStorage); return row;