@Override protected <T extends Field> T build(String caption, Class<?> dataType, Class<T> fieldType) throws BindException { T field = super.build(caption, dataType, fieldType); if (field instanceof CheckBox) { field.setCaption(null); } return field; }
/** * Creates a field based on the given data type. * <p> * The data type is the type that we want to edit using the field. The field * type is the type of field we want to create, can be {@link Field} if any * Field is good. * </p> * * @param caption * The caption for the new field * @param dataType * The data model type that we want to edit using the field * @param fieldType * The type of field that we want to create * @return A Field capable of editing the given type * @throws BindException * If the field could not be created */ protected <T extends Field> T build(String caption, Class<?> dataType, Class<T> fieldType) throws BindException { T field = getFieldFactory().createField(dataType, fieldType); if (field == null) { throw new BindException( "Unable to build a field of type " + fieldType.getName() + " for editing " + dataType.getName()); } field.setCaption(caption); return field; }
@Override public Field<?> createField(Item item, Object propertyId, Component uiContext) { Class<?> type = item.getItemProperty(propertyId).getType(); Field<?> field = createFieldByPropertyType(type); field.setCaption(createCaptionByPropertyId(propertyId)); return field; }
@Override public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) { Property containerProperty = container.getContainerProperty(itemId, propertyId); Class<?> type = containerProperty.getType(); Field<?> field = createFieldByPropertyType(type); field.setCaption(createCaptionByPropertyId(propertyId)); return field; }
@SuppressWarnings("unchecked") protected Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) { ColumnModel model = getColumnModel(String.valueOf(propertyId)); boolean editable = tableEditable && itemId.equals(editableId) && model.isEditable() ; Field<?> f = null; Class<?> type = container.getType(propertyId); f = createFieldForType(type); f.setCaption(null); f.setWidth("100%"); f.setReadOnly(!editable); if (f instanceof AbstractField) { if (model.getConverter() == null) { model.setConverter(findDefaultConverter(model,type)); } if (model.getConverter() != null) ((AbstractField<String>)f).setConverter((Converter<String, ?>)model.generateConverter(type)); } return f; }
@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; } } }
skipDefaultVMField.setCaption("Skip JVM MBeans"); skipDefaultVMField.setId(MetaConfigModel.SKIP_DEFAULT_VM); ((AbstractComponent) skipDefaultVMField).setDescription("Set to include/exclude default JavaVM MBeans"); skipNonNumberField.setCaption("Skip non-number values"); ((AbstractComponent) skipNonNumberField).setDescription("Set to include/exclude non-number values"); addComponent(skipNonNumberField);