final List<IColumn<AddressDO, String>> columns = new ArrayList<IColumn<AddressDO, String>>();
final CellItemListener<AddressDO> cellItemListener = new CellItemListener<AddressDO>() {
@Override
public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel)
{
final AddressDO address = rowModel.getObject();
final PersonalAddressDO personalAddress = personalAddressMap.get(address.getId());
appendCssClasses(item, address.getId(), address.isDeleted());
if (address.isDeleted() == true) {
// Do nothing further
} else if (personalAddress != null && personalAddress.isFavoriteCard() == true) {
appendCssClasses(item, RowCssClass.FAVORITE_ENTRY);
}
}
};
columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(getString("modified")),
getSortable("lastUpdate", sortable), "lastUpdate", cellItemListener) {
/**
* @see org.projectforge.web.wicket.CellItemListenerPropertyColumn#populateItem(org.apache.wicket.markup.repeater.Item,
* java.lang.String, org.apache.wicket.model.IModel)
*/
@Override
public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel)
{
final AddressDO address = rowModel.getObject();
final RepeatingView view = new RepeatingView(componentId);
item.add(view);
view.add(new ListSelectActionPanel(view.newChildId(), rowModel, AddressEditPage.class, address.getId(), returnToPage,
DateTimeFormatter.instance().getFormattedDate(address.getLastUpdate())));
view.add(new IconLinkPanel(view.newChildId(), IconType.PRINT, new ResourceModel("printView"), new Link<Void>(IconLinkPanel.LINK_ID) {
@Override
public void onClick()
{
final PageParameters params = new PageParameters();
params.add(AbstractEditPage.PARAMETER_KEY_ID, address.getId());
final AddressViewPage addressViewPage = new AddressViewPage(params);
setResponsePage(addressViewPage);
}
}));
addRowClick(item);
cellItemListener.populateItem(item, componentId, rowModel);
}
});
columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(getString("name")), getSortable("name", sortable), "name",
cellItemListener));
columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(getString("firstName")),
getSortable("firstName", sortable), "firstName", cellItemListener));
columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(getString("organization")), getSortable("organization",
sortable), "organization", cellItemListener));
columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(getString("email")), null, "email", cellItemListener) {
/**
* @see org.projectforge.web.wicket.CellItemListenerPropertyColumn#populateItem(org.apache.wicket.markup.repeater.Item,
* java.lang.String, org.apache.wicket.model.IModel)
*/
@Override
public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel)
{
final AddressDO address = rowModel.getObject();
final RepeatingView view = new RepeatingView(componentId);
item.add(view);
boolean first = true;
if (StringUtils.isNotBlank(address.getEmail()) == true) {
final ExternalLinkPanel mailToLinkPanel = new ExternalLinkPanel(view.newChildId(), "mailto:" + address.getEmail(), address
.getEmail());
mailToLinkPanel.getLink().add(AttributeModifier.replace("onclick", "javascript:suppressNextRowClick();"));
view.add(mailToLinkPanel);
first = false;
}
if (StringUtils.isNotBlank(address.getPrivateEmail()) == true) {
if (first == true) {
first = false;
} else {
view.add(new Label(view.newChildId(), "<br/>").setEscapeModelStrings(false));
}
view.add(new ExternalLinkPanel(view.newChildId(), "mailto:" + address.getPrivateEmail(), address.getPrivateEmail()));
}
cellItemListener.populateItem(item, componentId, rowModel);
}
});
columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(getString("address.phoneNumbers")), null, null,
cellItemListener) {
/**
* @see org.projectforge.web.wicket.CellItemListenerPropertyColumn#populateItem(org.apache.wicket.markup.repeater.Item,
* java.lang.String, org.apache.wicket.model.IModel)
*/
@Override
public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel)
{
final AddressDO address = rowModel.getObject();
final PersonalAddressDO personalAddress = personalAddressMap.get(address.getId());
final RepeatingView view = new RepeatingView(componentId);
item.add(view);
final Integer id = address.getId();
boolean first = addPhoneNumber(view, id, PhoneType.BUSINESS, address.getBusinessPhone(),
(personalAddress != null && personalAddress.isFavoriteBusinessPhone() == true), false, IconType.BUILDING, true);
first = addPhoneNumber(view, id, PhoneType.MOBILE, address.getMobilePhone(),
(personalAddress != null && personalAddress.isFavoriteMobilePhone() == true), true, IconType.TABLET, first);
first = addPhoneNumber(view, id, PhoneType.PRIVATE, address.getPrivatePhone(),
(personalAddress != null && personalAddress.isFavoritePrivatePhone() == true), false, IconType.HOME, first);
first = addPhoneNumber(view, id, PhoneType.PRIVATE_MOBILE, address.getPrivateMobilePhone(),
(personalAddress != null && personalAddress.isFavoritePrivateMobilePhone() == true), true, IconType.TABLET,
first);
cellItemListener.populateItem(item, componentId, rowModel);
item.add(AttributeModifier.append("style", new Model<String>("white-space: nowrap;")));
}