use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class KeyCombination method format.
public String format() {
Messages messages = AppBeans.get(Messages.NAME);
StringBuilder sb = new StringBuilder();
if (modifiers != null) {
for (Modifier modifier : modifiers) {
if (sb.length() > 0) {
sb.append("+");
}
sb.append(messages.getMainMessage(SHORTCUT_PREFIX + modifier.name()));
}
}
if (sb.length() > 0) {
sb.append("+");
}
sb.append(messages.getMainMessage(SHORTCUT_PREFIX + key.name()));
return sb.toString();
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class DesktopRowsCount method onCollectionChanged.
protected void onCollectionChanged() {
if (datasource == null) {
return;
}
String msgKey;
size = datasource.size();
start = 0;
boolean refreshSizeButton = false;
if (datasource instanceof CollectionDatasource.SupportsPaging) {
CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource;
if (samePage) {
state = lastState == null ? State.FIRST_COMPLETE : lastState;
start = ds.getFirstResult();
samePage = false;
refreshSizeButton = State.LAST.equals(state);
} else if ((size == 0 || size < ds.getMaxResults()) && ds.getFirstResult() == 0) {
state = State.FIRST_COMPLETE;
lastState = state;
} else if (size == ds.getMaxResults() && ds.getFirstResult() == 0) {
state = State.FIRST_INCOMPLETE;
lastState = state;
} else if (size == ds.getMaxResults() && ds.getFirstResult() > 0) {
state = State.MIDDLE;
start = ds.getFirstResult();
lastState = state;
} else if (size < ds.getMaxResults() && ds.getFirstResult() > 0) {
state = State.LAST;
start = ds.getFirstResult();
lastState = state;
} else {
state = State.FIRST_COMPLETE;
lastState = state;
}
} else {
state = State.FIRST_COMPLETE;
lastState = state;
}
String countValue;
switch(state) {
case FIRST_COMPLETE:
impl.getCountButton().setVisible(false);
impl.getPrevButton().setVisible(false);
impl.getNextButton().setVisible(false);
impl.getFirstButton().setVisible(false);
impl.getLastButton().setVisible(false);
if (size % 100 > 10 && size % 100 < 20) {
msgKey = "table.rowsCount.msg2Plural1";
} else {
switch(size % 10) {
case 1:
msgKey = "table.rowsCount.msg2Singular";
break;
case 2:
case 3:
case 4:
msgKey = "table.rowsCount.msg2Plural2";
break;
default:
msgKey = "table.rowsCount.msg2Plural1";
}
}
countValue = String.valueOf(size);
break;
case FIRST_INCOMPLETE:
impl.getCountButton().setVisible(true);
impl.getPrevButton().setVisible(false);
impl.getNextButton().setVisible(true);
impl.getFirstButton().setVisible(false);
impl.getLastButton().setVisible(true);
msgKey = "table.rowsCount.msg1";
countValue = countValue(start, size);
break;
case MIDDLE:
impl.getCountButton().setVisible(true);
impl.getPrevButton().setVisible(true);
impl.getNextButton().setVisible(true);
impl.getFirstButton().setVisible(true);
impl.getLastButton().setVisible(true);
msgKey = "table.rowsCount.msg1";
countValue = countValue(start, size);
break;
case LAST:
impl.getCountButton().setVisible(false);
impl.getPrevButton().setVisible(true);
impl.getNextButton().setVisible(false);
impl.getFirstButton().setVisible(true);
impl.getLastButton().setVisible(false);
msgKey = "table.rowsCount.msg2Plural2";
countValue = countValue(start, size);
break;
default:
throw new UnsupportedOperationException();
}
String messagesPack = AppConfig.getMessagesPack();
Messages messages = AppBeans.get(Messages.NAME);
impl.getLabel().setText(messages.formatMessage(messagesPack, msgKey, countValue));
if (impl.getCountButton().isVisible() && !refreshing || refreshSizeButton) {
impl.getCountButton().setText(messages.getMessage(messagesPack, "table.rowsCount.msg3"));
}
impl.repaint();
impl.revalidate();
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class DesktopAbstractTextField method showValidationMessage.
protected void showValidationMessage() {
if (ValidationAlertHolder.isListen()) {
ValidationAlertHolder.validationFailed();
}
impl.requestFocus();
Messages messages = AppBeans.get(Messages.NAME);
DesktopComponentsHelper.getTopLevelFrame(this).showNotification(messages.getMessage(AppConfig.getMessagesPack(), "validationFail"), Frame.NotificationType.TRAY);
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class DesktopFileMultiUploadField method uploadFiles.
protected void uploadFiles(File[] files) {
for (File file : files) {
try {
fireFileUploadStart(file.getName(), file.length());
FileInfo fileInfo = fileUploading.createFile();
UUID tempFileId = fileInfo.getId();
File tmpFile = fileInfo.getFile();
FileUtils.copyFile(file, tmpFile);
filesMap.put(tempFileId, file.getName());
fireFileUploadFinish(file.getName(), file.length());
} catch (Exception ex) {
Messages messages = AppBeans.get(Messages.NAME);
String uploadError = messages.formatMessage(DesktopFileMultiUploadField.class, "multiupload.uploadError", file.getName());
TopLevelFrame topLevelFrame = DesktopComponentsHelper.getTopLevelFrame(this);
topLevelFrame.showNotification(uploadError, Frame.NotificationType.ERROR);
fireFileUploadError(file.getName(), file.length(), ex);
}
}
fireQueueUploadComplete();
}
use of com.haulmont.cuba.core.global.Messages in project cuba by cuba-platform.
the class DesktopFileMultiUploadField method notifyFileExtensionNotAllowed.
protected void notifyFileExtensionNotAllowed(File file) {
Messages messages = AppBeans.get(Messages.NAME);
String warningMsg = messages.formatMainMessage("upload.fileIncorrectExtension.message", file.getName());
getFrame().showNotification(warningMsg, Frame.NotificationType.WARNING);
}
Aggregations