SimpleTreeNode simpleTreeNode = (SimpleTreeNode) data;
final BaseCalendar baseCalendar = (BaseCalendar) simpleTreeNode
.getData();
item.setValue(data);
Treerow treerow = new Treerow();
Treecell nameTreecell = new Treecell();
Label nameLabel = new Label(baseCalendar.getName());
nameTreecell.appendChild(nameLabel);
treerow.appendChild(nameTreecell);
// append start date of the current work week
Treecell startDateTreecell = new Treecell();
Label startDateLabel = new Label("---");
CalendarData version = baseCalendar.getCalendarData(LocalDate
.fromDateFields(new Date()));
CalendarData prevVersion = baseCalendar.getPrevious(version);
if ((prevVersion != null)
&& (prevVersion.getExpiringDate() != null)) {
startDateLabel.setValue(prevVersion
.getExpiringDate().toString());
}
startDateTreecell.appendChild(startDateLabel);
treerow.appendChild(startDateTreecell);
// append expiring date of the current work week
Treecell expiringDateTreecell = new Treecell();
Label expiringDateLabel = new Label("---");
if (version.getExpiringDate() != null) {
expiringDateLabel
.setValue(version.getExpiringDate().toString());
}
expiringDateTreecell.appendChild(expiringDateLabel);
treerow.appendChild(expiringDateTreecell);
Treecell operationsTreecell = new Treecell();
Button createDerivedButton = new Button();
createDerivedButton.setTooltiptext(_("Create derived"));
createDerivedButton.setSclass("icono");
createDerivedButton.setImage("/common/img/ico_derived1.png");
createDerivedButton.setHoverImage("/common/img/ico_derived.png");
createDerivedButton.addEventListener(Events.ON_CLICK,
new EventListener() {
@Override
public void onEvent(Event event) {
goToCreateDerivedForm(baseCalendar);
}
});
operationsTreecell.appendChild(createDerivedButton);
Button createCopyButton = new Button();
createCopyButton.setSclass("icono");
createCopyButton.setTooltiptext(_("Create copy"));
createCopyButton.setImage("/common/img/ico_copy1.png");
createCopyButton.setHoverImage("/common/img/ico_copy.png");
createCopyButton.addEventListener(Events.ON_CLICK,
new EventListener() {
@Override
public void onEvent(Event event) {
goToCreateCopyForm(baseCalendar);
}
});
operationsTreecell.appendChild(createCopyButton);
Button editButton = new Button();
editButton.setTooltiptext(_("Edit"));
editButton.setSclass("icono");
editButton.setImage("/common/img/ico_editar1.png");
editButton.setHoverImage("/common/img/ico_editar.png");
editButton.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event event) {
goToEditForm(baseCalendar);
}
});
operationsTreecell.appendChild(editButton);
Button removeButton = new Button();
removeButton.setTooltiptext(_("Remove"));
removeButton.setSclass("icono");
removeButton.setImage("/common/img/ico_borrar1.png");
removeButton.setHoverImage("/common/img/ico_borrar.png");
removeButton.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event event) {
confirmRemove(baseCalendar);
}
});
if (baseCalendarModel.isDefaultCalendar(baseCalendar)) {
removeButton.setDisabled(true);
removeButton.setImage("/common/img/ico_borrar_out.png");
removeButton.setHoverImage("/common/img/ico_borrar_out.png");
}
operationsTreecell.appendChild(removeButton);
treerow.appendChild(operationsTreecell);
item.appendChild(treerow);
// Show the tree expanded at start
item.setOpen(true);