*
* @param row
*/
private void appendHoursType(final Row row) {
final WorkReportLine workReportLine = (WorkReportLine) row.getValue();
final Listbox lbHoursType = new Listbox();
lbHoursType.setMold("select");
lbHoursType.setModel(allHoursType);
lbHoursType.renderAll();
lbHoursType.applyProperties();
if (lbHoursType.getItems().isEmpty()) {
row.appendChild(lbHoursType);
return;
}
// First time is rendered, select first item
TypeOfWorkHours type = workReportLine.getTypeOfWorkHours();
if (workReportLine.isNewObject() && type == null) {
Listitem item = lbHoursType.getItemAtIndex(0);
item.setSelected(true);
setHoursType(workReportLine, item);
} else {
// If workReportLine has a type, select item with that type
Listitem item = ComponentsFinder.findItemByValue(lbHoursType, type);
if (item != null) {
lbHoursType.selectItem(item);
}
}
lbHoursType.addEventListener(Events.ON_SELECT, new EventListener() {
@Override
public void onEvent(Event event) {
Listitem item = lbHoursType.getSelectedItem();
if (item != null) {
setHoursType((WorkReportLine) row.getValue(), item);
}
}