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;
}
}
});
}
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());
}
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);
}
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());
}
}
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);
}
Aggregations