Search in sources :

Example 11 with Messages

use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.

the class EntitySerializationExceptionHandler method doHandle.

@Override
protected void doHandle(Thread thread, String className, String message, @Nullable Throwable throwable) {
    Messages messages = AppBeans.get(Messages.NAME);
    String title = messages.getMessage(getClass(), "entitySerializationException.title");
    String msg = messages.getMessage(getClass(), "entitySerializationException.description");
    App.getInstance().getMainFrame().showNotification(title, msg, Frame.NotificationType.ERROR_HTML);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages)

Example 12 with Messages

use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.

the class InvalidValueExceptionHandler method doHandle.

@Override
protected void doHandle(App app, String className, String message, @Nullable Throwable throwable) {
    Messages messages = AppBeans.get(Messages.NAME);
    app.getWindowManager().showNotification(messages.getMainMessage("validationFail.caption"), messages.getMainMessage("validationFail"), Frame.NotificationType.TRAY);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages)

Example 13 with Messages

use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.

the class NoUserSessionHandler method showNoUserSessionDialog.

protected void showNoUserSessionDialog(App app) {
    Messages messages = AppBeans.get(Messages.NAME);
    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);
    dialog.setResizable(false);
    dialog.setModal(true);
    AppUI ui = app.getAppUI();
    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }
    Label messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.setStyleName("c-nousersession-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);
    Button reloginBtn = new Button();
    if (ui.isTestMode()) {
        reloginBtn.setCubaId("reloginBtn");
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
    reloginBtn.addStyleName(WebButton.ICON_STYLE);
    reloginBtn.addStyleName("c-primary-action");
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));
    String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
    reloginBtn.setIcon(AppBeans.get(IconResolver.class).getIconResource(iconName));
    ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());
    reloginBtn.focus();
    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);
    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);
    ui.addWindow(dialog);
    dialog.center();
}
Also used : CubaWindow(com.haulmont.cuba.web.toolkit.ui.CubaWindow) Messages(com.haulmont.cuba.core.global.Messages) CubaLabel(com.haulmont.cuba.web.toolkit.ui.CubaLabel) Configuration(com.haulmont.cuba.core.global.Configuration) WebButton(com.haulmont.cuba.web.gui.components.WebButton) CubaLabel(com.haulmont.cuba.web.toolkit.ui.CubaLabel) Icons(com.haulmont.cuba.gui.icons.Icons) ClientConfig(com.haulmont.cuba.client.ClientConfig) AppUI(com.haulmont.cuba.web.AppUI)

Example 14 with Messages

use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.

the class WebDatePicker method handleDateOutOfRange.

protected void handleDateOutOfRange(Date value) {
    if (getFrame() != null) {
        Messages messages = AppBeans.get(Messages.NAME);
        getFrame().showNotification(messages.getMainMessage("datePicker.dateOutOfRangeMessage"), Frame.NotificationType.TRAY);
    }
    updatingInstance = true;
    try {
        component.setValue((Date) prevValue);
    } finally {
        updatingInstance = false;
    }
}
Also used : Messages(com.haulmont.cuba.core.global.Messages)

Example 15 with Messages

use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.

the class WebFileMultiUploadField method initComponent.

protected void initComponent() {
    CubaFileUpload impl = createComponent();
    impl.setMultiSelect(true);
    Messages messages = AppBeans.get(Messages.NAME);
    impl.setProgressWindowCaption(messages.getMainMessage("upload.uploadingProgressTitle"));
    impl.setUnableToUploadFileMessage(messages.getMainMessage("upload.unableToUploadFile"));
    impl.setCancelButtonCaption(messages.getMainMessage("upload.cancel"));
    impl.setCaption(messages.getMainMessage("upload.submit"));
    impl.setDropZonePrompt(messages.getMainMessage("upload.dropZonePrompt"));
    impl.setDescription(null);
    Configuration configuration = AppBeans.get(Configuration.NAME);
    final int maxUploadSizeMb = configuration.getConfig(ClientConfig.class).getMaxUploadSizeMb();
    final int maxSizeBytes = maxUploadSizeMb * BYTES_IN_MEGABYTE;
    impl.setFileSizeLimit(maxSizeBytes);
    impl.setReceiver((fileName, MIMEType) -> {
        FileOutputStream outputStream;
        try {
            FileUploadingAPI.FileInfo fileInfo = fileUploading.createFile();
            tempFileId = fileInfo.getId();
            File tmpFile = fileInfo.getFile();
            outputStream = new FileOutputStream(tmpFile);
        } catch (Exception e) {
            throw new RuntimeException("Unable to receive file", e);
        }
        return outputStream;
    });
    impl.addStartedListener(event -> fireFileUploadStart(event.getFileName(), event.getContentLength()));
    impl.addQueueUploadFinishedListener(event -> fireQueueUploadComplete());
    impl.addSucceededListener(event -> {
        files.put(tempFileId, event.getFileName());
        fireFileUploadFinish(event.getFileName(), event.getContentLength());
    });
    impl.addFailedListener(event -> {
        try {
            // close and remove temp file
            fileUploading.deleteFile(tempFileId);
            tempFileId = null;
        } catch (Exception e) {
            if (e instanceof FileStorageException) {
                FileStorageException fse = (FileStorageException) e;
                if (fse.getType() != FileStorageException.Type.FILE_NOT_FOUND) {
                    LoggerFactory.getLogger(WebFileMultiUploadField.class).warn("Could not remove temp file {} after broken uploading", tempFileId);
                }
            }
            LoggerFactory.getLogger(WebFileMultiUploadField.class).warn("Error while delete temp file {}", tempFileId);
        }
        fireFileUploadError(event.getFileName(), event.getContentLength(), event.getReason());
    });
    impl.addFileSizeLimitExceededListener(e -> {
        String warningMsg = messages.formatMessage(WebFileMultiUploadField.class, "multiupload.filesizeLimitExceed", e.getFileName(), getFileSizeLimitString());
        getFrame().showNotification(warningMsg, Frame.NotificationType.WARNING);
    });
    impl.addFileExtensionNotAllowedListener(e -> {
        String warningMsg = messages.formatMainMessage("upload.fileIncorrectExtension.message", e.getFileName());
        getFrame().showNotification(warningMsg, Frame.NotificationType.WARNING);
    });
    component = impl;
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) Configuration(com.haulmont.cuba.core.global.Configuration) FileStorageException(com.haulmont.cuba.core.global.FileStorageException) FileStorageException(com.haulmont.cuba.core.global.FileStorageException) IOException(java.io.IOException) CubaFileUpload(com.haulmont.cuba.web.toolkit.ui.CubaFileUpload) FileUploadingAPI(com.haulmont.cuba.gui.upload.FileUploadingAPI) FileOutputStream(java.io.FileOutputStream) ClientConfig(com.haulmont.cuba.client.ClientConfig) File(java.io.File)

Aggregations

Messages (com.haulmont.cuba.core.global.Messages)34 Configuration (com.haulmont.cuba.core.global.Configuration)4 ClientConfig (com.haulmont.cuba.client.ClientConfig)3 File (java.io.File)3 MetaClass (com.haulmont.chile.core.model.MetaClass)2 FileStorageException (com.haulmont.cuba.core.global.FileStorageException)2 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)2 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)2 FileUploadingAPI (com.haulmont.cuba.gui.upload.FileUploadingAPI)2 AppUI (com.haulmont.cuba.web.AppUI)2 CubaButton (com.haulmont.cuba.web.toolkit.ui.CubaButton)2 CubaWindow (com.haulmont.cuba.web.toolkit.ui.CubaWindow)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 Pattern (java.util.regex.Pattern)2 MetaProperty (com.haulmont.chile.core.annotations.MetaProperty)1 EnumClass (com.haulmont.chile.core.datatypes.impl.EnumClass)1 Instance (com.haulmont.chile.core.model.Instance)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 AbstractInstance (com.haulmont.chile.core.model.impl.AbstractInstance)1