Exemple #1
0
 public OptionGroup clone() throws CloneNotSupportedException {
   OptionGroup result = new OptionGroup(getId());
   result.editable = editable;
   result.setValues(this);
   result.options = new ArrayList<Option>(options);
   result.optionMap = new HashMap<String, Option>(optionMap);
   return result;
 }
Exemple #2
0
 private void addOptionGroup(OptionGroup group) {
   for (Option option : group.getOptions()) {
     optionMap.put(option.getId(), option);
     if (option instanceof OptionGroup) {
       addOptionGroup((OptionGroup) option);
     }
   }
 }
Exemple #3
0
 /**
  * Adds the given <code>Option</code>.
  *
  * @param option The <code>Option</code> that should be added to this <code>OptionGroup</code>.
  */
 public void add(Option option) {
   String id = option.getId();
   if (optionMap.containsKey(id)) {
     for (int index = 0; index < options.size(); index++) {
       if (id.equals(options.get(index).getId())) {
         options.remove(index);
         options.add(index, option);
         break;
       }
     }
   } else {
     options.add(option);
   }
   optionMap.put(id, option);
   if (option instanceof OptionGroup) {
     OptionGroup group = (OptionGroup) option;
     group.setEditable(editable && group.isEditable());
     addOptionGroup(group);
   }
 }
Exemple #4
0
 /**
  * Copy the options of another OptionGroup.
  *
  * @param value an <code>Object</code> value
  */
 @SuppressWarnings("unchecked")
 public void setValue(OptionGroup value) {
   for (Option other : value.getOptions()) {
     Option mine = getOption(other.getId());
     // could be null if using custom.xml generated from an
     // older version of the specification, for example
     if (mine != null) {
       mine.setValue(other.getValue());
     }
   }
 }