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;
}
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());
}
}
}
}
Aggregations