鉴于我将此实体作为编辑器链的一部分:
public class Commission implements Serializable
{
private EnumSet<CommissionType> commissionTypes;
private CommissionType type; // must exist in commissionTypes
private String value;
public Commission()
{
}
}
和这个编辑器:
public class CommissionEditor extends Composite implements Editor<Commission>
{
private static CommissionEditorUiBinder uiBinder = GWT.create(CommissionEditorUiBinder.class);
interface CommissionEditorUiBinder extends UiBinder<Widget, CommissionEditor>
{
}
@UiField(provided = true)
ValueListBox<CommissionType> type = new ValueListBox<CommissionType>(new AbstractRenderer<CommissionType>()
{
@Override
public String render(CommissionType object)
{
return object == null ? "" : object.toString();
}
});
@UiField
TextBox value;
public CommissionEditor()
{
type.setAcceptableValues(Arrays.asList(CommissionType.values()));
initWidget(uiBinder.createAndBindUi(this));
}
}
目前,ValueListBox 呈现 CommissionType 的所有可能选项,如下所示:
EnumSet 可以包含 1 到 4 个可能的选项,具体取决于特定实体。有没有办法让 ValueListBox 只呈现 EnumSet 中的选项,然后将值保存在 CommissionType 中?
请记住,我也想设置commissionType 的值。