@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void applyState() {
if (getObject().isStateful()) {
GridState state = getState();
Set<String> hidden = state.getHidden();
if (hidden != null) {
for (String path : hidden) {
ColumnConfig<M, ?> column = getObject().getColumnModel().findColumnConfig(path);
if (column != null) {
column.setHidden(true);
}
}
}
Map<String, Integer> widths = state.getWidths();
if (widths != null) {
for (String path : widths.keySet()) {
ColumnConfig<M, ?> column = getObject().getColumnModel().findColumnConfig(path);
if (column != null) {
column.setWidth(widths.get(path));
}
}
}
if (state.getSortField() != null) {
ValueProvider<? super M, Comparable> vp = (ValueProvider) getObject().getColumnModel().findColumnConfig(
state.getSortField()).getValueProvider();
if (vp != null) {
getObject().getStore().clearSortInfo();
getObject().getStore().addSortInfo(new StoreSortInfo<M>(vp, state.getSortDir()));
}
}
}
}