Search in sources :

Example 41 with Messages

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

the class AbstractLookup method initLookupActions.

protected void initLookupActions(@SuppressWarnings("unused") InitEvent event) {
    addAction(new SelectAction(this));
    Messages messages = getBeanLocator().get(Messages.NAME);
    addAction(new BaseAction(LOOKUP_CANCEL_ACTION_ID).withCaption(messages.getMainMessage("actions.Cancel")).withHandler(e -> close("cancel")));
}
Also used : LookupSelectionChangeNotifier(com.haulmont.cuba.gui.components.LookupComponent.LookupSelectionChangeNotifier) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Fragments(com.haulmont.cuba.gui.Fragments) Messages(com.haulmont.cuba.core.global.Messages) StringUtils(org.apache.commons.lang3.StringUtils) Lookup(com.haulmont.cuba.gui.components.Window.Lookup) Consumer(java.util.function.Consumer) ScreenFragment(com.haulmont.cuba.gui.screen.ScreenFragment) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) Element(org.dom4j.Element) Nullable(javax.annotation.Nullable) UiControllerUtils(com.haulmont.cuba.gui.screen.UiControllerUtils) Messages(com.haulmont.cuba.core.global.Messages) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction)

Example 42 with Messages

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

the class StandardLookup method initActions.

protected void initActions(@SuppressWarnings("unused") InitEvent event) {
    Window window = getWindow();
    Configuration configuration = getBeanLocator().get(Configuration.NAME);
    Messages messages = getBeanLocator().get(Messages.NAME);
    Icons icons = getBeanLocator().get(Icons.NAME);
    String commitShortcut = configuration.getConfig(ClientConfig.class).getCommitShortcut();
    Action commitAction = new BaseAction(LOOKUP_SELECT_ACTION_ID).withCaption(messages.getMainMessage("actions.Select")).withIcon(icons.get(CubaIcon.LOOKUP_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(this::select);
    window.addAction(commitAction);
    Action closeAction = new BaseAction(LOOKUP_CANCEL_ACTION_ID).withCaption(messages.getMainMessage("actions.Cancel")).withIcon(icons.get(CubaIcon.LOOKUP_CANCEL)).withHandler(this::cancel);
    window.addAction(closeAction);
}
Also used : BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) Messages(com.haulmont.cuba.core.global.Messages) Configuration(com.haulmont.cuba.core.global.Configuration) Icons(com.haulmont.cuba.gui.icons.Icons) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 43 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.jupiter.api.Test)

Example 44 with Messages

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

the class ConnectExceptionHandler method handle.

@Override
public boolean handle(Thread thread, Throwable exception) {
    @SuppressWarnings("unchecked") List<Throwable> list = ExceptionUtils.getThrowableList(exception);
    for (Throwable throwable : list) {
        if (throwable instanceof RemoteAccessException) {
            Messages messages = AppBeans.get(Messages.NAME);
            String msg = messages.getMessage(getClass(), "connectException.message");
            if (throwable.getCause() == null) {
                App.getInstance().getMainFrame().showNotification(msg, Frame.NotificationType.ERROR);
            } else {
                String description = messages.formatMessage(getClass(), "connectException.description", throwable.getCause().toString());
                App.getInstance().getMainFrame().showNotification(msg, description, Frame.NotificationType.ERROR);
            }
            return true;
        }
    }
    return false;
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) RemoteAccessException(org.springframework.remoting.RemoteAccessException)

Example 45 with Messages

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

the class EntityLogItem method getDisplayedEntityName.

@MetaProperty
public String getDisplayedEntityName() {
    Metadata metadata = AppBeans.get(Metadata.NAME);
    Messages messages = AppBeans.get(Messages.NAME);
    MetaClass metaClass = metadata.getSession().getClass(entity);
    if (metaClass != null) {
        metaClass = metadata.getExtendedEntities().getEffectiveMetaClass(metaClass);
        return messages.getTools().getEntityCaption(metaClass);
    }
    return entity;
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) MetaClass(com.haulmont.chile.core.model.MetaClass) Metadata(com.haulmont.cuba.core.global.Metadata) MetaProperty(com.haulmont.chile.core.annotations.MetaProperty)

Aggregations

Messages (com.haulmont.cuba.core.global.Messages)56 ClientConfig (com.haulmont.cuba.client.ClientConfig)7 Configuration (com.haulmont.cuba.core.global.Configuration)7 Notifications (com.haulmont.cuba.gui.Notifications)5 Icons (com.haulmont.cuba.gui.icons.Icons)4 CubaButton (com.haulmont.cuba.web.widgets.CubaButton)4 File (java.io.File)4 MetaClass (com.haulmont.chile.core.model.MetaClass)3 FileStorageException (com.haulmont.cuba.core.global.FileStorageException)3 UserSessionSource (com.haulmont.cuba.core.global.UserSessionSource)3 WindowManager (com.haulmont.cuba.gui.WindowManager)3 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)3 FileUploadingAPI (com.haulmont.cuba.gui.upload.FileUploadingAPI)3 UserSession (com.haulmont.cuba.security.global.UserSession)3 FileOutputStream (java.io.FileOutputStream)3 IOException (java.io.IOException)3 Locale (java.util.Locale)3 MetaProperty (com.haulmont.chile.core.annotations.MetaProperty)2 Metadata (com.haulmont.cuba.core.global.Metadata)2 Dialogs (com.haulmont.cuba.gui.Dialogs)2