Search in sources :

Example 26 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 27 with Messages

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

the class LogWindow method initUI.

private void initUI() {
    ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class);
    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);
    com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction("closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers()));
    addActionHandler(new com.vaadin.event.Action.Handler() {

        @Override
        public com.vaadin.event.Action[] getActions(Object target, Object sender) {
            return new com.vaadin.event.Action[] { closeShortcutAction };
        }

        @Override
        public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
            if (Objects.equals(action, closeShortcutAction)) {
                close();
            }
        }
    });
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);
    Panel scrollablePanel = new Panel();
    scrollablePanel.setSizeFull();
    VerticalLayout scrollContent = new VerticalLayout();
    scrollContent.setSizeUndefined();
    scrollablePanel.setContent(scrollContent);
    final Label label = new Label();
    label.setContentMode(ContentMode.HTML);
    label.setValue(writeLog());
    label.setSizeUndefined();
    label.setStyleName("c-log-content");
    ((Layout) scrollablePanel.getContent()).addComponent(label);
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setHeightUndefined();
    Messages messages = AppBeans.get(Messages.NAME);
    Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), (Button.ClickListener) event -> label.setValue(writeLog()));
    topLayout.addComponent(refreshBtn);
    layout.addComponent(topLayout);
    layout.addComponent(scrollablePanel);
    layout.setExpandRatio(scrollablePanel, 1.0f);
}
Also used : CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) StringUtils(org.apache.commons.lang.StringUtils) ContentMode(com.vaadin.shared.ui.label.ContentMode) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination) App(com.haulmont.cuba.web.App) Messages(com.haulmont.cuba.core.global.Messages) AppBeans(com.haulmont.cuba.core.global.AppBeans) DateFormatUtils(org.apache.commons.lang.time.DateFormatUtils) Objects(java.util.Objects) List(java.util.List) Configuration(com.haulmont.cuba.core.global.Configuration) CubaWindow(com.haulmont.cuba.web.toolkit.ui.CubaWindow) AppUI(com.haulmont.cuba.web.AppUI) ClientConfig(com.haulmont.cuba.client.ClientConfig) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) com.vaadin.ui(com.vaadin.ui) Messages(com.haulmont.cuba.core.global.Messages) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 28 with Messages

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

the class PresentationEditor method initLayout.

protected void initLayout() {
    ThemeConstants theme = App.getInstance().getThemeConstants();
    VerticalLayout root = new VerticalLayout();
    root.setWidthUndefined();
    root.setSpacing(true);
    setContent(root);
    messages = AppBeans.get(Messages.class);
    nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
    nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
    nameField.setValue(getPresentationCaption());
    root.addComponent(nameField);
    autoSaveField = new CheckBox();
    autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
    autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
    root.addComponent(autoSaveField);
    defaultField = new CheckBox();
    defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
    defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
    root.addComponent(defaultField);
    if (allowGlobalPresentations) {
        globalField = new CheckBox();
        globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
        globalField.setValue(!isNew && presentation.getUser() == null);
        root.addComponent(globalField);
    }
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidthUndefined();
    root.addComponent(buttons);
    root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);
    Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
    commitButton.addClickListener(event -> {
        if (validate()) {
            commit();
            close();
        }
    });
    buttons.addComponent(commitButton);
    Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
    closeButton.addClickListener(event -> {
        close();
    });
    buttons.addComponent(closeButton);
    nameField.focus();
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) Messages(com.haulmont.cuba.core.global.Messages) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton)

Example 29 with Messages

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

the class NumericOverflowExceptionHandler method doHandle.

@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
    Messages messages = AppBeans.get(Messages.NAME);
    String msg = messages.getMessage(getClass(), "numericFieldOverflow.message");
    windowManager.showNotification(msg, Frame.NotificationType.ERROR);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages)

Example 30 with Messages

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

the class WebEntityLinkField method openEntityEditor.

protected void openEntityEditor() {
    Object value = getValue();
    Entity entity;
    if (value instanceof Entity) {
        entity = (Entity) value;
    } else {
        entity = datasource.getItem();
    }
    if (entity == null) {
        return;
    }
    WindowManager wm;
    Window window = ComponentsHelper.getWindow(this);
    if (window == null) {
        throw new IllegalStateException("Please specify Frame for EntityLinkField");
    } else {
        wm = window.getWindowManager();
    }
    if (screenOpenType.getOpenMode() == OpenMode.DIALOG && screenDialogParams != null) {
        wm.getDialogParams().copyFrom(screenDialogParams);
    }
    if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) {
        Messages messages = AppBeans.get(Messages.NAME);
        wm.showNotification(messages.getMainMessage("OpenAction.objectIsDeleted"), Frame.NotificationType.HUMANIZED);
        return;
    }
    DataSupplier dataSupplier = window.getDsContext().getDataSupplier();
    entity = dataSupplier.reload(entity, View.MINIMAL);
    String windowAlias = screen;
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    if (windowAlias == null) {
        windowAlias = windowConfig.getEditorScreenId(entity.getMetaClass());
    }
    final Window.Editor editor = wm.openEditor(windowConfig.getWindowInfo(windowAlias), entity, screenOpenType, screenParams != null ? screenParams : Collections.<String, Object>emptyMap());
    editor.addCloseListener(actionId -> {
        // move focus to component
        component.focus();
        if (Window.COMMIT_ACTION_ID.equals(actionId)) {
            Entity item = editor.getItem();
            afterCommitOpenedEntity(item);
        }
        if (screenCloseListener != null) {
            screenCloseListener.windowClosed(editor, actionId);
        }
    });
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Entity(com.haulmont.cuba.core.entity.Entity) Messages(com.haulmont.cuba.core.global.Messages) SoftDelete(com.haulmont.cuba.core.entity.SoftDelete) DataSupplier(com.haulmont.cuba.gui.data.DataSupplier) WindowManager(com.haulmont.cuba.gui.WindowManager)

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