use of org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter in project scout.rt by eclipse.
the class LargeMemoryPolicy method storeSearchFormState.
@Override
protected void storeSearchFormState(IForm f, String pageFormIdentifier) {
// cache search form data
if (f.isEmpty()) {
m_searchFormCache.remove(pageFormIdentifier);
} else {
String xml = f.storeToXmlString();
SearchFilter filter = f.getSearchFilter();
m_searchFormCache.put(pageFormIdentifier, new SearchFormState(xml, filter));
}
}
use of org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter in project scout.rt by eclipse.
the class AbstractPageWithTable method getSearchFilter.
@Override
public SearchFilter getSearchFilter() {
ensureSearchFormCreated();
ensureSearchFormStarted();
if (getSearchFormInternal() != null) {
return getSearchFormInternal().getSearchFilter();
} else {
ISearchFilterService sfs = BEANS.get(ISearchFilterService.class);
if (sfs != null) {
return sfs.createNewSearchFilter();
} else {
return new SearchFilter();
}
}
}
use of org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter in project scout.rt by eclipse.
the class BookmarkUtility method createBookmark.
@SuppressWarnings("squid:S1643")
public static Bookmark createBookmark(IPage<?> page) {
if (page == null || page.getOutline() == null) {
return null;
}
IBookmarkAdapter bookmarkAdapter = getBookmarkAdapter(page);
IOutline outline = page.getOutline();
Bookmark b = new Bookmark();
b.setIconId(bookmarkAdapter.getIconId());
// outline
b.setOutlineClassName(bookmarkAdapter.getOutlineClassName());
ArrayList<IPage<?>> path = new ArrayList<IPage<?>>();
ArrayList<String> titleSegments = new ArrayList<String>();
while (page != null) {
IBookmarkAdapter currentBookmarkAdapter = getBookmarkAdapter(page);
path.add(0, page);
String s = currentBookmarkAdapter.getTitle();
if (s != null) {
titleSegments.add(0, s);
}
// next
page = (IPage) page.getParentNode();
}
if (bookmarkAdapter.getOutlineTitle() != null) {
titleSegments.add(0, bookmarkAdapter.getOutlineTitle());
}
// title
int len = 0;
if (titleSegments.size() > 0) {
len += titleSegments.get(0).length();
}
if (titleSegments.size() > 1) {
len += titleSegments.get(titleSegments.size() - 1).length();
}
for (int i = titleSegments.size() - 1; i > 0; i--) {
if (len > 200) {
titleSegments.remove(i);
} else if (len + titleSegments.get(i).length() <= 200) {
len += titleSegments.get(i).length();
} else {
titleSegments.set(i, "...");
len = 201;
}
}
StringBuilder buf = new StringBuilder();
for (String s : titleSegments) {
if (buf.length() > 0) {
buf.append(" - ");
}
buf.append(s);
}
b.setTitle(buf.toString());
// text
StringBuilder text = new StringBuilder();
// add constraints texts
String prefix = "";
for (int i = 0; i < path.size(); i++) {
page = path.get(i);
IBookmarkAdapter currentBookmarkAdapter = getBookmarkAdapter(page);
if (i > 0 || outline.isRootNodeVisible()) {
text.append(prefix + currentBookmarkAdapter.getText());
text.append("\n");
if (page instanceof IPageWithTable) {
IPageWithTable tablePage = (IPageWithTable) page;
SearchFilter search = tablePage.getSearchFilter();
if (search != null) {
for (String s : search.getDisplayTexts()) {
if (s != null) {
String indent = prefix + " ";
s = s.trim().replaceAll("[\\n]", "\n" + indent);
if (s.length() > 0) {
text.append(indent + s);
text.append("\n");
}
}
}
}
}
prefix += " ";
}
}
b.setText(text.toString().trim());
// path
for (int i = 0; i < path.size(); i++) {
page = path.get(i);
if (page instanceof IPageWithTable) {
IPageWithTable tablePage = (IPageWithTable) page;
IPage<?> childPage = null;
if (i + 1 < path.size()) {
childPage = path.get(i + 1);
}
b.addPathElement(bmStoreTablePage(tablePage, childPage));
} else if (page instanceof IPageWithNodes) {
IPageWithNodes nodePage = (IPageWithNodes) page;
b.addPathElement(bmStoreNodePage(nodePage));
}
}
return b;
}
use of org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter in project scout.rt by eclipse.
the class AbstractForm method resetSearchFilter.
@Override
public void resetSearchFilter() {
if (m_searchFilter == null) {
SearchFilter filter;
ISearchFilterService sfs = BEANS.get(ISearchFilterService.class);
if (sfs != null) {
filter = sfs.createNewSearchFilter();
} else {
filter = new SearchFilter();
}
m_searchFilter = filter;
}
try {
interceptResetSearchFilter(m_searchFilter);
} catch (Exception e) {
BEANS.get(ExceptionHandler.class).handle(e);
}
}
use of org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter in project scout.rt by eclipse.
the class AbstractPageWithTable method execPopulateTable.
/**
* Populates this page's table.
* <p>
* It is good practice to populate table using {@code ITable.replaceRows} instead of {@code ITable.removeAllRows();
* ITable.addRows} because in the former case the outline tree structure below the changing rows is not discarded but
* only marked as dirty. The subtree is lazily reloaded when the user clicks next time on a child node.
* <p>
* Subclasses can override this method. In most cases it is sufficient to override
* {@link #interceptLoadData(SearchFilter)} or {@link #interceptLoadTableData(SearchFilter)} instead.<br/>
* This default implementation does the following: It queries methods {@link #isSearchActive()} and
* {@link #isSearchRequired()} and then calls {@link #interceptLoadData(SearchFilter)} if appropriate.
*/
@ConfigOperation
@Order(100)
protected void execPopulateTable() {
if (isSearchActive()) {
SearchFilter filter = getSearchFilter();
if (filter.isCompleted() || !isSearchRequired()) {
// create a copy of the filter, just in case the subprocess is modifying
// or extending the filter
filter = filter.copy();
interceptLoadData(filter);
}
} else {
// searchFilter should never be null
interceptLoadData(new SearchFilter());
}
// update table data status
if (isSearchActive() && getSearchFilter() != null && (!getSearchFilter().isCompleted()) && isSearchRequired()) {
setTableStatus(new Status(TEXTS.get("TooManyRows"), IStatus.WARNING));
} else {
setTableStatus(null);
}
T table = getTable();
if (isLimitedResult() && table != null) {
String maxOutlineWarningKey = "MaxOutlineRowWarning";
if (UserAgentUtility.isTouchDevice()) {
maxOutlineWarningKey = "MaxOutlineRowWarningMobile";
}
setTableStatus(new Status(TEXTS.get(maxOutlineWarningKey, "" + table.getRowCount()), IStatus.WARNING));
}
}
Aggregations