Search in sources :

Example 36 with Messages

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);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages)

Example 37 with Messages

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);
}
Also used : UserSessionSource(com.haulmont.cuba.core.global.UserSessionSource) Messages(com.haulmont.cuba.core.global.Messages)

Example 38 with Messages

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));
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) Notifications(com.haulmont.cuba.gui.Notifications)

Example 39 with Messages

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);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages)

Example 40 with Messages

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);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages)

Aggregations

Messages (com.haulmont.cuba.core.global.Messages)56 ClientConfig (com.haulmont.cuba.client.ClientConfig)7 Configuration (com.haulmont.cuba.core.global.Configuration)7 Notifications (com.haulmont.cuba.gui.Notifications)5 Icons (com.haulmont.cuba.gui.icons.Icons)4 CubaButton (com.haulmont.cuba.web.widgets.CubaButton)4 File (java.io.File)4 MetaClass (com.haulmont.chile.core.model.MetaClass)3 FileStorageException (com.haulmont.cuba.core.global.FileStorageException)3 UserSessionSource (com.haulmont.cuba.core.global.UserSessionSource)3 WindowManager (com.haulmont.cuba.gui.WindowManager)3 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)3 FileUploadingAPI (com.haulmont.cuba.gui.upload.FileUploadingAPI)3 UserSession (com.haulmont.cuba.security.global.UserSession)3 FileOutputStream (java.io.FileOutputStream)3 IOException (java.io.IOException)3 Locale (java.util.Locale)3 MetaProperty (com.haulmont.chile.core.annotations.MetaProperty)2 Metadata (com.haulmont.cuba.core.global.Metadata)2 Dialogs (com.haulmont.cuba.gui.Dialogs)2