Search in sources :

Example 11 with BaseAction

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);
    }
}
Also used : BaseAction(io.jmix.ui.action.BaseAction) SearchResult(io.jmix.search.searching.SearchResult)

Example 12 with BaseAction

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);
}
Also used : Window(io.jmix.ui.component.Window) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Messages(io.jmix.core.Messages) UiScreenProperties(io.jmix.ui.UiScreenProperties) Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

Example 13 with BaseAction

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();
    });
}
Also used : RunTimeConfiguration(io.jmix.ui.component.filter.configuration.RunTimeConfiguration) DesignTimeConfiguration(io.jmix.ui.component.filter.configuration.DesignTimeConfiguration) BaseAction(io.jmix.ui.action.BaseAction)

Example 14 with BaseAction

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;
}
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 15 with BaseAction

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);
}
Also used : Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

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