Search in sources :

Example 1 with IStatus

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

the class ProcessingExceptionTest method testCreateException.

@Test
public void testCreateException() {
    final Throwable testThrowable = new Throwable("cause");
    final int severity = IProcessingStatus.FATAL;
    final int errorCode = -1;
    ProcessingException pe = new ProcessingException(m_body, testThrowable).withCode(errorCode).withSeverity(severity);
    assertEquals(m_body + " [severity=FATAL, code=-1]", pe.getMessage());
    assertEquals(m_body, pe.getDisplayMessage());
    assertEquals(testThrowable, pe.getCause());
    IStatus errorStatus = pe.getStatus();
    assertEquals(m_body, errorStatus.getMessage());
    assertEquals(errorCode, errorStatus.getCode());
    assertEquals(severity, errorStatus.getSeverity());
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) Test(org.junit.Test)

Example 2 with IStatus

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

the class JsonTable method initJsonProperties.

@Override
protected void initJsonProperties(T model) {
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isEnabled();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_MULTI_SELECT, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isMultiSelect();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_MULTI_CHECK, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isMultiCheck();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_MULTILINE_TEXT, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isMultilineText();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_CHECKABLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isCheckable();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_ROW_ICON_VISIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isRowIconVisible();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_HEADER_VISIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isHeaderVisible();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_HEADER_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isHeaderEnabled();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_KEYBOARD_NAVIGATION, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().hasKeyboardNavigation();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_AUTO_RESIZE_COLUMNS, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isAutoResizeColumns();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_SCROLL_TO_SELECTION, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isScrollToSelection();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_TABLE_STATUS_VISIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isTableStatusVisible();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_TABLE_STATUS, model) {

        @Override
        protected IStatus modelValue() {
            return getModel().getTableStatus();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            return JsonStatus.toJson((IStatus) value);
        }
    });
    putJsonProperty(new JsonAdapterProperty<ITable>(ITable.PROP_TABLE_CONTROLS, model, getUiSession()) {

        @Override
        protected JsonAdapterPropertyConfig createConfig() {
            return new JsonAdapterPropertyConfigBuilder().filter(new DisplayableActionFilter<ITableControl>()).build();
        }

        @Override
        protected List<ITableControl> modelValue() {
            return getModel().getTableControls();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_DROP_TYPE, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getDropType();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_DROP_MAXIMUM_SIZE, model) {

        @Override
        protected Long modelValue() {
            return getModel().getDropMaximumSize();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_SORT_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isSortEnabled();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_UI_SORT_POSSIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isUiSortPossible();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_LOADING, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isLoading();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_GROUPING_STYLE, model) {

        @Override
        protected GroupingStyle modelValue() {
            return getModel().getGroupingStyle();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            return ((GroupingStyle) value).name().toLowerCase();
        }
    });
    putJsonProperty(new JsonAdapterProperty<ITable>(ITable.PROP_KEY_STROKES, model, getUiSession()) {

        @Override
        protected JsonAdapterPropertyConfig createConfig() {
            return new JsonAdapterPropertyConfigBuilder().filter(new DisplayableActionFilter<IAction>()).build();
        }

        @Override
        protected List<IKeyStroke> modelValue() {
            return getModel().getKeyStrokes();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_CSS_CLASS, model) {

        @Override
        protected String modelValue() {
            return getModel().getCssClass();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_CONTEXT_COLUMN, model) {

        @Override
        protected Object modelValue() {
            return getModel().getContextColumn();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            if (value == null) {
                return null;
            }
            return m_jsonColumns.get(value).getId();
        }
    });
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) JsonAdapterPropertyConfig(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ITableControl(org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl) JsonAdapterPropertyConfigBuilder(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) TextTransferObject(org.eclipse.scout.rt.client.ui.dnd.TextTransferObject) ResourceListTransferObject(org.eclipse.scout.rt.client.ui.dnd.ResourceListTransferObject) JSONObject(org.json.JSONObject) TransferObject(org.eclipse.scout.rt.client.ui.dnd.TransferObject) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) GroupingStyle(org.eclipse.scout.rt.client.ui.basic.table.GroupingStyle)

Example 3 with IStatus

use of org.eclipse.scout.rt.platform.status.IStatus 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;
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) Status(org.eclipse.scout.rt.platform.status.Status) IMultiStatus(org.eclipse.scout.rt.platform.status.IMultiStatus)

Example 4 with IStatus

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

the class AbstractTableFieldTest method testSetTableStatusToTable.

@Test
public void testSetTableStatusToTable() {
    IStatus status = new Status("Hello hello", IStatus.ERROR);
    setTableStatus(status);
    Assert.assertSame(status, getTable().getTableStatus());
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) Status(org.eclipse.scout.rt.platform.status.Status) IStatus(org.eclipse.scout.rt.platform.status.IStatus) Test(org.junit.Test)

Example 5 with IStatus

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

the class AbstractSequenceBox method checkNonEmptyFromTo.

private <T extends Comparable<T>> void checkNonEmptyFromTo(ArrayList<IValueField<T>> nonEmptyFields, int nonEmptyIndex) {
    // check changed field against its non-empty neighbours
    IValueField<T> v = nonEmptyFields.get(nonEmptyIndex);
    // check greater left neighbor
    IValueField<T> left = (nonEmptyIndex - 1 >= 0) ? nonEmptyFields.get(nonEmptyIndex - 1) : null;
    IStatus leftError = checkFromTo(left, v, false);
    if (leftError != null) {
        v.addErrorStatus(leftError);
    } else {
        // check right neighbor greater
        IValueField<T> right = (nonEmptyIndex + 1 < nonEmptyFields.size()) ? nonEmptyFields.get(nonEmptyIndex + 1) : null;
        IStatus rightError = checkFromTo(v, right, true);
        if (rightError != null) {
            v.addErrorStatus(rightError);
        } else {
            clearSequenceErrors(nonEmptyFields);
        }
    }
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus)

Aggregations

IStatus (org.eclipse.scout.rt.platform.status.IStatus)6 IMultiStatus (org.eclipse.scout.rt.platform.status.IMultiStatus)2 Status (org.eclipse.scout.rt.platform.status.Status)2 JSONObject (org.json.JSONObject)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 IAction (org.eclipse.scout.rt.client.ui.action.IAction)1 GroupingStyle (org.eclipse.scout.rt.client.ui.basic.table.GroupingStyle)1 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)1 ITableControl (org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl)1 ResourceListTransferObject (org.eclipse.scout.rt.client.ui.dnd.ResourceListTransferObject)1 TextTransferObject (org.eclipse.scout.rt.client.ui.dnd.TextTransferObject)1 TransferObject (org.eclipse.scout.rt.client.ui.dnd.TransferObject)1 JsonAdapterPropertyConfig (org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig)1 JsonAdapterPropertyConfigBuilder (org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder)1