private void populateLocalAnaesthetic(LocalAnaestheticCollection localAnaesthetic, DynamicGridCell cell) { if (localAnaesthetic == null || localAnaesthetic.size() == 0 || cell == null) return; LocalAnaesthetic cellValue = (LocalAnaesthetic) cell.getValue(); cell.getItems().clear(); for (int i = 0; i < localAnaesthetic.size(); i++) { if (!alreadyAdded(localAnaesthetic.get(i), cell)) { cell.getItems().newItem(localAnaesthetic.get(i)); } } cell.setValue(cellValue); }
private boolean alreadyAdded(LocalAnaesthetic localAnaesthetic, DynamicGridCell cell) { if (localAnaesthetic == null || cell == null) return true; DynamicGridColumn column = form.lyr1().tabDetails().ctn1().dyngrdAnaesthetis().getColumns().getByIdentifier(COL_DRUG); for (int i = 0; i < form.lyr1().tabDetails().ctn1().dyngrdAnaesthetis().getRows().size(); i++) { if (!cell.getRow().equals(form.lyr1().tabDetails().ctn1().dyngrdAnaesthetis().getRows().get(i)) && form.lyr1().tabDetails().ctn1().dyngrdAnaesthetis().getRows().get(i).getCells().get(column).getValue() != null && form.lyr1().tabDetails().ctn1().dyngrdAnaesthetis().getRows().get(i).getCells().get(column).getValue().equals(localAnaesthetic)) return true; } return false; }