private void rememberLastEntry(ConfigurationItem preparedConfigurationItem) { for (String id : preparedConfigurationItem.getRememberLastEntryForIds()) { ConfigurationItem item = new ConfigurationItem(preparedConfigurationItem); item.setLabel(preparedConfigurationItem.getValue()); item.setRawValue(preparedConfigurationItem.getValue()); item.setLastEntryItem(true); lastEntries.put(id, item); } }
@VisibleForTesting String getSelectedConfigItemValue() { if (selectedConfigItem != null && selectedConfigItem.isLastEntryItem()) { return selectedConfigItem.getValue(); } ConfigurationItem preparedConfigurationItem = prepareSelectedConfigurationItemForInput(); if (preparedConfigurationItem != null) { String value = preparedConfigurationItem.getValue(); if (preparedConfigurationItem.shouldRememberLastEntry()) { rememberLastEntry(preparedConfigurationItem); } return value; } return null; }
private ConfigurationItem prepareConfigurationItemForDialogList( ConfigurationItem configurationItem) { if (configurationItem != null && configurationItem.getValue() == null) { if (configurationVariablePattern != null) { String newConfigurationItemValue = replaceVariableKeysWithValues(configurationItem.getRawValue()); configurationItem.setValue(newConfigurationItemValue); } else { configurationItem.setValue(configurationItem.getRawValue()); } } return configurationItem; }
private ConfigurationItem prepareSelectedConfigurationItemForInput() { if (selectedConfigItem != null) { // Check if the selected config item raw value is configuration variable key if (helper.isConfigurationVariableKey(selectedConfigItem.getRawValue())) { String configurationVariableValue = helper.getConfigurationVariableValue(selectedConfigItem.getRawValue()); if (configurationVariableValue != null) { ConfigurationItem preparedConfigurationItem = new ConfigurationItem(selectedConfigItem); preparedConfigurationItem.setValue(configurationVariableValue); return preparedConfigurationItem; } } else if (selectedConfigItem.getValue() == null) { ConfigurationItem preparedConfigurationItem = new ConfigurationItem(prepareConfigurationItemForDialogList(selectedConfigItem)); selectedConfigItem.setValue(null); return preparedConfigurationItem; } else { ConfigurationItem preparedConfigurationItem = new ConfigurationItem(selectedConfigItem); selectedConfigItem.setValue(null); return preparedConfigurationItem; } } return null; }