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