Search in sources :

Example 1 with JsonDateRange

use of org.eclipse.scout.rt.ui.html.json.JsonDateRange 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)

Example 2 with JsonDateRange

use of org.eclipse.scout.rt.ui.html.json.JsonDateRange in project scout.rt by eclipse.

the class JsonCalendarComponent method toJson.

@Override
public JSONObject toJson() {
    JSONObject json = super.toJson();
    json.put("item", new JsonCalendarItem(getModel().getItem()).toJson());
    json.put("fromDate", new JsonDate(getModel().getFromDate()).asJsonString());
    json.put("toDate", new JsonDate(getModel().getToDate()).asJsonString());
    if (getModel().getCoveredDaysRange() != null) {
        Object coveredDaysRange = new JsonDateRange(getModel().getCoveredDaysRange()).toJson();
        json.put("coveredDaysRange", coveredDaysRange);
    }
    json.put("fullDay", getModel().isFullDay());
    json.put("draggable", getModel().getProvider().isMoveItemEnabled());
    return json;
}
Also used : JSONObject(org.json.JSONObject) JsonDateRange(org.eclipse.scout.rt.ui.html.json.JsonDateRange) JsonDate(org.eclipse.scout.rt.ui.html.json.JsonDate) JSONObject(org.json.JSONObject)

Example 3 with JsonDateRange

use of org.eclipse.scout.rt.ui.html.json.JsonDateRange in project scout.rt by eclipse.

the class JsonCalendar method initJsonProperties.

@Override
protected void initJsonProperties(CALENDAR model) {
    putJsonProperty(new JsonAdapterProperty<CALENDAR>(ICalendar.PROP_COMPONENTS, model, getUiSession()) {

        @Override
        protected Set<? extends CalendarComponent> modelValue() {
            return getModel().getComponents();
        }
    });
    putJsonProperty(new JsonAdapterProperty<CALENDAR>(ICalendar.PROP_SELECTED_COMPONENT, model, getUiSession()) {

        @Override
        protected CalendarComponent modelValue() {
            return getModel().getSelectedComponent();
        }

        @Override
        protected JsonAdapterPropertyConfig createConfig() {
            return new JsonAdapterPropertyConfigBuilder().disposeOnChange(false).build();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_DISPLAY_MODE, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getDisplayMode();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_DISPLAY_CONDENSED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isDisplayCondensed();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_TITLE, model) {

        @Override
        protected String modelValue() {
            return getModel().getTitle();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.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<CALENDAR>(ICalendar.PROP_SELECTED_DATE, model) {

        @Override
        protected Date modelValue() {
            return getModel().getSelectedDate();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            return new JsonDate((Date) value).asJsonString();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_LOAD_IN_PROGRESS, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isLoadInProgress();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_START_HOUR, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getStartHour();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_END_HOUR, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getEndHour();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_USE_OVERFLOW_CELLS, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().getUseOverflowCells();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_SHOW_DISPLAY_MODE_SELECTION, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().getShowDisplayModeSelection();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_MARK_NOON_HOUR, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().getMarkNoonHour();
        }
    });
    putJsonProperty(new JsonProperty<CALENDAR>(ICalendar.PROP_MARK_OUT_OF_MONTH_DAYS, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().getMarkOutOfMonthDays();
        }
    });
}
Also used : Set(java.util.Set) JsonAdapterPropertyConfig(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig) CalendarComponent(org.eclipse.scout.rt.client.ui.basic.calendar.CalendarComponent) JsonDateRange(org.eclipse.scout.rt.ui.html.json.JsonDateRange) JsonDate(org.eclipse.scout.rt.ui.html.json.JsonDate) 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) JsonAdapterPropertyConfigBuilder(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder) JSONObject(org.json.JSONObject)

Aggregations

JsonDate (org.eclipse.scout.rt.ui.html.json.JsonDate)3 JsonDateRange (org.eclipse.scout.rt.ui.html.json.JsonDateRange)3 JSONObject (org.json.JSONObject)3 Date (java.util.Date)2 Set (java.util.Set)2 Range (org.eclipse.scout.rt.platform.util.Range)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 CalendarComponent (org.eclipse.scout.rt.client.ui.basic.calendar.CalendarComponent)1 Activity (org.eclipse.scout.rt.client.ui.basic.planner.Activity)1 DisplayModeOptions (org.eclipse.scout.rt.client.ui.basic.planner.DisplayModeOptions)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