Search in sources :

Example 1 with JsonDate

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

the class JsonActivity method toJson.

@Override
public JSONObject toJson() {
    if (m_activity == null) {
        return null;
    }
    JSONObject json = new JSONObject();
    json.put("id", m_idProvider.getId(m_activity));
    json.put("beginTime", new JsonDate(m_activity.getBeginTime()).asJsonString());
    json.put("endTime", new JsonDate(m_activity.getEndTime()).asJsonString());
    json.put("text", m_activity.getText());
    json.put("backgroundColor", m_activity.getBackgroundColor());
    json.put("foregroundColor", m_activity.getForegroundColor());
    json.put("level", m_activity.getLevel());
    json.put("levelColor", m_activity.getLevelColor());
    json.put("tooltipText", m_activity.getTooltipText());
    json.put("cssClass", m_activity.getCssClass());
    JsonObjectUtility.filterDefaultValues(json, "Activity");
    return json;
}
Also used : JSONObject(org.json.JSONObject) JsonDate(org.eclipse.scout.rt.ui.html.json.JsonDate)

Example 2 with JsonDate

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

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

the class JsonRecurrencePattern method toJson.

@Override
public JSONObject toJson() {
    if (m_recurrencePattern == null) {
        return null;
    }
    JSONObject json = new JSONObject();
    json.put("lastModified", m_recurrencePattern.getLastModified());
    json.put("regenerate", m_recurrencePattern.isRegenerate());
    json.put("startTimeMinutes", m_recurrencePattern.getStartTimeMinutes());
    json.put("endTimeMinutes", m_recurrencePattern.getEndTimeMinutes());
    json.put("durationMinutes", m_recurrencePattern.getDurationMinutes());
    json.put("firstDate", new JsonDate(m_recurrencePattern.getFirstDate()).asJsonString());
    json.put("lastDate", new JsonDate(m_recurrencePattern.getLastDate()).asJsonString());
    json.put("occurrences", m_recurrencePattern.getOccurrences());
    json.put("noEndDate", m_recurrencePattern.getNoEndDate());
    json.put("type", m_recurrencePattern.getType());
    json.put("interval", m_recurrencePattern.getInterval());
    json.put("instance", m_recurrencePattern.getInstance());
    json.put("dayOfWeekBits", m_recurrencePattern.getDayOfWeek());
    json.put("dayOfMonth", m_recurrencePattern.getDayOfMonth());
    json.put("monthOfYear", m_recurrencePattern.getMonthOfYear());
    // TODO [7.0] bsh: Add RecurrenceException?
    return json;
}
Also used : JSONObject(org.json.JSONObject) JsonDate(org.eclipse.scout.rt.ui.html.json.JsonDate)

Example 4 with JsonDate

use of org.eclipse.scout.rt.ui.html.json.JsonDate 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)4 JSONObject (org.json.JSONObject)4 JsonDateRange (org.eclipse.scout.rt.ui.html.json.JsonDateRange)2 Date (java.util.Date)1 Set (java.util.Set)1 CalendarComponent (org.eclipse.scout.rt.client.ui.basic.calendar.CalendarComponent)1 Range (org.eclipse.scout.rt.platform.util.Range)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