Create a single-valued choice preference input.

@param name
@param label
@param displayType
@param options
@param defaultValue
@return
161127
public static Preference createSingleChoicePreference(
            String name,
            String label,
            SingleChoiceDisplay displayType,
            List<Option> options,
            String defaultValue) {
        SingleChoicePreferenceInput input = new SingleChoicePreferenceInput();
        input.setDefault(defaultValue);
        input.setDisplay(displayType);
        input.getOptions().addAll(options);

        Preference pref = new Preference();
        pref.setName(name);
        pref.setLabel(label);
        pref.setPreferenceInput(
                new JAXBElement<SingleChoicePreferenceInput>(
                        new QName("single-choice-parameter-input"),
                        SingleChoicePreferenceInput.class,
                        input));

        return pref;
    }
1342604
public String getConfigurationOptionValue (String optionName, String defaultValue) {
		String optionValue;
		Node configurationOption = this.getConfigurationOption (optionName);
		if (configurationOption != null) {
			optionValue = configurationOption.getTextContent ();
		} else {
			optionValue = defaultValue;
		}
		return optionValue;
	}
270724
static public Value colorValue(String name, Color currentValue) {
		return new DefaultValue(name, EffectUtil.toString(currentValue)) {
			public void showDialog () {
				Color newColor = JColorChooser.showDialog(null, "Choose a color", EffectUtil.fromString(value));
				if (newColor != null) value = EffectUtil.toString(newColor);
			}

			public Object getObject () {
				return EffectUtil.fromString(value);
			}
		};
	}
1368720
@Nonnull
  public JSLabel label (@Nonnull @Nonempty final String sName)
  {
    return addStatement (new JSLabel (sName));
  }
1261985
@SuppressWarnings("unchecked")
    public static InputComponent createUIInput(UIProvider provider, InputComponentFactory factory, ConverterFactory converterFactory, String parentName, String name,
                                               Class inputClazz, String required, String currentValue, String defaultValue, String enums, String description,
                                               boolean promptInInteractiveMode, boolean multiValue, String prefix) {

        // is the current value a property placeholder, then we need to use a regular text based UI
        if (currentValue != null && currentValue.startsWith("{{") && currentValue.endsWith("}}")) {
            // switch over to plain string
            inputClazz = String.class;
            enums = null;
        }

        InputComponent input;
        if (enums != null) {
            UISelectOne ui = factory.createSelectOne(name, inputClazz);
            // the enums are comma separated
            List<String> enumValues = new ArrayList<>();
            String[] values = enums.split(",");
            for (String v : values) {
                enumValues.add(v.trim());
            }
            ui.setValueChoices(enumValues);
            if (defaultValue != null) {
                Object value = defaultValue;
                Converter converter = converterFactory.getConverter(String.class, inputClazz);
                if (converter != null) {
                    value = converter.convert(defaultValue);
                }
                ui.setDefaultValue(value);
            }
            if (currentValue != null) {
                Object value = currentValue;
                Converter converter = converterFactory.getConverter(String.class, inputClazz);
                if (converter != null) {
                    value = converter.convert(currentValue);
                }
                // set the value from the enum choices so the UI can indicate this correctly in the UI
                for (String v : enumValues) {
                    if (v.equalsIgnoreCase((String) value)) {
                        value = v;
                        break;
                    }
                }
                ui.setValue(value);
            }

            if ("true".equals(required) || promptInInteractiveMode) {
                // This will always prompt, regardless if there is a value set
                Iterator it = ui.getFacets().iterator();
                while (it.hasNext()) {
                    Object facet = it.next();
                    if (facet instanceof HintsFacet) {
                        ((HintsFacet) facet).setPromptInInteractiveMode(true);
                    }
                }
            }

            input = ui;
        } else {
            UIInput ui = factory.createInput(name, inputClazz);
            if (defaultValue != null) {
                Object value = defaultValue;
                Converter converter = converterFactory.getConverter(String.class, inputClazz);
                if (converter != null) {
                    value = converter.convert(defaultValue);
                }
                ui.setDefaultValue(value);
            }
            if (currentValue != null) {
                Object value = currentValue;
                Converter converter = converterFactory.getConverter(String.class, inputClazz);
                if (converter != null) {
                    value = converter.convert(currentValue);
                }
                ui.setValue(value);
            }

            if ("true".equals(required) || promptInInteractiveMode) {
                // This will always prompt, regardless if there is a value set
                Iterator it = ui.getFacets().iterator();
                while (it.hasNext()) {
                    Object facet = it.next();
                    if (facet instanceof HintsFacet) {
                        ((HintsFacet) facet).setPromptInInteractiveMode(true);
                    }
                }
            }

            input = ui;
        }

        if (Objects.equals("true", required)) {
            input.setRequired(true);
        }

        // if the name is "expression" then its a placeholder for the parent name to be used instead as label
        String label;
        if (name.equals("expression") && parentName != null) {
            label = asTitleCase(parentName + "Language");
        } else if (name.startsWith("expression_") && parentName != null) {
            // the expression may have a number of extra inputs we need to show as well
            String namePostfix = name.substring(11);
            // upper case the first char
            namePostfix = Character.toTitleCase(namePostfix.charAt(0)) + namePostfix.substring(1);
            label = asTitleCase(parentName + namePostfix);
        } else {
            label = asTitleCase(name);
        }
        if (multiValue) {
            label += " (multivalued)";
        }
        input.setLabel(label);

        if (!provider.isGUI()) {
            // no description in CLI/embedded as that clutters the shell
            input.setDescription("");
        } else {
            if (multiValue) {
                String extra = "This option is multi valued, which means you can provide multiple key/value pairs"
                        + " prefixed with " + prefix + " and separated with &, eg " + prefix + "foo=123&" + prefix + "bar=456";
                if (description == null) {
                    description = extra;
                } else {
                    if (description.endsWith(".")) {
                        description += " " + extra;
                    } else {
                        description += ". " + extra;
                    }
                }
            }
            // must use an empty description otherwise the GUI prints null
            input.setDescription(description != null ? description : "");
        }

        return input;
    }
864273
public String checkbox (String name, boolean defaultValue)
    {
        String value = getParameter(name);
        return fixedCheckbox(
            name, (value == null) ? defaultValue : !value.equals(""));
    }
633697
function(idx, label, opt) {

        var labels = this.labels();

        idx = (isFinite(idx) && idx !== null) ? (idx | 0) : 0;
        if (idx < 0) idx = labels.length + idx;

        // getter
        if (arguments.length <= 1) return this.prop(['labels', idx]);
        // setter
        return this.prop(['labels', idx], label, opt);
    }
578354
protected SelectItem createSelectItem(FacesContext context, UISelectItems uiSelectItems, Object value,
			Object label) {
		String var = (String) uiSelectItems.getAttributes().get("var");
		Map<String, Object> attrs = uiSelectItems.getAttributes();
		Map<String, Object> requestMap = context.getExternalContext().getRequestMap();

		if (var != null) {
			requestMap.put(var, value);
		}

		Object itemLabelValue = attrs.get("itemLabel");
		Object itemValue = attrs.get("itemValue");
		String description = (String) attrs.get("itemDescription");
		Object itemDisabled = attrs.get("itemDisabled");
		Object itemEscaped = attrs.get("itemLabelEscaped");
		Object noSelection = attrs.get("noSelectionOption");

		if (itemValue == null) {
			itemValue = value;
		}

		if (itemLabelValue == null) {
			itemLabelValue = label;
		}

		String itemLabel = itemLabelValue == null ? String.valueOf(value) : String.valueOf(itemLabelValue);
		boolean disabled = itemDisabled == null ? false : Boolean.valueOf(itemDisabled.toString());
		boolean escaped = itemEscaped == null ? false : Boolean.valueOf(itemEscaped.toString());
		boolean noSelectionOption = noSelection == null ? false : Boolean.valueOf(noSelection.toString());

		if (var != null) {
			requestMap.remove(var);
		}

		return new SelectItem(itemValue, itemLabel, description, disabled, escaped, noSelectionOption);
	}
356308
public String option (
        String name, String value, String item, Object defaultValue)
    {
        String selectedValue = getValue(name, defaultValue);
        return fixedOption(name, value, item, selectedValue);
    }
804064
public Parser<T> label(final String name) {
    return new Parser<T>() {
      @Override public Parser<T> label(String overrideName) {
        return Parser.this.label(overrideName);
      }
      @Override boolean apply(ParseContext ctxt) {
        return ctxt.applyNewNode(Parser.this, name);
      }
      @Override public String toString() {
        return name;
      }
    };
  }
892472
public Option defaultValue(String defaultValue) throws RequiredParametersException {
		if (this.choices.isEmpty()) {
			return this.setDefaultValue(defaultValue);
		} else {
			if (this.choices.contains(defaultValue)) {
				return this.setDefaultValue(defaultValue);
			} else {
				throw new RequiredParametersException("Default value " + defaultValue +
						" is not in the list of valid values for option " + this.longName);
			}
		}
	}
793939
public static Preference createSingleTextPreference(String name, String label) {
        return createSingleTextPreference(
                name, "attribute.displayName." + name, TextDisplay.TEXT, null);
    }
138289
@Override
	public String getDisplayValue(final ResourceBundleKey resourceBundleKey)
	{
		return ResourceModelFactory
			.newResourceModel(getPropertiesKey(resourceBundleKey.getKey()),
				resourceBundleKey.getParameters(), component, resourceBundleKey.getDefaultValue())
			.getObject();
	}
1054054
function opt(options, name, defaultValue){
    return options && options[name]!==undefined ? options[name] : defaultValue;
}
373346
public <T> OverlayUI<T> overlayUI(String name) {
        try {
            checkGuiThread();
            // Load the UI from disk.
            URL location = GuiUtils.getResource(name);
            FXMLLoader loader = new FXMLLoader(location);
            Pane ui = loader.load();
            T controller = loader.getController();
            OverlayUI<T> pair = new OverlayUI<T>(ui, controller);
            // Auto-magically set the overlayUI member, if it's there.
            try {
                if (controller != null)
                    controller.getClass().getField("overlayUI").set(controller, pair);
            } catch (IllegalAccessException | NoSuchFieldException ignored) {
                ignored.printStackTrace();
            }
            pair.show();
            return pair;
        } catch (IOException e) {
            throw new RuntimeException(e);  // Can't happen.
        }
    }
838323
public static String getPreference( String preferenceKey, String defaultValue ) {
        Preferences preferences = Preferences.userRoot().node(PREFS_NODE_NAME);
        String preference = preferences.get(preferenceKey, defaultValue);
        return preference;
    }
82068
public static void label(final String name, final String value) {
        final Label label = new Label().setName(name).setValue(value);
        getLifecycle().updateTestCase(testResult -> testResult.getLabels().add(label));
    }