Search in sources :

Example 31 with Action

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

the class WebFrameActionsHolder method actionPropertyChanged.

protected void actionPropertyChanged(PropertyChangeEvent propertyChangeEvent) {
    if (Action.PROP_SHORTCUT.equals(propertyChangeEvent.getPropertyName())) {
        Action action = (Action) propertyChangeEvent.getSource();
        actions.inverse().remove(action);
        if (action.getShortcutCombination() != null) {
            actions.put(createShortcutAction(action), action);
        }
    }
}
Also used : Action(com.haulmont.cuba.gui.components.Action)

Example 32 with Action

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

the class WebPickerField method setDebugId.

@Override
public void setDebugId(String id) {
    super.setDebugId(id);
    if (id != null) {
        String debugId = getDebugId();
        TestIdManager testIdManager = AppUI.getCurrent().getTestIdManager();
        for (Action action : actions) {
            CubaButton button = actionButtons.get(action);
            if (button != null && Strings.isNullOrEmpty(button.getId())) {
                button.setId(testIdManager.getTestId(debugId + "_" + action.getId()));
            }
        }
    }
}
Also used : TestIdManager(com.haulmont.cuba.gui.sys.TestIdManager) ShortcutAction(com.vaadin.event.ShortcutAction) Action(com.haulmont.cuba.gui.components.Action) CubaButton(com.haulmont.cuba.web.widgets.CubaButton)

Example 33 with Action

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

the class WebPickerField method actionPropertyChanged.

protected void actionPropertyChanged(PropertyChangeEvent evt) {
    Action action = (Action) evt.getSource();
    CubaButton button = actionButtons.get(action);
    if (Action.PROP_ICON.equals(evt.getPropertyName())) {
        setPickerButtonIcon(button, action.getIcon());
    } else if (Action.PROP_CAPTION.equals(evt.getPropertyName())) {
        button.setCaption(action.getCaption());
    } else if (Action.PROP_DESCRIPTION.equals(evt.getPropertyName())) {
        button.setDescription(action.getDescription());
    } else if (Action.PROP_ENABLED.equals(evt.getPropertyName())) {
        button.setEnabled(action.isEnabled());
    } else if (Action.PROP_VISIBLE.equals(evt.getPropertyName())) {
        button.setVisible(action.isVisible());
    } else if (action instanceof PickerFieldAction && PickerFieldAction.PROP_EDITABLE.equals(evt.getPropertyName())) {
        button.setVisible(((PickerFieldAction) action).isEditable());
    }
}
Also used : ShortcutAction(com.vaadin.event.ShortcutAction) Action(com.haulmont.cuba.gui.components.Action) CubaButton(com.haulmont.cuba.web.widgets.CubaButton)

Example 34 with Action

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

the class WebNotificationFacet method subscribeOnAction.

protected void subscribeOnAction(Frame owner) {
    Action action = WebComponentsHelper.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 : BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) Action(com.haulmont.cuba.gui.components.Action) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction)

Example 35 with Action

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

the class UserSwitchLinkHandlerProcessor method substituteUserAndOpenWindow.

protected void substituteUserAndOpenWindow(ExternalLinkContext linkContext, UUID userId) {
    App app = linkContext.getApp();
    UserSession userSession = app.getConnection().getSession();
    assert userSession != null;
    final User substitutedUser = loadUser(userId, userSession.getUser());
    if (substitutedUser != null) {
        app.getWindowManager().showOptionDialog(messages.getMainMessage("toSubstitutedUser.title"), getDialogMessage(substitutedUser), Frame.MessageType.CONFIRMATION_HTML, new Action[] { new ChangeSubstUserAction(substitutedUser) {

            @Override
            public void doAfterChangeUser() {
                super.doAfterChangeUser();
                screenHandler.handle(linkContext);
            }

            @Override
            public void doRevert() {
                super.doRevert();
                JavaScript js = Page.getCurrent().getJavaScript();
                js.execute("window.close();");
            }

            @Override
            public String getCaption() {
                return messages.getMainMessage("action.switch");
            }
        }, new DoNotChangeSubstUserAction() {

            @Override
            public void actionPerform(Component component) {
                super.actionPerform(component);
                JavaScript js = Page.getCurrent().getJavaScript();
                js.execute("window.close();");
            }

            @Override
            public String getCaption() {
                return messages.getMainMessage("action.cancel");
            }
        } });
    } else {
        User user = loadUser(userId);
        app.getWindowManager().showOptionDialog(messages.getMainMessage("warning.title"), getWarningMessage(user), Frame.MessageType.WARNING_HTML, new Action[] { new DialogAction(DialogAction.Type.OK).withHandler(event -> {
            JavaScript js = Page.getCurrent().getJavaScript();
            js.execute("window.close();");
        }) });
    }
}
Also used : App(com.haulmont.cuba.web.App) LoadContext(com.haulmont.cuba.core.global.LoadContext) Frame(com.haulmont.cuba.gui.components.Frame) JavaScript(com.vaadin.ui.JavaScript) Ordered(org.springframework.core.Ordered) Logger(org.slf4j.Logger) Resource(javax.annotation.Resource) DoNotChangeSubstUserAction(com.haulmont.cuba.web.actions.DoNotChangeSubstUserAction) App(com.haulmont.cuba.web.App) Messages(com.haulmont.cuba.core.global.Messages) UUID(java.util.UUID) User(com.haulmont.cuba.security.entity.User) StringUtils(org.apache.commons.lang3.StringUtils) UserSession(com.haulmont.cuba.security.global.UserSession) Inject(javax.inject.Inject) List(java.util.List) Page(com.vaadin.server.Page) TimeSource(com.haulmont.cuba.core.global.TimeSource) DialogAction(com.haulmont.cuba.gui.components.DialogAction) UserSubstitution(com.haulmont.cuba.security.entity.UserSubstitution) ChangeSubstUserAction(com.haulmont.cuba.web.actions.ChangeSubstUserAction) Component(com.haulmont.cuba.gui.components.Component) DataService(com.haulmont.cuba.core.app.DataService) Action(com.haulmont.cuba.gui.components.Action) DoNotChangeSubstUserAction(com.haulmont.cuba.web.actions.DoNotChangeSubstUserAction) ChangeSubstUserAction(com.haulmont.cuba.web.actions.ChangeSubstUserAction) User(com.haulmont.cuba.security.entity.User) DialogAction(com.haulmont.cuba.gui.components.DialogAction) UserSession(com.haulmont.cuba.security.global.UserSession) JavaScript(com.vaadin.ui.JavaScript) DoNotChangeSubstUserAction(com.haulmont.cuba.web.actions.DoNotChangeSubstUserAction) Component(com.haulmont.cuba.gui.components.Component)

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