Search in sources :

Example 46 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 47 with Messages

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

the class MismatchedUserSessionHandler method showMismatchedSessionDialog.

protected void showMismatchedSessionDialog(AppUI ui) {
    Messages messages = beanLocator.get(Messages.class);
    Connection connection = ui.getApp().getConnection();
    // noinspection ConstantConditions
    Locale locale = connection.getSession().getLocale();
    Window dialog = new MismatchedUserSessionExceptionDialog();
    dialog.setStyleName("c-sessionchanged-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);
    dialog.setResizable(false);
    dialog.setModal(true);
    CubaLabel messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("sessionChangedMsg", locale));
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(false);
    layout.setWidthUndefined();
    layout.setStyleName("c-sessionchanged-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);
    CubaButton reloginBtn = new CubaButton();
    reloginBtn.addStyleName(WebButton.PRIMARY_ACTION_STYLENAME);
    reloginBtn.setCaption(messages.getMainMessage(DialogAction.Type.OK.getMsgKey(), locale));
    reloginBtn.addClickListener(event -> ui.getApp().recreateUi(ui));
    String iconName = beanLocator.get(Icons.class).get(DialogAction.Type.OK.getIconKey());
    reloginBtn.setIcon(beanLocator.get(IconResolver.class).getIconResource(iconName));
    ClientConfig clientConfig = beanLocator.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());
    reloginBtn.focus();
    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);
    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);
    ui.addWindow(dialog);
    dialog.center();
    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        reloginBtn.setCubaId("reloginBtn");
    }
    if (ui.isPerformanceTestMode()) {
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
}
Also used : Locale(java.util.Locale) Window(com.vaadin.ui.Window) CubaWindow(com.haulmont.cuba.web.widgets.CubaWindow) Messages(com.haulmont.cuba.core.global.Messages) CubaLabel(com.haulmont.cuba.web.widgets.CubaLabel) Configuration(com.haulmont.cuba.core.global.Configuration) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) Connection(com.haulmont.cuba.web.Connection) VerticalLayout(com.vaadin.ui.VerticalLayout) Icons(com.haulmont.cuba.gui.icons.Icons) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 48 with Messages

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

the class ShowLinkAction method actionPerform.

@Override
public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
    if (ds == null) {
        return;
    }
    Messages messages = AppBeans.get(Messages.NAME);
    WindowManager wm = App.getInstance().getWindowManager();
    wm.showMessageDialog(messages.getMainMessage("table.showLinkAction"), compileLink(ds), Frame.MessageType.CONFIRMATION_HTML);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) WindowManager(com.haulmont.cuba.gui.WindowManager)

Example 49 with Messages

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

the class ShowLinkAction method compileLink.

protected String compileLink(CollectionDatasource ds) {
    StringBuilder sb = new StringBuilder();
    Messages messages = AppBeans.get(Messages.NAME);
    sb.append(messages.getMainMessage("table.showLinkAction.link")).append("<br/>");
    sb.append("<textarea class=\"c-table-showlink-textarea\" autofocus=\"true\" readonly=\"true\">").append(handler.makeLink(ds.getItem()).replace("&", "&amp")).append("</textarea>");
    return sb.toString();
}
Also used : Messages(com.haulmont.cuba.core.global.Messages)

Example 50 with Messages

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

the class CronValidator method validate.

@Override
public void validate(Object value) throws ValidationException {
    if (value != null) {
        ServerInfoService serverInfoService = AppBeans.get(ServerInfoService.NAME);
        Messages messages = AppBeans.get(Messages.NAME);
        try {
            new CronSequenceGenerator(value.toString(), serverInfoService.getTimeZone());
        } catch (Exception e) {
            throw new ValidationException(messages.getMessage(CronValidator.class, "validation.cronInvalid"));
        }
    }
}
Also used : ServerInfoService(com.haulmont.cuba.core.app.ServerInfoService) Messages(com.haulmont.cuba.core.global.Messages) ValidationException(com.haulmont.cuba.gui.components.ValidationException) CronSequenceGenerator(org.springframework.scheduling.support.CronSequenceGenerator) ValidationException(com.haulmont.cuba.gui.components.ValidationException)

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