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