Search in sources :

Example 1 with SearchFilter

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));
    }
}
Also used : SearchFilter(org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter)

Example 2 with SearchFilter

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();
        }
    }
}
Also used : ISearchFilterService(org.eclipse.scout.rt.client.services.common.search.ISearchFilterService) SearchFilter(org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter)

Example 3 with 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;
}
Also used : IPageWithTable(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithTable) IBookmarkAdapter(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkAdapter) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) SearchFilter(org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter) IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) IPageWithNodes(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithNodes)

Example 4 with SearchFilter

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);
    }
}
Also used : ISearchFilterService(org.eclipse.scout.rt.client.services.common.search.ISearchFilterService) SearchFilter(org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException)

Example 5 with SearchFilter

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));
    }
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) Status(org.eclipse.scout.rt.platform.status.Status) SearchFilter(org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Aggregations

SearchFilter (org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter)7 ISearchFilterService (org.eclipse.scout.rt.client.services.common.search.ISearchFilterService)2 ArrayList (java.util.ArrayList)1 IBookmarkAdapter (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkAdapter)1 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)1 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)1 IPageWithNodes (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithNodes)1 IPageWithTable (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithTable)1 Order (org.eclipse.scout.rt.platform.Order)1 ConfigOperation (org.eclipse.scout.rt.platform.annotations.ConfigOperation)1 PlatformException (org.eclipse.scout.rt.platform.exception.PlatformException)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)1 IStatus (org.eclipse.scout.rt.platform.status.IStatus)1 Status (org.eclipse.scout.rt.platform.status.Status)1 Bookmark (org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark)1 Before (org.junit.Before)1