コード例 #1
0
  /** Only add a new widget row if there are any remaining choices to make */
  @Override
  protected boolean canAddNewRowFor(PropertyDescriptor<?> desc, PropertySource source) {

    Object[] choices = desc.choices();
    Object[] values = (Object[]) source.getProperty(desc);

    return choices.length > values.length;
  }
コード例 #2
0
  @Override
  protected Object addValueIn(Control widget, PropertyDescriptor<?> desc, PropertySource source) {

    int idx = ((Combo) widget).getSelectionIndex();
    if (idx < 0) return null;

    String newValue = ((Combo) widget).getItem(idx);

    String[] currentValues = (String[]) valueFor(source, desc);
    String[] newValues = CollectionUtil.addWithoutDuplicates(currentValues, newValue);
    if (currentValues.length == newValues.length) return null;

    source.setProperty((EnumeratedMultiProperty<?>) desc, newValues);
    return newValue;
  }
コード例 #3
0
 @Override
 protected void update(PropertySource source, PropertyDescriptor<?> desc, List<Object> newValues) {
   source.setProperty(
       (EnumeratedMultiProperty<?>) desc, newValues.toArray(new String[newValues.size()]));
 }