Search in sources :

Example 26 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class FilterDelegateImpl method initShortcutActions.

protected void initShortcutActions() {
    String filterApplyShortcut = properties.getFilterApplyShortcut();
    String filterSelectShortcut = properties.getFilterSelectShortcut();
    if (filter.getApplyTo() instanceof ListComponent) {
        ListComponent listComponent = (ListComponent) filter.getApplyTo();
        if (listComponent.getAction(Filter.APPLY_ACTION_ID) == null) {
            Action applyFilterAction = new BaseAction(Filter.APPLY_ACTION_ID).withShortcut(filterApplyShortcut).withHandler(event -> {
                if (event.getSource().isVisible()) {
                    applyFilter();
                }
            });
            listComponent.addAction(applyFilterAction);
        }
        if (listComponent.getAction(Filter.SELECT_ACTION_ID) == null) {
            Action selectFilterAction = new BaseAction(Filter.SELECT_ACTION_ID).withShortcut(filterSelectShortcut).withHandler(event -> {
                if (event.getSource().isVisible()) {
                    openFilterSelectMenu();
                }
            });
            listComponent.addAction(selectFilterAction);
        }
    }
    groupBoxLayout.addShortcutAction(new ShortcutAction(filterApplyShortcut, shortcutTriggeredEvent -> applyFilter()));
    groupBoxLayout.addShortcutAction(new ShortcutAction(filterSelectShortcut, shortcutTriggeredEvent -> openFilterSelectMenu()));
}
Also used : Node(io.jmix.core.common.datastruct.Node) CssLayout(io.jmix.ui.component.CssLayout) SettingsImpl(com.haulmont.cuba.settings.SettingsImpl) Autowired(org.springframework.beans.factory.annotation.Autowired) CubaProperties(com.haulmont.cuba.CubaProperties) AppBeans(com.haulmont.cuba.core.global.AppBeans) StringUtils(org.apache.commons.lang3.StringUtils) Icons(io.jmix.ui.icon.Icons) Matcher(java.util.regex.Matcher) ScreenBuilders(io.jmix.ui.ScreenBuilders) DynamicAttributesCondition(com.haulmont.cuba.gui.components.filter.condition.DynamicAttributesCondition) BoxLayout(io.jmix.ui.component.BoxLayout) Action(io.jmix.ui.action.Action) HasPresentations(com.haulmont.cuba.gui.components.HasPresentations) HBoxLayout(io.jmix.ui.component.HBoxLayout) Filter(com.haulmont.cuba.gui.components.Filter) DenyingClause(com.haulmont.cuba.core.global.filter.DenyingClause) TablePresentations(io.jmix.ui.presentation.TablePresentations) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) Subscription(io.jmix.core.common.event.Subscription) Pair(io.jmix.core.common.datastruct.Pair) Table(io.jmix.ui.component.Table) FtsCondition(com.haulmont.cuba.gui.components.filter.condition.FtsCondition) ThemeConstantsManager(io.jmix.ui.theme.ThemeConstantsManager) HierarchicalDatasource(com.haulmont.cuba.gui.data.HierarchicalDatasource) Field(io.jmix.ui.component.Field) UiComponents(com.haulmont.cuba.gui.UiComponents) Attribute(org.dom4j.Attribute) io.jmix.ui.component(io.jmix.ui.component) java.util(java.util) WindowManager(com.haulmont.cuba.gui.WindowManager) LoaderSupportsApplyToSelected(com.haulmont.cuba.gui.model.LoaderSupportsApplyToSelected) GridLayout(com.haulmont.cuba.gui.components.GridLayout) FrameOwner(io.jmix.ui.screen.FrameOwner) DynAttrMetadata(io.jmix.dynattr.DynAttrMetadata) BooleanUtils(org.apache.commons.lang3.BooleanUtils) GroupBoxLayout(io.jmix.ui.component.GroupBoxLayout) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Scope(org.springframework.context.annotation.Scope) UserSession(com.haulmont.cuba.security.global.UserSession) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) BaseAction(io.jmix.ui.action.BaseAction) ButtonsPanel(io.jmix.ui.component.ButtonsPanel) QueryFilter(com.haulmont.cuba.core.global.filter.QueryFilter) Window(io.jmix.ui.component.Window) Nullable(javax.annotation.Nullable) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) PersistenceManagerClient(com.haulmont.cuba.client.sys.PersistenceManagerClient) CollectionContainer(io.jmix.ui.model.CollectionContainer) JpqlCondition(io.jmix.core.querycondition.JpqlCondition) UserSessionSource(com.haulmont.cuba.core.global.UserSessionSource) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) JmixIcon(io.jmix.ui.icon.JmixIcon) UiControllerUtils(io.jmix.ui.screen.UiControllerUtils) ScreenSettingsFacet(io.jmix.ui.settings.facet.ScreenSettingsFacet) WindowInfo(io.jmix.ui.WindowInfo) DatasourceDataUnit(com.haulmont.cuba.gui.components.data.meta.DatasourceDataUnit) AbstractAction(io.jmix.ui.action.AbstractAction) LookupField(com.haulmont.cuba.gui.components.LookupField) ListComponent(com.haulmont.cuba.gui.components.ListComponent) MetaClass(io.jmix.core.metamodel.model.MetaClass) FilterSelectWindow(com.haulmont.cuba.gui.components.filter.filterselect.FilterSelectWindow) Security(com.haulmont.cuba.core.global.Security) ParameterInfo(com.haulmont.cuba.core.global.filter.ParameterInfo) LoggerFactory(org.slf4j.LoggerFactory) ParamsMap(io.jmix.core.common.util.ParamsMap) QueryFilters(com.haulmont.cuba.core.global.filter.QueryFilters) WindowConfig(io.jmix.ui.WindowConfig) Configuration(com.haulmont.cuba.core.global.Configuration) Type(io.jmix.ui.action.DialogAction.Type) VBoxLayout(io.jmix.ui.component.VBoxLayout) Dom4jTools(io.jmix.core.common.xmlparsing.Dom4jTools) PopupButton(io.jmix.ui.component.PopupButton) PersistenceHelper(com.haulmont.cuba.core.global.PersistenceHelper) Splitter(com.google.common.base.Splitter) LogicalCondition(com.haulmont.cuba.core.global.filter.LogicalCondition) Dialogs(io.jmix.ui.Dialogs) Messages(com.haulmont.cuba.core.global.Messages) AbstractCondition(com.haulmont.cuba.gui.components.filter.condition.AbstractCondition) Collectors(java.util.stream.Collectors) WindowParams(com.haulmont.cuba.gui.WindowParams) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) PropertyCondition(com.haulmont.cuba.gui.components.filter.condition.PropertyCondition) PostConstruct(javax.annotation.PostConstruct) CubaFilterSettings(com.haulmont.cuba.settings.component.CubaFilterSettings) Pattern(java.util.regex.Pattern) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) ParametersHelper(com.haulmont.cuba.core.global.filter.ParametersHelper) BaseCollectionLoader(io.jmix.ui.model.BaseCollectionLoader) CommitContext(com.haulmont.cuba.core.global.CommitContext) io.jmix.core(io.jmix.core) Alignment(io.jmix.ui.component.Component.Alignment) Frame(io.jmix.ui.component.Frame) QueryTransformerFactory(io.jmix.data.QueryTransformerFactory) AppFolder(com.haulmont.cuba.core.entity.AppFolder) Metadata(com.haulmont.cuba.core.global.Metadata) Notifications(io.jmix.ui.Notifications) Component(io.jmix.ui.component.Component) FilterEditor(com.haulmont.cuba.gui.components.filter.edit.FilterEditor) StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) Condition(com.haulmont.cuba.core.global.filter.Condition) Clause(com.haulmont.cuba.core.global.filter.Clause) ValuePathHelper(io.jmix.ui.sys.ValuePathHelper) DialogAction(io.jmix.ui.action.DialogAction) TextField(io.jmix.ui.component.TextField) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) Logger(org.slf4j.Logger) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) ThemeConstants(io.jmix.ui.theme.ThemeConstants) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) CheckBox(io.jmix.ui.component.CheckBox) ApplicationContext(org.springframework.context.ApplicationContext) QueryParser(io.jmix.data.QueryParser) Consumer(java.util.function.Consumer) Label(io.jmix.ui.component.Label) CustomCondition(com.haulmont.cuba.gui.components.filter.condition.CustomCondition) Element(org.dom4j.Element) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) AbstractAction(io.jmix.ui.action.AbstractAction) StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) DialogAction(io.jmix.ui.action.DialogAction) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) ListComponent(com.haulmont.cuba.gui.components.ListComponent) BaseAction(io.jmix.ui.action.BaseAction)

Example 27 with BaseAction

use of io.jmix.ui.action.BaseAction 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)

Example 28 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class ListEditorDelegateImpl method addClearBtn.

protected void addClearBtn() {
    clearBtn = uiComponents.create(Button.class);
    clearBtn.setIconFromSet(JmixIcon.VALUEPICKER_CLEAR);
    clearBtn.setStyleName("jmix-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) LoggerFactory(org.slf4j.LoggerFactory) Options(io.jmix.ui.component.data.Options) Autowired(org.springframework.beans.factory.annotation.Autowired) DatatypeRegistry(com.haulmont.chile.core.datatypes.DatatypeRegistry) EventHub(io.jmix.core.common.event.EventHub) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Scope(org.springframework.context.annotation.Scope) Field(com.haulmont.cuba.gui.components.Field) Strings(com.google.common.base.Strings) BigDecimal(java.math.BigDecimal) BaseAction(io.jmix.ui.action.BaseAction) TextField(com.haulmont.cuba.gui.components.TextField) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) HBoxLayout(io.jmix.ui.component.HBoxLayout) ParseException(java.text.ParseException) Splitter(com.google.common.base.Splitter) Window(io.jmix.ui.component.Window) Logger(org.slf4j.Logger) Subscription(io.jmix.core.common.event.Subscription) ListEditor(com.haulmont.cuba.gui.components.ListEditor) Collectors(java.util.stream.Collectors) JmixIcon(io.jmix.ui.icon.JmixIcon) Consumer(java.util.function.Consumer) Component(org.springframework.stereotype.Component) io.jmix.ui.screen(io.jmix.ui.screen) PostConstruct(javax.annotation.PostConstruct) Button(io.jmix.ui.component.Button) UiComponents(com.haulmont.cuba.gui.UiComponents) Joiner(com.google.common.base.Joiner) ComponentsHelper(io.jmix.ui.component.ComponentsHelper) Button(io.jmix.ui.component.Button) BaseAction(io.jmix.ui.action.BaseAction)

Example 29 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class ComponentLoaderHelper method loadInvokeAction.

public static Optional<Action> loadInvokeAction(ComponentLoader.Context context, ActionsHolder actionsHolder, Element element, String id, String caption, String description, String iconPath, @Nullable String shortcut) {
    String invokeMethod = element.attributeValue("invoke");
    if (StringUtils.isEmpty(invokeMethod) || !isLegacyFrame(context)) {
        return Optional.empty();
    }
    String trackSelection = element.attributeValue("trackSelection");
    boolean shouldTrackSelection = Boolean.parseBoolean(trackSelection);
    BaseAction action;
    if (shouldTrackSelection) {
        action = new DeclarativeTrackingAction(id, caption, description, iconPath, element.attributeValue("enable"), element.attributeValue("visible"), invokeMethod, shortcut, actionsHolder);
        loadActionConstraint(action, element);
        return Optional.of(action);
    } else {
        action = new DeclarativeAction(id, caption, description, iconPath, element.attributeValue("enable"), element.attributeValue("visible"), invokeMethod, shortcut, actionsHolder);
    }
    action.setPrimary(Boolean.parseBoolean(element.attributeValue("primary")));
    return Optional.of(action);
}
Also used : DeclarativeTrackingAction(com.haulmont.cuba.gui.xml.DeclarativeTrackingAction) BaseAction(io.jmix.ui.action.BaseAction) DeclarativeAction(com.haulmont.cuba.gui.xml.DeclarativeAction)

Example 30 with BaseAction

use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.

the class ScheduledTaskBrowser method init.

@Override
public void init(Map<String, Object> params) {
    tasksTable.addAction(CreateAction.create(tasksTable));
    tasksTable.addAction(EditAction.create(tasksTable));
    tasksTable.addAction(RemoveAction.create(tasksTable));
    Action editAction = tasksTable.getActionNN(EditAction.ACTION_ID);
    editAction.setEnabled(false);
    Action removeAction = tasksTable.getActionNN(RemoveAction.ACTION_ID);
    removeAction.setEnabled(false);
    activateBtn.setAction(new BaseAction("activate").withCaption(messages.getMainMessage("activate")).withHandler(e -> {
        Set<ScheduledTask> tasks = tasksTable.getSelected();
        service.setActive(tasks, !BooleanUtils.isTrue(tasks.iterator().next().getActive()));
        tasksDs.refresh();
    }));
    activateBtn.setEnabled(false);
    ShowExecutionsAction showExecutionsAction = new ShowExecutionsAction();
    tasksTable.addAction(showExecutionsAction);
    ExecuteOnceAction executeOnceAction = new ExecuteOnceAction();
    tasksTable.addAction(executeOnceAction);
    tasksDs.addItemChangeListener(e -> {
        ScheduledTask singleSelected = tasksTable.getSingleSelected();
        Set<ScheduledTask> selected = tasksTable.getSelected().stream().filter(Objects::nonNull).collect(Collectors.toSet());
        boolean isSingleSelected = selected.size() == 1;
        boolean enableEdit = singleSelected != null && !BooleanUtils.isTrue(singleSelected.getActive());
        editAction.setEnabled(enableEdit);
        removeAction.setEnabled(checkAllTasksAreNotActive(selected));
        activateBtn.setEnabled(checkAllTasksHaveSameStatus(selected));
        if (singleSelected == null) {
            activateBtn.setCaption(messages.getMainMessage("activate"));
        } else {
            activateBtn.setCaption(BooleanUtils.isTrue(singleSelected.getActive()) ? messages.getMainMessage("deactivate") : messages.getMainMessage("activate"));
        }
        showExecutionsAction.setEnabled(isSingleSelected);
        executeOnceAction.setEnabled(isSingleSelected && enableEdit);
    });
}
Also used : ItemTrackingAction(io.jmix.ui.action.ItemTrackingAction) java.util(java.util) ScheduledTask(com.haulmont.cuba.core.entity.ScheduledTask) Subscribe(io.jmix.ui.screen.Subscribe) Logger(org.slf4j.Logger) Table(com.haulmont.cuba.gui.components.Table) LoggerFactory(org.slf4j.LoggerFactory) BooleanUtils(org.apache.commons.lang3.BooleanUtils) EditAction(com.haulmont.cuba.gui.components.actions.EditAction) Collectors(java.util.stream.Collectors) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) CreateAction(com.haulmont.cuba.gui.components.actions.CreateAction) Inject(javax.inject.Inject) Component(io.jmix.ui.component.Component) AbstractWindow(com.haulmont.cuba.gui.components.AbstractWindow) Screens(com.haulmont.cuba.gui.Screens) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) RunTaskOnceException(com.haulmont.cuba.core.global.RunTaskOnceException) Button(io.jmix.ui.component.Button) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) SchedulingService(com.haulmont.cuba.core.app.SchedulingService) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) ItemTrackingAction(io.jmix.ui.action.ItemTrackingAction) EditAction(com.haulmont.cuba.gui.components.actions.EditAction) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) CreateAction(com.haulmont.cuba.gui.components.actions.CreateAction) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) BaseAction(io.jmix.ui.action.BaseAction) ScheduledTask(com.haulmont.cuba.core.entity.ScheduledTask)

Aggregations

BaseAction (io.jmix.ui.action.BaseAction)49 Action (io.jmix.ui.action.Action)30 Autowired (org.springframework.beans.factory.annotation.Autowired)12 Icons (io.jmix.ui.icon.Icons)11 io.jmix.ui.screen (io.jmix.ui.screen)9 DialogAction (io.jmix.ui.action.DialogAction)8 Window (io.jmix.ui.component.Window)8 UiScreenProperties (io.jmix.ui.UiScreenProperties)7 io.jmix.ui.component (io.jmix.ui.component)7 JmixIcon (io.jmix.ui.icon.JmixIcon)7 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)6 Notifications (io.jmix.ui.Notifications)6 Component (io.jmix.ui.component.Component)6 Collection (java.util.Collection)6 Messages (io.jmix.core.Messages)5 UiComponents (io.jmix.ui.UiComponents)5 Nullable (javax.annotation.Nullable)5 Strings (com.google.common.base.Strings)4 Dialogs (io.jmix.ui.Dialogs)4 ItemTrackingAction (io.jmix.ui.action.ItemTrackingAction)4