use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class NumericOverflowExceptionHandler method doHandle.
@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
Messages messages = AppBeans.get(Messages.NAME);
String msg = messages.getMessage(getClass(), "numericFieldOverflow.message");
windowManager.showNotification(msg, Frame.NotificationType.ERROR);
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class WebCalendar method initComponent.
protected void initComponent(CubaCalendar component) {
Messages messages = beanLocator.get(Messages.NAME);
String[] monthNamesShort = new String[12];
monthNamesShort[0] = messages.getMainMessage("calendar.januaryCaption");
monthNamesShort[1] = messages.getMainMessage("calendar.februaryCaption");
monthNamesShort[2] = messages.getMainMessage("calendar.marchCaption");
monthNamesShort[3] = messages.getMainMessage("calendar.aprilCaption");
monthNamesShort[4] = messages.getMainMessage("calendar.mayCaption");
monthNamesShort[5] = messages.getMainMessage("calendar.juneCaption");
monthNamesShort[6] = messages.getMainMessage("calendar.julyCaption");
monthNamesShort[7] = messages.getMainMessage("calendar.augustCaption");
monthNamesShort[8] = messages.getMainMessage("calendar.septemberCaption");
monthNamesShort[9] = messages.getMainMessage("calendar.octoberCaption");
monthNamesShort[10] = messages.getMainMessage("calendar.novemberCaption");
monthNamesShort[11] = messages.getMainMessage("calendar.decemberCaption");
component.setMonthNamesShort(monthNamesShort);
String[] dayNamesShort = new String[7];
dayNamesShort[0] = messages.getMainMessage("calendar.sundayCaption");
dayNamesShort[1] = messages.getMainMessage("calendar.mondayCaption");
dayNamesShort[2] = messages.getMainMessage("calendar.tuesdayCaption");
dayNamesShort[3] = messages.getMainMessage("calendar.wednesdayCaption");
dayNamesShort[4] = messages.getMainMessage("calendar.thursdayCaption");
dayNamesShort[5] = messages.getMainMessage("calendar.fridayCaption");
dayNamesShort[6] = messages.getMainMessage("calendar.saturdayCaption");
component.setDayNamesShort(dayNamesShort);
if (TIME_FORMAT_12H.equals(messages.getMainMessage("calendar.timeFormat"))) {
setTimeFormat(TimeFormat.FORMAT_12H);
} else if (TIME_FORMAT_24H.equals(messages.getMainMessage("calendar.timeFormat"))) {
setTimeFormat(TimeFormat.FORMAT_24H);
} else {
throw new IllegalStateException(String.format("Can't set time format '%s'", messages.getMainMessage("calendar.timeFormat")));
}
UserSessionSource userSessionSource = beanLocator.get(UserSessionSource.NAME);
TimeZone userTimeZone = userSessionSource.getUserSession().getTimeZone();
if (userTimeZone != null) {
setTimeZone(userTimeZone);
}
setNavigationButtonsStyle(navigationButtonsVisible);
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class WebDateField method handleDateOutOfRange.
protected void handleDateOutOfRange(V value) {
if (getFrame() != null) {
Messages messages = beanLocator.get(Messages.NAME);
Notifications notifications = ComponentsHelper.getScreenContext(this).getNotifications();
notifications.create().withCaption(messages.getMainMessage("datePicker.dateOutOfRangeMessage")).withType(Notifications.NotificationType.TRAY).show();
}
setValueToPresentation(convertToLocalDateTime(value, zoneId));
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class WebDateField method validate.
@Override
public void validate() throws ValidationException {
if (hasValidationError()) {
setValidationError(null);
}
if (!isVisibleRecursive() || !isEditableWithParent() || !isEnabledRecursive()) {
return;
}
Messages messages = beanLocator.get(Messages.NAME);
V value = constructModelValue();
if (!checkRange(value, false)) {
LoggerFactory.getLogger(WebDateField.class).trace("DateField value is out of range");
String dateOutOfRangeMessage = messages.getMainMessage("datePicker.dateOutOfRangeMessage");
setValidationError(dateOutOfRangeMessage);
throw new ValidationException(dateOutOfRangeMessage);
}
if (isEmpty() && isRequired()) {
String requiredMessage = getRequiredMessage();
if (requiredMessage == null) {
requiredMessage = messages.getMainMessage("validationFail.defaultRequiredMessage");
}
throw new RequiredValueMissingException(requiredMessage, this);
}
value = getValue();
triggerValidators(value);
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class DesktopTimeField method showValidationMessage.
private void showValidationMessage() {
Messages messages = AppBeans.get(Messages.NAME);
DesktopComponentsHelper.getTopLevelFrame(this).showNotification(messages.getMainMessage("validationFail"), com.haulmont.cuba.gui.components.Frame.NotificationType.TRAY);
}
Aggregations