use of org.eclipse.scout.rt.client.ui.basic.table.userfilter.TableUserFilterManager in project scout.rt by eclipse.
the class AbstractTable method linkColumnFilters.
private void linkColumnFilters() {
TableUserFilterManager filterManager = getUserFilterManager();
if (filterManager == null) {
return;
}
for (IColumn<?> col : getColumns()) {
IUserFilterState filter = getUserFilterManager().getFilter(col.getColumnId());
if (filter == null) {
continue;
}
if (!(filter instanceof ColumnUserFilterState)) {
throw new IllegalStateException("Unexpected filter state" + filter.getClass());
}
((ColumnUserFilterState) filter).setColumn(col);
}
}
use of org.eclipse.scout.rt.client.ui.basic.table.userfilter.TableUserFilterManager in project scout.rt by eclipse.
the class LargeMemoryPolicy method storeUserFilterState.
@Override
protected void storeUserFilterState(ITable table, String pageTableIdentifier) {
TableUserFilterManager filterManager = table.getUserFilterManager();
if (filterManager == null || filterManager.isEmpty()) {
m_tableUserFilterState.remove(pageTableIdentifier);
return;
}
m_tableUserFilterState.put(pageTableIdentifier, filterManager.getSerializedData());
}
use of org.eclipse.scout.rt.client.ui.basic.table.userfilter.TableUserFilterManager in project scout.rt by eclipse.
the class MediumMemoryPolicy method loadUserFilterState.
@Override
protected void loadUserFilterState(ITable table, String pageTableIdentifier) {
TableUserFilterManager filterManager = table.getUserFilterManager();
if (filterManager == null) {
return;
}
byte[] state = m_tableUserFilterState.get(pageTableIdentifier);
if (state != null) {
filterManager.setSerializedData(state);
}
}
use of org.eclipse.scout.rt.client.ui.basic.table.userfilter.TableUserFilterManager in project scout.rt by eclipse.
the class MediumMemoryPolicy method storeUserFilterState.
@Override
protected void storeUserFilterState(ITable table, String pageTableIdentifier) {
TableUserFilterManager filterManager = table.getUserFilterManager();
if (filterManager == null || filterManager.isEmpty()) {
m_tableUserFilterState.remove(pageTableIdentifier);
return;
}
m_tableUserFilterState.put(pageTableIdentifier, filterManager.getSerializedData());
}
use of org.eclipse.scout.rt.client.ui.basic.table.userfilter.TableUserFilterManager in project scout.rt by eclipse.
the class BookmarkUtility method bmLoadTablePage.
private static IPage<?> bmLoadTablePage(IPageWithTable tablePage, TablePageState tablePageState, boolean leafState, boolean resetViewAndWarnOnFail) {
ITable table = tablePage.getTable();
if (tablePageState.getTableCustomizerData() != null && tablePage.getTable().getTableCustomizer() != null) {
byte[] newData = tablePageState.getTableCustomizerData();
ITableCustomizer tc = tablePage.getTable().getTableCustomizer();
byte[] curData = tc.getSerializedData();
if (ObjectUtility.notEquals(curData, newData)) {
tc.removeAllColumns();
tc.setSerializedData(newData);
table.resetColumnConfiguration();
tablePage.setChildrenLoaded(false);
}
}
// starts search form
tablePage.getSearchFilter();
// setup table
try {
table.setTableChanging(true);
restoreTableColumns(tablePage.getTable(), tablePageState.getAvailableColumns());
} finally {
table.setTableChanging(false);
}
// setup user filter
if (tablePageState.getUserFilterData() != null && tablePage.getTable().getUserFilterManager() != null) {
byte[] newData = tablePageState.getUserFilterData();
TableUserFilterManager ufm = tablePage.getTable().getUserFilterManager();
byte[] curData = ufm.getSerializedData();
if (ObjectUtility.notEquals(curData, newData)) {
try {
ufm.setSerializedData(newData);
} catch (RuntimeException e) {
LOG.error("User filters could not be restored. ", e);
}
}
}
// setup search
if (tablePageState.getSearchFormState() != null) {
ISearchForm searchForm = tablePage.getSearchFormInternal();
if (searchForm != null) {
boolean doSearch = true;
String newSearchFilterState = tablePageState.getSearchFilterState();
String oldSearchFilterState = "" + createSearchFilterCRC(searchForm.getSearchFilter());
if (ObjectUtility.equals(oldSearchFilterState, newSearchFilterState)) {
String newSearchFormState = tablePageState.getSearchFormState();
String oldSearchFormState = searchForm.storeToXmlString();
if (ObjectUtility.equals(oldSearchFormState, newSearchFormState)) {
doSearch = false;
}
}
// in case search form is in correct state, but no search has been executed, force search
if (tablePage.getTable().getRowCount() == 0) {
doSearch = true;
}
if (doSearch) {
searchForm.loadFromXmlString(tablePageState.getSearchFormState());
if (tablePageState.isSearchFilterComplete()) {
searchForm.doSaveWithoutMarkerChange();
}
}
}
}
IPage<?> childPage = null;
boolean loadChildren = !leafState;
if (tablePage.isChildrenDirty() || tablePage.isChildrenVolatile()) {
loadChildren = true;
tablePage.setChildrenLoaded(false);
}
if (loadChildren) {
tablePage.ensureChildrenLoaded();
tablePage.setChildrenDirty(false);
CompositeObject childPk = tablePageState.getExpandedChildPrimaryKey();
if (childPk != null) {
for (int r = 0; r < table.getRowCount(); r++) {
CompositeObject testPkLegacy = new CompositeObject(BookmarkUtility.makeSerializableKeys(table.getRowKeys(r), true));
CompositeObject testPk = new CompositeObject(BookmarkUtility.makeSerializableKeys(table.getRowKeys(r), false));
if (testPk.equals(childPk) || testPkLegacy.equals(childPk)) {
if (r < tablePage.getChildNodeCount()) {
childPage = tablePage.getChildPage(r);
}
break;
}
}
} else {
List<ITreeNode> filteredChildNodes = tablePage.getFilteredChildNodes();
if (filteredChildNodes.size() > 0) {
childPage = (IPage) CollectionUtility.firstElement(filteredChildNodes);
} else if (tablePage.getChildNodeCount() > 0) {
childPage = tablePage.getChildPage(0);
}
}
}
// load selections
if (leafState) {
if (tablePageState.getSelectedChildrenPrimaryKeys().size() > 0) {
tablePage.ensureChildrenLoaded();
HashSet<CompositeObject> selectionSet = new HashSet<CompositeObject>(tablePageState.getSelectedChildrenPrimaryKeys());
ArrayList<ITableRow> rowList = new ArrayList<ITableRow>();
for (ITableRow row : table.getRows()) {
CompositeObject testPkLegacy = new CompositeObject(BookmarkUtility.makeSerializableKeys(row.getKeyValues(), true));
CompositeObject testPk = new CompositeObject(BookmarkUtility.makeSerializableKeys(row.getKeyValues(), false));
if ((selectionSet.contains(testPk) || selectionSet.contains(testPkLegacy)) && row.isFilterAccepted()) {
rowList.add(row);
}
}
if (rowList.size() > 0) {
table.selectRows(rowList);
}
}
return childPage;
}
// check, whether table column filter must be reset
if (resetViewAndWarnOnFail) {
final boolean childPageHidden = childPage == null || (!childPage.isFilterAccepted() && table.getUserFilterManager() != null);
if (childPageHidden) {
table.getUserFilterManager().reset();
tablePage.setTableStatus(new Status(TEXTS.get("BookmarkResetColumnFilters"), IStatus.WARNING));
}
}
// child page is not available or filtered out
if (childPage == null || !childPage.isFilterAccepted()) {
if (resetViewAndWarnOnFail) {
// set appropriate warning
if (tablePage.isSearchActive() && tablePage.getSearchFormInternal() != null) {
tablePage.setTableStatus(new Status(TEXTS.get("BookmarkResolutionCanceledCheckSearchCriteria"), IStatus.ERROR));
} else {
tablePage.setTableStatus(new Status(TEXTS.get("BookmarkResolutionCanceled"), IStatus.ERROR));
}
}
childPage = null;
}
return childPage;
}
Aggregations