Search in sources :

Example 6 with Messages

use of io.jmix.core.Messages in project jmix by jmix-framework.

the class BulkEditAction method actionPerform.

@Override
public void actionPerform(Component component) {
    if (beforeActionPerformedHandler != null && !beforeActionPerformedHandler.beforeActionPerformed()) {
        return;
    }
    Security security = AppBeans.get(Security.class);
    if (!security.isSpecificPermitted(BulkEditor.PERMISSION)) {
        Messages messages = AppBeans.get(Messages.class);
        Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
        notifications.create(NotificationType.ERROR).withCaption(messages.getMessage("accessDenied.message")).show();
        return;
    }
    if (target.getSelected().isEmpty()) {
        Messages messages = AppBeans.get(Messages.class);
        Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
        notifications.create(NotificationType.HUMANIZED).withCaption(messages.getMessage("actions.BulkEdit.emptySelection")).show();
        return;
    }
    OpenType openType = this.openType;
    if (openType.getOpenMode() == OpenMode.DIALOG) {
        ThemeConstantsManager themeManager = AppBeans.get(ThemeConstantsManager.class);
        ThemeConstants theme = themeManager.getConstants();
        openType = openType.copy().width(theme.get("cuba.gui.BulkEditAction.editorDialog.width")).height(theme.get("cuba.gui.BulkEditAction.editorDialog.height")).resizable(true);
    }
    Map<String, Object> params = ParamsMap.of().pair("metaClass", target.getDatasource().getMetaClass()).pair("selected", target.getSelected()).pair("exclude", exclude).pair("includeProperties", includeProperties != null ? includeProperties : Collections.EMPTY_LIST).pair("fieldValidators", fieldValidators).pair("modelValidators", modelValidators).pair("loadDynamicAttributes", loadDynamicAttributes).pair("useConfirmDialog", useConfirmDialog).pair("columnsMode", columnsMode).create();
    WindowManager wm = ((WindowManager) getScreenContext(target.getFrame()).getScreens());
    WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("bulkEditor");
    Window bulkEditor = wm.openWindow(windowInfo, openType, params);
    bulkEditor.addCloseListener(actionId -> {
        if (Window.COMMIT_ACTION_ID.equals(actionId)) {
            target.getDatasource().refresh();
        }
        if (target instanceof Component.Focusable) {
            ((Component.Focusable) target).focus();
        }
    });
}
Also used : Window(com.haulmont.cuba.gui.components.Window) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) Messages(io.jmix.core.Messages) ThemeConstantsManager(io.jmix.ui.theme.ThemeConstantsManager) Security(com.haulmont.cuba.core.global.Security) WindowManager(com.haulmont.cuba.gui.WindowManager) WindowInfo(io.jmix.ui.WindowInfo) WindowConfig(io.jmix.ui.WindowConfig) ThemeConstants(io.jmix.ui.theme.ThemeConstants) Notifications(io.jmix.ui.Notifications)

Example 7 with Messages

use of io.jmix.core.Messages in project jmix by jmix-framework.

the class WindowBreadCrumbs method setApplicationContext.

public void setApplicationContext(ApplicationContext applicationContext) {
    setWidth(100, Unit.PERCENTAGE);
    setHeightUndefined();
    setPrimaryStyleName(C_HEADLINE_CONTAINER);
    if (workAreaMode == Mode.TABBED) {
        super.setVisible(false);
    }
    Layout logoLayout = createLogoLayout();
    linksLayout = createLinksLayout();
    linksLayout.setSizeUndefined();
    if (workAreaMode == Mode.SINGLE) {
        Messages messages = applicationContext.getBean(Messages.class);
        JmixButton closeBtn = new JmixButton("");
        closeBtn.setDescription(messages.getMessage("windowBreadCrumbs.closeButton.description"));
        closeBtn.setClickHandler(this::onCloseWindowButtonClick);
        closeBtn.setIcon(resolveIcon(applicationContext, JmixIcon.CLOSE));
        closeBtn.setStyleName("jmix-closetab-button");
        this.closeBtn = closeBtn;
    }
    Layout enclosingLayout = createEnclosingLayout();
    enclosingLayout.addComponent(linksLayout);
    addComponent(logoLayout);
    addComponent(enclosingLayout);
    boolean controlsVisible = applicationContext.getBean(UiProperties.class).isShowBreadCrumbs();
    enclosingLayout.setVisible(controlsVisible);
    if (closeBtn != null) {
        addComponent(closeBtn);
    }
}
Also used : Messages(io.jmix.core.Messages) CssLayout(com.vaadin.ui.CssLayout) Layout(com.vaadin.ui.Layout) UiProperties(io.jmix.ui.UiProperties)

Example 8 with Messages

use of io.jmix.core.Messages in project jmix by jmix-framework.

the class TextFieldImpl method convertToPresentation.

@SuppressWarnings("unchecked")
@Override
protected String convertToPresentation(@Nullable V modelValue) throws ConversionException {
    if (formatter != null) {
        return nullToEmpty(formatter.apply(modelValue));
    }
    if (datatype != null) {
        return nullToEmpty(datatype.format(modelValue, locale));
    }
    if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) {
        EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource();
        Range range = entityValueSource.getMetaPropertyPath().getRange();
        if (range.isDatatype()) {
            Datatype<V> propertyDataType = range.asDatatype();
            return nullToEmpty(propertyDataType.format(modelValue, locale));
        } else {
            setEditable(false);
            if (modelValue == null)
                return "";
            if (range.isClass()) {
                MetadataTools metadataTools = applicationContext.getBean(MetadataTools.class);
                if (range.getCardinality().isMany()) {
                    return ((Collection<Object>) modelValue).stream().map(metadataTools::getInstanceName).collect(Collectors.joining(", "));
                } else {
                    return metadataTools.getInstanceName(modelValue);
                }
            } else if (range.isEnum()) {
                Messages messages = applicationContext.getBean(Messages.class);
                return messages.getMessage((Enum) modelValue);
            }
        }
    }
    return nullToEmpty(super.convertToPresentation(modelValue));
}
Also used : EntityValueSource(io.jmix.ui.component.data.meta.EntityValueSource) MetadataTools(io.jmix.core.MetadataTools) Messages(io.jmix.core.Messages) Collection(java.util.Collection) Range(io.jmix.core.metamodel.model.Range)

Example 9 with Messages

use of io.jmix.core.Messages in project jmix by jmix-framework.

the class ShowLinkAction method compileLink.

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

Example 10 with Messages

use of io.jmix.core.Messages in project jmix by jmix-framework.

the class AbstractLookup method initLookupActions.

protected void initLookupActions(@SuppressWarnings("unused") InitEvent event) {
    addAction(new SelectAction(this));
    Messages messages = getApplicationContext().getBean(Messages.class);
    addAction(new BaseAction(LOOKUP_CANCEL_ACTION_ID).withCaption(messages.getMessage("actions.Cancel")).withHandler(e -> close("cancel")));
}
Also used : ScreenFragment(io.jmix.ui.screen.ScreenFragment) Predicate(java.util.function.Predicate) Collection(java.util.Collection) StringUtils(org.apache.commons.lang3.StringUtils) Messages(io.jmix.core.Messages) UiControllerUtils(io.jmix.ui.screen.UiControllerUtils) Consumer(java.util.function.Consumer) Component(io.jmix.ui.component.Component) Fragments(io.jmix.ui.Fragments) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Element(org.dom4j.Element) Window(io.jmix.ui.component.Window) Nullable(javax.annotation.Nullable) Messages(io.jmix.core.Messages) BaseAction(io.jmix.ui.action.BaseAction)

Aggregations

Messages (io.jmix.core.Messages)18 BaseAction (io.jmix.ui.action.BaseAction)5 Icons (io.jmix.ui.icon.Icons)4 Action (io.jmix.ui.action.Action)3 Window (io.jmix.ui.component.Window)3 MetadataTools (io.jmix.core.MetadataTools)2 Notifications (io.jmix.ui.Notifications)2 UiScreenProperties (io.jmix.ui.UiScreenProperties)2 Collection (java.util.Collection)2 Security (com.haulmont.cuba.core.global.Security)1 Op (com.haulmont.cuba.core.global.filter.Op)1 OpManager (com.haulmont.cuba.core.global.filter.OpManager)1 WindowManager (com.haulmont.cuba.gui.WindowManager)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 Window (com.haulmont.cuba.gui.components.Window)1 ComponentsFactory (com.haulmont.cuba.gui.xml.layout.ComponentsFactory)1 CssLayout (com.vaadin.ui.CssLayout)1 Layout (com.vaadin.ui.Layout)1 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1