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();
}
});
}
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;
}
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();
}
});
}
Aggregations