Search in sources :

Example 1 with SmartField2Result

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield2.SmartField2Result in project scout.rt by eclipse.

the class JsonSmartField2 method initJsonProperties.

@Override
protected void initJsonProperties(MODEL model) {
    super.initJsonProperties(model);
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(IValueField.PROP_VALUE, model) {

        @Override
        protected VALUE modelValue() {
            return getModel().getValue();
        }

        @Override
        @SuppressWarnings("unchecked")
        public Object prepareValueForToJson(Object value) {
            return JsonSmartField2.this.valueToJson((VALUE) value);
        }
    });
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_RESULT, model) {

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

        @Override
        @SuppressWarnings("unchecked")
        public Object prepareValueForToJson(Object value) {
            return resultToJson((SmartField2Result<VALUE>) value);
        }
    });
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_LOOKUP_ROW, model) {

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

        @Override
        @SuppressWarnings("unchecked")
        public Object prepareValueForToJson(Object value) {
            return lookupRowToJson((LookupRow<VALUE>) value, hasMultipleColumns());
        }
    });
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_BROWSE_MAX_ROW_COUNT, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getBrowseMaxRowCount();
        }
    });
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_BROWSE_AUTO_EXPAND_ALL, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isBrowseAutoExpandAll();
        }
    });
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_BROWSE_LOAD_INCREMENTAL, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isBrowseLoadIncremental();
        }
    });
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_ACTIVE_FILTER_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isActiveFilterEnabled();
        }
    });
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_ACTIVE_FILTER, model) {

        @Override
        protected TriState modelValue() {
            return getModel().getActiveFilter();
        }
    });
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_ACTIVE_FILTER_LABELS, model) {

        @Override
        protected String[] modelValue() {
            return getModel().getActiveFilterLabels();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            return new JSONArray(value);
        }
    });
    putJsonProperty(new JsonProperty<ISmartField2<VALUE>>(ISmartField2.PROP_COLUMN_DESCRIPTORS, model) {

        @Override
        protected ColumnDescriptor[] modelValue() {
            return getModel().getColumnDescriptors();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            return columnDescriptorsToJson(value);
        }
    });
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) LookupRow(org.eclipse.scout.rt.shared.services.lookup.LookupRow) SmartField2Result(org.eclipse.scout.rt.client.ui.form.fields.smartfield2.SmartField2Result) JSONArray(org.json.JSONArray) JSONObject(org.json.JSONObject) TriState(org.eclipse.scout.rt.platform.util.TriState) ISmartField2(org.eclipse.scout.rt.client.ui.form.fields.smartfield2.ISmartField2)

Aggregations

ISmartField2 (org.eclipse.scout.rt.client.ui.form.fields.smartfield2.ISmartField2)1 SmartField2Result (org.eclipse.scout.rt.client.ui.form.fields.smartfield2.SmartField2Result)1 TriState (org.eclipse.scout.rt.platform.util.TriState)1 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)1 LookupRow (org.eclipse.scout.rt.shared.services.lookup.LookupRow)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1