Search in sources :

Example 1 with BaseAction

use of com.haulmont.cuba.gui.components.actions.BaseAction in project cuba by cuba-platform.

the class ListEditorDelegateImpl method addClearBtn.

protected void addClearBtn() {
    clearBtn = componentsFactory.createComponent(Button.class);
    clearBtn.setIconFromSet(CubaIcon.PICKERFIELD_CLEAR);
    clearBtn.setStyleName("c-listeditor-button");
    clearBtn.setCaption("");
    clearBtn.setAction(new BaseAction("clear").withCaption("Clear").withHandler(event -> actualField.setValue(null)));
    layout.add(clearBtn);
}
Also used : java.util(java.util) WindowManager(com.haulmont.cuba.gui.WindowManager) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) Scope(org.springframework.context.annotation.Scope) Inject(javax.inject.Inject) Component(org.springframework.stereotype.Component) ComponentsFactory(com.haulmont.cuba.gui.xml.layout.ComponentsFactory) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) PostConstruct(javax.annotation.PostConstruct) EventRouter(com.haulmont.bali.events.EventRouter) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) WindowManagerProvider(com.haulmont.cuba.gui.WindowManagerProvider) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Joiner(com.google.common.base.Joiner) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction)

Example 2 with BaseAction

use of com.haulmont.cuba.gui.components.actions.BaseAction in project cuba by cuba-platform.

the class AttributeEditor method initFieldGroup.

protected void initFieldGroup() {
    attributeFieldGroup.addCustomField("defaultBoolean", new FieldGroup.CustomFieldGenerator() {

        @Override
        public Component generateField(Datasource datasource, String propertyId) {
            LookupField lookupField = factory.createComponent(LookupField.class);
            Map<String, Object> options = new TreeMap<>();
            options.put(datatypeFormatter.formatBoolean(true), true);
            options.put(datatypeFormatter.formatBoolean(false), false);
            lookupField.setOptionsMap(options);
            lookupField.setDatasource(attributeDs, "defaultBoolean");
            return lookupField;
        }
    });
    attributeFieldGroup.addCustomField("dataType", new FieldGroup.CustomFieldGenerator() {

        @Override
        public Component generateField(Datasource datasource, String propertyId) {
            dataTypeField = factory.createComponent(LookupField.class);
            Map<String, Object> options = new TreeMap<>();
            PropertyType[] types = PropertyType.values();
            for (PropertyType propertyType : types) {
                options.put(getMessage(propertyType.toString()), propertyType);
            }
            dataTypeField.setWidth(fieldWidth);
            dataTypeField.setNewOptionAllowed(false);
            dataTypeField.setRequired(true);
            dataTypeField.setRequiredMessage(getMessage("dataTypeRequired"));
            dataTypeField.setOptionsMap(options);
            dataTypeField.setCaption(getMessage("dataType"));
            dataTypeField.setFrame(frame);
            dataTypeField.setDatasource(datasource, propertyId);
            return dataTypeField;
        }
    });
    attributeFieldGroup.addCustomField("screen", new FieldGroup.CustomFieldGenerator() {

        @Override
        public Component generateField(Datasource datasource, String propertyId) {
            screenField = factory.createComponent(LookupField.class);
            screenField.setId("screenField");
            screenField.setCaption(getMessage("screen"));
            screenField.setWidth(fieldWidth);
            screenField.setRequired(true);
            screenField.setRequiredMessage(getMessage("entityScreenRequired"));
            screenField.setFrame(frame);
            screenField.setDatasource(datasource, propertyId);
            return screenField;
        }
    });
    attributeFieldGroup.addCustomField("entityClass", new FieldGroup.CustomFieldGenerator() {

        @Override
        public Component generateField(Datasource datasource, String propertyId) {
            entityTypeField = factory.createComponent(LookupField.class);
            entityTypeField.setId("entityClass");
            entityTypeField.setCaption(getMessage("entityType"));
            entityTypeField.setRequired(true);
            entityTypeField.setRequiredMessage(getMessage("entityTypeRequired"));
            entityTypeField.setWidth(fieldWidth);
            entityTypeField.setFrame(frame);
            Map<String, Object> options = new TreeMap<>();
            MetaClass entityType = null;
            for (MetaClass metaClass : metadataTools.getAllPersistentMetaClasses()) {
                if (!metadataTools.isSystemLevel(metaClass)) {
                    if (metadata.getTools().hasCompositePrimaryKey(metaClass) && !HasUuid.class.isAssignableFrom(metaClass.getJavaClass())) {
                        continue;
                    }
                    options.put(messageTools.getDetailedEntityCaption(metaClass), metaClass.getJavaClass().getName());
                    if (attribute != null && metaClass.getJavaClass().getName().equals(attribute.getEntityClass())) {
                        entityType = metaClass;
                    }
                }
            }
            entityTypeField.setOptionsMap(options);
            entityTypeField.setValue(entityType);
            entityTypeField.setDatasource(datasource, propertyId);
            return entityTypeField;
        }
    });
    attributeFieldGroup.addCustomField("defaultEntityId", (datasource, propertyId) -> {
        defaultEntityField = factory.createComponent(PickerField.class);
        defaultEntityField.setCaption(messages.getMessage(CategoryAttribute.class, "CategoryAttribute.defaultEntityId"));
        defaultEntityField.addValueChangeListener(e -> {
            Entity entity = (Entity) e.getValue();
            if (entity != null) {
                attribute.setObjectDefaultEntityId(referenceToEntitySupport.getReferenceId(entity));
            } else {
                attribute.setObjectDefaultEntityId(null);
            }
            ((AbstractDatasource) attributeDs).modified(attribute);
        });
        entityLookupAction = defaultEntityField.addLookupAction();
        defaultEntityField.addClearAction();
        return defaultEntityField;
    });
    attributeFieldGroup.addCustomField("enumeration", (datasource, propertyId) -> {
        enumerationListEditor = factory.createComponent(ListEditor.class);
        enumerationListEditor.setWidth("100%");
        enumerationListEditor.setItemType(ListEditor.ItemType.STRING);
        enumerationListEditor.setRequired(true);
        enumerationListEditor.setRequiredMessage(getMessage("enumRequired"));
        enumerationListEditor.addValueChangeListener(e -> {
            List<String> value = (List<String>) e.getValue();
            attribute.setEnumeration(Joiner.on(",").join(value));
        });
        if (localizedFrame != null) {
            enumerationListEditor.setEditorWindowId("localizedEnumerationWindow");
            enumerationListEditor.setEditorParamsSupplier(() -> ParamsMap.of("enumerationLocales", attribute.getEnumerationLocales()));
            enumerationListEditor.addEditorCloseListener(closeEvent -> {
                if (closeEvent.getActionId().equals(COMMIT_ACTION_ID)) {
                    LocalizedEnumerationWindow enumerationWindow = (LocalizedEnumerationWindow) closeEvent.getWindow();
                    attribute.setEnumerationLocales(enumerationWindow.getLocalizedValues());
                }
            });
        }
        return enumerationListEditor;
    });
    attributeFieldGroup.addCustomField("whereClause", (datasource, propertyId) -> {
        whereField = factory.createComponent(SourceCodeEditor.class);
        whereField.setDatasource(attributeDs, "whereClause");
        whereField.setWidth("100%");
        whereField.setHeight(themeConstants.get("cuba.gui.customConditionFrame.whereField.height"));
        whereField.setSuggester((source, text, cursorPosition) -> requestHint(whereField, text, cursorPosition));
        whereField.setHighlightActiveLine(false);
        whereField.setShowGutter(false);
        return whereField;
    });
    attributeFieldGroup.addCustomField("joinClause", (datasource, propertyId) -> {
        joinField = factory.createComponent(SourceCodeEditor.class);
        joinField.setDatasource(attributeDs, "joinClause");
        joinField.setWidth("100%");
        joinField.setHeight(themeConstants.get("cuba.gui.customConditionFrame.joinField.height"));
        joinField.setSuggester((source, text, cursorPosition) -> requestHint(joinField, text, cursorPosition));
        joinField.setHighlightActiveLine(false);
        joinField.setShowGutter(false);
        return joinField;
    });
    attributeFieldGroup.addCustomField("constraintWizard", (datasource, propertyId) -> {
        HBoxLayout hbox = factory.createComponent(HBoxLayout.class);
        hbox.setWidth("100%");
        LinkButton linkButton = factory.createComponent(LinkButton.class);
        linkButton.setAction(new BaseAction("constraintWizard").withHandler(event -> openConstraintWizard()));
        linkButton.setCaption(getMessage("constraintWizard"));
        linkButton.setAlignment(Alignment.MIDDLE_LEFT);
        hbox.add(linkButton);
        return hbox;
    });
    attributeDs.addItemPropertyChangeListener(e -> {
        String property = e.getProperty();
        CategoryAttribute attribute = getItem();
        if ("dataType".equalsIgnoreCase(property) || "lookup".equalsIgnoreCase(property) || "defaultDateIsCurrent".equalsIgnoreCase(property) || "entityClass".equalsIgnoreCase(property)) {
            setupVisibility();
        }
        if ("name".equalsIgnoreCase(property)) {
            fillAttributeCode();
        }
        if ("screen".equalsIgnoreCase(property) || "joinClause".equals(property) || "whereClause".equals(property)) {
            dynamicAttributesGuiTools.initEntityPickerField(defaultEntityField, attribute);
        }
    });
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) StrBuilder(org.apache.commons.lang.text.StrBuilder) StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) WindowManager(com.haulmont.cuba.gui.WindowManager) Datasource(com.haulmont.cuba.gui.data.Datasource) DynamicAttributesGuiTools(com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools) Dom4j(com.haulmont.bali.util.Dom4j) ParamsMap(com.haulmont.bali.util.ParamsMap) Multimap(com.google.common.collect.Multimap) MetaClass(com.haulmont.chile.core.model.MetaClass) FakeFilterSupport(com.haulmont.cuba.gui.components.filter.FakeFilterSupport) com.haulmont.cuba.core.global(com.haulmont.cuba.core.global) AbstractDatasource(com.haulmont.cuba.gui.data.impl.AbstractDatasource) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) FilterEditor(com.haulmont.cuba.gui.components.filter.edit.FilterEditor) Lists(com.google.common.collect.Lists) FilterParser(com.haulmont.cuba.gui.components.filter.FilterParser) HasUuid(com.haulmont.cuba.core.entity.HasUuid) JpqlSuggestionFactory(com.haulmont.cuba.gui.components.autocomplete.JpqlSuggestionFactory) ComponentsFactory(com.haulmont.cuba.gui.xml.layout.ComponentsFactory) CategoryAttribute(com.haulmont.cuba.core.entity.CategoryAttribute) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) Splitter(com.google.common.base.Splitter) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) ScreensHelper(com.haulmont.cuba.gui.ScreensHelper) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) Sets(com.google.common.collect.Sets) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) String.format(java.lang.String.format) ConditionsTree(com.haulmont.cuba.gui.components.filter.ConditionsTree) Suggestion(com.haulmont.cuba.gui.components.autocomplete.Suggestion) ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) Param(com.haulmont.cuba.gui.components.filter.Param) SecurityJpqlGenerator(com.haulmont.cuba.core.global.filter.SecurityJpqlGenerator) Element(org.dom4j.Element) PropertyType(com.haulmont.cuba.core.app.dynamicattributes.PropertyType) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) Joiner(com.google.common.base.Joiner) Entity(com.haulmont.cuba.core.entity.Entity) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) Entity(com.haulmont.cuba.core.entity.Entity) PropertyType(com.haulmont.cuba.core.app.dynamicattributes.PropertyType) HasUuid(com.haulmont.cuba.core.entity.HasUuid) Datasource(com.haulmont.cuba.gui.data.Datasource) AbstractDatasource(com.haulmont.cuba.gui.data.impl.AbstractDatasource) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) AbstractDatasource(com.haulmont.cuba.gui.data.impl.AbstractDatasource) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) CategoryAttribute(com.haulmont.cuba.core.entity.CategoryAttribute) MetaClass(com.haulmont.chile.core.model.MetaClass) ParamsMap(com.haulmont.bali.util.ParamsMap)

Example 3 with BaseAction

use of com.haulmont.cuba.gui.components.actions.BaseAction in project cuba by cuba-platform.

the class DesktopWindow method close.

@Override
public boolean close(final String actionId) {
    if (!forceClose) {
        if (!delegate.preClose(actionId))
            return false;
    }
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    if (!forceClose && isModified()) {
        final Committable committable = (getWrapper() instanceof Committable) ? (Committable) getWrapper() : (this instanceof Committable) ? (Committable) this : null;
        if ((committable != null) && clientConfig.getUseSaveConfirmation()) {
            windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("saveUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.OK, Status.PRIMARY).withCaption(messages.getMainMessage("closeUnsaved.save")).withHandler(event -> {
                committable.commitAndClose();
            }), new BaseAction("discard").withIcon("icons/cancel.png").withCaption(messages.getMainMessage("closeUnsaved.discard")).withHandler(event -> {
                committable.close(actionId, true);
            }), new DialogAction(Type.CANCEL).withIcon(null).withHandler(event -> {
                doAfterClose = null;
            }) });
        } else {
            windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("closeUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.YES).withHandler(event -> {
                getWrapper().close(actionId, true);
            }), new DialogAction(Type.NO, Status.PRIMARY).withHandler(event -> {
                doAfterClose = null;
            }) });
        }
        return false;
    }
    if (!clientConfig.getManualScreenSettingsSaving()) {
        if (delegate.getWrapper() != null) {
            delegate.getWrapper().saveSettings();
        } else {
            saveSettings();
        }
    }
    delegate.disposeComponents();
    windowManager.close(this);
    boolean res = onClose(actionId);
    if (res && doAfterClose != null) {
        doAfterClose.run();
    }
    stopTimers();
    userActionsLog.trace("Window {} was closed", getId());
    return res;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) BoxLayoutAdapter(com.haulmont.cuba.desktop.sys.layout.BoxLayoutAdapter) Datasource(com.haulmont.cuba.gui.data.Datasource) LoggerFactory(org.slf4j.LoggerFactory) Settings(com.haulmont.cuba.gui.settings.Settings) AppBeans(com.haulmont.cuba.core.global.AppBeans) Icons(com.haulmont.cuba.gui.icons.Icons) BooleanUtils(org.apache.commons.lang.BooleanUtils) Pair(com.haulmont.bali.datastruct.Pair) com.haulmont.cuba.gui(com.haulmont.cuba.gui) Window(com.haulmont.cuba.gui.components.Window) Configuration(com.haulmont.cuba.core.global.Configuration) DesktopWindowManager(com.haulmont.cuba.desktop.sys.DesktopWindowManager) EventRouter(com.haulmont.bali.events.EventRouter) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) Preconditions.checkNotNullArgument(com.haulmont.bali.util.Preconditions.checkNotNullArgument) AncestorEvent(javax.swing.event.AncestorEvent) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) Frame(com.haulmont.cuba.gui.components.Frame) Status(com.haulmont.cuba.gui.components.Action.Status) DesktopConfig(com.haulmont.cuba.desktop.DesktopConfig) Messages(com.haulmont.cuba.core.global.Messages) ApplicationListener(org.springframework.context.ApplicationListener) DialogWindow(com.haulmont.cuba.desktop.sys.DialogWindow) List(java.util.List) ClientConfig(com.haulmont.cuba.client.ClientConfig) LayoutAdapter(com.haulmont.cuba.desktop.sys.layout.LayoutAdapter) JTabbedPaneExt(com.haulmont.cuba.desktop.sys.vcl.JTabbedPaneExt) Iterables(com.google.common.collect.Iterables) java.util(java.util) LookupSelectionChangeNotifier(com.haulmont.cuba.gui.components.LookupComponent.LookupSelectionChangeNotifier) Timer(com.haulmont.cuba.gui.components.Timer) ComponentSize(com.haulmont.cuba.desktop.gui.data.ComponentSize) CollectionUtils(org.apache.commons.collections4.CollectionUtils) AncestorListener(javax.swing.event.AncestorListener) DesktopContainerHelper(com.haulmont.cuba.desktop.gui.data.DesktopContainerHelper) CC(net.miginfocom.layout.CC) Component(com.haulmont.cuba.gui.components.Component) DsContext(com.haulmont.cuba.gui.data.DsContext) Nullable(javax.annotation.Nullable) App(com.haulmont.cuba.desktop.App) UserActionsLogger(com.haulmont.cuba.gui.logging.UserActionsLogger) Logger(org.slf4j.Logger) MigLayout(net.miginfocom.swing.MigLayout) Type(com.haulmont.cuba.gui.components.DialogAction.Type) JTextComponent(javax.swing.text.JTextComponent) Preconditions(com.haulmont.bali.util.Preconditions) java.awt(java.awt) UiEventsMulticaster(com.haulmont.cuba.gui.events.sys.UiEventsMulticaster) AbstractAction(com.haulmont.cuba.gui.components.AbstractAction) Element(org.dom4j.Element) MigLayoutHelper(com.haulmont.cuba.desktop.sys.layout.MigLayoutHelper) Action(com.haulmont.cuba.gui.components.Action) Entity(com.haulmont.cuba.core.entity.Entity) javax.swing(javax.swing) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 4 with BaseAction

use of com.haulmont.cuba.gui.components.actions.BaseAction in project cuba by cuba-platform.

the class WebWindowManager method checkModificationsAndCloseAll.

/**
 * Check modifications and close all screens in all main windows.
 *
 * @param runIfOk     a closure to run after all screens are closed
 * @param runIfCancel a closure to run if there were modifications and a user canceled the operation
 */
public void checkModificationsAndCloseAll(final Runnable runIfOk, @Nullable final Runnable runIfCancel) {
    boolean modified = false;
    for (Window window : getOpenWindows()) {
        if (!disableSavingScreenHistory) {
            screenHistorySupport.saveScreenHistory(window, windowOpenMode.get(window).getOpenMode());
        }
        if (window instanceof WrappedWindow && ((WrappedWindow) window).getWrapper() != null) {
            ((WrappedWindow) window).getWrapper().saveSettings();
        } else {
            window.saveSettings();
        }
        if (window.getDsContext() != null && window.getDsContext().isModified()) {
            modified = true;
        }
    }
    disableSavingScreenHistory = true;
    if (modified) {
        showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("discardChangesOnClose"), MessageType.WARNING, new Action[] { new BaseAction("closeApplication").withCaption(messages.getMainMessage("closeApplication")).withIcon(icons.get(CubaIcon.DIALOG_OK)).withHandler(event -> {
            closeAllWindows();
            runIfOk.run();
        }), new DialogAction(Type.CANCEL, Status.PRIMARY).withHandler(event -> {
            if (runIfCancel != null) {
                runIfCancel.run();
            }
        }) });
    } else {
        closeAllWindows();
        runIfOk.run();
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) StringUtils(org.apache.commons.lang.StringUtils) ScreenHistorySupport(com.haulmont.cuba.gui.ScreenHistorySupport) Datasource(com.haulmont.cuba.gui.data.Datasource) WindowMode(com.vaadin.shared.ui.window.WindowMode) MessageType(com.haulmont.cuba.gui.components.Frame.MessageType) LoggerFactory(org.slf4j.LoggerFactory) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) BeforeCloseWithShortcutEvent(com.haulmont.cuba.gui.components.Window.BeforeCloseWithShortcutEvent) Icons(com.haulmont.cuba.gui.icons.Icons) BooleanUtils(org.apache.commons.lang.BooleanUtils) Pair(com.haulmont.bali.datastruct.Pair) IconResolver(com.haulmont.cuba.web.gui.icons.IconResolver) AUTO_SIZE_PX(com.haulmont.cuba.gui.components.Component.AUTO_SIZE_PX) Window(com.haulmont.cuba.gui.components.Window) LayoutAnalyzer(com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer) UserIndicator(com.haulmont.cuba.gui.components.mainwindow.UserIndicator) Page(com.vaadin.server.Page) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ShortcutAction(com.vaadin.event.ShortcutAction) SilentException(com.haulmont.cuba.core.global.SilentException) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) BelongToFrame(com.haulmont.cuba.gui.components.Component.BelongToFrame) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) ClientType(com.haulmont.cuba.core.global.ClientType) Status(com.haulmont.cuba.gui.components.Action.Status) FoldersPane(com.haulmont.cuba.gui.components.mainwindow.FoldersPane) WindowBreadCrumbs(com.haulmont.cuba.web.sys.WindowBreadCrumbs) WebWrapperUtils(com.haulmont.cuba.web.gui.components.WebWrapperUtils) UuidSource(com.haulmont.cuba.core.global.UuidSource) ExceptionDialog(com.haulmont.cuba.web.exception.ExceptionDialog) ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) WebButton(com.haulmont.cuba.web.gui.components.WebButton) WebComponentsHelper.convertNotificationType(com.haulmont.cuba.web.gui.components.WebComponentsHelper.convertNotificationType) ClientConfig(com.haulmont.cuba.client.ClientConfig) ComponentsHelper(com.haulmont.cuba.gui.ComponentsHelper) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent) java.util(java.util) WindowManager(com.haulmont.cuba.gui.WindowManager) ContentMode(com.vaadin.shared.ui.label.ContentMode) ParamsMap(com.haulmont.bali.util.ParamsMap) CssLayout(com.vaadin.ui.CssLayout) LayoutTip(com.haulmont.cuba.gui.app.core.dev.LayoutTip) Scope(org.springframework.context.annotation.Scope) Inject(javax.inject.Inject) Lists(com.google.common.collect.Lists) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException) Label(com.vaadin.ui.Label) LayoutLoaderConfig(com.haulmont.cuba.gui.xml.layout.LayoutLoaderConfig) com.haulmont.cuba.web.toolkit.ui(com.haulmont.cuba.web.toolkit.ui) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Collections.singletonMap(java.util.Collections.singletonMap) Nullable(javax.annotation.Nullable) TopLevelWindowAttachListener(com.haulmont.cuba.gui.components.mainwindow.TopLevelWindowAttachListener) Logger(org.slf4j.Logger) AppWorkArea(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea) UserSettingService(com.haulmont.cuba.security.app.UserSettingService) Type(com.haulmont.cuba.gui.components.DialogAction.Type) ExceptionUtils(org.apache.commons.lang.exception.ExceptionUtils) NotificationType(com.haulmont.cuba.gui.components.Frame.NotificationType) BorderStyle(com.vaadin.shared.ui.BorderStyle) Preconditions(com.haulmont.bali.util.Preconditions) BeforeCloseWithCloseButtonEvent(com.haulmont.cuba.gui.components.Window.BeforeCloseWithCloseButtonEvent) Button(com.vaadin.ui.Button) WebComponentsHelper(com.haulmont.cuba.web.gui.components.WebComponentsHelper) Mode(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea.Mode) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindow(com.haulmont.cuba.web.gui.WebWindow) DialogParams(com.haulmont.cuba.gui.DialogParams) ShortcutListener(com.vaadin.event.ShortcutListener) Container(com.haulmont.cuba.gui.components.Component.Container) Unit(com.vaadin.server.Sizeable.Unit) Entity(com.haulmont.cuba.core.entity.Entity) com.vaadin.ui(com.vaadin.ui) Component(com.vaadin.ui.Component) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction)

Example 5 with BaseAction

use of com.haulmont.cuba.gui.components.actions.BaseAction in project cuba by cuba-platform.

the class CategoryBrowser method init.

@Override
public void init(Map<String, Object> params) {
    categoryTable.addAction(new CreateAction());
    categoryTable.addAction(new EditAction());
    categoryTable.addAction(new RemoveAction(categoryTable));
    categoryTable.addAction(new BaseAction("applyChanges").withCaption(getMessage("categoryTable.applyChanges")).withHandler(actionPerformedEvent -> {
        dynamicAttributesCacheService.loadCache();
        clientCacheManager.refreshCached(DynamicAttributesCacheStrategy.NAME);
        permissionConfig.clearConfigCache();
        showNotification(getMessage("notification.changesApplied"));
    }));
    categoryTable.removeGeneratedColumn("entityType");
    categoryTable.addGeneratedColumn("entityType", entity -> {
        Label dataTypeLabel = componentsFactory.createComponent(Label.class);
        MetaClass meta = metadata.getSession().getClassNN(entity.getEntityType());
        dataTypeLabel.setValue(messageTools.getEntityCaption(meta));
        return dataTypeLabel;
    });
}
Also used : DynamicAttributesCacheStrategy(com.haulmont.cuba.client.sys.cache.DynamicAttributesCacheStrategy) Category(com.haulmont.cuba.core.entity.Category) Set(java.util.Set) MetaClass(com.haulmont.chile.core.model.MetaClass) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) Metadata(com.haulmont.cuba.core.global.Metadata) Inject(javax.inject.Inject) ComponentsFactory(com.haulmont.cuba.gui.xml.layout.ComponentsFactory) PermissionConfig(com.haulmont.cuba.gui.config.PermissionConfig) Map(java.util.Map) ClientCacheManager(com.haulmont.cuba.client.sys.cache.ClientCacheManager) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) DynamicAttributesCacheService(com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesCacheService) MessageTools(com.haulmont.cuba.core.global.MessageTools) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) MetaClass(com.haulmont.chile.core.model.MetaClass) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction)

Aggregations

BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)11 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)10 Inject (javax.inject.Inject)9 java.util (java.util)7 StringUtils (org.apache.commons.lang.StringUtils)7 ParamsMap (com.haulmont.bali.util.ParamsMap)6 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)6 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)5 MetaClass (com.haulmont.chile.core.model.MetaClass)4 ClientConfig (com.haulmont.cuba.client.ClientConfig)4 Metadata (com.haulmont.cuba.core.global.Metadata)4 Window (com.haulmont.cuba.gui.components.Window)4 Map (java.util.Map)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 EventRouter (com.haulmont.bali.events.EventRouter)3 Preconditions (com.haulmont.bali.util.Preconditions)3 Entity (com.haulmont.cuba.core.entity.Entity)3 JmxInstance (com.haulmont.cuba.core.entity.JmxInstance)3 WindowManager (com.haulmont.cuba.gui.WindowManager)3