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;
}
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);
}
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));
}
}
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());
}
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());
}
Aggregations