Search in sources :

Example 21 with Messages

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

the class DesktopFileMultiUploadField method notifyFileSizeExceedLimit.

protected void notifyFileSizeExceedLimit(File file) {
    Messages messages = AppBeans.get(Messages.NAME);
    String warningMsg = messages.formatMainMessage("upload.fileTooBig.message", file.getName(), getFileSizeLimitString());
    getFrame().showNotification(warningMsg, Frame.NotificationType.WARNING);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages)

Example 22 with Messages

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

the class EntityLogAttr method getDisplayName.

@MetaProperty
public String getDisplayName() {
    String entityName = getLogItem().getEntity();
    String message;
    com.haulmont.chile.core.model.MetaClass metaClass = getClassFromEntityName(entityName);
    if (metaClass != null) {
        Messages messages = AppBeans.get(Messages.NAME);
        message = messages.getTools().getPropertyCaption(metaClass, getName());
    } else {
        return getName();
    }
    return (message != null ? message : getName());
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) MetaProperty(com.haulmont.chile.core.annotations.MetaProperty)

Example 23 with Messages

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

the class BeanValidator method getDefaultErrorMessage.

public String getDefaultErrorMessage() {
    Messages messages = AppBeans.get(Messages.NAME);
    Metadata metadata = AppBeans.get(Metadata.NAME);
    MetaClass metaClass = metadata.getClass(beanClass);
    return messages.formatMainMessage("validation.defaultMsg", messages.getTools().getPropertyCaption(metaClass, beanProperty));
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) MetaClass(com.haulmont.chile.core.model.MetaClass) Metadata(com.haulmont.cuba.core.global.Metadata)

Example 24 with Messages

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

the class EntityLogTest method testEnumDisplayValue.

@Test
public void testEnumDisplayValue() throws Exception {
    Transaction tx = cont.persistence().createTransaction();
    try {
        EntityManager em = cont.persistence().getEntityManager();
        Role role = new Role();
        roleId = role.getId();
        role.setName("role1");
        role.setType(RoleType.READONLY);
        em.persist(role);
        tx.commit();
    } finally {
        tx.end();
    }
    List<EntityLogItem> items;
    tx = cont.persistence().createTransaction();
    try {
        EntityManager em = cont.persistence().getEntityManager();
        TypedQuery<EntityLogItem> query = em.createQuery("select i from sec$EntityLog i where i.entity = ?1 and i.entityRef.entityId = ?2", EntityLogItem.class);
        query.setParameter(1, "sec$Role");
        query.setParameter(2, roleId);
        items = query.getResultList();
        tx.commit();
    } finally {
        tx.end();
    }
    assertNotNull(items);
    assertEquals(1, items.size());
    assertNotNull(items.get(0).getAttributes());
    assertEquals(1, items.get(0).getAttributes().size());
    EntityLogAttr attr = items.get(0).getAttributes().iterator().next();
    Messages messages = AppBeans.get(Messages.NAME);
    assertEquals(messages.getMessage(RoleType.READONLY), attr.getDisplayValue());
}
Also used : EntityManager(com.haulmont.cuba.core.EntityManager) Messages(com.haulmont.cuba.core.global.Messages) Transaction(com.haulmont.cuba.core.Transaction) Test(org.junit.Test)

Example 25 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)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