Search in sources :

Example 11 with ComboBox

use of com.vaadin.ui.ComboBox in project VaadinUtils by rlsutton1.

the class JasperReportScheduleLayout method buildScheduleTab.

private void buildScheduleTab(ValidatingFieldGroup<ReportEmailScheduleEntity> validatingFieldGroup, FormLayout main, FormHelper<ReportEmailScheduleEntity> helper) {
    helper.bindBooleanField(main, validatingFieldGroup, "Enabled", ReportEmailScheduleEntity_.enabled);
    helper.bindDateField(main, validatingFieldGroup, "Last Run Time", ReportEmailScheduleEntity_.lastRuntime, "yyyy/MM/dd HH:mm", Resolution.MINUTE).setReadOnly(true);
    helper.bindDateField(main, validatingFieldGroup, "Next Run Time", ReportEmailScheduleEntity_.nextScheduledTime, "yyyy/MM/dd HH:mm", Resolution.MINUTE).setReadOnly(true);
    ComboBox modeCombo = helper.bindEnumField(main, validatingFieldGroup, "Frequency", ReportEmailScheduleEntity_.scheduleMode, ScheduleMode.class);
    final DateField oneTime = helper.bindDateField(main, validatingFieldGroup, "Start time", ReportEmailScheduleEntity_.oneTimeRunDateTime, "yyyy/MM/dd HH:mm", Resolution.MINUTE);
    final TimePicker timeOfDay = new TimePicker("Start time");
    main.addComponent(timeOfDay);
    validatingFieldGroup.bind(timeOfDay, ReportEmailScheduleEntity_.timeOfDayToRun.getName());
    // day of week
    final DayOfWeekCheckBoxes dayLayout = new DayOfWeekCheckBoxes();
    validatingFieldGroup.bind(dayLayout, ReportEmailScheduleEntity_.scheduledDaysOfWeek.getName());
    main.addComponent(dayLayout);
    // day of month
    List<String> options = new LinkedList<String>();
    for (int i = 1; i < 32; i++) {
        options.add("" + i);
    }
    final ComboBox dayOfMonth = helper.bindComboBox(main, validatingFieldGroup, ReportEmailScheduleEntity_.scheduledDayOfMonth.getName(), "Day of month", options);
    dayOfMonth.setConverter(Integer.class);
    dayOfMonth.setNullSelectionAllowed(true);
    modeCombo.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 3640488458535487174L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            ScheduleMode mode = (ScheduleMode) event.getProperty().getValue();
            if (mode == null) {
                mode = ScheduleMode.ONE_TIME;
            }
            oneTime.setRequired(false);
            switch(mode) {
                case ONE_TIME:
                    oneTime.setRequired(true);
                    oneTime.setVisible(true);
                    timeOfDay.setVisible(false);
                    dayLayout.setVisible(false);
                    dayOfMonth.setVisible(false);
                    break;
                case DAY_OF_MONTH:
                    oneTime.setVisible(false);
                    timeOfDay.setVisible(true);
                    dayLayout.setVisible(false);
                    dayOfMonth.setVisible(true);
                    break;
                case DAY_OF_WEEK:
                    oneTime.setVisible(false);
                    timeOfDay.setVisible(true);
                    dayLayout.setVisible(true);
                    dayLayout.setRequired(true);
                    dayOfMonth.setVisible(false);
                    break;
                case EVERY_DAY:
                    oneTime.setVisible(false);
                    timeOfDay.setVisible(true);
                    dayLayout.setVisible(false);
                    dayOfMonth.setVisible(false);
                    break;
            }
        }
    });
}
Also used : TimePicker(au.com.vaadinutils.layout.TimePicker) ComboBox(com.vaadin.ui.ComboBox) LinkedList(java.util.LinkedList) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) ScheduleMode(au.com.vaadinutils.jasper.scheduler.entities.ScheduleMode) DateField(com.vaadin.ui.DateField)

Example 12 with ComboBox

use of com.vaadin.ui.ComboBox in project opennms by OpenNMS.

the class EventFormTest method testGroupField.

/**
 * Test the group field.
 *
 * @throws Exception the exception
 */
@Test
public void testGroupField() throws Exception {
    EventForm form = new EventForm();
    FieldGroup group = form.eventEditor;
    Field<?> uei = group.getField("uei");
    Assert.assertTrue(uei instanceof TextField);
    Assert.assertEquals("uei.opennms.org/newEvent", uei.getValue());
    Field<?> logMsgDest = group.getField("logmsg.dest");
    Assert.assertNotNull(logMsgDest);
    Assert.assertTrue(logMsgDest instanceof ComboBox);
    Assert.assertEquals(LogDestType.LOGNDISPLAY, logMsgDest.getValue());
    String eventUei = "uei.opennms.org/ietf/mplsTeStdMib/traps/mplsTunnelUp";
    Event event = dao.findByUei(eventUei);
    Assert.assertNotNull(event);
    form.setEvent(event);
    logMsgDest = group.getField("logmsg.dest");
    Assert.assertNotNull(logMsgDest);
    Assert.assertTrue(logMsgDest instanceof ComboBox);
    Assert.assertEquals(event.getLogmsg().getDest(), logMsgDest.getValue());
}
Also used : FieldGroup(com.vaadin.data.fieldgroup.FieldGroup) ComboBox(com.vaadin.ui.ComboBox) TextField(com.vaadin.ui.TextField) Event(org.opennms.netmgt.xml.eventconf.Event) Test(org.junit.Test)

Example 13 with ComboBox

use of com.vaadin.ui.ComboBox in project cuba by cuba-platform.

the class WebComponentsUtils method disallowNullSelection.

@Deprecated
public static void disallowNullSelection(LookupField lookupField) {
    ComboBox vCombobox = (ComboBox) WebComponentsHelper.unwrap(lookupField);
    vCombobox.setNullSelectionAllowed(false);
}
Also used : ComboBox(com.vaadin.ui.ComboBox)

Example 14 with ComboBox

use of com.vaadin.ui.ComboBox in project cuba by cuba-platform.

the class WebFilterHelper method setLookupCaptions.

@Override
public void setLookupCaptions(LookupField lookupField, Map<Object, String> captions) {
    ComboBox vLookupField = lookupField.unwrap(ComboBox.class);
    vLookupField.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT);
    for (Map.Entry<Object, String> entry : captions.entrySet()) {
        vLookupField.setItemCaption(entry.getKey(), entry.getValue());
    }
}
Also used : ComboBox(com.vaadin.ui.ComboBox)

Example 15 with ComboBox

use of com.vaadin.ui.ComboBox in project cuba by cuba-platform.

the class WebLookupPickerField method createComponent.

@Override
protected void createComponent() {
    super.createComponent();
    // delegate error indication
    this.componentErrorHandler = message -> {
        if (message instanceof UserError) {
            return false;
        }
        pickerField.component.setComponentError(message);
        return true;
    };
    component.setCustomValueEquals(InstanceUtils::propertyValueEquals);
    final ComboBox selectComponent = component;
    final WebPickerField.Picker picker = new WebPickerField.Picker(this, component) {

        @Override
        public void setRequired(boolean required) {
            super.setRequired(required);
            selectComponent.setNullSelectionAllowed(!required);
        }
    };
    pickerField = new WebPickerField(picker);
    // Required for custom components in fieldgroup
    initValueSync(selectComponent, picker);
}
Also used : UserError(com.vaadin.server.UserError) ComboBox(com.vaadin.ui.ComboBox) InstanceUtils(com.haulmont.chile.core.model.utils.InstanceUtils)

Aggregations

ComboBox (com.vaadin.ui.ComboBox)41 HorizontalLayout (com.vaadin.ui.HorizontalLayout)7 TextField (com.vaadin.ui.TextField)7 Button (com.vaadin.ui.Button)6 SplitComboBox (au.com.vaadinutils.crud.splitFields.SplitComboBox)5 LegacySplitComboBox (au.com.vaadinutils.crud.splitFields.legacy.LegacySplitComboBox)5 Item (com.vaadin.data.Item)5 Label (com.vaadin.ui.Label)5 VerticalLayout (com.vaadin.ui.VerticalLayout)5 Test (org.junit.Test)4 LegacyComboBox (org.vaadin.ui.LegacyComboBox)4 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 Panel (com.vaadin.ui.Panel)3 UI (com.vaadin.ui.UI)3 LinkkiComboBox (org.linkki.core.ui.components.LinkkiComboBox)3 TimePicker (au.com.vaadinutils.layout.TimePicker)2 ViewRiksdagenCommittee (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee)2 ApplicationEventGroup (com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup)2 DataContainer (com.hack23.cia.service.api.DataContainer)2