Table CellClickListener should have <E> parameter #906

This commit is contained in:
Gleb Gorelov 2018-06-09 13:24:07 +04:00
parent 74c72753bb
commit dab80cd987
3 changed files with 14 additions and 8 deletions

View File

@ -2210,7 +2210,7 @@ public abstract class DesktopAbstractTable<C extends JXTable, E extends Entity>
}
@Override
public void setClickListener(String columnId, CellClickListener clickListener) {
public void setClickListener(String columnId, CellClickListener<? super E> clickListener) {
}
@Override

View File

@ -456,7 +456,7 @@ public interface Table<E extends Entity>
* @param columnId id of column
* @param clickListener click listener
*/
void setClickListener(String columnId, CellClickListener clickListener);
void setClickListener(String columnId, CellClickListener<? super E> clickListener);
/**
* Remove click listener.
@ -468,12 +468,12 @@ public interface Table<E extends Entity>
/**
* Lightweight click listener for table cells.
*/
interface CellClickListener {
interface CellClickListener<T extends Entity> {
/**
* @param item row item
* @param columnId id of column
*/
void onClick(Entity item, String columnId);
void onClick(T item, String columnId);
}
/**

View File

@ -2393,11 +2393,17 @@ public abstract class WebAbstractTable<T extends com.vaadin.v7.ui.Table & CubaEn
}
@Override
public void setClickListener(String columnId, CellClickListener clickListener) {
public void setClickListener(String columnId, CellClickListener<? super E> clickListener) {
component.setClickListener(getColumn(columnId).getId(), (itemId, columnId1) -> {
ItemWrapper wrapper = (ItemWrapper) component.getItem(itemId);
Entity entity = wrapper.getItem();
clickListener.onClick(entity, columnId1.toString());
// TableItemWrapper wrapper = (TableItemWrapper) component.getItem(itemId);
// Object itemId2 = wrapper.getItemId();
TableSource<E> tableSource = getTableSource();
if (tableSource == null) {
return;
}
E item = tableSource.getItem(itemId);
clickListener.onClick(item, columnId1.toString());
});
}