Ejemplo n.º 1
0
  private static void addMinMaxOptionsAndHideOriginal(Options options, SimpleListener listener) {
    for (Options.Option option : options.getOptions()) {
      if (option.isAdvanced()) {
        // At this stage we don't want to deal with batches of advanced options.
        // The advanced options at the moment are only for MUSCLE and there are a lot of them
        // which would bloat the interface too much if we added them all on one line as a
        // MultiValueOption
        option.setAdvanced(
            false); // add advanced option back to basic panel, since there is a layout issue on
                    // small screen
        continue;
      }

      MultiValueOption multiValueOption = null;
      if (option instanceof Options.IntegerOption) {
        multiValueOption = new IntegerMultiValueOption((Options.IntegerOption) option);
      } else if (option instanceof Options.DoubleOption) {
        multiValueOption = new DoubleMultiValueOption((Options.DoubleOption) option);
      }

      if (multiValueOption != null) {
        option.setVisible(false);
        options.addCustomOption(multiValueOption);
        multiValueOption.addChangeListener(listener);
      }
    }

    for (Options childOptions : options.getChildOptions().values()) {
      addMinMaxOptionsAndHideOriginal(childOptions, listener);
    }
  }
Ejemplo n.º 2
0
 private static int getBatchSize(Options options) {
   int total = 1;
   for (Option option : options.getOptions()) {
     if (option instanceof MultiValueOption<?>) {
       total *= ((MultiValueOption<?>) option).getValue().size();
     }
   }
   for (Options childOptions : options.getChildOptions().values()) {
     total *= getBatchSize(childOptions);
   }
   return total;
 }
Ejemplo n.º 3
0
 private static Map<String, MultiValueOption<?>> getMultiValueOptions(
     String prefix, Options options) {
   Map<String, MultiValueOption<?>> result = new HashMap<String, MultiValueOption<?>>();
   for (Option option : options.getOptions()) {
     if (option instanceof MultiValueOption) {
       result.put(
           prefix + option.getName().replace(MultiValueOption.SUFFIX, ""),
           (MultiValueOption) option);
     }
   }
   for (Map.Entry<String, Options> entry : options.getChildOptions().entrySet()) {
     result.putAll(getMultiValueOptions(prefix + entry.getKey() + ".", entry.getValue()));
   }
   return result;
 }