Search in sources :

Example 1 with ValuePicker

use of io.jmix.ui.component.ValuePicker in project jmix-docs by Haulmont.

the class ValuePickerScreen method onInit.

// end::inject-valuePickerClearAction[]
// tag::onInit-start[]
@Subscribe
protected void onInit(InitEvent event) {
    // end::onInit-start[]
    // tag::base-action-value-picker[]
    ValuePicker valueField = uiComponents.create(ValuePicker.NAME);
    valueField.addAction(new BaseAction("hello") {

        @Override
        public String getCaption() {
            return null;
        }

        @Override
        public String getDescription() {
            return messageBundle.getMessage("helloDescription");
        }

        @Override
        public String getIcon() {
            return JmixIcon.HANDSHAKE_O.source();
        }

        @Override
        public void actionPerform(Component component) {
            notifications.create().withCaption("Hello!").withType(Notifications.NotificationType.TRAY).show();
        }
    });
    valueField.addAction(new BaseAction("goodbye").withCaption(null).withDescription(messageBundle.getMessage("goodbyeDescription")).withIcon(JmixIcon.HAND_PAPER_O.source()).withHandler(e -> notifications.create().withCaption("Goodbye!").withType(Notifications.NotificationType.TRAY).show()));
    vBox.add(valueField);
    // end::base-action-value-picker[]
    loginValuePicker.addAction(new BaseAction("showValue").withHandler(actionPerformedEvent -> {
        String value = loginValuePicker.getValue();
        notifications.create().withCaption(value != null ? value : "No value").show();
    }).withDescription("Show Value").withIcon(JmixIcon.EYE.source()));
    // tag::add-clear-action1[]
    loginValuePicker.addAction(actions.create(ValueClearAction.ID));
// end::add-clear-action1[]
// tag::onInit-end[]
}
Also used : ValuePicker(io.jmix.ui.component.ValuePicker) Dialogs(io.jmix.ui.Dialogs) Autowired(org.springframework.beans.factory.annotation.Autowired) ValuePicker(io.jmix.ui.component.ValuePicker) Notifications(io.jmix.ui.Notifications) JmixIcon(io.jmix.ui.icon.JmixIcon) Strings(com.google.common.base.Strings) Component(io.jmix.ui.component.Component) UiComponents(io.jmix.ui.UiComponents) ValueClearAction(io.jmix.ui.action.valuepicker.ValueClearAction) io.jmix.ui.screen(io.jmix.ui.screen) VBoxLayout(io.jmix.ui.component.VBoxLayout) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) RandomStringUtils(org.apache.commons.lang3.RandomStringUtils) Named(javax.inject.Named) DialogAction(io.jmix.ui.action.DialogAction) Actions(io.jmix.ui.Actions) BaseAction(io.jmix.ui.action.BaseAction) Component(io.jmix.ui.component.Component)

Aggregations

Strings (com.google.common.base.Strings)1 Actions (io.jmix.ui.Actions)1 Dialogs (io.jmix.ui.Dialogs)1 Notifications (io.jmix.ui.Notifications)1 UiComponents (io.jmix.ui.UiComponents)1 Action (io.jmix.ui.action.Action)1 BaseAction (io.jmix.ui.action.BaseAction)1 DialogAction (io.jmix.ui.action.DialogAction)1 ValueClearAction (io.jmix.ui.action.valuepicker.ValueClearAction)1 Component (io.jmix.ui.component.Component)1 VBoxLayout (io.jmix.ui.component.VBoxLayout)1 ValuePicker (io.jmix.ui.component.ValuePicker)1 JmixIcon (io.jmix.ui.icon.JmixIcon)1 io.jmix.ui.screen (io.jmix.ui.screen)1 Named (javax.inject.Named)1 RandomStringUtils (org.apache.commons.lang3.RandomStringUtils)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1