Search in sources :

Example 1 with JmixButton

use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.

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);
    nameField = new TextField(messages.getMessage("PresentationsEditor.name"));
    nameField.setWidth(theme.get("jmix.ui.PresentationEditor.name.width"));
    nameField.setValue(getPresentationCaption());
    root.addComponent(nameField);
    autoSaveField = new CheckBox();
    autoSaveField.setCaption(messages.getMessage("PresentationsEditor.autoSave"));
    autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
    root.addComponent(autoSaveField);
    defaultField = new CheckBox();
    defaultField.setCaption(messages.getMessage("PresentationsEditor.default"));
    defaultField.setValue(Objects.equals(EntityValues.<UUID>getId(presentation), (component.getDefaultPresentationId())));
    root.addComponent(defaultField);
    if (allowGlobalPresentations) {
        globalField = new CheckBox();
        globalField.setCaption(messages.getMessage("PresentationsEditor.global"));
        globalField.setValue(!isNew && presentation.getUsername() == 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 JmixButton(messages.getMessage("PresentationsEditor.save"));
    commitButton.addClickListener(event -> {
        if (validate()) {
            commit();
            forceClose();
        }
    });
    buttons.addComponent(commitButton);
    Button closeButton = new JmixButton(messages.getMessage("PresentationsEditor.close"));
    closeButton.addClickListener(event -> forceClose());
    buttons.addComponent(closeButton);
    nameField.focus();
}
Also used : ThemeConstants(io.jmix.ui.theme.ThemeConstants) JmixButton(io.jmix.ui.widget.JmixButton) JmixButton(io.jmix.ui.widget.JmixButton) UUID(java.util.UUID)

Example 2 with JmixButton

use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.

the class AbstractActionsHolderComponent 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())) {
        JmixButton 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(io.jmix.ui.action.Action) JmixButton(io.jmix.ui.widget.JmixButton)

Example 3 with JmixButton

use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.

the class ValuePickerImpl method removeAction.

@Override
public void removeAction(Action action) {
    if (actions.remove(action)) {
        actionHandler.removeAction(action);
        JmixButton button = actionButtons.remove(action);
        component.removeButton(button);
        action.removePropertyChangeListener(actionPropertyChangeListener);
        if (action instanceof ValuePickerAction) {
            ((ValuePickerAction) action).setPicker(null);
        }
    }
}
Also used : JmixButton(io.jmix.ui.widget.JmixButton)

Example 4 with JmixButton

use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.

the class ValuePickerImpl 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);
    JmixButton vButton = new JmixButton();
    setupButtonAction(vButton, action);
    action.addPropertyChangeListener(actionPropertyChangeListener);
    component.addButton(vButton, index);
    actionButtons.put(action, vButton);
    if (StringUtils.isNotEmpty(getDebugId()) && AppUI.getCurrent() != null) {
        TestIdManager testIdManager = AppUI.getCurrent().getTestIdManager();
        // Set debug id
        vButton.setId(testIdManager.getTestId(getDebugId() + "_" + action.getId()));
    }
    if (action instanceof ValuePickerAction) {
        ValuePickerAction pickerAction = (ValuePickerAction) action;
        pickerAction.setPicker(this);
        if (!isEditable()) {
            pickerAction.editableChanged(isEditable());
        }
    }
    actionsPermissions.apply(action);
    refreshActionsState();
}
Also used : TestIdManager(io.jmix.ui.sys.TestIdManager) JmixButton(io.jmix.ui.widget.JmixButton)

Example 5 with JmixButton

use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.

the class PaletteComponentsFactoryImpl method createCommonButton.

protected PaletteButton createCommonButton() {
    PaletteButton button = factory.create(PaletteButton.class);
    button.setWidth("100%");
    button.setHeight("50px");
    button.setStyleName(DashboardStyleConstants.DASHBOARD_BUTTON);
    DragSourceExtension<JmixButton> dragSourceExtension = new DragSourceExtension<>(button.unwrap(JmixButton.class));
    dragSourceExtension.setEffectAllowed(EffectAllowed.COPY);
    dragSourceExtension.addDragStartListener(e -> dragSourceExtension.setDragData(button.getLayout()));
    dragSourceExtension.addDragEndListener(e -> dragSourceExtension.setDragData(null));
    return button;
}
Also used : PaletteButton(io.jmix.dashboardsui.component.impl.PaletteButton) JmixButton(io.jmix.ui.widget.JmixButton) DragSourceExtension(com.vaadin.ui.dnd.DragSourceExtension)

Aggregations

JmixButton (io.jmix.ui.widget.JmixButton)11 Action (io.jmix.ui.action.Action)5 TestIdManager (io.jmix.ui.sys.TestIdManager)3 ShortcutAction (com.vaadin.event.ShortcutAction)2 CssLayout (com.vaadin.ui.CssLayout)1 DragSourceExtension (com.vaadin.ui.dnd.DragSourceExtension)1 PaletteButton (io.jmix.dashboardsui.component.impl.PaletteButton)1 AppUI (io.jmix.ui.AppUI)1 BaseAction (io.jmix.ui.action.BaseAction)1 ThemeConstants (io.jmix.ui.theme.ThemeConstants)1 UUID (java.util.UUID)1