Search in sources :

Example 11 with CubaButton

use of com.haulmont.cuba.web.widgets.CubaButton 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 12 with CubaButton

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

the class WebPickerField method addAction.

@Override
public void addAction(Action action, int index) {
    checkNotNullArgument(action, "action must be non null");
    int oldIndex = findActionById(actions, action.getId());
    if (oldIndex >= 0) {
        removeAction(actions.get(oldIndex));
        if (index > oldIndex) {
            index--;
        }
    }
    actions.add(index, action);
    actionHandler.addAction(action, index);
    CubaButton vButton = new CubaButton();
    setPickerButtonAction(vButton, action);
    component.addButton(vButton, index);
    actionButtons.put(action, vButton);
    if (StringUtils.isNotEmpty(getDebugId())) {
        TestIdManager testIdManager = AppUI.getCurrent().getTestIdManager();
        // Set debug id
        vButton.setId(testIdManager.getTestId(getDebugId() + "_" + action.getId()));
    }
    if (action instanceof PickerFieldAction) {
        PickerFieldAction pickerFieldAction = (PickerFieldAction) action;
        pickerFieldAction.setPickerField(this);
        if (!isEditable()) {
            pickerFieldAction.editableChanged(this, isEditable());
        }
    }
    actionsPermissions.apply(action);
    refreshActionsState();
}
Also used : TestIdManager(com.haulmont.cuba.gui.sys.TestIdManager) CubaButton(com.haulmont.cuba.web.widgets.CubaButton)

Example 13 with CubaButton

use of com.haulmont.cuba.web.widgets.CubaButton 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 14 with CubaButton

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

the class LogWindow method initUI.

protected void initUI() {
    ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class);
    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);
    com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction("closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers()));
    addActionHandler(new com.vaadin.event.Action.Handler() {

        @Override
        public com.vaadin.event.Action[] getActions(Object target, Object sender) {
            return new com.vaadin.event.Action[] { closeShortcutAction };
        }

        @Override
        public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
            if (Objects.equals(action, closeShortcutAction)) {
                close();
            }
        }
    });
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(false);
    layout.setSizeFull();
    setContent(layout);
    Panel scrollablePanel = new Panel();
    scrollablePanel.setSizeFull();
    VerticalLayout scrollContent = new VerticalLayout();
    scrollContent.setMargin(false);
    scrollContent.setSpacing(false);
    scrollContent.setSizeUndefined();
    scrollablePanel.setContent(scrollContent);
    final Label label = new Label();
    label.setContentMode(ContentMode.HTML);
    label.setValue(writeLog());
    label.setSizeUndefined();
    label.setStyleName("c-log-content");
    ((Layout) scrollablePanel.getContent()).addComponent(label);
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setMargin(false);
    topLayout.setSpacing(false);
    topLayout.setWidth("100%");
    topLayout.setHeightUndefined();
    Messages messages = AppBeans.get(Messages.NAME);
    Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), event -> label.setValue(writeLog()));
    topLayout.addComponent(refreshBtn);
    layout.addComponent(topLayout);
    layout.addComponent(scrollablePanel);
    layout.setExpandRatio(scrollablePanel, 1.0f);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 15 with CubaButton

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

the class PresentationEditor method initLayout.

protected void initLayout() {
    ThemeConstants theme = App.getInstance().getThemeConstants();
    VerticalLayout root = new VerticalLayout();
    root.setWidthUndefined();
    root.setSpacing(true);
    root.setMargin(false);
    setContent(root);
    messages = AppBeans.get(Messages.class);
    nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
    nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
    nameField.setValue(getPresentationCaption());
    root.addComponent(nameField);
    autoSaveField = new CheckBox();
    autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
    autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
    root.addComponent(autoSaveField);
    defaultField = new CheckBox();
    defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
    defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
    root.addComponent(defaultField);
    if (allowGlobalPresentations) {
        globalField = new CheckBox();
        globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
        globalField.setValue(!isNew && presentation.getUser() == null);
        root.addComponent(globalField);
    }
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setMargin(false);
    buttons.setSpacing(true);
    buttons.setWidthUndefined();
    root.addComponent(buttons);
    root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);
    Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
    commitButton.addClickListener(event -> {
        if (validate()) {
            commit();
            forceClose();
        }
    });
    buttons.addComponent(commitButton);
    Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
    closeButton.addClickListener(event -> forceClose());
    buttons.addComponent(closeButton);
    nameField.focus();
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) Messages(com.haulmont.cuba.core.global.Messages) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) 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