use of org.jowidgets.cap.ui.api.table.IBeanTableModel in project jo-client-platform by jo-source.
the class BeanTableSetToAllActionBuilder method build.
@Override
public ICommandAction build() {
final ICommandAction result = super.build();
table.addCellMenuListener(new IPopupMenuListener<ITableCellPopupEvent>() {
@Override
public void beforeMenuShow(final ITableCellPopupEvent event) {
final int columnIndex = event.getColumnIndex();
final int rowIndex = event.getRowIndex();
final IBeanTableModel<?> model = table.getModel();
final String entityLabelPlural = model.getEntityLabelPlural();
final Object cellValue = model.getValue(rowIndex, columnIndex);
final String cellText;
if (cellValue != null) {
cellText = StringUtils.truncateToLength(model.getTableModel().getCell(rowIndex, columnIndex).getText(), 30);
} else {
cellText = NOT_SET.get();
}
final IAttribute<Object> attribute = model.getAttribute(columnIndex);
final String columnLabel = attribute.getLabel().get();
final ArrayList<Integer> selection = model.getSelection();
if (selection.size() > 1) {
// set to selection
result.setText(MessageReplacer.replace(SET_TO_SELECTION.get(), columnLabel, cellText, entityLabelPlural));
} else if (selection.size() <= 1) {
// set to all
result.setText(MessageReplacer.replace(SET_TO_ALL.get(), columnLabel, cellText, entityLabelPlural));
}
}
});
return result;
}
Aggregations