Search in sources :

Example 6 with Messages

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

Example 7 with Messages

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

Example 8 with Messages

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

Example 9 with Messages

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();
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) FileInfo(com.haulmont.cuba.gui.upload.FileUploadingAPI.FileInfo) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) File(java.io.File)

Example 10 with Messages

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

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