use of com.qcadoo.view.internal.components.ganttChart.GanttChartScaleImpl.ZoomLevel in project qcadoo by qcadoo.
the class GanttChartComponentState method initializeContent.
@Override
protected void initializeContent(final JSONObject json) throws JSONException {
JSONObject headerDataObject = json.getJSONObject("headerParameters");
ZoomLevel zoomLevel = ZoomLevel.valueOf(headerDataObject.getString("scale"));
String dateFromString = headerDataObject.getString("dateFrom");
String dateToString = headerDataObject.getString("dateTo");
DateTime now = new DateTime().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
Date dateFrom = now.plusDays(defaultStartDay).toDate();
Date dateTo = now.plusDays(defaultEndDay).toDate();
if (dateFromString == null || "".equals(dateFromString)) {
dateFromErrorMessage = translate("errorMessage.emptyDate");
} else {
ValueAndError dateFromVaE = DATETYPE.toObject(null, dateFromString);
if (dateFromVaE.getMessage() == null) {
dateFrom = (Date) dateFromVaE.getValue();
} else {
dateFromErrorMessage = translate("errorMessage.dateNotValid");
}
}
if (dateToString == null || "".equals(dateToString)) {
dateToErrorMessage = translate("errorMessage.emptyDate");
} else {
ValueAndError dateToVaE = DATETYPE.toObject(null, dateToString);
if (dateToVaE.getMessage() == null) {
dateTo = (Date) dateToVaE.getValue();
} else {
dateToErrorMessage = translate("errorMessage.dateNotValid");
}
}
scale = new GanttChartScaleImpl(this, zoomLevel, dateFrom, dateTo);
if (dateFromErrorMessage == null && globalErrorMessage == null) {
if (scale.isFromLargerThanTo()) {
globalErrorMessage = translate("errorMessage.fromLargerThanTo");
} else if (scale.isTooLargeRange()) {
globalErrorMessage = translate("errorMessage.tooLargeRange", String.valueOf(scale.getMaxRangeInMonths()));
}
}
if (json.has("selectedEntityId")) {
selectedEntityId = json.getLong("selectedEntityId");
}
}
Aggregations