use of com.vaadin.data.fieldgroup.FieldGroup 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.data.fieldgroup.FieldGroup in project opennms by OpenNMS.
the class NameEditForm method selectionChanged.
@Override
public void selectionChanged(SelectionChangedEvent changeEvent) {
if (parameter != null) {
try {
blockListenerOrValidators = true;
setData(changeEvent.getSelectedBean());
setItemId(changeEvent.getSelectedItemId());
final BeanItem beanItem = new BeanItem(changeEvent.getSelectedBean(), parameter.getEditablePropertyName(), parameter.getNonEditablePropertyName());
// this is a hack, but we need to know if the selection changed
beanItem.addItemProperty("selected", changeEvent.getSelectedItem().getItemProperty("selected"));
captionLabel.setValue(String.format("<b>%s</b>", parameter.getCaption()));
fieldGroup = new FieldGroup();
fieldGroup.setBuffered(false);
fieldGroup.bind(selectedField, "selected");
fieldGroup.bind(editableField, parameter.getEditablePropertyName());
fieldGroup.bind(nonEditableField, parameter.getNonEditablePropertyName());
fieldGroup.setItemDataSource(beanItem);
fieldGroup.getField(parameter.getNonEditablePropertyName()).setCaption(parameter.getNonEditablePropertyCaption());
fieldGroup.getField(parameter.getNonEditablePropertyName()).setReadOnly(true);
fieldGroup.getField(parameter.getEditablePropertyName()).setCaption(parameter.getEditablePropertyCaption());
fieldGroup.getField(parameter.getEditablePropertyName()).setReadOnly(false);
updateEnabledState();
UIHelper.validateField(editableField, true);
} finally {
blockListenerOrValidators = false;
}
}
}