Search in sources :

Example 11 with Status

use of org.eclipse.scout.rt.platform.status.Status 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;
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) Status(org.eclipse.scout.rt.platform.status.Status) ArrayList(java.util.ArrayList) TableUserFilterManager(org.eclipse.scout.rt.client.ui.basic.table.userfilter.TableUserFilterManager) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ISearchForm(org.eclipse.scout.rt.client.ui.desktop.outline.pages.ISearchForm) ITableCustomizer(org.eclipse.scout.rt.client.ui.basic.table.customizer.ITableCustomizer) HashSet(java.util.HashSet)

Example 12 with Status

use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.

the class ErrorPopup method ensureErrorParsed.

/**
 * Fills the member variables based on the given <code>error</code>. This method has no effect after the first
 * execution.
 */
protected void ensureErrorParsed(Throwable error) {
    if (!m_parsed.compareAndSet(false, true)) {
        return;
    }
    m_parsedError = unwrapException(error);
    // Defaults
    m_header = TEXTS.get("Error");
    m_body = TEXTS.get("ErrorAndRetryTextDefault");
    m_html = HTML.div(StringUtility.box(TEXTS.get("CorrelationId") + ": ", CorrelationId.CURRENT.get(), "")).cssClass("error-popup-correlation-id");
    m_yesButtonText = TEXTS.get("Ok");
    m_noButtonText = null;
    m_reloadOnYesClick = false;
    m_status = new Status(IStatus.ERROR);
    Throwable t = m_parsedError;
    Throwable rootCause = m_parsedError;
    while (t != null) {
        if (parseError(t)) {
            extractStatus(t);
            m_parsedError = t;
            return;
        }
        rootCause = t;
        t = t.getCause();
    }
    parseUnexpectedProblem(rootCause);
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) Status(org.eclipse.scout.rt.platform.status.Status) IProcessingStatus(org.eclipse.scout.rt.platform.exception.IProcessingStatus)

Example 13 with Status

use of org.eclipse.scout.rt.platform.status.Status 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)

Example 14 with Status

use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.

the class FormFieldTest method testGetErrorStatus.

@Test
public void testGetErrorStatus() throws Exception {
    SimpleTestFormField testField = new SimpleTestFormField();
    final MultiStatus ms = new MultiStatus();
    ms.add(new Status("error"));
    testField.setErrorStatus(ms);
    assertEquals(ms, testField.getErrorStatus());
    assertNotSame(ms, testField.getErrorStatus());
    // get always returns a new object
    assertNotSame(testField.getErrorStatus(), testField.getErrorStatus());
}
Also used : InvalidSequenceStatus(org.eclipse.scout.rt.client.ui.form.fields.sequencebox.InvalidSequenceStatus) Status(org.eclipse.scout.rt.platform.status.Status) IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus) MultiStatus(org.eclipse.scout.rt.platform.status.MultiStatus) IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus) MultiStatus(org.eclipse.scout.rt.platform.status.MultiStatus) Test(org.junit.Test)

Example 15 with Status

use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.

the class FormFieldTest method testAddSameErrorStatus.

@Test
public void testAddSameErrorStatus() throws Exception {
    SimpleTestFormField testField = new SimpleTestFormField();
    P_PropertyChangeEventCounter counter = new P_PropertyChangeEventCounter();
    testField.addPropertyChangeListener(IFormField.PROP_ERROR_STATUS, counter);
    IMultiStatus status0 = testField.getErrorStatus();
    testField.addErrorStatus(new Status("error"));
    assertTrue(testField.getErrorStatus().containsStatus(Status.class));
    IMultiStatus status1 = testField.getErrorStatus();
    // no event, because same status already exists
    testField.addErrorStatus(new Status("error"));
    assertTrue(testField.getErrorStatus().containsStatus(Status.class));
    IMultiStatus status2 = testField.getErrorStatus();
    assertNotEquals(status0, status1);
    assertEquals(status1, status2);
    assertEquals(1, counter.getCount());
}
Also used : InvalidSequenceStatus(org.eclipse.scout.rt.client.ui.form.fields.sequencebox.InvalidSequenceStatus) Status(org.eclipse.scout.rt.platform.status.Status) IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus) MultiStatus(org.eclipse.scout.rt.platform.status.MultiStatus) IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus) Test(org.junit.Test)

Aggregations

Status (org.eclipse.scout.rt.platform.status.Status)23 Test (org.junit.Test)15 IStatus (org.eclipse.scout.rt.platform.status.IStatus)14 MultiStatus (org.eclipse.scout.rt.platform.status.MultiStatus)11 IMultiStatus (org.eclipse.scout.rt.platform.status.IMultiStatus)9 InvalidSequenceStatus (org.eclipse.scout.rt.client.ui.form.fields.sequencebox.InvalidSequenceStatus)8 ParsingFailedStatus (org.eclipse.scout.rt.client.ui.form.fields.ParsingFailedStatus)3 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 IProcessingStatus (org.eclipse.scout.rt.platform.exception.IProcessingStatus)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)1 ITableCustomizer (org.eclipse.scout.rt.client.ui.basic.table.customizer.ITableCustomizer)1 TableUserFilterManager (org.eclipse.scout.rt.client.ui.basic.table.userfilter.TableUserFilterManager)1 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)1 ISearchForm (org.eclipse.scout.rt.client.ui.desktop.outline.pages.ISearchForm)1 Order (org.eclipse.scout.rt.platform.Order)1 ConfigOperation (org.eclipse.scout.rt.platform.annotations.ConfigOperation)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)1