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