Search in sources :

Example 1 with Activity

use of org.eclipse.scout.rt.client.ui.basic.planner.Activity in project scout.rt by eclipse.

the class JsonPlanner method initJsonProperties.

@Override
protected void initJsonProperties(PLANNER model) {
    super.initJsonProperties(model);
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_LABEL, model) {

        @Override
        protected String modelValue() {
            return getModel().getLabel();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_AVAILABLE_DISPLAY_MODES, model) {

        @Override
        protected Set<Integer> modelValue() {
            return getModel().getAvailableDisplayModes();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_DISPLAY_MODE, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getDisplayMode();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_DISPLAY_MODE_OPTIONS, model) {

        @Override
        protected Map<Integer, DisplayModeOptions> modelValue() {
            return getModel().getDisplayModeOptions();
        }

        @SuppressWarnings("unchecked")
        @Override
        public Object prepareValueForToJson(Object value) {
            if (value == null) {
                return null;
            }
            JSONObject options = new JSONObject();
            for (Entry<Integer, DisplayModeOptions> option : ((Map<Integer, DisplayModeOptions>) value).entrySet()) {
                options.put(String.valueOf(option.getKey()), MainJsonObjectFactory.get().createJsonObject(option.getValue()).toJson());
            }
            return options;
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_VIEW_RANGE, model) {

        @Override
        protected Range<Date> modelValue() {
            return getModel().getViewRange();
        }

        @SuppressWarnings("unchecked")
        @Override
        public Object prepareValueForToJson(Object value) {
            if (value == null) {
                return null;
            }
            return new JsonDateRange((Range<Date>) value).toJson();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_HEADER_VISIBLE, model) {

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

        @Override
        protected Range<Date> modelValue() {
            return getModel().getSelectionRange();
        }

        @SuppressWarnings("unchecked")
        @Override
        public Object prepareValueForToJson(Object value) {
            if (value == null) {
                return null;
            }
            return new JsonDateRange((Range<Date>) value).toJson();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_SELECTED_ACTIVITY, model) {

        @Override
        protected Activity<?, ?> modelValue() {
            return getModel().getSelectedActivity();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            Activity<?, ?> activityCell = (Activity<?, ?>) value;
            return new P_GetOrCreateCellIdProvider().getId(activityCell);
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_SELECTION_MODE, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getSelectionMode();
        }
    });
    putJsonProperty(new JsonProperty<PLANNER>(IPlanner.PROP_ACTIVITY_SELECTABLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isActivitySelectable();
        }
    });
}
Also used : Set(java.util.Set) JsonDateRange(org.eclipse.scout.rt.ui.html.json.JsonDateRange) DisplayModeOptions(org.eclipse.scout.rt.client.ui.basic.planner.DisplayModeOptions) Activity(org.eclipse.scout.rt.client.ui.basic.planner.Activity) Range(org.eclipse.scout.rt.platform.util.Range) JsonDateRange(org.eclipse.scout.rt.ui.html.json.JsonDateRange) Date(java.util.Date) JsonDate(org.eclipse.scout.rt.ui.html.json.JsonDate) Entry(java.util.Map.Entry) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Activity (org.eclipse.scout.rt.client.ui.basic.planner.Activity)1 DisplayModeOptions (org.eclipse.scout.rt.client.ui.basic.planner.DisplayModeOptions)1 Range (org.eclipse.scout.rt.platform.util.Range)1 JsonDate (org.eclipse.scout.rt.ui.html.json.JsonDate)1 JsonDateRange (org.eclipse.scout.rt.ui.html.json.JsonDateRange)1 JSONObject (org.json.JSONObject)1