use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class SearchResultsScreen method renderNavigationControls.
protected void renderNavigationControls(Queue<Page> pages) {
navigationBox.removeAll();
boolean showNextPage = true;
Page lastPage = getLastPage();
if (lastPage != null) {
SearchResult lastSearchResult = lastPage.getSearchResult();
showNextPage = lastSearchResult.isMoreDataAvailable();
}
if (pages.size() > 1 || showNextPage) {
for (Page page : pages) {
LinkButton pageButton = uiComponents.create(LinkButton.class);
BaseAction action = new BaseAction("page_" + page.getPageNumber()).withCaption(page.getDisplayedPageNumber()).withHandler(e -> openPage(page));
pageButton.setAction(action);
if (page == currentPage) {
pageButton.setStyleName("jmix-fts-current-page");
} else {
pageButton.setStyleName("jmix-fts-page");
}
navigationBox.add(pageButton);
}
}
if (showNextPage) {
LinkButton nextPageButton = uiComponents.create(LinkButton.class);
BaseAction action = new BaseAction("nextPage").withCaption(messages.getMessage(SearchResultsScreen.class, "nextPage")).withHandler(e -> openNextPage());
nextPageButton.setAction(action);
nextPageButton.setStyleName("jmix-fts-page");
navigationBox.add(nextPageButton);
}
}
use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class RoleAssignmentScreen method initScreenActions.
protected void initScreenActions() {
Window window = getWindow();
Messages messages = getApplicationContext().getBean(Messages.class);
Icons icons = getApplicationContext().getBean(Icons.class);
String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
Action commitAndCloseAction = new BaseAction(Window.COMMIT_ACTION_ID).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
// noinspection ConstantConditions
getScreenData().getDataContext().commit();
close(new StandardCloseAction(Window.COMMIT_ACTION_ID));
});
window.addAction(commitAndCloseAction);
Action closeAction = new BaseAction(Window.CLOSE_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Cancel")).withHandler(actionPerformedEvent -> {
if (dataContext.hasChanges()) {
screenValidation.showUnsavedChangesDialog(this, WINDOW_CLOSE_ACTION).onDiscard(() -> close(WINDOW_CLOSE_ACTION));
} else {
close(WINDOW_CLOSE_ACTION);
}
});
window.addAction(closeAction);
}
use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class FilterImpl method createResetFilterAction.
protected Action createResetFilterAction() {
return new BaseAction("filter_reset").withCaption(messages.getMessage("actions.Filter.Reset")).withHandler(actionPerformedEvent -> {
Configuration configuration = getEmptyConfiguration();
configuration.getRootLogicalFilterComponent().removeAll();
configuration.setModified(false);
setCurrentConfiguration(configuration);
apply();
});
}
use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class StandardEditor method addDefaultCommitAndCloseAction.
protected Action addDefaultCommitAndCloseAction(Messages messages, Icons icons) {
String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
Action action = new BaseAction(WINDOW_COMMIT_AND_CLOSE).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut);
getWindow().addAction(action);
return action;
}
use of io.jmix.ui.action.BaseAction in project jmix by jmix-framework.
the class StandardEditor method initActions.
protected void initActions(@SuppressWarnings("unused") InitEvent event) {
Messages messages = getApplicationContext().getBean(Messages.class);
Icons icons = getApplicationContext().getBean(Icons.class);
BaseAction commitAndCloseAction = (BaseAction) getWindowActionOptional(WINDOW_COMMIT_AND_CLOSE).orElseGet(() -> addDefaultCommitAndCloseAction(messages, icons));
commitAndCloseAction.addActionPerformedListener(this::commitAndClose);
BaseAction commitAction = (BaseAction) getWindowActionOptional(WINDOW_COMMIT).orElseGet(() -> addDefaultCommitAction(messages, icons));
commitAction.addActionPerformedListener(this::commit);
BaseAction closeAction = (BaseAction) getWindowActionOptional(WINDOW_CLOSE).orElseGet(() -> addDefaultCloseAction(messages, icons));
closeAction.addActionPerformedListener(this::cancel);
BaseAction enableEditingAction = (BaseAction) getWindowActionOptional(ENABLE_EDITING).orElseGet(() -> addDefaultEnableEditingAction(messages, icons));
enableEditingAction.addActionPerformedListener(this::enableEditing);
}
Aggregations