Do not apply cuba.web.table.cacheRate for Tables with generated columns #PL-5910

This commit is contained in:
Yuriy Artamonov 2015-09-14 08:35:23 +00:00
parent ecea8d6cdc
commit d92a1e8b66
4 changed files with 45 additions and 1 deletions

View File

@ -1878,7 +1878,8 @@ public abstract class WebAbstractTable<T extends com.vaadin.ui.Table & CubaEnhan
} }
} }
protected static class AbbreviatedColumnGenerator implements SystemTableColumnGenerator { protected static class AbbreviatedColumnGenerator implements SystemTableColumnGenerator,
CubaEnhancedTable.PlainTextGeneratedColumn {
protected Table.Column column; protected Table.Column column;

View File

@ -77,4 +77,11 @@ public interface CubaEnhancedTable extends AggregationContainer {
interface CellClickListener { interface CellClickListener {
void onClick(Object itemId, Object columnId); void onClick(Object itemId, Object columnId);
} }
/**
* Marker interface for generated columns which return String value.
* Used to work with custom cacheRate and pageLength.
*/
interface PlainTextGeneratedColumn {
}
} }

View File

@ -263,6 +263,13 @@ public class CubaTable extends com.vaadin.ui.Table implements TableContainer, Cu
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Can not add the same GeneratedColumn twice, id:" + id); "Can not add the same GeneratedColumn twice, id:" + id);
} else { } else {
if (!(generatedColumn instanceof PlainTextGeneratedColumn)) {
// do not use custom cache row settings for table with generated columns
if (getCacheRate() != 2) {
setCacheRate(2);
}
}
columnGenerators.put(id, generatedColumn); columnGenerators.put(id, generatedColumn);
/* /*
* add to visible column list unless already there (overriding * add to visible column list unless already there (overriding
@ -280,6 +287,17 @@ public class CubaTable extends com.vaadin.ui.Table implements TableContainer, Cu
} }
} }
@Override
public void setEditable(boolean editable) {
super.setEditable(editable);
if (editable) {
if (getCacheRate() != 2) {
setCacheRate(2);
}
}
}
@Override @Override
public void addShortcutListener(ShortcutListener shortcut) { public void addShortcutListener(ShortcutListener shortcut) {
if (shortcutActionManager == null) { if (shortcutActionManager == null) {

View File

@ -333,6 +333,13 @@ public class CubaTreeTable extends com.vaadin.ui.TreeTable implements TreeTableC
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Can not add the same GeneratedColumn twice, id:" + id); "Can not add the same GeneratedColumn twice, id:" + id);
} else { } else {
if (!(generatedColumn instanceof PlainTextGeneratedColumn)) {
// do not use custom cache row settings for table with generated columns
if (getCacheRate() != 2) {
setCacheRate(2);
}
}
columnGenerators.put(id, generatedColumn); columnGenerators.put(id, generatedColumn);
/* /*
* add to visible column list unless already there (overriding * add to visible column list unless already there (overriding
@ -350,6 +357,17 @@ public class CubaTreeTable extends com.vaadin.ui.TreeTable implements TreeTableC
} }
} }
@Override
public void setEditable(boolean editable) {
super.setEditable(editable);
if (editable) {
if (getCacheRate() != 2) {
setCacheRate(2);
}
}
}
@Override @Override
protected boolean changeVariables(Map<String, Object> variables) { protected boolean changeVariables(Map<String, Object> variables) {
boolean clientNeedsContentRefresh = super.changeVariables(variables); boolean clientNeedsContentRefresh = super.changeVariables(variables);