use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class JsonStatusTest method testToJson.
@Test
public void testToJson() {
assertEquals(null, JsonStatus.toJson(null));
Status status = new Status("foo", IStatus.INFO);
JSONObject json = (JSONObject) JsonStatus.toJson(status);
assertEquals("foo", json.getString("message"));
assertEquals(IStatus.INFO, json.getInt("severity"));
}
use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class CellTest method testClearErrorStatus.
/**
* When creating a cell. The errorstatus should not be set.
* {@link Cell#setErrorStatus(org.eclipse.scout.rt.platform.status.IStatus)}
*/
@Test
public void testClearErrorStatus() {
Cell c = new Cell();
c.addErrorStatus(new Status("error", IStatus.ERROR));
c.clearErrorStatus();
assertNull(c.getErrorStatus());
}
use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class AbstractProposalChooser method updateStatus.
protected void updateStatus(IContentAssistFieldDataFetchResult<LOOKUP_KEY> result) {
if (result != null && result.getException() instanceof FutureCancelledError) {
return;
}
List<? extends ILookupRow<LOOKUP_KEY>> rows = null;
Throwable exception = null;
String searchText = null;
if (result != null) {
rows = result.getLookupRows();
exception = result.getException();
searchText = result.getSearchParam().getSearchQuery();
}
if (rows == null) {
rows = CollectionUtility.emptyArrayList();
}
String statusText = null;
int severity = IStatus.INFO;
if (exception != null) {
if (exception instanceof ProcessingException) {
statusText = ((ProcessingException) exception).getStatus().getMessage();
} else {
statusText = exception.getMessage();
}
severity = IStatus.ERROR;
} else if (rows.isEmpty()) {
if (getContentAssistField().getWildcard().equals(searchText)) {
statusText = TEXTS.get("SmartFieldNoDataFound");
} else {
statusText = TEXTS.get("SmartFieldCannotComplete", (searchText == null) ? ("") : (searchText));
}
severity = IStatus.WARNING;
} else if (rows.size() > m_contentAssistField.getBrowseMaxRowCount()) {
statusText = TEXTS.get("SmartFieldMoreThanXRows", "" + m_contentAssistField.getBrowseMaxRowCount());
severity = IStatus.INFO;
}
if (statusText != null) {
setStatus(new Status(statusText, severity));
} else {
setStatus(null);
}
}
use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class JsonStatus method toScoutObject.
public static IStatus toScoutObject(JSONObject jsonStatus) {
if (jsonStatus == null) {
return null;
}
String message = jsonStatus.optString("message");
int severity = jsonStatus.getInt("severity");
String iconId = jsonStatus.optString("iconId");
Integer code = jsonStatus.optInt("code");
Status status = new Status(message, severity);
if (iconId != null) {
status.withIconId(iconId);
}
if (code != null) {
status.withCode(code);
}
return status;
}
use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class BookmarkUtility method bmLoadNodePage.
private static IPage<?> bmLoadNodePage(IPageWithNodes nodePage, NodePageState nodePageState, AbstractPageState childState, boolean resetViewAndWarnOnFail) {
IPage<?> childPage = null;
if (childState != null) {
nodePage.ensureChildrenLoaded();
IPage<?> p = BookmarkUtility.resolvePage(nodePage.getChildPages(), childState.getPageClassName(), childState.getBookmarkIdentifier());
if (p != null) {
ITable table = nodePage.getTable();
// reset table column filter if requested
if (resetViewAndWarnOnFail && !p.isFilterAccepted() && table.getUserFilterManager() != null) {
table.getUserFilterManager().reset();
}
// check table column filter
if (p.isFilterAccepted()) {
childPage = p;
}
}
// set appropriate warning if child page is not available or filtered out
if (childPage == null && resetViewAndWarnOnFail) {
nodePage.setTableStatus(new Status(TEXTS.get("BookmarkResolutionCanceled"), IStatus.ERROR));
}
}
return childPage;
}
Aggregations