Search in sources :

Example 81 with Action

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

the class StandardLookup method addDefaultSelectAction.

protected Action addDefaultSelectAction(Messages messages, Icons icons) {
    String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
    Action action = new BaseAction(LOOKUP_SELECT_ACTION_ID).withCaption(messages.getMessage("actions.Select")).withIcon(icons.get(JmixIcon.LOOKUP_OK)).withPrimary(true).withShortcut(commitShortcut);
    getWindow().addAction(action);
    return action;
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) UiScreenProperties(io.jmix.ui.UiScreenProperties) BaseAction(io.jmix.ui.action.BaseAction)

Example 82 with Action

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

the class StandardLookup method setSelectHandler.

@Override
public void setSelectHandler(@Nullable Consumer<Collection<T>> selectHandler) {
    this.selectHandler = selectHandler;
    Component lookupActionsLayout = getLookupActionsLayout();
    if (lookupActionsLayout != null) {
        lookupActionsLayout.setVisible(true);
        Component lookupComponent = getLookupComponent();
        if (lookupComponent instanceof LookupSelectionChangeNotifier) {
            LookupSelectionChangeNotifier selectionNotifier = (LookupSelectionChangeNotifier) lookupComponent;
            Action commitAction = getWindow().getAction(LOOKUP_SELECT_ACTION_ID);
            if (commitAction != null) {
                // noinspection unchecked
                selectionNotifier.addLookupValueChangeListener(valueChangeEvent -> commitAction.setEnabled(!selectionNotifier.getLookupSelectedItems().isEmpty()));
                commitAction.setEnabled(!selectionNotifier.getLookupSelectedItems().isEmpty());
            }
        }
    }
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) LookupSelectionChangeNotifier(io.jmix.ui.component.LookupComponent.LookupSelectionChangeNotifier) LookupComponent(io.jmix.ui.component.LookupComponent)

Aggregations

Action (io.jmix.ui.action.Action)82 BaseAction (io.jmix.ui.action.BaseAction)47 DialogAction (io.jmix.ui.action.DialogAction)11 ItemTrackingAction (io.jmix.ui.action.ItemTrackingAction)11 Component (io.jmix.ui.component.Component)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)8 Icons (io.jmix.ui.icon.Icons)8 UiScreenProperties (io.jmix.ui.UiScreenProperties)7 io.jmix.ui.component (io.jmix.ui.component)7 io.jmix.ui.screen (io.jmix.ui.screen)7 Nullable (javax.annotation.Nullable)7 Dialogs (io.jmix.ui.Dialogs)6 Notifications (io.jmix.ui.Notifications)6 AbstractAction (io.jmix.ui.action.AbstractAction)6 Window (io.jmix.ui.component.Window)6 JmixButton (io.jmix.ui.widget.JmixButton)6 JmixIcon (io.jmix.ui.icon.JmixIcon)5 Named (javax.inject.Named)5 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)4