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