Search in sources :

Example 26 with Action

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

the class MessageDialogFacetImpl method subscribeOnAction.

protected void subscribeOnAction(Frame owner) {
    Action action = ComponentsHelper.findAction(owner, actionId);
    if (!(action instanceof BaseAction)) {
        throw new GuiDevelopmentException(String.format("Unable to find Dialog target button with id '%s'", actionId), owner.getId());
    }
    ((BaseAction) action).addActionPerformedListener(e -> show());
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) BaseAction(io.jmix.ui.action.BaseAction)

Example 27 with Action

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

the class NotificationFacetImpl method subscribeOnAction.

protected void subscribeOnAction(Frame owner) {
    Action action = ComponentsHelper.findAction(owner, actionId);
    if (!(action instanceof BaseAction)) {
        throw new GuiDevelopmentException(String.format("Unable to find Notification target action with id '%s'", actionId), owner.getId());
    }
    ((BaseAction) action).addActionPerformedListener(e -> show());
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) BaseAction(io.jmix.ui.action.BaseAction)

Example 28 with Action

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

the class TreeImpl method createContextMenuItem.

protected AbstractDataGrid.ActionMenuItemWrapper createContextMenuItem(Action action) {
    MenuItem menuItem = contextMenu.addItem(action.getCaption(), null);
    menuItem.setStyleName("jmix-cm-item");
    return new AbstractDataGrid.ActionMenuItemWrapper(menuItem, showIconsForPopupMenuActions, iconResolver) {

        @Override
        public void performAction(Action action) {
            action.actionPerform(TreeImpl.this);
        }
    };
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) MenuItem(com.vaadin.ui.MenuBar.MenuItem)

Example 29 with Action

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

the class TreeImpl method createShortcutsDelegate.

protected ShortcutsDelegate<ShortcutListener> createShortcutsDelegate() {
    return new ShortcutsDelegate<ShortcutListener>() {

        @Override
        protected ShortcutListener attachShortcut(String actionId, KeyCombination keyCombination) {
            ShortcutListener shortcut = new ShortcutListenerDelegate(actionId, keyCombination.getKey().getCode(), KeyCombination.Modifier.codes(keyCombination.getModifiers())).withHandler((sender, target) -> {
                if (sender == componentComposition) {
                    Action action = getAction(actionId);
                    if (action != null && action.isEnabled() && action.isVisible()) {
                        action.actionPerform(TreeImpl.this);
                    }
                }
            });
            componentComposition.addShortcutListener(shortcut);
            return shortcut;
        }

        @Override
        protected void detachShortcut(Action action, ShortcutListener shortcutDescriptor) {
            componentComposition.removeShortcutListener(shortcutDescriptor);
        }

        @Override
        protected Collection<Action> getActions() {
            return TreeImpl.this.getActions();
        }
    };
}
Also used : ShortcutListener(com.vaadin.event.ShortcutListener) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) ShortcutListenerDelegate(io.jmix.ui.widget.ShortcutListenerDelegate) ShortcutsDelegate(io.jmix.ui.sys.ShortcutsDelegate)

Example 30 with Action

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

the class FilterLoader method loadActions.

@Override
protected void loadActions(ActionsHolder actionsHolder, Element element) {
    Element actionsEl = element.element("actions");
    if (actionsEl == null) {
        return;
    }
    actionsHolder.removeAllActions();
    for (Element actionEl : actionsEl.elements("action")) {
        Action action = loadDeclarativeAction(actionsHolder, actionEl);
        if (action instanceof FilterAction) {
            ((FilterAction) action).setFilter(resultComponent);
        }
        actionsHolder.addAction(action);
    }
    getComponentContext().addPostInitTask((context1, window) -> actionsHolder.getActions().forEach(Action::refreshState));
}
Also used : FilterAction(io.jmix.ui.action.filter.FilterAction) Action(io.jmix.ui.action.Action) Element(org.dom4j.Element) FilterAction(io.jmix.ui.action.filter.FilterAction)

Aggregations

Action (io.jmix.ui.action.Action)88 BaseAction (io.jmix.ui.action.BaseAction)52 DialogAction (io.jmix.ui.action.DialogAction)15 Autowired (org.springframework.beans.factory.annotation.Autowired)14 ItemTrackingAction (io.jmix.ui.action.ItemTrackingAction)13 io.jmix.ui.screen (io.jmix.ui.screen)12 Notifications (io.jmix.ui.Notifications)10 io.jmix.ui.component (io.jmix.ui.component)10 Component (io.jmix.ui.component.Component)10 Named (javax.inject.Named)10 Dialogs (io.jmix.ui.Dialogs)9 JmixIcon (io.jmix.ui.icon.JmixIcon)9 ParamsMap (io.jmix.core.common.util.ParamsMap)8 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)8 Icons (io.jmix.ui.icon.Icons)8 Nullable (javax.annotation.Nullable)8 Metadata (io.jmix.core.Metadata)7 ScreenBuilders (io.jmix.ui.ScreenBuilders)7 UiScreenProperties (io.jmix.ui.UiScreenProperties)7 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)6