Search in sources :

Example 21 with Action

use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.

the class DesktopAbstractTable method createPopupMenu.

protected JPopupMenu createPopupMenu() {
    JPopupMenu popup = new JPopupMenu();
    JMenuItem menuItem;
    for (final Action action : actionList) {
        if (StringUtils.isNotBlank(action.getCaption()) && action.isVisible()) {
            menuItem = new JMenuItem(action.getCaption());
            if (action.getIcon() != null) {
                menuItem.setIcon(AppBeans.get(IconResolver.class).getIconResource(action.getIcon()));
            }
            if (action.getShortcutCombination() != null) {
                menuItem.setAccelerator(convertKeyCombination(action.getShortcutCombination()));
            }
            menuItem.setEnabled(action.isEnabled());
            menuItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    action.actionPerform(DesktopAbstractTable.this);
                }
            });
            popup.add(menuItem);
        }
    }
    return popup;
}
Also used : AbstractAction(javax.swing.AbstractAction) ShowInfoAction(com.haulmont.cuba.gui.components.sys.ShowInfoAction) BoundAction(org.jdesktop.swingx.action.BoundAction) Action(com.haulmont.cuba.gui.components.Action)

Example 22 with Action

use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.

the class DesktopAbstractTable method handleClickAction.

protected void handleClickAction() {
    Action action = getItemClickAction();
    if (action == null) {
        action = getEnterAction();
        if (action == null) {
            action = getAction("edit");
            if (action == null) {
                action = getAction("view");
            }
        }
    }
    if (action != null && action.isEnabled() && action.isVisible()) {
        Window window = ComponentsHelper.getWindow(DesktopAbstractTable.this);
        if (window instanceof Window.Wrapper) {
            window = ((Window.Wrapper) window).getWrappedWindow();
        }
        if (!(window instanceof Window.Lookup)) {
            action.actionPerform(DesktopAbstractTable.this);
        } else {
            Window.Lookup lookup = (Window.Lookup) window;
            com.haulmont.cuba.gui.components.Component lookupComponent = lookup.getLookupComponent();
            if (lookupComponent != this) {
                action.actionPerform(DesktopAbstractTable.this);
            } else if (action.getId().equals(WindowDelegate.LOOKUP_ITEM_CLICK_ACTION_ID)) {
                action.actionPerform(DesktopAbstractTable.this);
            }
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) AbstractAction(javax.swing.AbstractAction) ShowInfoAction(com.haulmont.cuba.gui.components.sys.ShowInfoAction) BoundAction(org.jdesktop.swingx.action.BoundAction) Action(com.haulmont.cuba.gui.components.Action) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components)

Example 23 with Action

use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.

the class CopySettings method init.

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    copyBtn.addClickListener(e -> {
        if (usersDs.getItem() == null) {
            showNotification(getMessage("selectUser"), NotificationType.HUMANIZED);
        } else {
            showOptionDialog(getMessage("confirmCopy.title"), getMessage("confirmCopy.msg"), MessageType.CONFIRMATION, new Action[] { new DialogAction(Type.YES).withHandler(event -> copySettings()), new DialogAction(Type.NO, Action.Status.PRIMARY) });
        }
    });
    cancelBtn.addClickListener(e -> close("cancel"));
}
Also used : Inject(javax.inject.Inject) AbstractWindow(com.haulmont.cuba.gui.components.AbstractWindow) Datasource(com.haulmont.cuba.gui.data.Datasource) WindowParam(com.haulmont.cuba.gui.WindowParam) UserSettingService(com.haulmont.cuba.security.app.UserSettingService) Map(java.util.Map) Button(com.haulmont.cuba.gui.components.Button) Type(com.haulmont.cuba.gui.components.DialogAction.Type) Set(java.util.Set) DialogAction(com.haulmont.cuba.gui.components.DialogAction) User(com.haulmont.cuba.security.entity.User) Action(com.haulmont.cuba.gui.components.Action) DialogAction(com.haulmont.cuba.gui.components.DialogAction)

Example 24 with Action

use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.

the class SessionLogBrowser method enableLogging.

public void enableLogging() {
    if (globalConfig.getUserSessionLogEnabled()) {
        showOptionDialog(getMessage("dialogs.Confirmation"), getMessage("confirmDisable"), MessageType.CONFIRMATION, new Action[] { new DialogAction(DialogAction.Type.YES, true).withHandler(actionPerformedEvent -> {
            globalConfig.setUserSessionLogEnabled(false);
            enableBtn.setCaption(getMessage("enableLogging"));
        }), new DialogAction(DialogAction.Type.NO) });
    } else {
        globalConfig.setUserSessionLogEnabled(true);
        enableBtn.setCaption(getMessage("disableLogging"));
    }
}
Also used : Inject(javax.inject.Inject) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) AbstractLookup(com.haulmont.cuba.gui.components.AbstractLookup) Map(java.util.Map) Button(com.haulmont.cuba.gui.components.Button) DialogAction(com.haulmont.cuba.gui.components.DialogAction) Action(com.haulmont.cuba.gui.components.Action) DialogAction(com.haulmont.cuba.gui.components.DialogAction)

Example 25 with Action

use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.

the class DesktopTree method createPopupMenu.

protected JPopupMenu createPopupMenu() {
    JPopupMenu popup = new JPopupMenu();
    JMenuItem menuItem;
    for (final com.haulmont.cuba.gui.components.Action action : actionList) {
        if (StringUtils.isNotBlank(action.getCaption()) && action.isVisible()) {
            menuItem = new JMenuItem(action.getCaption());
            if (action.getIcon() != null) {
                menuItem.setIcon(AppBeans.get(IconResolver.class).getIconResource(action.getIcon()));
            }
            if (action.getShortcutCombination() != null) {
                menuItem.setAccelerator(DesktopComponentsHelper.convertKeyCombination(action.getShortcutCombination()));
            }
            menuItem.setEnabled(action.isEnabled());
            menuItem.addActionListener(e -> action.actionPerform(DesktopTree.this));
            popup.add(menuItem);
        }
    }
    return popup;
}
Also used : com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Action(com.haulmont.cuba.gui.components.Action)

Aggregations

Action (com.haulmont.cuba.gui.components.Action)35 ShowInfoAction (com.haulmont.cuba.gui.components.sys.ShowInfoAction)5 AbstractAction (javax.swing.AbstractAction)5 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)4 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)3 Component (com.haulmont.cuba.gui.components.Component)3 DialogAction (com.haulmont.cuba.gui.components.DialogAction)3 Window (com.haulmont.cuba.gui.components.Window)3 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)3 Datasource (com.haulmont.cuba.gui.data.Datasource)3 CubaButton (com.haulmont.cuba.web.widgets.CubaButton)3 Inject (javax.inject.Inject)3 MetaClass (com.haulmont.chile.core.model.MetaClass)2 ClientConfig (com.haulmont.cuba.client.ClientConfig)2 Messages (com.haulmont.cuba.core.global.Messages)2 ValidationAwareAction (com.haulmont.cuba.desktop.sys.validation.ValidationAwareAction)2 AbstractAction (com.haulmont.cuba.gui.components.AbstractAction)2 Button (com.haulmont.cuba.gui.components.Button)2 ListActionType (com.haulmont.cuba.gui.components.actions.ListActionType)2 CollectionDsActionsNotifier (com.haulmont.cuba.gui.data.impl.CollectionDsActionsNotifier)2