Search in sources :

Example 1 with CubaButton

use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.

the class WebDialogs method createButton.

public CubaButton createButton(Action action) {
    CubaButton button = new CubaButton();
    if (action instanceof DialogAction) {
        DialogAction.Type type = ((DialogAction) action).getType();
        button.setCaption(messages.getMainMessage(type.getMsgKey()));
        String iconPath = icons.get(type.getIconKey());
        button.setIcon(iconResolver.getIconResource(iconPath));
    }
    button.setEnabled(action.isEnabled());
    if (StringUtils.isNotEmpty(action.getCaption())) {
        button.setCaption(action.getCaption());
    }
    if (StringUtils.isNotEmpty(action.getDescription())) {
        button.setDescription(action.getDescription());
    }
    if (StringUtils.isNotEmpty(action.getIcon())) {
        button.setIcon(iconResolver.getIconResource(action.getIcon()));
    }
    return button;
}
Also used : CubaButton(com.haulmont.cuba.web.widgets.CubaButton) InputDialogAction(com.haulmont.cuba.gui.components.inputdialog.InputDialogAction)

Example 2 with CubaButton

use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.

the class WebPopupButton method createActionButton.

protected CubaButton createActionButton(Action action) {
    CubaButton button = new CubaButton();
    button.setWidth(100, Sizeable.Unit.PERCENTAGE);
    button.setPrimaryStyleName(CONTEXT_MENU_BUTTON_STYLENAME);
    setPopupButtonAction(button, action);
    AppUI ui = AppUI.getCurrent();
    if (ui != null) {
        if (ui.isTestMode()) {
            button.setCubaId(action.getId());
        }
        if (ui.isPerformanceTestMode()) {
            String debugId = getDebugId();
            if (debugId != null) {
                TestIdManager testIdManager = ui.getTestIdManager();
                button.setId(testIdManager.getTestId(debugId + "_" + action.getId()));
            }
        }
    }
    return button;
}
Also used : TestIdManager(com.haulmont.cuba.gui.sys.TestIdManager) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) AppUI(com.haulmont.cuba.web.AppUI)

Example 3 with CubaButton

use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.

the class WebPickerField method removeAction.

@Override
public void removeAction(@Nullable Action action) {
    if (actions.remove(action)) {
        actionHandler.removeAction(action);
        if (action != null) {
            CubaButton button = actionButtons.remove(action);
            component.removeButton(button);
            action.removePropertyChangeListener(actionPropertyChangeListener);
        }
        if (action instanceof PickerFieldAction) {
            ((PickerFieldAction) action).setPickerField(null);
        }
    }
}
Also used : CubaButton(com.haulmont.cuba.web.widgets.CubaButton)

Example 4 with CubaButton

use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.

the class TablePresentations method createActionButton.

protected CubaButton createActionButton(Action action) {
    CubaButton actionBtn = new CubaButton();
    actionBtn.setWidth("100%");
    actionBtn.setPrimaryStyleName(CONTEXT_MENU_BUTTON_STYLENAME);
    setPopupButtonAction(actionBtn, action);
    AppUI ui = AppUI.getCurrent();
    if (ui != null) {
        if (ui.isTestMode()) {
            actionBtn.setCubaId(action.getId());
        }
        if (ui.isPerformanceTestMode()) {
            String debugId = getDebugId();
            if (debugId != null) {
                TestIdManager testIdManager = ui.getTestIdManager();
                actionBtn.setId(testIdManager.getTestId(debugId + "_" + action.getId()));
            }
        }
    }
    return actionBtn;
}
Also used : TestIdManager(com.haulmont.cuba.gui.sys.TestIdManager) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) StringUtils.defaultString(org.apache.commons.lang3.StringUtils.defaultString) AppUI(com.haulmont.cuba.web.AppUI)

Example 5 with CubaButton

use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.

the class WebAbstractActionsHolderComponent method addAction.

@Override
public void addAction(Action action, int index) {
    checkNotNullArgument(action, "action must be non null");
    int oldIndex = findActionById(actionList, action.getId());
    if (oldIndex >= 0) {
        removeAction(actionList.get(oldIndex));
        if (index > oldIndex) {
            index--;
        }
    }
    if (StringUtils.isNotEmpty(action.getCaption())) {
        CubaButton contextMenuButton = createContextMenuButton();
        initContextMenuButton(contextMenuButton, action);
        int visibleActionsIndex = 0;
        int i = 0;
        while (i < index && i < actionList.size()) {
            Action componentAction = actionList.get(i);
            if (StringUtils.isNotEmpty(componentAction.getCaption()) && actionButtons.containsKey(componentAction)) {
                visibleActionsIndex++;
            }
            i++;
        }
        contextMenuPopup.addComponent(contextMenuButton, visibleActionsIndex);
        actionButtons.put(action, contextMenuButton);
    }
    actionList.add(index, action);
    shortcutsDelegate.addAction(null, action);
    attachAction(action);
    actionsPermissions.apply(action);
}
Also used : Action(com.haulmont.cuba.gui.components.Action) CubaButton(com.haulmont.cuba.web.widgets.CubaButton)

Aggregations

CubaButton (com.haulmont.cuba.web.widgets.CubaButton)16 Messages (com.haulmont.cuba.core.global.Messages)5 Action (com.haulmont.cuba.gui.components.Action)4 TestIdManager (com.haulmont.cuba.gui.sys.TestIdManager)4 ClientConfig (com.haulmont.cuba.client.ClientConfig)3 Configuration (com.haulmont.cuba.core.global.Configuration)2 Icons (com.haulmont.cuba.gui.icons.Icons)2 AppUI (com.haulmont.cuba.web.AppUI)2 Connection (com.haulmont.cuba.web.Connection)2 CubaLabel (com.haulmont.cuba.web.widgets.CubaLabel)2 CubaWindow (com.haulmont.cuba.web.widgets.CubaWindow)2 ShortcutAction (com.vaadin.event.ShortcutAction)2 CssLayout (com.vaadin.ui.CssLayout)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 Window (com.vaadin.ui.Window)2 Locale (java.util.Locale)2 KeyCombination (com.haulmont.cuba.gui.components.KeyCombination)1 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)1 InputDialogAction (com.haulmont.cuba.gui.components.inputdialog.InputDialogAction)1 ShowInfoAction (com.haulmont.cuba.gui.components.sys.ShowInfoAction)1