Search in sources :

Example 16 with Action

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

the class EntityInspectorBrowser method addSelectionListener.

private void addSelectionListener() {
    entitiesTable.addSelectionListener(event -> {
        Table.SelectionEvent selectionEvent = (Table.SelectionEvent) event;
        boolean removeEnabled = true;
        boolean restoreEnabled = true;
        if (!selectionEvent.getSelected().isEmpty()) {
            for (Object o : selectionEvent.getSelected()) {
                if (o instanceof Entity) {
                    if (EntityValues.isSoftDeleted(o)) {
                        removeEnabled = false;
                    } else {
                        restoreEnabled = false;
                    }
                    if (!removeEnabled && !restoreEnabled) {
                        break;
                    }
                }
            }
        }
        Action removeAction = entitiesTable.getAction(RemoveAction.ID);
        if (removeAction != null) {
            removeAction.setEnabled(removeEnabled);
        }
        Action restoreAction = entitiesTable.getAction(RESTORE_ACTION_ID);
        if (restoreAction != null) {
            restoreAction.setEnabled(restoreEnabled);
        }
    });
}
Also used : ItemTrackingAction(io.jmix.ui.action.ItemTrackingAction) CreateAction(io.jmix.ui.action.list.CreateAction) EditAction(io.jmix.ui.action.list.EditAction) Action(io.jmix.ui.action.Action) DialogAction(io.jmix.ui.action.DialogAction) RefreshAction(io.jmix.ui.action.list.RefreshAction) ListAction(io.jmix.ui.action.ListAction) ShowEntityInfoAction(io.jmix.datatoolsui.action.ShowEntityInfoAction) ExcelExportAction(io.jmix.uiexport.action.ExcelExportAction) RemoveAction(io.jmix.ui.action.list.RemoveAction)

Example 17 with Action

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

the class InputDialog method initActions.

protected void initActions(List<Action> actions) {
    for (Action action : actions) {
        Button button = uiComponents.create(Button.NAME);
        button.setAction(action);
        if (action instanceof DialogAction) {
            DialogAction.Type type = ((DialogAction) action).getType();
            button.setCaption(messages.getMessage(type.getMsgKey()));
            String iconPath = icons.get(type.getIconKey());
            button.setIcon(iconPath);
        }
        actionsLayout.add(button);
    }
}
Also used : Action(io.jmix.ui.action.Action) DialogAction(io.jmix.ui.action.DialogAction) InputDialogAction(io.jmix.ui.component.inputdialog.InputDialogAction) DialogAction(io.jmix.ui.action.DialogAction) InputDialogAction(io.jmix.ui.component.inputdialog.InputDialogAction)

Example 18 with Action

use of io.jmix.ui.action.Action 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 19 with Action

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

the class StandardLookup method addDefaultCancelAction.

protected Action addDefaultCancelAction(Messages messages, Icons icons) {
    Action action = new BaseAction(LOOKUP_CANCEL_ACTION_ID).withCaption(messages.getMessage("actions.Cancel")).withIcon(icons.get(JmixIcon.LOOKUP_CANCEL));
    getWindow().addAction(action);
    return action;
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) BaseAction(io.jmix.ui.action.BaseAction)

Example 20 with Action

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

the class AbstractDataGrid 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(AbstractDataGrid.this);
                    }
                }
            });
            componentComposition.addShortcutListener(shortcut);
            return shortcut;
        }

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

        @Override
        protected Collection<Action> getActions() {
            return AbstractDataGrid.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)

Aggregations

Action (io.jmix.ui.action.Action)82 BaseAction (io.jmix.ui.action.BaseAction)47 DialogAction (io.jmix.ui.action.DialogAction)11 ItemTrackingAction (io.jmix.ui.action.ItemTrackingAction)11 Component (io.jmix.ui.component.Component)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)8 Icons (io.jmix.ui.icon.Icons)8 UiScreenProperties (io.jmix.ui.UiScreenProperties)7 io.jmix.ui.component (io.jmix.ui.component)7 io.jmix.ui.screen (io.jmix.ui.screen)7 Nullable (javax.annotation.Nullable)7 Dialogs (io.jmix.ui.Dialogs)6 Notifications (io.jmix.ui.Notifications)6 AbstractAction (io.jmix.ui.action.AbstractAction)6 Window (io.jmix.ui.component.Window)6 JmixButton (io.jmix.ui.widget.JmixButton)6 JmixIcon (io.jmix.ui.icon.JmixIcon)5 Named (javax.inject.Named)5 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)4